Open c4-bot-8 opened 4 months ago
dmvt marked the issue as primary issue
0xRektora (sponsor) acknowledged
0xRektora marked the issue as disagree with severity
The probability of this happening are close to nothing.
this function is not restricted to who can call it, hence there might be scenarios where it is not triggered for a week.
Anyone having the possibility to call is the opposite of this. One would be incentivized to participate early, on top of having the protocol automatically calling it.
0xRektora marked the issue as agree with severity
0xRektora (sponsor) disputed
dmvt marked the issue as duplicate of #38
dmvt changed the severity to QA (Quality Assurance)
dmvt marked the issue as grade-a
Lines of code
https://github.com/Tapioca-DAO/tap-token/blob/20a83b1d2d5577653610a6c3879dff9df4968345/contracts/tokens/TapToken.sol#L397 https://github.com/Tapioca-DAO/tap-token/blob/20a83b1d2d5577653610a6c3879dff9df4968345/contracts/options/TapiocaOptionBroker.sol#L411-L412
Vulnerability details
Description
In the
TapToken
contract, theemitForWeek()
function serves to emit the amount of TAP tokens to be minted in the current week, while also accumulating the unminted TAP tokens from the previous week.However, the calculation of
week
is based on the current timestamp. Therefore, if the function hasn't been called for one week or more, the unclaimed TAP tokens will not be accumulated for the next week.For instance, if the contract isn't called throughout week 2, and then in week 3, the contract is invoked, the
emitForWeek()
function will not accumulate the unminted amount from week 1.It's noteworthy that the
emitForWeek()
function can only be called by the minter, which is theTapiocaOptionBreaker
contract, through theTapiocaOptionBreaker.newEpoch()
function. However, this function is not restricted to who can call it, hence there might be scenarios where it is not triggered for a week. Additionally, if there are no active singularities registered in the tOLP contract, thenewEpoch()
function will revert with aNoActiveSingularities
error. If this occurs during a week, the aforementioned issue will arise even there are some applications are used to trigger the function each week.Impact
There is a risk of losing some unclaimed TAP tokens from the previous week.
Tools Used
Manual review
Recommended Mitigation Steps
Instead of retrieving the unclaimed amount from
week - 1
, it should be obtained from the most recent week whenemitForWeek()
is triggered.Assessed type
Other