function increaseLock(uint256 _depositId, address _receiver, uint256 _increaseAmount) external {
// Check if actually increasing
if (_increaseAmount == 0) {
revert ZeroAmountError();
}
// Makes sure the msg.sender is the owner of the lock.
require(_msgSender() == _receiver, "Not the owner of the lock");
Deposit memory userDeposit = depositsOf[_msgSender()][_depositId];
// Only can extend if it has not expired
if (block.timestamp >= userDeposit.end) {
revert DepositExpiredError();
}
depositToken.safeTransferFrom(_msgSender(), address(this), _increaseAmount);
// Multiplier should be acording the remaining time to the deposit to end
uint256 remainingDuration = uint256(userDeposit.end - block.timestamp);
uint256 mintAmount = _increaseAmount * getMultiplier(remainingDuration) / 1e18;
depositsOf[_receiver][_depositId].amount += _increaseAmount;
depositsOf[_receiver][_depositId].shareAmount += mintAmount;
_mint(_receiver, mintAmount);
emit LockIncreased(_depositId, _receiver, _msgSender(), _increaseAmount);
}
-
-
Save CodingNameKiki/cec8dd78feeb562104e2bc0a0c0b6e87 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment