Skip to content

Commit

Permalink
Merge pull request #1646 from QuickSwap/feature/change-undeposit-old-…
Browse files Browse the repository at this point in the history
…farm

the undeposit just withdraws the LP  and not call the claim function
  • Loading branch information
sameepsi authored Dec 18, 2024
2 parents 2f5100e + 605e9af commit 691ef43
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 62 deletions.
8 changes: 4 additions & 4 deletions src/components/StakerMyStakes/FarmStakeButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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);
}}
>
<small>
{selectedTokenId === el.id &&
selectedFarmingType === FarmingType.ETERNAL &&
txType === 'claimRewards' &&
txType === 'exitFarmings' &&
!txConfirmed &&
!txError
? t('undepositing')
Expand Down
61 changes: 3 additions & 58 deletions src/hooks/useStakerHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
{
Expand All @@ -43,10 +43,6 @@ export function useFarmingHandlers() {
eternalBonusRewardToken,
eternalStartTime,
eternalEndTime,
eternalBonusEarned,
eternalEarned,
limitBonusEarned,
limitEarned,
isDetached,
}: any,
farmingType: any,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
);
Expand Down Expand Up @@ -663,7 +608,7 @@ export function useFarmingHandlers() {
approveHandler,
farmHandler,
withdrawHandler,
claimRewardsHandler,
exitFarmingsHandler,
eternalCollectRewardHandler,
eternalOnlyCollectRewardHandler,
};
Expand Down

0 comments on commit 691ef43

Please sign in to comment.