From f34e928e351f1b116127fb5829186cc937aa79dd Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 13 Oct 2023 19:11:30 +0000 Subject: [PATCH] test: update --- .../components/lib/hooks/use-balances.tsx | 19 ++----------------- packages/dapp/components/lib/types.ts | 15 ++++++++++++++- .../dapp/components/redeem/debt-coupon.tsx | 3 ++- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/packages/dapp/components/lib/hooks/use-balances.tsx b/packages/dapp/components/lib/hooks/use-balances.tsx index 0648a01ad..65f6cc84a 100644 --- a/packages/dapp/components/lib/hooks/use-balances.tsx +++ b/packages/dapp/components/lib/hooks/use-balances.tsx @@ -1,5 +1,4 @@ import { erc1155BalanceOf, _3crvTokenAddress } from "@/lib/utils"; -import { BigNumber } from "ethers"; import { createContext, useContext, useEffect, useState } from "react"; import useNamedContracts from "./contracts/use-named-contracts"; import useWalletAddress from "./use-wallet-address"; @@ -7,19 +6,7 @@ import { ChildrenShim } from "./children-shim-d"; import useProtocolContracts from "@/components/lib/hooks/contracts/use-protocol-contracts"; import { getERC20Contract } from "@/components/utils/contracts"; import useWeb3 from "@/components/lib/hooks/use-web-3"; - -export interface Balances { - uad: BigNumber; - _3crv: BigNumber; - uad3crv: BigNumber; - ucr: BigNumber; - ucrNft: BigNumber; - ubq: BigNumber; - stakingShares: BigNumber; - usdc: BigNumber; - dai: BigNumber; - usdt: BigNumber; -} +import { Balances } from "../types"; type RefreshBalances = () => Promise; @@ -39,10 +26,9 @@ export const BalancesContextProvider: React.FC = ({ children }) => const contracts = await protocolContracts; - if(contracts.creditNft && contracts.stakingShare) { + if (contracts.creditNft && contracts.stakingShare) { // const _3crvTokenAddress = await contracts.managerFacet?.curve3PoolTokenAddress(); const _3crvTokenContract = getERC20Contract(_3crvTokenAddress, provider); - const [uad, _3crv, uad3crv, ucr, ubq, ucrNft, stakingShares, usdc, dai, usdt] = await Promise.all([ contracts.dollarToken?.balanceOf(walletAddress), _3crvTokenContract.balanceOf(walletAddress), @@ -55,7 +41,6 @@ export const BalancesContextProvider: React.FC = ({ children }) => namedContracts.dai.balanceOf(walletAddress), namedContracts.usdt.balanceOf(walletAddress), ]); - setBalances({ uad, _3crv, diff --git a/packages/dapp/components/lib/types.ts b/packages/dapp/components/lib/types.ts index e3d93ffd2..f27dcabbf 100644 --- a/packages/dapp/components/lib/types.ts +++ b/packages/dapp/components/lib/types.ts @@ -1,4 +1,4 @@ -import { ethers } from "ethers"; +import { BigNumber, ethers } from "ethers"; export interface EthAccount { balance: number; @@ -30,3 +30,16 @@ export interface PoolState { feeProtocol: number; unlocked: boolean; } + +export interface Balances { + uad: BigNumber; + _3crv: BigNumber; + uad3crv: BigNumber; + ucr: BigNumber; + ucrNft: BigNumber; + ubq: BigNumber; + stakingShares: BigNumber; + usdc: BigNumber; + dai: BigNumber; + usdt: BigNumber; +} diff --git a/packages/dapp/components/redeem/debt-coupon.tsx b/packages/dapp/components/redeem/debt-coupon.tsx index cf18ba7c9..2bc062d1d 100644 --- a/packages/dapp/components/redeem/debt-coupon.tsx +++ b/packages/dapp/components/redeem/debt-coupon.tsx @@ -2,9 +2,10 @@ import { constrainNumber, formatTimeDiff } from "@/lib/utils"; import withLoadedContext, { LoadedContext } from "@/lib/with-loaded-context"; import { BigNumber, ethers } from "ethers"; import { ChangeEvent, Dispatch, memo, SetStateAction, useEffect, useMemo, useState } from "react"; -import useBalances, { Balances } from "../lib/hooks/use-balances"; +import useBalances from "../lib/hooks/use-balances"; import useTransactionLogger from "../lib/hooks/use-transaction-logger"; import usePrices from "./lib/use-prices"; +import { Balances } from "../lib/types"; type Actions = { onRedeem: () => void;