From f4ae8348a68456ae368e7028e32feec8f9ed73dc Mon Sep 17 00:00:00 2001 From: Abhishek <77395788+abhishek-01k@users.noreply.github.com> Date: Fri, 24 Nov 2023 17:49:04 +0530 Subject: [PATCH] YieldFarming deployed to sepolia and Issue Fixed (#1315) * YieldFarming deployed to sepolia and Issue Fixed * Changed the contract addredd of uni v2 for sepolia --- src/components/StepsTransactionModal.tsx | 4 +- src/components/yield/YieldPushFeeV3.tsx | 42 +++++++++++++-------- src/config/config-dev.js | 31 +++++++++------ src/helpers/pushStaking/src/CoreV2Reward.ts | 2 - src/helpers/pushStaking/src/constants.ts | 1 + src/modules/yield/YieldFarmingModuleV2.tsx | 2 +- 6 files changed, 50 insertions(+), 32 deletions(-) diff --git a/src/components/StepsTransactionModal.tsx b/src/components/StepsTransactionModal.tsx index bed6c8f948..f9a793ed9e 100644 --- a/src/components/StepsTransactionModal.tsx +++ b/src/components/StepsTransactionModal.tsx @@ -90,9 +90,9 @@ const StepsTransactionModal = ({ onClose, InnerComponentProps }) => { Transaction Error - + {/* User denied the transaction signature. - + */} diff --git a/src/components/yield/YieldPushFeeV3.tsx b/src/components/yield/YieldPushFeeV3.tsx index 93ad256f06..0f38172dd7 100644 --- a/src/components/yield/YieldPushFeeV3.tsx +++ b/src/components/yield/YieldPushFeeV3.tsx @@ -131,12 +131,11 @@ const YieldPushFeeV3 = ({ var signer = provider.getSigner(account); let pushCoreV2 = new ethers.Contract(addresses.pushCoreV2, abis.pushCoreV2, signer); - + const currentEpoch = PUSHPoolstats?.currentEpochNumber; const batchSize = 14; - + const isAddressDelegate = await checkDelegateAddress(pushCoreV2); - setTxInProgressClaimRewards(false); if (!isAddressDelegate) { return; } @@ -145,18 +144,18 @@ const YieldPushFeeV3 = ({ _tillEpoch = await getLastClaimedBlock(pushCoreV2); openTransactionModal(); + setTxInProgressClaimRewards(false); let totalTransactionNumber = 0; + //!TODO Verify Again. Edge Cases if (currentEpoch - _tillEpoch < batchSize) { totalTransactionNumber = Math.ceil((currentEpoch - _tillEpoch) / batchSize); } else { - totalTransactionNumber = Math.floor((currentEpoch - _tillEpoch) / batchSize); + totalTransactionNumber = Math.ceil((currentEpoch - _tillEpoch) / batchSize); } setTotalTransactionNo(totalTransactionNumber); - console.log("Total transaction number", totalTransactionNumber, _tillEpoch, currentEpoch); - if (totalTransactionNumber == 0) { return; } @@ -217,6 +216,12 @@ const YieldPushFeeV3 = ({ }).catch((error) => { console.log("Error in claiming the reward", error); + pushFeeToast.showMessageToast({ + toastTitle: 'Error', + toastMessage: `Transaction failed! ${error.reason}`, + toastType: 'ERROR', + getToastIcon: (size) => , + }); setTransactionText(''); setTxInProgressWithdraw(false); getUserDataPush(); @@ -247,8 +252,6 @@ const YieldPushFeeV3 = ({ // Checking if the address is delegated or not const isAddressDelegate = await checkDelegateAddress(pushCoreV2); - - console.log("Is Address delegate", isAddressDelegate); setTxInProgressClaimRewards(false); if (!isAddressDelegate) { return; @@ -260,16 +263,25 @@ const YieldPushFeeV3 = ({ let _tillEpoch = 0; _tillEpoch = await getLastClaimedBlock(pushCoreV2); - console.log("Last Claimed Block", _tillEpoch, currentEpoch); + // Case -: When the user has just claimed reward and then trying to unstake + if (_tillEpoch >= currentEpoch - 1) { + setTxInProgressWithdraw(false); + setUnstakeErrorMessage("PUSH cannot be unstaked until current epoch is over."); + pushFeeToast.showMessageToast({ + toastTitle: 'Unstaking Error', + toastMessage: `You cannot unstake until Current Epoch gets over.`, + toastType: 'ERROR', + getToastIcon: (size) => , + }); + return; + } // Modal for displaying transactions openTransactionModal(); - + const totalTransactionNumber = Math.ceil((currentEpoch - _tillEpoch) / batchSize); setTotalTransactionNo(totalTransactionNumber); - console.log("Totlal transaction Number", totalTransactionNumber, _tillEpoch) - if (totalTransactionNumber > 1) { await RewardsPaginated(totalTransactionNumber - 1, _tillEpoch, pushCoreV2, batchSize); } @@ -316,7 +328,7 @@ const YieldPushFeeV3 = ({ console.log("Error: ", err) const unstakeErrorMessage = err.reason.includes("PushCoreV2::unstake:"); const harvestErrorMessage = err.reason.includes("PushCoreV2::harvestPaginated:"); - if(unstakeErrorMessage || harvestErrorMessage){ + if (unstakeErrorMessage || harvestErrorMessage) { setUnstakeErrorMessage("PUSH cannot be unstaked until current epoch is over."); } else { let errorMessage = err.reason.slice(err.reason.indexOf('::') + 1); @@ -356,8 +368,6 @@ const YieldPushFeeV3 = ({ ModalComponent: TransactionModal, } = useModalBlur(); - - return ( : - formatTokens(userDataPush?.userStaked) === 0 || unstakeErrorMessage !== null ? + formatTokens(userDataPush?.userStaked) == 0 || unstakeErrorMessage !== null ? { useEffect(() => { - if (chainId !== 1 && chainId !== 5) { + if (chainId !== 1 && chainId !== 11155111) { displayNonEthChainModal(); handleChainChange(); }