Skip to content

Commit

Permalink
test: update
Browse files Browse the repository at this point in the history
  • Loading branch information
molecula451 committed Oct 13, 2023
1 parent f57ed92 commit f34e928
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
19 changes: 2 additions & 17 deletions packages/dapp/components/lib/hooks/use-balances.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,12 @@
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";
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<void>;

Expand All @@ -39,10 +26,9 @@ export const BalancesContextProvider: React.FC<ChildrenShim> = ({ 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),
Expand All @@ -55,7 +41,6 @@ export const BalancesContextProvider: React.FC<ChildrenShim> = ({ children }) =>
namedContracts.dai.balanceOf(walletAddress),
namedContracts.usdt.balanceOf(walletAddress),
]);

setBalances({
uad,
_3crv,
Expand Down
15 changes: 14 additions & 1 deletion packages/dapp/components/lib/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ethers } from "ethers";
import { BigNumber, ethers } from "ethers";

export interface EthAccount {
balance: number;
Expand Down Expand Up @@ -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;
}
3 changes: 2 additions & 1 deletion packages/dapp/components/redeem/debt-coupon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f34e928

Please sign in to comment.