Skip to content

Commit

Permalink
indexer-agent: Add fallback if decimals() call to DAI contract fails
Browse files Browse the repository at this point in the history
  • Loading branch information
fordN committed Nov 27, 2023
1 parent ae296c7 commit 82fb292
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/indexer-agent/src/cost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,16 @@ const monitorAndInjectDai = async ({
// Identify the decimals used by the DAI or USDC contract
const chainId = ethereum.network.chainId
const stableCoin = new Contract(daiContractAddress, ERC20_ABI, ethereum)
const decimals = await stableCoin.decimals()
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const decimals = await stableCoin.decimals().catch((error: any) => {
logger.warn(
`Failed to call 'decimals()' on '${daiContractAddress}', defaulting to '18'`,
{
error,
},
)
return 18
})

const DAI = new Token(chainId, daiContractAddress, decimals)
const GRT = new Token(chainId, contracts.token.address, 18)
Expand Down

0 comments on commit 82fb292

Please sign in to comment.