From 605e9aff6414d7170efede36e7dff4366bed0773 Mon Sep 17 00:00:00 2001 From: brianshattuck Date: Tue, 17 Dec 2024 07:20:09 -0800 Subject: [PATCH] the undeposit just withdraws the LP and not call the claim function --- .../StakerMyStakes/FarmStakeButtons.tsx | 8 +-- src/hooks/useStakerHandlers.ts | 61 +------------------ 2 files changed, 7 insertions(+), 62 deletions(-) diff --git a/src/components/StakerMyStakes/FarmStakeButtons.tsx b/src/components/StakerMyStakes/FarmStakeButtons.tsx index 82ef5312a..720a5e0c3 100644 --- a/src/components/StakerMyStakes/FarmStakeButtons.tsx +++ b/src/components/StakerMyStakes/FarmStakeButtons.tsx @@ -20,7 +20,7 @@ export default function FarmStakeButtons({ el }: FarmCardDetailProps) { const { txType, selectedTokenId, txConfirmed, txError, selectedFarmingType } = v3Stake ?? {}; - const { eternalCollectRewardHandler, withdrawHandler, claimRewardsHandler } = + const { eternalCollectRewardHandler, withdrawHandler, exitFarmingsHandler } = useFarmingHandlers() || {}; return ( @@ -80,18 +80,18 @@ export default function FarmStakeButtons({ el }: FarmCardDetailProps) { disabled={ selectedTokenId === el.id && selectedFarmingType === FarmingType.ETERNAL && - txType === 'claimRewards' && + txType === 'exitFarmings' && !txConfirmed && !txError } onClick={() => { - claimRewardsHandler(el.id, { ...el }, FarmingType.ETERNAL); + exitFarmingsHandler(el.id, { ...el }, FarmingType.ETERNAL); }} > {selectedTokenId === el.id && selectedFarmingType === FarmingType.ETERNAL && - txType === 'claimRewards' && + txType === 'exitFarmings' && !txConfirmed && !txError ? t('undepositing') diff --git a/src/hooks/useStakerHandlers.ts b/src/hooks/useStakerHandlers.ts index 070580823..8ada9f272 100644 --- a/src/hooks/useStakerHandlers.ts +++ b/src/hooks/useStakerHandlers.ts @@ -30,7 +30,7 @@ export function useFarmingHandlers() { const { updateV3Stake } = useV3StakeData(); //exit from basic farming and claim than - const claimRewardsHandler = useCallback( + const exitFarmingsHandler = useCallback( async ( token: any, { @@ -43,10 +43,6 @@ export function useFarmingHandlers() { eternalBonusRewardToken, eternalStartTime, eternalEndTime, - eternalBonusEarned, - eternalEarned, - limitBonusEarned, - limitEarned, isDetached, }: any, farmingType: any, @@ -56,19 +52,12 @@ export function useFarmingHandlers() { updateV3Stake({ selectedTokenId: token, selectedFarmingType: farmingType, - txType: 'claimRewards', + txType: 'exitFarmings', txConfirmed: false, txHash: '', txError: '', }); - const MaxUint128 = toHex( - JSBI.subtract( - JSBI.exponentiate(JSBI.BigInt(2), JSBI.BigInt(128)), - JSBI.BigInt(1), - ), - ); - const farmingCenterContract = new Contract( FARMING_CENTER[chainId], FARMING_CENTER_ABI, @@ -95,28 +84,6 @@ export function useFarmingHandlers() { ]), ]; - if (Boolean(+eternalEarned)) { - callDatas.push( - farmingCenterInterface.encodeFunctionData('claimReward', [ - eternalRewardToken.address, - account, - 0, - MaxUint128, - ]), - ); - } - - if (Boolean(+eternalBonusEarned)) { - callDatas.push( - farmingCenterInterface.encodeFunctionData('claimReward', [ - eternalBonusRewardToken.address, - account, - 0, - MaxUint128, - ]), - ); - } - if (isDetached) { const estimatedGas = await farmingCenterContract.estimateGas.multicall( callDatas, @@ -169,28 +136,6 @@ export function useFarmingHandlers() { ]), ]; - if (Boolean(+limitEarned)) { - callDatas.push( - farmingCenterInterface.encodeFunctionData('claimReward', [ - limitRewardToken.address, - account, - MaxUint128, - 0, - ]), - ); - } - - if (Boolean(+limitBonusEarned)) { - callDatas.push( - farmingCenterInterface.encodeFunctionData('claimReward', [ - limitBonusRewardToken.address, - account, - MaxUint128, - 0, - ]), - ); - } - const estimatedGas = await farmingCenterContract.estimateGas.multicall( callDatas, ); @@ -663,7 +608,7 @@ export function useFarmingHandlers() { approveHandler, farmHandler, withdrawHandler, - claimRewardsHandler, + exitFarmingsHandler, eternalCollectRewardHandler, eternalOnlyCollectRewardHandler, };