force users to migrate or leave

This commit is contained in:
Ricardo Guilherme Schmidt 2023-06-26 12:26:02 -03:00
parent da5ea645b0
commit 6bf8d66221
No known key found for this signature in database
GPG Key ID: 3F95A3AD0B607030
2 changed files with 17 additions and 1 deletions

View File

@ -104,6 +104,16 @@ contract StakeManager is Ownable {
multiplierSupply += increasedMultiplier; multiplierSupply += increasedMultiplier;
} }
/**
* @notice leave without processing account
*/
function leave() external onlyVault {
Account memory account = accounts[msg.sender];
delete accounts[msg.sender];
multiplierSupply -= account.multiplier;
stakeSupply -= _account.mount;
}
/** /**
* @notice Release rewards for current epoch and increase epoch. * @notice Release rewards for current epoch and increase epoch.
*/ */
@ -170,7 +180,8 @@ contract StakeManager is Ownable {
function processAccount(Account storage account, uint256 _limitEpoch) private { function processAccount(Account storage account, uint256 _limitEpoch) private {
processEpoch(); processEpoch();
require(_limitEpoch <= currentEpoch, "Non-sese call"); require(address(migration) == address(0), "Contract ended, please migrate");
require(_limitEpoch <= currentEpoch, "Non-sense call");
uint256 userReward; uint256 userReward;
uint256 userEpoch = account.epoch; uint256 userEpoch = account.epoch;
for (Epoch memory iEpoch = epochs[userEpoch]; userEpoch < _limitEpoch; userEpoch++) { for (Epoch memory iEpoch = epochs[userEpoch]; userEpoch < _limitEpoch; userEpoch++) {

View File

@ -32,6 +32,11 @@ contract StakeVault is Ownable {
stakedToken.transferFrom(address(this), msg.sender, _amount); stakedToken.transferFrom(address(this), msg.sender, _amount);
} }
function leave() external onlyOwner {
stakeManager.leave();
stakedToken.transferFrom(address(this), msg.sender, stakedToken.balanceOf(address(this)));
}
/** /**
* @notice Opt-in migration to a new StakeManager contract. * @notice Opt-in migration to a new StakeManager contract.
*/ */