Skip to content

Commit

Permalink
YieldFarming deployed to sepolia and Issue Fixed (#1315)
Browse files Browse the repository at this point in the history
* YieldFarming deployed to sepolia and Issue Fixed

* Changed the contract addredd of uni v2 for sepolia
  • Loading branch information
abhishek-01k authored Nov 24, 2023
1 parent 87594d0 commit f4ae834
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 32 deletions.
4 changes: 2 additions & 2 deletions src/components/StepsTransactionModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ const StepsTransactionModal = ({ onClose, InnerComponentProps }) => {
<H2V2 fontSize='28px' fontWeight='500' letterSpacing='-0.84px'>
Transaction Error
</H2V2>
<H2V2 fontSize='18px' fontWeight='400' color='#657795'>
{/* <H2V2 fontSize='18px' fontWeight='400' color='#657795'>
User denied the transaction signature.
</H2V2>
</H2V2> */}
</ItemVV2>

<ItemVV2>
Expand Down
42 changes: 26 additions & 16 deletions src/components/yield/YieldPushFeeV3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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) => <MdError size={size} color="red" />,
});
setTransactionText('');
setTxInProgressWithdraw(false);
getUserDataPush();
Expand Down Expand Up @@ -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;
Expand All @@ -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) => <MdError size={size} color="red" />,
});
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);
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -356,8 +368,6 @@ const YieldPushFeeV3 = ({
ModalComponent: TransactionModal,
} = useModalBlur();



return (
<Container>
<StakingComponent
Expand Down Expand Up @@ -608,7 +618,7 @@ const YieldPushFeeV3 = ({
ButtonTitle={"Unstake PUSH"}
/>
:
formatTokens(userDataPush?.userStaked) === 0 || unstakeErrorMessage !== null ?
formatTokens(userDataPush?.userStaked) == 0 || unstakeErrorMessage !== null ?
<ErrorToolTip
ToolTipTitle={unstakeErrorMessage ? unstakeErrorMessage : "Nothing to unstake, Stake First"}
ButtonTitle={"Unstake PUSH"}
Expand Down
31 changes: 20 additions & 11 deletions src/config/config-dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ export const addresses = {
batchMintNFT: "0xCf733D547B9f7F87c1B1f63f45c197C007F8eedf",
NFTRewards: "0xc4708BB6EC3B797344f123126171302e4e3E68E2",
distributor: "0x5B548D33874DeABaC2F683A6E1864795E09932F0",
uniswapV2Router02: "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D", //n
WETHAddress: "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6", // mainnet address //n
USDTAddress: "0x11fe4b6ae13d2a6055c8d9cf65c55bac32b5d844", // mainnet address //n
rockstarV2: "0xA2b885e7065EA59a3251489715ca80DE5Ff642f8", //mainnet address
NFTRewardsV2: "0xdc66567a990B7fa10730459537620857c9e03287", //mainnet address

Expand All @@ -101,15 +98,27 @@ export const addresses = {
depYieldFarmPUSH: "0x6EA019f7FE2640A55154DdC36Bfd21275De388BD", // deprecated YieldFarm Push address
depYieldFarmLP:"0xc2886D0e7DAd16cc92b1156Dc9A0b0D3F047FD15",

//For Yield Farm V2
// stakingV2: "0x6C83ce5eE433d53E10b64E277B1cf5207C37b662",
stakingV2: "0x0B318CA01Cec62bB29526591f368b44f4b8a0303",
yieldFarmLP: "0x576c46b328433AaDcb9d9cDd81E0A92852bb0B6F",
// yieldFarmLP: "0x13ac63901c8fD5797939099553582951fAbAFDE3",
pushCoreV2: "0x5AB1520E2bd519BDab2e1347EEe81C00a77f4946",
// pushCoreV2: "0x0E76e9776CB192f5840B357780efB325885073FF",
uniV2LPToken: "0x698839247E5b83572fFF6ccdcf386CC37e60bEf5",
pushToken: "0x37c779a1564DCc0e3914aB130e0e787d93e21804",

// For Sepolia
pushToken: "0x37c779a1564DCc0e3914aB130e0e787d93e21804",
// pushCoreV2: "0x8a965286c0752DFE821868312025091f60BD902A", // 15 min epoch
pushCoreV2: "0x5AB1520E2bd519BDab2e1347EEe81C00a77f4946", //21 days epoch
uniV2LPToken: "0x2333609Cc527a9309Cdad16E0742a3C6DC1C551b",
uniswapV2Router02: "0xC532a74256D3Db42D0Bf7a0400fEFDbad7694008",
WETHAddress: "0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9",
USDTAddress: "0x7169D38820dfd117C3FA1f22a697dBA58d90BA06",

//For 30 mins epoch
// stakingV2: "0xCa02F3FdF3794aF08CADb98b0E4504261cB8c302",
// yieldFarmLP: "0x22C1dBC8975c23De9e2219C0fC3E03b404577512",

//For 21 days Epoch
stakingV2: "0xFf13FBc1dE7FBF300059FE56495c82bBa2F986c6",
yieldFarmLP: "0xAB531bD9D39c492a05de65Eee85F6C712c05ea0b",






Expand Down
2 changes: 0 additions & 2 deletions src/helpers/pushStaking/src/CoreV2Reward.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,9 @@ export class CoreV2Reward {
let rewards = Helpers.toBN(0);
for (let i = nextFromEpoch; i <= _tillEpoch; i++) {
const claimableReward = this.calculateEpochRewards(i);
console.log("Epoch Number", i , "ClaimableReward",claimableReward,parseFloat(ethers.utils.formatEther(claimableReward)));
rewards = rewards.add(claimableReward);
}

console.log("Available for claiming reward",rewards,parseFloat(ethers.utils.formatEther(rewards)));

return rewards;
}
Expand Down
1 change: 1 addition & 0 deletions src/helpers/pushStaking/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ export const Constants = {
},

epochDuration: 21 * 7156,
// epochDuration: 80 ,
// epochDuration: 50,
};
2 changes: 1 addition & 1 deletion src/modules/yield/YieldFarmingModuleV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const YieldFarmingModuleV2 = () => {

useEffect(() => {

if (chainId !== 1 && chainId !== 5) {
if (chainId !== 1 && chainId !== 11155111) {
displayNonEthChainModal();
handleChainChange();
}
Expand Down

0 comments on commit f4ae834

Please sign in to comment.