From a303498dffeef5f07aec51649ecb5c547f8d5a5b Mon Sep 17 00:00:00 2001 From: Jinal Joshi Date: Sat, 13 Apr 2024 16:47:19 +0530 Subject: [PATCH] Update Vesting.sol --- Exa Protocol/Vesting.sol | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Exa Protocol/Vesting.sol b/Exa Protocol/Vesting.sol index cc9eeb1..45d3604 100644 --- a/Exa Protocol/Vesting.sol +++ b/Exa Protocol/Vesting.sol @@ -87,7 +87,7 @@ contract Vesting { // Initialize vesting parameters for each wallet for(uint i = 0; i < _wallet.length; i++) { - if(_tokenamount[i]>0 && _vestingTime[i]>0 && _readytoUsePercentage[i] >0){ + if(_tokenamount[i]>0 && _vestingTime[i]>0){ require(_wallet[i]!=address(0),"Please add valid wallet address!"); require(_readytoUsePercentage[i] <= 100,"You can add maximum 100 Percentage!"); @@ -191,24 +191,26 @@ contract Vesting { if(block.timestamp >= unlockDate[msg.sender] + (onemonth * i)) { // Check if the withdrawal for this period has not already occurred if(withdrawdetails[msg.sender][i].time == 0) { + // Calculate and accumulate the withdrawal amount withdrawAMT += (lockingWallet[msg.sender] / vestingTime[msg.sender]); // Record the withdrawal details withdrawdetails[msg.sender][i] = _withdrawdetails(block.timestamp, (lockingWallet[msg.sender] / vestingTime[msg.sender])); + + // for transfering all locked amount + if(i==(vestingTime[msg.sender]-1)){ + withdrawAMT += (lockedAmount[msg.sender]-withdrawAMT); + } } } else { break; // Exit loop if the current period is not yet unlocked } } - } - - + } withdrawAMT=(withdrawAMT+readytoUseAmt[msg.sender]); - require(withdrawAMT!=0, "Unable to Withdraw"); - - + require(withdrawAMT!=0, "Unable to Withdraw"); // Transfer the accumulated withdrawal amount to the sender Token(tokenContract).transfer(msg.sender, withdrawAMT);