Submitted by cccz, also found by bin2chen
In AirdropBroker, when a user receives an airdrop, it should only be able to exercise the options in the current epoch.
For example, Alice received the airdrop for epoch 1, then Alice can participate in epoch 1 and exercise the options in epoch 1. When Alice exercises her option, the TAP price is determined at the beginning of epoch 1.
The problem here is that when block.timestamp == lastEpochUpdate + EPOCH_DURATION, newEpoch() can be called to enter epoch 2, and exerciseOption() can also be called to exercise the option of epoch 1. This allows the user to exercise the epoch 1 option at the epoch 2 TAP price.
Consider the following scenario, Alice receives a 1000 options airdrop for epoch 1.
Epoch 1 starts, lastEpochUpdate = day 0, TAP price is 5 USD, and TAP price is in a downward trend. If Alice exercises the option in epoch 1, she needs to pay 5000 * 0.5 = 2500 USD.
However, when block.timestamp == lastEpochUpdate + EPOCH_DURATION, the current TAP price is 2 USD, Alice can call newEpoch() and exerciseOption() in one transaction, Alice will exercise the option at the price of epoch 2, and only needs to pay 1000 USD to get 1000 TAP.
https://github.com/Tapioca-DAO/tap-token//blob/20a83b1d2d5577653610a6c3879dff9df4968345/contracts/option-airdrop/AirdropBroker.sol#L226-L233
https://github.com/Tapioca-DAO/tap-token//blob/20a83b1d2d5577653610a6c3879dff9df4968345/contracts/option-airdrop/AirdropBroker.sol#L264-L267
It is recommended that exercise is not allowed when block.timestamp == lastEpochUpdate + EPOCH_DURATION.
Context
0xRektora (Tapioca) confirmed, but disagreed with severity and commented:
LSDan (judge) decreased severity to Low
cryptotechmaker (Tapioca) commented:
cccz (warden) commented:
LSDan (Judge) increased severity to Medium and commented:
