From 6ac94a925fc8420460aaef83643fbef70b02818a Mon Sep 17 00:00:00 2001 From: Majorfi Date: Tue, 17 Oct 2023 16:43:54 +0200 Subject: [PATCH] fix: price --- apps/veyfi/components/RedeemTab.tsx | 11 +++++---- apps/veyfi/components/RewardsTab.tsx | 5 ++-- apps/veyfi/contexts/useOption.tsx | 35 ++++++++++++++-------------- 3 files changed, 25 insertions(+), 26 deletions(-) diff --git a/apps/veyfi/components/RedeemTab.tsx b/apps/veyfi/components/RedeemTab.tsx index e63a497cf..0028e6cca 100644 --- a/apps/veyfi/components/RedeemTab.tsx +++ b/apps/veyfi/components/RedeemTab.tsx @@ -6,7 +6,7 @@ import {validateAllowance, validateAmount} from '@veYFI/utils/validations'; import {Button} from '@yearn-finance/web-lib/components/Button'; import {useWeb3} from '@yearn-finance/web-lib/contexts/useWeb3'; import {toAddress} from '@yearn-finance/web-lib/utils/address'; -import {ETH_TOKEN_ADDRESS} from '@yearn-finance/web-lib/utils/constants'; +import {ETH_TOKEN_ADDRESS, YFI_ADDRESS} from '@yearn-finance/web-lib/utils/constants'; import {toNormalizedBN} from '@yearn-finance/web-lib/utils/format.bigNumber'; import {formatCounterValue} from '@yearn-finance/web-lib/utils/format.value'; import {handleInputChangeEventValue} from '@yearn-finance/web-lib/utils/handlers/handleInputChangeEventValue'; @@ -24,16 +24,17 @@ export function RedeemTab(): ReactElement { const [redeemAmount, set_redeemAmount] = useState(toNormalizedBN(0)); const {provider, address, isActive} = useWeb3(); const {refresh: refreshBalances} = useWallet(); - const {getRequiredEth, price: optionPrice, position: dYFIBalance, allowances, refresh} = useOption(); + const {getRequiredEth, position: dYFIBalance, allowances, refresh, dYFIPrice} = useOption(); const clearLockAmount = (): void => set_redeemAmount(toNormalizedBN(0)); const refreshData = useCallback((): unknown => Promise.all([refresh(), refreshBalances()]), [refresh, refreshBalances]); const onTxSuccess = useCallback((): unknown => Promise.all([refreshData(), clearLockAmount()]), [refreshData]); const ethBalance = useBalance(ETH_TOKEN_ADDRESS); - const dYFIPrice = useTokenPrice(VEYFI_DYFI_ADDRESS); + const yfiPrice = useTokenPrice(YFI_ADDRESS); const [approveRedeemStatus, set_approveRedeemStatus] = useState(defaultTxStatus); const [redeemStatus, set_redeemStatus] = useState(defaultTxStatus); const [ethRequired, set_ethRequired] = useState(toNormalizedBN(0)); + useAsyncTrigger(async (): Promise => { const result = await getRequiredEth(redeemAmount.raw); set_ethRequired(toNormalizedBN(result)); @@ -101,7 +102,7 @@ export function RedeemTab(): ReactElement { set_redeemAmount(dYFIBalance)} onMaxClick={(): void => set_redeemAmount(dYFIBalance)} - legend={formatCounterValue(redeemAmount.normalized, dYFIPrice)} + legend={formatCounterValue(redeemAmount.normalized, yfiPrice)} error={redeemAmountError} /> (); const {provider, isActive} = useWeb3(); const {gaugeAddresses, gaugesMap, positionsMap, refresh: refreshGauges} = useGauge(); - const {price: optionPrice} = useOption(); + const {dYFIPrice} = useOption(); const {vaults} = useYearn(); const refreshData = useCallback((): unknown => Promise.all([refreshGauges()]), [refreshGauges]); const [claimStatus, set_claimStatus] = useState(defaultTxStatus); @@ -72,7 +71,7 @@ export function RewardsTab(): ReactElement {