Skip to content

Commit

Permalink
fix: zapper zod types (#7598)
Browse files Browse the repository at this point in the history
Co-authored-by: woody <125113430+woodenfurniture@users.noreply.github.com>
  • Loading branch information
0xApotheosis and woodenfurniture authored Aug 22, 2024
1 parent bce5f79 commit f1cf719
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/state/apis/zapper/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ type ZapperToken = {
price?: number
supply?: number
symbol: string
decimals: number
decimals: string | number
dataProps?: Infer<typeof ZapperDataPropsSchema>
displayProps?: Infer<typeof ZapperDisplayPropsSchema>
pricePerShare?: (string | number)[]
Expand All @@ -155,7 +155,7 @@ const ZapperTokenSchema: Type<ZapperToken> = 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(),
Expand Down
9 changes: 6 additions & 3 deletions src/state/apis/zapper/zapperApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
},
)
Expand Down
4 changes: 2 additions & 2 deletions src/state/slices/opportunitiesSlice/resolvers/uniV2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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!)
Expand Down

0 comments on commit f1cf719

Please sign in to comment.