Skip to content

Commit

Permalink
fix(protocol): fix ERC20Airdrop2.sol with an extended withdrawal wind…
Browse files Browse the repository at this point in the history
…ow (#16596)

Co-authored-by: Keszey Dániel <keszeyd@MacBook-Pro.local>
  • Loading branch information
dantaik and Keszey Dániel authored Apr 3, 2024
1 parent c4b705b commit bc542d8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion packages/protocol/contracts/team/airdrop/ERC20Airdrop2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ contract ERC20Airdrop2 is MerkleClaimable {
using LibMath for uint256;
using SafeERC20 for IERC20;

uint256 public constant WITHDRAWAL_GRACE_PERIOD = 30 days;

/// @notice The address of the token contract.
address public token;

Expand All @@ -39,7 +41,10 @@ contract ERC20Airdrop2 is MerkleClaimable {
error WITHDRAWALS_NOT_ONGOING();

modifier ongoingWithdrawals() {
if (claimEnd > block.timestamp || claimEnd + withdrawalWindow < block.timestamp) {
if (
claimEnd > block.timestamp
|| claimEnd + withdrawalWindow + WITHDRAWAL_GRACE_PERIOD < block.timestamp
) {
revert WITHDRAWALS_NOT_ONGOING();
}
_;
Expand Down
4 changes: 2 additions & 2 deletions packages/protocol/test/team/airdrop/ERC20Airdrop2.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ contract TestERC20Airdrop2 is TaikoTest {
vm.expectRevert(ERC20Airdrop2.WITHDRAWALS_NOT_ONGOING.selector);
airdrop2.withdraw(Alice);

// Roll 11 day after
// Roll 31 day after
vm.roll(block.number + 200);
vm.warp(claimEnd + 11 days);
vm.warp(claimEnd + 10 days + 30 days + 1); // withdrawal window + grace period + 1sec

(uint256 balance, uint256 withdrawable) = airdrop2.getBalance(Alice);

Expand Down

0 comments on commit bc542d8

Please sign in to comment.