-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nonce cannot be incremented by depositor #89
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
pragma solidity ^0.8.23; | ||
|
||
import {DelegationSurrogate} from "src/DelegationSurrogate.sol"; | ||
import {DelegationSurrogateVotes} from "src/DelegationSurrogateVotes.sol"; | ||
import {INotifiableRewardReceiver} from "src/interfaces/INotifiableRewardReceiver.sol"; | ||
import {IEarningPowerCalculator} from "src/interfaces/IEarningPowerCalculator.sol"; | ||
import {IERC20} from "openzeppelin/token/ERC20/IERC20.sol"; | ||
|
@@ -761,10 +760,7 @@ abstract contract GovernanceStaker is INotifiableRewardReceiver, Multicall { | |
uint256 _depositNewEarningPower, | ||
uint256 _totalEarningPower | ||
) internal pure returns (uint256 _newTotalEarningPower) { | ||
if (_depositNewEarningPower >= _depositOldEarningPower) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. was this changed because of a different finding? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it was do you think we should keep it the same? |
||
return _totalEarningPower + (_depositNewEarningPower - _depositOldEarningPower); | ||
} | ||
return _totalEarningPower - (_depositOldEarningPower - _depositNewEarningPower); | ||
return _totalEarningPower + _depositNewEarningPower - _depositOldEarningPower; | ||
} | ||
|
||
/// @notice Internal helper method which sets the admin address. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1269,12 +1269,11 @@ contract ClaimRewardOnBehalf is GovernanceStakerRewardsTest { | |
uint256 _depositAmount, | ||
uint256 _durationPercent, | ||
uint256 _rewardAmount, | ||
address _delegatee, | ||
address _depositor, | ||
uint256 _currentNonce, | ||
uint256 _deadline | ||
) public { | ||
vm.assume(_delegatee != address(0) && _depositor != address(0) && _sender != address(0)); | ||
vm.assume(_depositor != address(0) && _sender != address(0)); | ||
_claimerPrivateKey = bound(_claimerPrivateKey, 1, 100e18); | ||
address _claimer = vm.addr(_claimerPrivateKey); | ||
|
||
|
@@ -1284,7 +1283,7 @@ contract ClaimRewardOnBehalf is GovernanceStakerRewardsTest { | |
|
||
// A user deposits staking tokens | ||
(_depositAmount, _depositId) = | ||
_boundMintAndStake(_depositor, _depositAmount, _delegatee, _claimer); | ||
_boundMintAndStake(_depositor, _depositAmount, address(0x01), _claimer); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand why this change was made? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question, this is to avoid a stack too deep error |
||
// The contract is notified of a reward | ||
_mintTransferAndNotifyReward(_rewardAmount); | ||
// A portion of the duration passes | ||
|
@@ -1307,10 +1306,12 @@ contract ClaimRewardOnBehalf is GovernanceStakerRewardsTest { | |
keccak256(abi.encodePacked("\x19\x01", EIP712_DOMAIN_SEPARATOR, _message)); | ||
bytes memory _signature = _sign(_claimerPrivateKey, _messageHash); | ||
|
||
uint256 _oldDepositorNonce = govStaker.nonces(_depositor); | ||
vm.prank(_sender); | ||
govStaker.claimRewardOnBehalf(_depositId, _deadline, _signature); | ||
|
||
assertEq(rewardToken.balanceOf(_claimer), _earned); | ||
assertEq(govStaker.nonces(_depositor), _oldDepositorNonce); | ||
} | ||
|
||
function testFuzz_ClaimRewardOnBehalfOfDepositor( | ||
|
@@ -1319,12 +1320,11 @@ contract ClaimRewardOnBehalf is GovernanceStakerRewardsTest { | |
uint256 _depositAmount, | ||
uint256 _durationPercent, | ||
uint256 _rewardAmount, | ||
address _delegatee, | ||
address _claimer, | ||
uint256 _currentNonce, | ||
uint256 _deadline | ||
) public { | ||
vm.assume(_delegatee != address(0) && _claimer != address(0) && _sender != address(0)); | ||
vm.assume(_claimer != address(0) && _sender != address(0)); | ||
_depositorPrivateKey = bound(_depositorPrivateKey, 1, 100e18); | ||
address _depositor = vm.addr(_depositorPrivateKey); | ||
|
||
|
@@ -1334,7 +1334,7 @@ contract ClaimRewardOnBehalf is GovernanceStakerRewardsTest { | |
|
||
// A user deposits staking tokens | ||
(_depositAmount, _depositId) = | ||
_boundMintAndStake(_depositor, _depositAmount, _delegatee, _claimer); | ||
_boundMintAndStake(_depositor, _depositAmount, address(0x01), _claimer); | ||
// The contract is notified of a reward | ||
_mintTransferAndNotifyReward(_rewardAmount); | ||
// A portion of the duration passes | ||
|
@@ -1357,10 +1357,12 @@ contract ClaimRewardOnBehalf is GovernanceStakerRewardsTest { | |
keccak256(abi.encodePacked("\x19\x01", EIP712_DOMAIN_SEPARATOR, _message)); | ||
bytes memory _signature = _sign(_depositorPrivateKey, _messageHash); | ||
|
||
uint256 _oldClaimerNonce = govStaker.nonces(_claimer); | ||
vm.prank(_sender); | ||
govStaker.claimRewardOnBehalf(_depositId, _deadline, _signature); | ||
|
||
assertEq(rewardToken.balanceOf(_depositor), _earned); | ||
assertEq(govStaker.nonces(_claimer), _oldClaimerNonce); | ||
} | ||
|
||
function testFuzz_ReturnsClaimedRewardAmount( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could use a test here.