Skip to content

Commit

Permalink
IERC20
Browse files Browse the repository at this point in the history
  • Loading branch information
jarbacoa committed Mar 17, 2022
1 parent 113bf61 commit 80a013d
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/hooks/convex/useStakedConvexBalances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ import BaseRewardPoolABI from "contracts/abi/ConvexBaseRewardPool.json"
import { CONVEX_CTOKEN_INFO } from "constants/convex";
import { Contract } from "ethers";
import { BigNumber } from "ethers";

import { useTokenBalances } from "hooks/useTokenBalance";
import { useMemo } from "react";
import { erc20ABI } from "wagmi";
import { Interface } from "ethers/lib/utils";

export type StakedConvexBalancesMap = {
[cToken: string]: {
Expand Down Expand Up @@ -69,7 +66,15 @@ type BalancesMap = {
[token: string]: BigNumber
}

const IERC20 = new Interface([
'function name() public view returns (string)',
'function symbol() public view returns (string)',
'function decimals() public view returns (uint8)',
'function balanceOf(address _owner) public view returns (uint256 balance)',
])

export const useCurveLPBalances = (): BalancesMap => {


const { fuse, address, isAuthed } = useRari();
const multiCallProvider = new providers.MulticallProvider(fuse.provider)
Expand All @@ -86,7 +91,7 @@ export const useCurveLPBalances = (): BalancesMap => {
Object.values(CONVEX_CTOKEN_INFO)
.map(c => ({ curveLPToken: c.lpToken }))
.map(({ curveLPToken }) => {
let contract = new Contract(curveLPToken, erc20ABI, multiCallProvider)
let contract = new Contract(curveLPToken, IERC20, multiCallProvider)
return contract.balanceOf(address)
.then((balance: BigNumber) => {
if (!balance.isZero()) {
Expand Down

0 comments on commit 80a013d

Please sign in to comment.