From c05ad1c8155b15ec977305fe35b519d7c19f4f03 Mon Sep 17 00:00:00 2001 From: Daniel Von Fange Date: Tue, 28 May 2024 18:08:09 -0400 Subject: [PATCH] Correct rounding behavior in previewWithdraw (#421) --- contracts/ExponentialStaking.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/ExponentialStaking.sol b/contracts/ExponentialStaking.sol index 0a5d6e3c..59fec764 100644 --- a/contracts/ExponentialStaking.sol +++ b/contracts/ExponentialStaking.sol @@ -265,8 +265,8 @@ contract ExponentialStaking is ERC20Votes { } uint256 fullDuration = end - block.timestamp; (uint256 fullPoints,) = previewPoints(1e18, fullDuration); - (uint256 currentPoints,) = previewPoints(1e36, 0); // 1e36 saves a later multiplication - return amount * ((currentPoints / fullPoints)) / 1e18; + (uint256 currentPoints,) = previewPoints(1e18, 0); + return amount * currentPoints / fullPoints; } /// @notice Returns the total number of lockups the user has