Repository navigation
audit: claim contracts #2288
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
Merged
Merged
audit: claim contracts #2288
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,8 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity 0.8.28; | ||
| pragma solidity 0.8.35; | ||
|
|
||
| import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | ||
| import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; | ||
| import {MerkleProof} from "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; | ||
| import {ReentrancyGuardUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol"; | ||
| import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; | ||
|
|
@@ -11,13 +12,24 @@ import {Ownable2StepUpgradeable} from "@openzeppelin/contracts-upgradeable/acces | |
| /// @title Claimable Airdrop | ||
| /// @notice This contract is the implementation of the Claimable Airdrop | ||
| /// @dev This contract is upgradeable and should be used only through the proxy contract | ||
| /// @dev Operational edge cases that cannot be enforced on-chain (the contract only | ||
| /// stores the Merkle root, never the full set of leaves): | ||
| /// - Revoking unclaimed approvals: the owner can call `updateMerkleRoot` (while | ||
| /// paused) to replace the root with one that no longer contains previously valid | ||
| /// but unclaimed approvals, effectively revoking them. | ||
| /// - First-come, first-served distribution: the contract cannot verify that | ||
| /// `tokenDistributor` holds (and has approved) enough tokens to cover every | ||
| /// approval. If the distributor is underfunded, later claims revert until it is | ||
| /// topped up, so claimants should claim as early as possible. | ||
| /// @custom:security-contact [email protected] | ||
| contract ClaimableAirdrop is | ||
| Initializable, | ||
| ReentrancyGuardUpgradeable, | ||
| PausableUpgradeable, | ||
| Ownable2StepUpgradeable | ||
| { | ||
| using SafeERC20 for IERC20; | ||
|
|
||
| /// @notice Address of the token contract to claim. | ||
| address public tokenProxy; | ||
|
|
||
|
|
@@ -94,12 +106,7 @@ contract ClaimableAirdrop is | |
|
|
||
| _verifyAndMark(amount, validFrom, merkleProof); | ||
|
|
||
| bool success = IERC20(tokenProxy).transferFrom( | ||
| tokenDistributor, | ||
| msg.sender, | ||
| amount | ||
| ); | ||
| require(success, "Failed to transfer funds"); | ||
| IERC20(tokenProxy).safeTransferFrom(tokenDistributor, msg.sender, amount); | ||
|
|
||
| emit TokensClaimed(msg.sender, amount); | ||
| } | ||
|
|
@@ -132,12 +139,11 @@ contract ClaimableAirdrop is | |
|
|
||
| require(totalClaimable > 0, "Nothing to claim"); | ||
|
|
||
| bool success = IERC20(tokenProxy).transferFrom( | ||
| IERC20(tokenProxy).safeTransferFrom( | ||
| tokenDistributor, | ||
| msg.sender, | ||
| totalClaimable | ||
| ); | ||
| require(success, "Failed to transfer funds"); | ||
|
|
||
| emit TokensClaimed(msg.sender, totalClaimable); | ||
| } | ||
|
|
@@ -206,4 +212,11 @@ contract ClaimableAirdrop is | |
| function unpause() external onlyOwner { | ||
| _unpause(); | ||
| } | ||
|
|
||
| /// @notice Prevents the owner from renouncing ownership. | ||
| /// @dev Renouncing would set the owner to address(0), permanently disabling | ||
| /// `updateMerkleRoot`, `extendClaimPeriod`, `pause`, and `unpause`. | ||
| function renounceOwnership() public view override onlyOwner { | ||
| revert("Cannot renounce ownership"); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.