Open code423n4 opened 2 years ago
This should be medium risk, as should only have a minor impact on users getting less rewards and no over-minting can occur.
The warden has shown how, due to an incorrect order of operations, rates for new rewards can be enacted before the old rewards are distributed, causing a loss of rewards for end users.
There are 2 ways to judge this finding:
Ultimately the impact is a loss of value, further minimized by the fact that anyone can call poolCheckpoint
as well as executeInflationRateUpdate
meaning the losses can be minimized.
So from a coding standpoint I believe the bug should be fixed before deployment, but from a impact point of view the impact can be minimized to make "loss of yield" mostly rounding errors
Given the impact I believe the finding to be of Medium Severity
Lines of code
https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/tokenomics/Minter.sol#L187-L215
Vulnerability details
When
Minter.sol#_executeInflationRateUpdate()
is called, if an_INFLATION_DECAY_PERIOD
has past sincelastInflationDecay
, it will update the InflationRate for all of the gauges.However, in the current implementation, the rates will be updated first, followed by the rewards being settled using the new rates on the gauges using
inflationManager().checkpointAllGauges()
.If the
_INFLATION_DECAY_PERIOD
has passed for a long time beforeMinter.sol#executeInflationRateUpdate()
is called, the users may lose a significant amount of rewards.On a side note,
totalAvailableToNow
is updated correctly.https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/tokenomics/Minter.sol#L187-L215
https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/tokenomics/InflationManager.sol#L110-L125
https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/tokenomics/KeeperGauge.sol#L110-L117
https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/tokenomics/InflationManager.sol#L507-L519
https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/tokenomics/Minter.sol#L173-L176
PoC
Given:
AmmGauge
pool;Minter.sol#_executeInflationRateUpdate()
is called;claimableRewards()
and received500
Bkd tokens.Expected Results:
1000
Bkd tokens as rewards.Actual Results:
500
Bkd tokens as rewards.Recommendation
Consider moving the call to
checkpointAllGauges()
to before thecurrentInflationAmountKeeper
is updated.