From bac90312d42fac3af5f7a926508ea2bff80d717a Mon Sep 17 00:00:00 2001 From: wildmolasses Date: Tue, 9 Apr 2024 11:42:07 -0400 Subject: [PATCH 1/2] dust rounding --- src/UniStaker.sol | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/UniStaker.sol b/src/UniStaker.sol index 026aa26..3f928d0 100644 --- a/src/UniStaker.sol +++ b/src/UniStaker.sol @@ -802,7 +802,8 @@ contract UniStaker is INotifiableRewardReceiver, Multicall, EIP712, Nonces { uint256 _reward = scaledUnclaimedRewardCheckpoint[_beneficiary] / SCALE_FACTOR; if (_reward == 0) return; - scaledUnclaimedRewardCheckpoint[_beneficiary] = 0; + scaledUnclaimedRewardCheckpoint[_beneficiary] = + scaledUnclaimedRewardCheckpoint[_beneficiary] - (_reward * SCALE_FACTOR); emit RewardClaimed(_beneficiary, _reward); SafeERC20.safeTransfer(REWARD_TOKEN, _beneficiary, _reward); From e7181c26d5aeac73b0c43e63c487c86e298b7b2d Mon Sep 17 00:00:00 2001 From: wildmolasses Date: Wed, 10 Apr 2024 11:12:41 -0400 Subject: [PATCH 2/2] add comment --- src/UniStaker.sol | 1 + 1 file changed, 1 insertion(+) diff --git a/src/UniStaker.sol b/src/UniStaker.sol index 3f928d0..3dd70a3 100644 --- a/src/UniStaker.sol +++ b/src/UniStaker.sol @@ -802,6 +802,7 @@ contract UniStaker is INotifiableRewardReceiver, Multicall, EIP712, Nonces { uint256 _reward = scaledUnclaimedRewardCheckpoint[_beneficiary] / SCALE_FACTOR; if (_reward == 0) return; + // retain sub-wei dust that would be left due to the precision loss scaledUnclaimedRewardCheckpoint[_beneficiary] = scaledUnclaimedRewardCheckpoint[_beneficiary] - (_reward * SCALE_FACTOR); emit RewardClaimed(_beneficiary, _reward);