RewardsPool.inflate sets wrong value to RewardsPool.InflationIntervalStartTime
variable
#239
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
duplicate-648
partial-50
Incomplete articulation of vulnerability; eligible for partial credit only (50%)
sponsor disputed
Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue
Lines of code
https://github.com/code-423n4/2022-12-gogopool/blob/main/contracts/contract/RewardsPool.sol#L98
Vulnerability details
Impact
RewardsPool.inflate sets wrong value to
RewardsPool.InflationIntervalStartTime
variable. As result inflation logic will be broken and GGP token will inflate much faster than it was expected.Proof of Concept
GGP token has limited total supply that is minted on deploy.
But at the beginning not all tokens are available. Token amount should inflate during the time to distribute its total supply.
To increase amount of tokens in circulation
RewardsPool.startRewardsCycle
function is called.This function then calls
inflate
function.https://github.com/code-423n4/2022-12-gogopool/blob/main/contracts/contract/RewardsPool.sol#L82-L100
This function calculates how many periods has passed since last inflate and then increases token's total supply.
It uses
getInflationIntervalStartTime
function to know when inflation was done last time.getInflationIntervalStartTime
function just checksInflationIntervalStartTime
variable.Later inflate function is updating
InflationIntervalStartTime
variable to provide time when last inflation was done.addUint(keccak256("RewardsPool.InflationIntervalStartTime"), inflationIntervalElapsedSeconds);
The problem is that
inflationIntervalElapsedSeconds
is set instead ofblock.timestamp
.inflationIntervalElapsedSeconds
is a time in seconds between the last inflation was done. It's not a timestamp.As a result when
inflate
will be called next time, thengetInflationAmt
function will calculate new tokens incorrectly and will distribute all total supply more faster.Example.
1.RewardsPool is deployed at time 1000. Then
InflationIntervalStartTime == 1000
.2.Inflation interval is 10.
3.
inflate
is called for first time at time 1010. As result price has increased once.InflationIntervalStartTime == inflationIntervalElapsedSeconds == 10
.4.
inflate
is called next time at time 1020.inflationIntervalElapsedSeconds = 1020 - 10 = 1010
. And price has changed 101 times instead of 1 asgetInflationAmt
function decided that 101 period has passed since last inflation.Tools Used
VsCode
Recommended Mitigation Steps
Set block.timestamp to inflationIntervalElapsedSeconds variable.
The text was updated successfully, but these errors were encountered: