diff --git a/src/state/apis/zapper/validators.ts b/src/state/apis/zapper/validators.ts index 9be3aa6eea7..9d2328d41e5 100644 --- a/src/state/apis/zapper/validators.ts +++ b/src/state/apis/zapper/validators.ts @@ -140,7 +140,7 @@ type ZapperToken = { price?: number supply?: number symbol: string - decimals: number + decimals: string | number dataProps?: Infer displayProps?: Infer pricePerShare?: (string | number)[] @@ -155,7 +155,7 @@ const ZapperTokenSchema: Type = z type: z.literals('base-token', 'app-token'), network: SupportedZapperNetworks, address: z.string(), - decimals: z.number(), + decimals: z.union([z.string(), z.number()]), symbol: z.string(), price: z.number(), metaType: z.literals('claimable', 'supplied', 'borrowed').optional(), diff --git a/src/state/apis/zapper/zapperApi.ts b/src/state/apis/zapper/zapperApi.ts index 24166bca17c..512c5518edf 100644 --- a/src/state/apis/zapper/zapperApi.ts +++ b/src/state/apis/zapper/zapperApi.ts @@ -411,7 +411,7 @@ export const zapper = createApi({ symbol: token.symbol, // No dice here, there's no name property name: token.symbol, - precision: token.decimals, + precision: bnOrZero(token.decimals).toNumber(), icon: token.displayProps?.images[i] ?? '', }) acc.ids = acc.ids.concat(rewardAssetId) @@ -545,7 +545,7 @@ export const zapper = createApi({ symbol: asset.tokens[i].symbol, // No dice here, there's no name property name: asset.tokens[i].symbol, - precision: asset.tokens[i].decimals, + precision: bnOrZero(asset.tokens[i].decimals).toNumber(), icon: asset.displayProps?.images[i] ?? '', }) acc.ids = acc.ids.concat(underlyingAssetId) @@ -580,7 +580,10 @@ export const zapper = createApi({ ? bn(reserveBaseUnit).div(totalSupplyBaseUnit).toString() : undefined if (bnOrZero(tokenPoolRatio).isZero()) return '0' - const ratio = toBaseUnit(tokenPoolRatio, asset.tokens[i].decimals) + const ratio = toBaseUnit( + tokenPoolRatio, + bnOrZero(asset.tokens[i].decimals).toNumber(), + ) return ratio }, ) diff --git a/src/state/slices/opportunitiesSlice/resolvers/uniV2/index.ts b/src/state/slices/opportunitiesSlice/resolvers/uniV2/index.ts index 47357832513..636cd9a18d4 100644 --- a/src/state/slices/opportunitiesSlice/resolvers/uniV2/index.ts +++ b/src/state/slices/opportunitiesSlice/resolvers/uniV2/index.ts @@ -127,8 +127,8 @@ export const uniV2LpOpportunitiesMetadataResolver = async ({ } } - token0Decimals = zapperAppBalanceData.tokens?.[0].decimals! - token1Decimals = zapperAppBalanceData.tokens?.[1].decimals! + token0Decimals = bnOrZero(zapperAppBalanceData.tokens?.[0].decimals!).toNumber() + token1Decimals = bnOrZero(zapperAppBalanceData.tokens?.[1].decimals!).toNumber() token0Reserves = bnOrZero(zapperAppBalanceData.dataProps?.reserves?.[0])! token1Reserves = bnOrZero(zapperAppBalanceData.dataProps?.reserves?.[1])! token0Address = getAddress(zapperAppBalanceData?.tokens?.[0].address!)