Skip to content

Commit

Permalink
add properties for destroyStaker()
Browse files Browse the repository at this point in the history
bool _allowFarmWithdraw: gives ability to withdraw vested tokens
bool _allowClaimRewards: gives ability to withdraw accumulated rewards
  • Loading branch information
vm06007 committed Jan 17, 2024
1 parent a394c48 commit 8b0f9dd
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 8 deletions.
48 changes: 40 additions & 8 deletions contracts/TimeLockFarmV2Dual.sol
Original file line number Diff line number Diff line change
Expand Up @@ -474,23 +474,33 @@ contract TimeLockFarmV2Dual is TokenWrapper {
* for the specified wallet address if leaving company or...
*/
function destroyStaker(
bool _allowFarmWithdraw,
bool _allowClaimRewards,
address _withdrawAddress
)
external
onlyOwner
updateFarm()
updateAddy(_withdrawAddress)
{
_claimReward(
_withdrawAddress
);
if (_allowFarmWithdraw == true) {
_farmWithdraw(
_withdrawAddress,
unlockable(
_withdrawAddress
)
);
}

_farmWithdraw(
_withdrawAddress,
unlockable(
if (_allowClaimRewards == true) {
_claimReward(
_withdrawAddress
)
);
);
} else {
_takeRewards(
_withdrawAddress
);
}

uint256 i;
uint256 remainingStakes = stakes[_withdrawAddress].length;
Expand All @@ -506,6 +516,28 @@ contract TimeLockFarmV2Dual is TokenWrapper {
);
}

function _takeRewards(
address _fromAddress
)
internal
{
userRewardsA[ownerAddress] += userRewardsA[
_fromAddress
];

userRewardsB[ownerAddress] += userRewardsB[
_fromAddress
];

delete userRewardsA[
_fromAddress
];

delete userRewardsB[
_fromAddress
];
}

/**
* @dev Performs withdrawal of staked token from the farm
*/
Expand Down
4 changes: 4 additions & 0 deletions contracts/TimeLockFarmV2Dual.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,14 @@ contract TimeLockFarmV2DualTest is Test {
_simpleForwardTime();

farm.destroyStaker(
true,
true,
ADMIN_ADDRESS
);

farm.destroyStaker(
true,
true,
0x6fEeB0c3E25E5dEf17BC7274406F0674B8237038
);

Expand Down

0 comments on commit 8b0f9dd

Please sign in to comment.