Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(protocol): fix ERC20Airdrop2.sol with an extended withdrawal window #16596

Merged
merged 3 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
dantaik marked this conversation as resolved.
Show resolved Hide resolved

/// @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
Loading