Skip to content

Commit

Permalink
fix: types
Browse files Browse the repository at this point in the history
  • Loading branch information
gomesalexandre committed Jan 17, 2024
1 parent 5edaa20 commit ad53095
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 36 deletions.
18 changes: 18 additions & 0 deletions src/lib/utils/thorchain/lp/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { AccountId, AssetId } from '@shapeshiftoss/caip'
import type { BN } from 'lib/bignumber/bignumber'

export type ThorNodeLiquidityProvider = {
Expand Down Expand Up @@ -198,3 +199,20 @@ export enum AsymSide {
Asset = 'asset',
Rune = 'rune',
}

export type UserLpDataPosition = {
dateFirstAdded: string
liquidityUnits: string
underlyingAssetAmountCryptoPrecision: string
underlyingRuneAmountCryptoPrecision: string
isAsymmetric: boolean
asymSide: AsymSide | null
underlyingAssetValueFiatUserCurrency: string
underlyingRuneValueFiatUserCurrency: string
totalValueFiatUserCurrency: string
poolOwnershipPercentage: string
opportunityId: string
poolShare: string
accountId: AccountId
assetId: AssetId
}
3 changes: 2 additions & 1 deletion src/pages/ThorChainLP/YourPositions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import type { ThornodePoolResponse } from 'lib/swapper/swappers/ThorchainSwapper
import { assetIdToPoolAssetId } from 'lib/swapper/swappers/ThorchainSwapper/utils/poolAssetHelpers/poolAssetHelpers'
import { isSome } from 'lib/utils'
import { calculateEarnings, getEarnings } from 'lib/utils/thorchain/lp'
import type { UserLpDataPosition } from 'lib/utils/thorchain/lp/types'
import { selectAssetById, selectMarketDataById } from 'state/slices/selectors'
import { useAppSelector } from 'state/store'

Expand Down Expand Up @@ -63,7 +64,7 @@ type PositionButtonProps = {
opportunityId: string
accountId: string
apy: string
userPoolData: any // TODO
userPoolData: UserLpDataPosition
}

const PositionButton = ({
Expand Down
18 changes: 2 additions & 16 deletions src/pages/ThorChainLP/hooks/useAllUserLpData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
getCurrentValue,
getThorchainLiquidityProviderPosition,
} from 'lib/utils/thorchain/lp'
import type { UserLpDataPosition } from 'lib/utils/thorchain/lp/types'
import { AsymSide, type MidgardPool } from 'lib/utils/thorchain/lp/types'
import { defaultMarketData } from 'state/slices/marketDataSlice/marketDataSlice'
import { findAccountsByAssetId } from 'state/slices/portfolioSlice/utils'
Expand All @@ -28,22 +29,7 @@ import { useAppSelector } from 'state/store'

type UseUserLpDataReturn = {
assetId: AssetId
positions: {
dateFirstAdded: string
liquidityUnits: string
underlyingAssetAmountCryptoPrecision: string
underlyingRuneAmountCryptoPrecision: string
isAsymmetric: boolean
asymSide: AsymSide | null
underlyingAssetValueFiatUserCurrency: string
underlyingRuneValueFiatUserCurrency: string
totalValueFiatUserCurrency: string
poolOwnershipPercentage: string
opportunityId: string
poolShare: string
accountId: AccountId
assetId: AssetId
}[]
positions: UserLpDataPosition[]
}

export const useAllUserLpData = ({
Expand Down
21 changes: 2 additions & 19 deletions src/pages/ThorChainLP/hooks/useUserLpData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
getCurrentValue,
getThorchainLiquidityProviderPosition,
} from 'lib/utils/thorchain/lp'
import type { MidgardPool } from 'lib/utils/thorchain/lp/types'
import type { MidgardPool, UserLpDataPosition } from 'lib/utils/thorchain/lp/types'
import { AsymSide } from 'lib/utils/thorchain/lp/types'
import { selectMarketDataById } from 'state/slices/marketDataSlice/selectors'
import { selectAccountIdsByAssetId } from 'state/slices/selectors'
Expand All @@ -27,26 +27,9 @@ type UseUserLpDataProps = {
assetId: AssetId
}

type UseUserLpDataReturn = {
dateFirstAdded: string
liquidityUnits: string
underlyingAssetAmountCryptoPrecision: string
underlyingRuneAmountCryptoPrecision: string
isAsymmetric: boolean
asymSide: AsymSide | null
underlyingAssetValueFiatUserCurrency: string
underlyingRuneValueFiatUserCurrency: string
totalValueFiatUserCurrency: string
poolOwnershipPercentage: string
opportunityId: string
poolShare: string
accountId: AccountId
assetId: AssetId
}[]

export const useUserLpData = ({
assetId,
}: UseUserLpDataProps): UseQueryResult<UseUserLpDataReturn | null> => {
}: UseUserLpDataProps): UseQueryResult<UserLpDataPosition[] | null> => {
const thorchainAccountIds = useAppSelector(state =>
selectAccountIdsByAssetId(state, { assetId: thorchainAssetId }),
)
Expand Down

0 comments on commit ad53095

Please sign in to comment.