Skip to content

Commit

Permalink
fix: prevent underflow
Browse files Browse the repository at this point in the history
  • Loading branch information
antoncoding committed Jul 27, 2021
1 parent e905795 commit 566c811
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions contracts/core/HodlERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ contract HodlERC20 is ERC20PermitUpgradeable {
require(address(_token) != address(_bonusToken), "INVALID_BONUS_TOKEN");
require(_feeRecipient != address(0), "INVALID_RECIPIENT");

totalTime = _expiry - block.timestamp;
totalTime = _expiry.sub(block.timestamp);

token = IERC20WithDetail(_token);
bonusToken = IERC20WithDetail(_bonusToken);
Expand Down Expand Up @@ -359,7 +359,7 @@ contract HodlERC20 is ERC20PermitUpgradeable {
* (total duration)^ n
*/
function _calculateShares(uint256 _amount) internal view returns (uint256) {
uint256 timeLeft = expiry - block.timestamp;
uint256 timeLeft = expiry.sub(block.timestamp);
return _amount.mul(timeLeft**n).div(totalTime**n);
}

Expand Down

0 comments on commit 566c811

Please sign in to comment.