From ee32256078ecf112dc98b45b741b5ffc7b7fb10b Mon Sep 17 00:00:00 2001 From: abtestingalpha <104046418+abtestingalpha@users.noreply.github.com> Date: Mon, 8 Jan 2024 09:41:44 -0500 Subject: [PATCH] Fixes pools apy loading (#1773) --- .../utils/actions/getPoolApyData.ts | 6 +++--- .../utils/actions/getStakedBalance.ts | 13 ++++++++++--- packages/synapse-interface/utils/isBlacklisted.ts | 1 + 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/packages/synapse-interface/utils/actions/getPoolApyData.ts b/packages/synapse-interface/utils/actions/getPoolApyData.ts index 8c5da07b96..2cffd59f76 100644 --- a/packages/synapse-interface/utils/actions/getPoolApyData.ts +++ b/packages/synapse-interface/utils/actions/getPoolApyData.ts @@ -78,15 +78,15 @@ export const getPoolApyData = async ( ], }) - // console.log(`data`, data) - const synapsePerSecondResult: bigint = data[0].result const totalAllocPointsResult: bigint = data[1].result const poolInfoResult: PoolInfoResult = data[2].result const lpTokenBalanceResult: bigint = data[3].result ?? 0n const lpTokenSupplyResult: bigint = data[4].result ?? 0n - const synPriceData = prices?.synPrices ?? (await getSynPrices()) + const synPriceData = prices?.synPrices?.synPrice + ? prices.synPrices + : await getSynPrices() const metisPrice = prices?.metisPrice ?? (await getMetisPrice()) const synapsePerSecond: bigint = synapsePerSecondResult ?? 0n diff --git a/packages/synapse-interface/utils/actions/getStakedBalance.ts b/packages/synapse-interface/utils/actions/getStakedBalance.ts index 20deaf465f..60518e6b0a 100644 --- a/packages/synapse-interface/utils/actions/getStakedBalance.ts +++ b/packages/synapse-interface/utils/actions/getStakedBalance.ts @@ -42,9 +42,16 @@ export const getStakedBalance = async ( const userInfo: UserInfoResult = data[0] const pendingSynapse: PendingSynapseResult = data[1] - return { - amount: userInfo?.result[0] ?? 0n, - reward: pendingSynapse?.result ?? 0n, + if (userInfo.status === 'success') { + return { + amount: userInfo?.result[0] ?? 0n, + reward: pendingSynapse?.result ?? 0n, + } + } else { + return { + amount: 0n, + reward: 0n, + } } } catch (error) { console.error('Error from getStakedBalance: ', error) diff --git a/packages/synapse-interface/utils/isBlacklisted.ts b/packages/synapse-interface/utils/isBlacklisted.ts index 8d02a38434..5e98eae8a8 100644 --- a/packages/synapse-interface/utils/isBlacklisted.ts +++ b/packages/synapse-interface/utils/isBlacklisted.ts @@ -3,6 +3,7 @@ import { Address, getAddress } from 'viem' import { EXCLUDED_ADDRESSES } from '@/constants/blacklist' export const isBlacklisted = (address: Address | string) => { + if (!address) return try { const checksummedAddress = getAddress(address)