From bf8e4669aa03937095539815e0ac8eab0c9e66e3 Mon Sep 17 00:00:00 2001 From: vkulinich Date: Mon, 10 Jun 2024 18:48:50 +0200 Subject: [PATCH] Fix api errors --- src/sections/pools/PoolsPage.utils.ts | 10 +++++----- src/sections/stats/StatsPage.utils.ts | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/sections/pools/PoolsPage.utils.ts b/src/sections/pools/PoolsPage.utils.ts index d5880dbb0..9dffbc6d0 100644 --- a/src/sections/pools/PoolsPage.utils.ts +++ b/src/sections/pools/PoolsPage.utils.ts @@ -205,12 +205,12 @@ export const usePools = () => { )?.spotPrice const tvlDisplay = BN( - tvls.data?.find((tvl) => tvl.asset_id === Number(assetId))?.tvl_usd ?? + tvls?.data?.find((tvl) => tvl.asset_id === Number(assetId))?.tvl_usd ?? BN_NAN, ).multipliedBy(apiSpotPrice ?? 1) const volume = BN( - volumes.data?.find((volume) => volume.asset_id.toString() === assetId) + volumes?.data?.find((volume) => volume.asset_id.toString() === assetId) ?.volume_usd ?? BN_NAN, ).multipliedBy(apiSpotPrice ?? 1) @@ -218,7 +218,7 @@ export const usePools = () => { assets.native.id === assetId ? BN_0 : BN( - fees.data?.find((fee) => fee.asset_id.toString() === assetId) + fees?.data?.find((fee) => fee.asset_id.toString() === assetId) ?.projected_apr_perc ?? BN_NAN, ) @@ -240,9 +240,9 @@ export const usePools = () => { canAddLiquidity: tradability.canAddLiquidity, canRemoveLiquidity: tradability.canRemoveLiquidity, volume, - isVolumeLoading: volumes.isLoading, + isVolumeLoading: volumes?.isLoading, fee, - isFeeLoading: fees.isLoading, + isFeeLoading: fees?.isLoading, omnipoolPositions: filteredOmnipoolPositions, miningPositions: filteredMiningPositions, isPositions, diff --git a/src/sections/stats/StatsPage.utils.ts b/src/sections/stats/StatsPage.utils.ts index c393282df..8a89cb67a 100644 --- a/src/sections/stats/StatsPage.utils.ts +++ b/src/sections/stats/StatsPage.utils.ts @@ -169,12 +169,12 @@ export const useOmnipoolAssetDetails = (sortBy: "tvl" | "pol") => { const pol = valueOfLiquidityPositions.plus(valueOfShares) const tvl = BN( - tvls.data?.find((tvl) => tvl.asset_id === Number(omnipoolAssetId)) + tvls?.data?.find((tvl) => tvl.asset_id === Number(omnipoolAssetId)) ?.tvl_usd ?? BN_NAN, ) const volume = BN( - volumes.data?.find( + volumes?.data?.find( (volume) => volume.asset_id === Number(omnipoolAssetId), )?.volume_usd ?? BN_NAN, ) @@ -183,8 +183,9 @@ export const useOmnipoolAssetDetails = (sortBy: "tvl" | "pol") => { assets.native.id === omnipoolAssetId ? BN_0 : BN( - fees.data?.find((fee) => fee.asset_id === Number(omnipoolAssetId)) - ?.projected_apr_perc ?? BN_NAN, + fees?.data?.find( + (fee) => fee.asset_id === Number(omnipoolAssetId), + )?.projected_apr_perc ?? BN_NAN, ) const iconIds = assets.isStableSwap(meta) ? meta.assets : meta.id @@ -201,7 +202,7 @@ export const useOmnipoolAssetDetails = (sortBy: "tvl" | "pol") => { volumePol: BN(0), price: spotPrice, fee, - isLoadingFee: fees.isInitialLoading, + isLoadingFee: fees?.isInitialLoading, isLoadingVolume: volumes.isInitialLoading, } }) @@ -209,8 +210,7 @@ export const useOmnipoolAssetDetails = (sortBy: "tvl" | "pol") => { }, [ apiIds.data, assets, - fees.data, - fees.isInitialLoading, + fees, omnipoolAssetBalances, omnipoolAssets.data, positions,