In contract TempleGold
, vestingFactor
is used to control the amount of tokens minted per second. The parameter vestingFactor
can be set or updated by using setVestingFactor
function. When vestingFactor
is updated, the new factor should be effective from the time it's changed. In current implementation, it is effective from lastMintTimestamp
which is not the expected behaviour.
When the vestingFactor
parameter is updated using setVestingFactor
function, it should only be effective from time at which it's updated. However, in current implementation of code, lastMintTimestamp
can be different from block.timestamp
at which vestingFactor
is updated. So, new vestingFactor
will be effective from lastMintTimestamp
and not the block.timestamp
when setVestingFactor
called. lastMintTimestamp
is updated when mint
function is called.
Steps to reproduce:
1) owner
sets vestingFactor
by calling setVestingFactor
function for first time. For sake of understanding, let's assume it's factor.numerator
is 2
and factor.denominator
is 100
. Let's assume MAX_SUPPLY
is 100
. So, it would take 50
seconds to reach MAX_SUPPLY
.
2) at time = 5
seconds, user
calls mint
. It mints 10
tokens. lastMintTimestamp
is updated to 5
.
3) at time = 25
seconds, owner
updates the vestingFactor
by calling setVestingFactor
function. let's assume new factor.numerator
is 1
and factor.denominator
is 100
4) at time = 30
seconds, user
calls mint
. It mints (30 - 5) * 1 = 25
tokens. But that's not correct. The number tokens that should be minted is (25 - 5) * 2 + (30 - 25) * 1 = 45
tokens. The main reason for this is new vestingFactor
should be effective from 25
seconds and not 5
seconds.
Updating vestingFactor
is not effective from timestamp
at which it's updated but it's effective from lastMintTimestamp
. This can result in incorrect minting of tokens.
Manual Review
ensure that mint
was called in the same block as setVestingFactor
.
This can be done by calling mint
internally in the setVestingFactor
function or adding following condition in setVestingFactor
function.
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.