Repair minting MPs with lock

- The "free MPs" in the amount of 100% of stake that are minted on deposit are now not minted anymore duplicitely in the lock function
This commit is contained in:
Martin Strobl 2023-07-11 12:08:30 +02:00
parent fe5cd4b517
commit a731962d32
1 changed files with 4 additions and 4 deletions

View File

@ -63,7 +63,7 @@ contract StakeManager is Ownable {
processAccount(account, currentEpoch);
account.balance += _amount;
account.rewardAddress = StakeVault(msg.sender).owner();
mintIntialMultiplier(account, _time, _amount);
mintIntialMultiplier(account, _time, _amount, 1);
stakeSupply += _amount;
}
@ -90,7 +90,7 @@ contract StakeManager is Ownable {
Account storage account = accounts[msg.sender];
processAccount(account, currentEpoch);
require(block.timestamp + _time > account.lockUntil, "Cannot decrease lock time");
mintIntialMultiplier(account, _time);
mintIntialMultiplier(account, _time, account.balance, 0);
}
/**
@ -200,11 +200,11 @@ contract StakeManager is Ownable {
multiplierSupply += increasedMultiplier;
}
function mintIntialMultiplier(Account storage account, uint256 lockTime, uint256 amount) private {
function mintIntialMultiplier(Account storage account, uint256 lockTime, uint256 amount, uint256 initMint) private {
//if balance still locked, multipliers must be minted from difference of time.
uint256 dT = account.lockUntil > block.timestamp ? block.timestamp + lockTime - account.lockUntil : lockTime;
account.lockUntil = block.timestamp + lockTime;
uint256 increasedMultiplier = amount * ((dT/YEAR)+1);
uint256 increasedMultiplier = amount * ((dT/YEAR)+initMint);
account.lastMint = block.timestamp;
account.multiplier += increasedMultiplier;
multiplierSupply += increasedMultiplier;