https://github.com/Cyfrin/2024-07-templegold/blob/main/protocol/contracts/templegold/TempleGold.sol#L130
https://github.com/Cyfrin/2024-07-templegold/blob/main/protocol/contracts/templegold/TempleGold.sol#L144
templeGold
is minted at a rate strictly following the VestingFactor
. However, when the operators call TempleGold::setVestingFactor
to modify the VestingFactor
, the tokens accumulated based on the previous factor are not resolved. This miscommunication results in an incorrect calculation of mint volumes, as the accumulated time is multiplied by the new VestingFactor
, making the emission of templeGold
unpredictable.
At Line 130, the VestingFactor
is updated directly without resolving the tokens to be minted based on the accumulated time and the previous VestingFactor
. This causes the accumulated time to be incorrectly calculated with the new VestingFactor
, leading to discrepancies between expected and actual minting amounts.
We will compare the actual minting quantity of the protocol with the expected minting quantity:
On the first day, minting follows the normal vesting factor rate.
On the second day, the vesting factor is doubled.
Expected behavior is that the first day follows the old rate and the second day follows the doubled rate, making the total equivalent to three days at the normal rate.
However, the protocol will incorrectly assume both days are minted at the doubled rate.
Place the following test into TempleGold.t.sol::TempleGoldTest
:
This issue can lead to significant fluctuations in the issuance rate of templeGold
, causing unpredictable minting patterns that can destabilize the protocol and undermine user confidence.
Manual Review.
Resolve Pending Mints Before Updating VestingFactor
: Call mint()
to resolve any tokens accumulated under the previous vesting factor before updating to a new VestingFactor
. This ensures that the calculation for the new vesting period starts accurately.
(Optional) Restrict VestingFactor Changes: Implement constraints on how significantly the VestingFactor can be changed relative to the previous factor and impose time-based restrictions on how frequently it can be updated. These measures will enhance the predictability and stability of templeGold emission.
By resolving any accumulated tokens before setting the new VestingFactor and by restricting the frequency and extent of VestingFactor changes, the protocol can maintain a stable and predictable minting process, thereby preserving the stability and user trust of the templeGold system.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.