From ad53095c088656e9bf2a0890c3782335655e94f2 Mon Sep 17 00:00:00 2001 From: gomes <17035424+gomesalexandre@users.noreply.github.com> Date: Wed, 17 Jan 2024 23:56:01 +0100 Subject: [PATCH] fix: types --- src/lib/utils/thorchain/lp/types.ts | 18 ++++++++++++++++ src/pages/ThorChainLP/YourPositions.tsx | 3 ++- .../ThorChainLP/hooks/useAllUserLpData.ts | 18 ++-------------- src/pages/ThorChainLP/hooks/useUserLpData.ts | 21 ++----------------- 4 files changed, 24 insertions(+), 36 deletions(-) diff --git a/src/lib/utils/thorchain/lp/types.ts b/src/lib/utils/thorchain/lp/types.ts index 3d4bf8a96fc..4b66713f2d3 100644 --- a/src/lib/utils/thorchain/lp/types.ts +++ b/src/lib/utils/thorchain/lp/types.ts @@ -1,3 +1,4 @@ +import type { AccountId, AssetId } from '@shapeshiftoss/caip' import type { BN } from 'lib/bignumber/bignumber' export type ThorNodeLiquidityProvider = { @@ -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 +} diff --git a/src/pages/ThorChainLP/YourPositions.tsx b/src/pages/ThorChainLP/YourPositions.tsx index 41400429d5b..1a56b1ef13d 100644 --- a/src/pages/ThorChainLP/YourPositions.tsx +++ b/src/pages/ThorChainLP/YourPositions.tsx @@ -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' @@ -63,7 +64,7 @@ type PositionButtonProps = { opportunityId: string accountId: string apy: string - userPoolData: any // TODO + userPoolData: UserLpDataPosition } const PositionButton = ({ diff --git a/src/pages/ThorChainLP/hooks/useAllUserLpData.ts b/src/pages/ThorChainLP/hooks/useAllUserLpData.ts index bd3c8804271..e4f1b742e03 100644 --- a/src/pages/ThorChainLP/hooks/useAllUserLpData.ts +++ b/src/pages/ThorChainLP/hooks/useAllUserLpData.ts @@ -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' @@ -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 = ({ diff --git a/src/pages/ThorChainLP/hooks/useUserLpData.ts b/src/pages/ThorChainLP/hooks/useUserLpData.ts index 8fc794f8d49..994d9ee7c1e 100644 --- a/src/pages/ThorChainLP/hooks/useUserLpData.ts +++ b/src/pages/ThorChainLP/hooks/useUserLpData.ts @@ -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' @@ -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 => { +}: UseUserLpDataProps): UseQueryResult => { const thorchainAccountIds = useAppSelector(state => selectAccountIdsByAssetId(state, { assetId: thorchainAssetId }), )