Skip to content

Commit

Permalink
check what type of token id it is
Browse files Browse the repository at this point in the history
  • Loading branch information
jnastaskin committed Aug 9, 2024
1 parent 2fcdc55 commit 7460005
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
8 changes: 4 additions & 4 deletions packages/app/src/lib/components/foil/positionSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { useAccount, useReadContract, useReadContracts } from 'wagmi';

import useFoilDeployment from './useFoilDeployment';
import { MarketContext } from '~/lib/context/MarketProvider';
import { PositionKind } from '~/lib/interfaces/interfaces';
import { Position, PositionKind } from '~/lib/interfaces/interfaces';

interface AccountSelectorProps {
isLP: boolean;
Expand Down Expand Up @@ -73,7 +73,7 @@ const useIsLps = (ids: number[]) => {
const tokensInfo = useReadContracts({
contracts: ids.map((i) => {
return {
abi: foilData.abi as AbiFunction[],
abi: foilData.abi,
address: foilData.address as `0x${string}`,
functionName: 'getPosition',
args: [i],
Expand All @@ -84,8 +84,8 @@ const useIsLps = (ids: number[]) => {
const isLps: boolean[] = useMemo(() => {
if (!tokensInfo.data) return [];
return tokensInfo.data.map((resp) => {
return true; // uncomment below when contrract is updated
//return resp.positionKind === PositionKind.Liquidity
const position = resp.result as Position;
return position.kind === PositionKind.Liquidity;
});
}, [tokensInfo.data]);

Expand Down
17 changes: 15 additions & 2 deletions packages/app/src/lib/interfaces/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
export enum PositionKind {
Liquidity = 'Liquidity',
Trade = 'Trade',
Liquidity,
Trade,
}
export interface Position {
tokenId: BigInt; // nft id
kind: PositionKind;
epochId: BigInt;
// Accounting data (debt and deposited collateral)
depositedCollateralAmount: BigInt; // configured collateral
borrowedVEth: BigInt;
borrowedVGas: BigInt;
// Position data (owned tokens and position size)
vEthAmount: BigInt;
vGasAmount: BigInt;
currentTokenAmount: BigInt;
}

0 comments on commit 7460005

Please sign in to comment.