From 0236396ce3554923aaf4fc262964fb47cd2d0868 Mon Sep 17 00:00:00 2001 From: Majorfi Date: Tue, 17 Oct 2023 09:40:49 +0200 Subject: [PATCH] feat: remove claim all --- apps/veyfi/components/RewardsTab.tsx | 55 ++-------------------------- 1 file changed, 4 insertions(+), 51 deletions(-) diff --git a/apps/veyfi/components/RewardsTab.tsx b/apps/veyfi/components/RewardsTab.tsx index 8820afc6c..211fef069 100644 --- a/apps/veyfi/components/RewardsTab.tsx +++ b/apps/veyfi/components/RewardsTab.tsx @@ -1,13 +1,12 @@ -import {useCallback, useMemo, useState} from 'react'; +import {useCallback, useState} from 'react'; import {useGauge} from '@veYFI/contexts/useGauge'; import {useOption} from '@veYFI/contexts/useOption'; import * as GaugeActions from '@veYFI/utils/actions/gauge'; -import {VEYFI_CHAIN_ID, VEYFI_CLAIM_REWARDS_ZAP_ADDRESS} from '@veYFI/utils/constants'; +import {VEYFI_CHAIN_ID} from '@veYFI/utils/constants'; import {validateNetwork} 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 {BIG_ZERO} from '@yearn-finance/web-lib/utils/constants'; +import {toAddress, truncateHex} from '@yearn-finance/web-lib/utils/address'; import {toBigInt, toNormalizedAmount} from '@yearn-finance/web-lib/utils/format.bigNumber'; import {formatCounterValue} from '@yearn-finance/web-lib/utils/format.value'; import {isZero} from '@yearn-finance/web-lib/utils/isZero'; @@ -27,7 +26,6 @@ export function RewardsTab(): ReactElement { const {vaults} = useYearn(); const refreshData = useCallback((): unknown => Promise.all([refreshGauges()]), [refreshGauges]); const [claimStatus, set_claimStatus] = useState(defaultTxStatus); - const [claimAllStatus, set_claimAllStatus] = useState(defaultTxStatus); const selectedGaugeAddress = toAddress(selectedGauge?.id); const selectedGaugeRewards = toBigInt(positionsMap[selectedGaugeAddress]?.reward?.balance?.raw); @@ -43,20 +41,6 @@ export function RewardsTab(): ReactElement { } }, [provider, refreshData, selectedGaugeAddress]); - const onClaimAll = useCallback(async (): Promise => { - const result = await GaugeActions.claimAllRewards({ - connector: provider, - chainID: VEYFI_CHAIN_ID, - contractAddress: VEYFI_CLAIM_REWARDS_ZAP_ADDRESS, - gaugeAddresses, - willLockRewards: false, - statusHandler: set_claimAllStatus - }); - if (result.isSuccessful) { - refreshData(); - } - }, [gaugeAddresses, provider, refreshData]); - const gaugeOptions = gaugeAddresses.filter((address): boolean => toBigInt(positionsMap[address]?.reward?.balance?.raw) > 0n ?? false) .map((address): TDropdownOption => { const gauge = gaugesMap[address]; @@ -65,17 +49,11 @@ export function RewardsTab(): ReactElement { return { id: address, - label: vault?.display_name ?? '', + label: vault?.display_name ?? `Vault ${truncateHex(vaultAddress, 4)}`, icon: `${process.env.BASE_YEARN_ASSETS_URI}/1/${vaultAddress}/logo-128.png` }; }); - const gaugesRewards = useMemo((): bigint => { - return gaugeAddresses.reduce((acc, address): bigint => { - return acc + toBigInt(positionsMap[address]?.reward?.balance?.raw); - }, BIG_ZERO); - }, [gaugeAddresses, positionsMap]); - const {isValid: isValidNetwork} = validateNetwork({supportedNetwork: VEYFI_CHAIN_ID, walletNetwork: chainID}); return ( @@ -87,31 +65,6 @@ export function RewardsTab(): ReactElement { -
- - -
- - -
-
-

- {'Claim Separately'} -

-
-