More Info
Private Name Tags
ContractCreator
Latest 25 from a total of 88,624 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Withdraw | 29313604 | 1 min ago | IN | 0 ETH | 0.00000193 | ||||
Withdraw | 29313604 | 1 min ago | IN | 0 ETH | 0.00000174 | ||||
Withdraw | 29313566 | 2 mins ago | IN | 0 ETH | 0.00000162 | ||||
Withdraw | 29313555 | 3 mins ago | IN | 0 ETH | 0.00000098 | ||||
Withdraw | 29313528 | 4 mins ago | IN | 0 ETH | 0.00000165 | ||||
Withdraw | 29313518 | 4 mins ago | IN | 0 ETH | 0.00000196 | ||||
Withdraw | 29313490 | 5 mins ago | IN | 0 ETH | 0.00000168 | ||||
Withdraw | 29313451 | 6 mins ago | IN | 0 ETH | 0.00000135 | ||||
Withdraw | 29313235 | 13 mins ago | IN | 0 ETH | 0.00000103 | ||||
Withdraw | 29313210 | 14 mins ago | IN | 0 ETH | 0.00000092 | ||||
Withdraw | 29313197 | 15 mins ago | IN | 0 ETH | 0.0000009 | ||||
Withdraw | 29313128 | 17 mins ago | IN | 0 ETH | 0.00000095 | ||||
Withdraw | 29313100 | 18 mins ago | IN | 0 ETH | 0.00001179 | ||||
Withdraw | 29313012 | 21 mins ago | IN | 0 ETH | 0.00000069 | ||||
Withdraw | 29313007 | 21 mins ago | IN | 0 ETH | 0.00000068 | ||||
Withdraw | 29312981 | 22 mins ago | IN | 0 ETH | 0.0000007 | ||||
Withdraw | 29312879 | 25 mins ago | IN | 0 ETH | 0.00000065 | ||||
Withdraw | 29312851 | 26 mins ago | IN | 0 ETH | 0.00000068 | ||||
Withdraw | 29312762 | 29 mins ago | IN | 0 ETH | 0.00000071 | ||||
Withdraw | 29312720 | 31 mins ago | IN | 0 ETH | 0.00000059 | ||||
Withdraw | 29312703 | 31 mins ago | IN | 0 ETH | 0.00000062 | ||||
Withdraw | 29312679 | 32 mins ago | IN | 0 ETH | 0.00000083 | ||||
Withdraw | 29312656 | 33 mins ago | IN | 0 ETH | 0.00000058 | ||||
Withdraw | 29312643 | 33 mins ago | IN | 0 ETH | 0.00000058 | ||||
Withdraw | 29312640 | 33 mins ago | IN | 0 ETH | 0.00000121 |
Latest 1 internal transaction
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
25085452 | 97 days ago | Contract Creation | 0 ETH |
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0xC0Dd0b6d...ea969ff2C The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
MerkleVester
Compiler Version
v0.8.27+commit.40a35a09
Optimization Enabled:
Yes with 200 runs
Other Settings:
cancun EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
pragma solidity ^0.8.24; import {IPostClaimHandler} from "./interfaces/IPostClaimHandler.sol"; import "./IMerkleVester.sol"; import "./MerkleValidator.sol"; import "./interfaces/ICalendarVester.sol"; import "./interfaces/IIntervalVester.sol"; import "@openzeppelin/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/utils/Multicall.sol"; import {MerkleProof} from "@openzeppelin/utils/cryptography/MerkleProof.sol"; import {SafeTransferLib} from "@solady/utils/SafeTransferLib.sol"; /** * @notice Vesting contract that uses merkle trees to scale to millions of allocations */ contract MerkleVester is IAirlockBase, IMerkleVester, IntervalVester, CalendarVester, MerkleValidator, Multicall { /// @dev maximum amount of claim fee in wei uint256 immutable maxClaimFee; /// @dev true, if claim fee should only be payed for the first claim of an allocation, false otherwise bool immutable shouldPayClaimFeeOnlyOnce; /// @dev mapping allocation id to a boolean to store allocation ids for which fee was already payed mapping(string => bool) private feeAlreadyPayed; /// @dev version number of the vester contract string public constant version = "dist_v2.1.2"; /** * @dev lazily store the mutable state as allocaitons are interacted with */ mapping(string => DistributionState) public schedules; /** * @dev new batches of allocations are added as an additional merkle root append only to keep existing allocations immutable */ bytes32[] public merkleRoots; /// @dev claim fee in wei uint256 public claimFee; /// @dev address where the fees will be transferred /// valid states for feeCollector, feeSetter: /// 1. feeCollector = address(0), feeSetter = address(0): Claim fees permanently disabled. /// 2. feeCollector != address(0), feeSetter = address(0): Claim fee is fixed at initialization and cannot be updated. /// 3. feeCollector != address(0), feeSetter != address(0): Claim fee can be updated by feeSetter. address public immutable feeCollector; /// @dev address who can update the fee address public immutable feeSetter; /// @dev role for the fee setter bytes32 public constant FEE_SETTER_ROLE = keccak256("FEE_SETTER_ROLE"); /** * @notice Constructor to create a MerkleVester contract * * @param token token address this vesting contract will distribute * @param benefactor inital administator and benefactor of the contract * @param _claimFee claim fee in wei * @param _feeCollector address where the fees will be transferred * @param _feeSetter address who can update the fee * @param _postClaimHandlers an array of post claim handlers to be whitelisted * @param _maxClaimFee the maximum claim fee * @param _shouldPayClaimFeeOnlyOnce true, if claim fee should only be payed for the first claim of an allocation, false otherwise */ constructor( address token, address benefactor, uint256 _claimFee, address _feeCollector, address _feeSetter, IPostClaimHandler[] memory _postClaimHandlers, uint256 _maxClaimFee, bool _shouldPayClaimFeeOnlyOnce ) IAirlockBase(token, benefactor, _postClaimHandlers) { if (_claimFee > _maxClaimFee) revert ClaimFeeExceedsMaximum(); claimFee = _claimFee; maxClaimFee = _maxClaimFee; shouldPayClaimFeeOnlyOnce = _shouldPayClaimFeeOnlyOnce; if (_feeCollector == address(0)) { if (_feeSetter != address(0)) revert InvalidFeeSetter(); if (_claimFee > 0) revert InvalidFeeCollector(); } feeCollector = _feeCollector; if (_feeSetter != address(0)) { _grantRole(FEE_SETTER_ROLE, _feeSetter); } feeSetter = _feeSetter; } /// @inheritdoc IMerkleVester function getCalendarLeafHash( string calldata allocationType, Allocation calldata allocation, CalendarUnlockSchedule calldata unlockSchedule ) external pure returns (bytes32) { return keccak256(abi.encode(allocationType, allocation, unlockSchedule)); } /// @inheritdoc IMerkleVester function getIntervalLeafHash( string calldata allocationType, Allocation calldata allocation, IntervalUnlockSchedule calldata unlockSchedule ) external pure returns (bytes32) { return keccak256(abi.encode(allocationType, allocation, unlockSchedule)); } /// @inheritdoc IMerkleVester function getCalendarLeafAllocationData(uint32 rootIndex, bytes calldata decodableArgs, bytes32[] calldata proof) external view returns (CalendarAllocation memory, CalendarUnlockSchedule memory) { (, Allocation memory allocation, CalendarUnlockSchedule memory calendarUnlockSchedule) = abi.decode(decodableArgs, (string, Allocation, CalendarUnlockSchedule)); this.validateLeaf(merkleRoots[rootIndex], decodableArgs, proof); DistributionState memory distributionState = schedules[allocation.id]; return ( CalendarAllocation(allocation, calendarUnlockSchedule.unlockScheduleId, distributionState), calendarUnlockSchedule ); } /// @inheritdoc IMerkleVester function getIntervalLeafAllocationData(uint32 rootIndex, bytes calldata decodableArgs, bytes32[] calldata proof) external view returns (IntervalAllocation memory, IntervalUnlockSchedule memory) { (, Allocation memory allocation, IntervalUnlockSchedule memory intervalUnlockSchedule) = abi.decode(decodableArgs, (string, Allocation, IntervalUnlockSchedule)); this.validateLeaf(merkleRoots[rootIndex], decodableArgs, proof); DistributionState memory distributionState = schedules[allocation.id]; return ( IntervalAllocation(allocation, intervalUnlockSchedule.unlockScheduleId, distributionState), intervalUnlockSchedule ); } /// @inheritdoc IMerkleVester function getLeafJustAllocationData(uint32 rootIndex, bytes memory decodableArgs, bytes32[] calldata proof) external view returns (Allocation memory) { this.validateLeaf(merkleRoots[rootIndex], decodableArgs, proof); (, Allocation memory allocation) = abi.decode(decodableArgs, (string, Allocation)); return allocation; } /// @inheritdoc IMerkleVester function addAllocationRoot(bytes32 merkleRoot) external nonReentrant onlyRole(BENEFACTOR) returns (uint256) { merkleRoots.push() = merkleRoot; return merkleRoots.length - 1; } /// @notice Sets the claim fee in wei function setClaimFee(uint256 _claimFee) external onlyRole(FEE_SETTER_ROLE) { if (_claimFee > maxClaimFee) revert ClaimFeeExceedsMaximum(); if (feeCollector == address(0)) revert InvalidFeeCollector(); claimFee = _claimFee; } /// @inheritdoc IMerkleVester function fund(uint256 amount) external override nonReentrant { _transferInFunds(amount); } /// @inheritdoc IMerkleVester function defund(uint256 amount) external override nonReentrant onlyRole(BENEFACTOR) { SafeERC20.safeTransfer(IERC20(token), msg.sender, amount); } /// @inheritdoc IMerkleVester function withdraw( uint256 withdrawalAmount, uint32 rootIndex, bytes memory decodableArgs, bytes32[] calldata proof, IPostClaimHandler postClaimHandler, bytes memory extraData ) public payable override nonReentrant { if (_isCalendar(decodableArgs)) { _withdrawCalendar(withdrawalAmount, rootIndex, decodableArgs, proof, postClaimHandler, extraData); } else { _withdrawInterval(withdrawalAmount, rootIndex, decodableArgs, proof, postClaimHandler, extraData); } } /// @inheritdoc IMerkleVester function withdraw(uint256 withdrawalAmount, uint32 rootIndex, bytes memory decodableArgs, bytes32[] calldata proof) external payable override { withdraw(withdrawalAmount, rootIndex, decodableArgs, proof, IPostClaimHandler(address(0)), ""); } /// @inheritdoc IMerkleVester function transferBeneficiaryAddress( address newBeneficiaryAddress, uint32 rootIndex, bytes memory decodableArgs, bytes32[] calldata proof ) external nonReentrant { Allocation memory allocation = this.getLeafJustAllocationData(rootIndex, decodableArgs, proof); _checkOrSetOriginalBeneficiary(allocation); _transferBeneficiaryAddress(schedules[allocation.id], allocation, newBeneficiaryAddress); } /// @inheritdoc IMerkleVester function cancel(uint32 rootIndex, bytes memory decodableArgs, bytes32[] calldata proof) external override nonReentrant onlyRole(BENEFACTOR) { Allocation memory allocation = this.getLeafJustAllocationData(rootIndex, decodableArgs, proof); if (allocation.originalBeneficiary == address(0)) revert InvalidAllocation(); if (!allocation.cancelable) revert NotCancellable(); if (schedules[allocation.id].terminatedTimestamp != 0) revert AlreadyTerminated(); _checkAlreadyFullyUnlocked(rootIndex, decodableArgs, proof); schedules[allocation.id].terminatedTimestamp = uint32(block.timestamp); emit ScheduleCanceled(allocation.id); } /// @inheritdoc IMerkleVester function revoke(uint32 rootIndex, bytes memory decodableArgs, bytes32[] calldata proof) external override nonReentrant onlyRole(BENEFACTOR) { Allocation memory allocation = this.getLeafJustAllocationData(rootIndex, decodableArgs, proof); if (allocation.originalBeneficiary == address(0)) revert InvalidAllocation(); if (!allocation.revokable) revert NotRevokable(); if (schedules[allocation.id].terminatedTimestamp != 0) revert AlreadyTerminated(); // We use 1 as a sentinel value here to ensure that any withdrawals would not see anything vested and thus withdrawable schedules[allocation.id].terminatedTimestamp = uint32(1); emit ScheduleRevoked(allocation.id); } /// @inheritdoc IMerkleVester function revokeAll() external nonReentrant onlyRole(BENEFACTOR) { SafeERC20.safeTransfer(IERC20(token), msg.sender, IERC20(token).balanceOf(address(this))); } /** * @notice Throws an exception if the allocation is fully unlocked * * @param rootIndex the index of the merkle root the allocation is in * @param decodableArgs the allocation data that constitutes the leaf to be decoded and verified * @param proof proof data of sibling leaves to verify the leaf is included in the root */ function _checkAlreadyFullyUnlocked(uint32 rootIndex, bytes memory decodableArgs, bytes32[] calldata proof) internal view { if (_isCalendar(decodableArgs)) { (, CalendarUnlockSchedule memory unlockSchedule) = this.getCalendarLeafAllocationData(rootIndex, decodableArgs, proof); if (block.timestamp >= unlockSchedule.unlockTimestamps[unlockSchedule.unlockTimestamps.length - 1]) { revert AlreadyFullyUnlocked(); } } else { (, IntervalUnlockSchedule memory intervalUnlockSchedule) = this.getIntervalLeafAllocationData(rootIndex, decodableArgs, proof); uint32 finalUnlockTimestamp = _getPieceEndTime(intervalUnlockSchedule.pieces[intervalUnlockSchedule.pieces.length - 1]); if (block.timestamp >= finalUnlockTimestamp) revert AlreadyFullyUnlocked(); } } /** * @notice Sets the original beneficiary, if not already set * @dev MerkleVester lazily sets the mutable schedule state, so we need to check if withdrawalAddress has not been set, and if so set it to the immutable allocations originalBeneficiary address * * @param allocation allocation containing the original beneficiary */ function _checkOrSetOriginalBeneficiary(Allocation memory allocation) internal { if (schedules[allocation.id].withdrawalAddress == address(0)) { schedules[allocation.id].withdrawalAddress = allocation.originalBeneficiary; } } /** * @notice Returns true, if the decodableArgs is calendar type * * @param decodableArgs decodable args to checks whether it is calendar type or not * * @return true, if decodable args is calendar type */ function _isCalendar(bytes memory decodableArgs) internal pure returns (bool) { (string memory allocationType) = abi.decode(decodableArgs, (string)); if (keccak256(abi.encodePacked(allocationType)) == keccak256("calendar")) { return true; } else if (keccak256(abi.encodePacked(allocationType)) == keccak256("interval")) { return false; } else { revert InvalidAllocationType(); } } /** * @notice Withdraws vested funds from the contract to the beneficiary using Calendar type allocation * * @param withdrawalAmount optional amount to withdraw, specify 0 to withdraw all vested funds. If amount specified is greater than vested amount this call will fail since that implies a incorrect intention * @param rootIndex the index of the merkle root the allocation is in * @param decodableArgs the allocation data that constitutes the leaf to be decoded and verified * @param proof proof data of sibling leaves to verify the leaf is included in the root * @param postClaimHandler the tokens will be automatically transferred to postClaimHandler contract, after which the handlePostClaim will be automatically called * @param extraData extra data that will be passed to the post claim handler */ function _withdrawCalendar( uint256 withdrawalAmount, uint32 rootIndex, bytes memory decodableArgs, bytes32[] calldata proof, IPostClaimHandler postClaimHandler, bytes memory extraData ) internal { (CalendarAllocation memory calendar, CalendarUnlockSchedule memory unlockSchedule) = this.getCalendarLeafAllocationData(rootIndex, decodableArgs, proof); uint256 withdrawableAmount = _getVestedAmount( unlockSchedule.unlockTimestamps, unlockSchedule.unlockAmounts, calendar.allocation.totalAllocation, schedules[calendar.allocation.id].terminatedTimestamp ) - schedules[calendar.allocation.id].withdrawn; uint256 contractBalance = IERC20(token).balanceOf(address(this)); _checkOrSetOriginalBeneficiary(calendar.allocation); withdrawableAmount = Math.min(withdrawableAmount, contractBalance); _handleClaimFee(calendar.allocation.id); _withdrawToBeneficiary( calendar.allocation, schedules[calendar.allocation.id], withdrawableAmount, withdrawalAmount, postClaimHandler, extraData ); } /** * @notice Withdraws vested funds from the contract to the beneficiary using Interval type allocation * * @param withdrawalAmount optional amount to withdraw, specify 0 to withdraw all vested funds. If amount specified is greater than vested amount this call will fail since that implies a incorrect intention * @param rootIndex the index of the merkle root the allocation is in * @param decodableArgs the allocation data that constitutes the leaf to be decoded and verified * @param proof proof data of sibling leaves to verify the leaf is included in the root * @param postClaimHandler the tokens will be automatically transferred to postClaimHandler contract, after which the handlePostClaim will be automatically called * @param extraData extra data that will be passed to the post claim handler */ function _withdrawInterval( uint256 withdrawalAmount, uint32 rootIndex, bytes memory decodableArgs, bytes32[] calldata proof, IPostClaimHandler postClaimHandler, bytes memory extraData ) internal { (IntervalAllocation memory interval, IntervalUnlockSchedule memory intervalUnlockSchedule) = this.getIntervalLeafAllocationData(rootIndex, decodableArgs, proof); uint256 withdrawableAmount = _getVestedAmount(interval, intervalUnlockSchedule) - schedules[interval.allocation.id].withdrawn; uint256 contractBalance = IERC20(token).balanceOf(address(this)); _checkOrSetOriginalBeneficiary(interval.allocation); withdrawableAmount = Math.min(withdrawableAmount, contractBalance); _handleClaimFee(interval.allocation.id); _withdrawToBeneficiary( interval.allocation, schedules[interval.allocation.id], withdrawableAmount, withdrawalAmount, postClaimHandler, extraData ); } /** * @notice Returns the claim fee for an allocation id * * @param allocationId the allocation id * * @return the claim fee */ function getClaimFee(string memory allocationId) external view returns (uint256) { if (shouldPayClaimFeeOnlyOnce && feeAlreadyPayed[allocationId]) { return 0; } else { return claimFee; } } /** * @notice Validates the fee parameters and transfers fee to fee collector * * @param allocationId the allocation id */ function _handleClaimFee(string memory allocationId) private { uint256 calculatedClaimFee; if (shouldPayClaimFeeOnlyOnce) { if (!feeAlreadyPayed[allocationId] && claimFee != 0) { // if claimFee is 0, feeAlreadyPayed is not set to true feeAlreadyPayed[allocationId] = true; calculatedClaimFee = claimFee; } } else { calculatedClaimFee = claimFee; } if (msg.value != calculatedClaimFee) revert InvalidFeeFundsSent(); if (calculatedClaimFee > 0) { if (feeCollector == address(0)) { revert InvalidFeeCollector(); } SafeTransferLib.safeTransferETH(feeCollector, calculatedClaimFee); } } }
pragma solidity ^0.8.24; import {IERC20} from "@openzeppelin/interfaces/IERC20.sol"; /// @dev the address for denoting whether direct claims are allowed IPostClaimHandler constant DIRECT_CLAIM_HANDLER = IPostClaimHandler(address(0)); /// @notice Interface for post claim handlers interface IPostClaimHandler { /** * @notice Implementing this method provides a way to claim vesting tokens and execute some custom action afterwards * @dev Implementors can assume that 'amount' amount of 'claimToken' has already been transferred to this contract address. * Implementors should: * 1. check if the calling contract is the vesting contract, and revert otherwise * 2. revert the transaction, if for any reasons this contract cannot execute the custom actions * @param claimToken Address of the vesting token. * @param amount The amount of vesting tokens that were claimed and transferred to this contract address. * @param originalBeneficiary The address of the user who was the original owner of the vesting tokens at the time the vesting contract was created. * @param withdrawalAddress The latest owner of the vesting tokens which might be the same as the 'originalBeneficiary' in case no ownership transfer took place. * @param allocationId The allocation id from which the withdrawn amount was taken. * @param extraData Any abi encoded extra data that is necessary for the custom action. For example in case of a custom staking action, the user could state his * staking preference by providing extraData. */ function handlePostClaim( IERC20 claimToken, uint256 amount, address originalBeneficiary, address withdrawalAddress, string memory allocationId, bytes memory extraData ) external; }
pragma solidity ^0.8.24; import {IPostClaimHandler} from "./interfaces/IPostClaimHandler.sol"; import "./interfaces/IAirlockBase.sol"; import "@openzeppelin/token/ERC20/utils/SafeERC20.sol"; /// @notice Abstract contract to define common behavior for Merkle type vesters interface IMerkleVester { /** * @notice Calculates the hash of a given Calendar allocation leaf * * @param allocationType 'calendar' or 'interval' * @param allocation allocation data * @param unlockSchedule calendar unlock schedule * * @return the hash of a given Calendar allocation leaf */ function getCalendarLeafHash( string calldata allocationType, Allocation calldata allocation, CalendarUnlockSchedule calldata unlockSchedule ) external pure returns (bytes32); /** * @notice Calculates the hash of a given Interval allocation leaf * * @param allocationType 'calendar' or 'interval' * @param allocation allocation data * @param unlockSchedule interval unlock schedule * * @return the hash of a given Interval allocation leaf */ function getIntervalLeafHash( string calldata allocationType, Allocation calldata allocation, IntervalUnlockSchedule calldata unlockSchedule ) external pure returns (bytes32); /** * @notice Decodes calendar allocation data from decodable arguments and state stored on chain * * @param rootIndex the index of the merkle root the allocation is in * @param decodableArgs the allocation data that constitutes the leaf to be decoded and verified * @param proof proof data of sibling leaves to verify the leaf is included in the root * * @return calendarAllocation decoded calendar allocation * @return calendarUnlockSchedule decoded calendar unlock schedule */ function getCalendarLeafAllocationData(uint32 rootIndex, bytes calldata decodableArgs, bytes32[] calldata proof) external view returns (CalendarAllocation memory calendarAllocation, CalendarUnlockSchedule memory calendarUnlockSchedule); /** * @notice Decodes interval allocation data from decodable arguments and state stored on chain * * @param rootIndex the index of the merkle root the allocation is in * @param decodableArgs the allocation data that constitutes the leaf to be decoded and verified * @param proof proof data of sibling leaves to verify the leaf is included in the root * * @return intervalAllocation decoded interval allocation * @return intervalUnlockSchedule decoded interval unlock schedule */ function getIntervalLeafAllocationData(uint32 rootIndex, bytes calldata decodableArgs, bytes32[] calldata proof) external view returns (IntervalAllocation memory intervalAllocation, IntervalUnlockSchedule memory intervalUnlockSchedule); /** * @notice Decodes allocation data from decodable arguments, works for both calendar and interval allocations * * @param rootIndex the index of the merkle root the allocation is in * @param decodableArgs the allocation data that constitutes the leaf to be decoded and verified * @param proof proof data of sibling leaves to verify the leaf is included in the root * * @return decoded allocation */ function getLeafJustAllocationData(uint32 rootIndex, bytes memory decodableArgs, bytes32[] calldata proof) external view returns (Allocation memory); /** * @notice Adds additional allocations in an append only manner * @dev dapp is responsible for ensuring funding across all allocations otherwise withdrawals will be fulfilled first come first served * * @param merkleRoot the additional merkle root to append representing additional allocations * * @return the new lenght of the number of merkle roots array minus 1 */ function addAllocationRoot(bytes32 merkleRoot) external returns (uint256); /** * @notice Funds the contract with the specified amount of tokens * @dev MerkleVester contracts are funded as a whole rather than funding individual allocations */ function fund(uint256 amount) external; /** * @notice Defunds the contract the specified amount of tokens * @dev using defund can result in underfunding the total liabilies of the allocations, in which case allocations will be served on a first come first serve basis */ function defund(uint256 amount) external; /** * @notice Withdraws vested funds from the contract to the beneficiary * @dev if direct claim feature is disabled, then this method should not be called * * @param withdrawalAmount optional amount to withdraw, specify 0 to withdraw all vested funds. If amount specified is greater than vested amount this call will fail since that implies a incorrect intention * @param rootIndex the index of the merkle root the allocation is in * @param decodableArgs the allocation data that constitutes the leaf to be decoded and verified * @param proof proof data of sibling leaves to verify the leaf is included in the root */ function withdraw(uint256 withdrawalAmount, uint32 rootIndex, bytes memory decodableArgs, bytes32[] calldata proof) external payable; /** * @notice Withdraws vested funds from the contract to the beneficiary * * @param withdrawalAmount optional amount to withdraw, specify 0 to withdraw all vested funds. If amount specified is greater than vested amount this call will fail since that implies a incorrect intention * @param rootIndex the index of the merkle root the allocation is in * @param decodableArgs the allocation data that constitutes the leaf to be decoded and verified * @param proof proof data of sibling leaves to verify the leaf is included in the root * @param postClaimHandler the tokens will be automatically transferred to postClaimHandler contract, after which the handlePostClaim will be automatically called * @param extraData extra data that will be passed to the post claim handler */ function withdraw( uint256 withdrawalAmount, uint32 rootIndex, bytes memory decodableArgs, bytes32[] calldata proof, IPostClaimHandler postClaimHandler, bytes calldata extraData ) external payable; /** * @notice Transfers the beneficiary address of the allocation, only for allocations either transferable by the beneficiary or benefactor * * @param newBeneficiaryAddress the new beneficiary address * @param rootIndex the index of the merkle root the allocation is in * @param decodableArgs the allocation data that constitutes the leaf to be decoded and verified * @param proof proof data of sibling leaves to verify the leaf is included in the root */ function transferBeneficiaryAddress( address newBeneficiaryAddress, uint32 rootIndex, bytes memory decodableArgs, bytes32[] calldata proof ) external; /** * @notice Cancels the allocation, already vested funds remain withdrawable to the beneficiary * @dev don't need to track the terminated amount since merkle vester doesn't have per allocation underfunding * * @param rootIndex the index of the merkle root the allocation is in * @param decodableArgs the allocation data that constitutes the leaf to be decoded and verified * @param proof proof data of sibling leaves to verify the leaf is included in the root */ function cancel(uint32 rootIndex, bytes memory decodableArgs, bytes32[] calldata proof) external; /** * @notice Revokes the allocation, unwithdrawn funds are no longer withdrawable to the beneficiary * @dev don't need to track the terminated amount since merkle vester doesn't have per allocation underfunding * * @param rootIndex the index of the merkle root the allocation is in * @param decodableArgs the allocation data that constitutes the leaf to be decoded and verified * @param proof proof data of sibling leaves to verify the leaf is included in the root */ function revoke(uint32 rootIndex, bytes memory decodableArgs, bytes32[] calldata proof) external; /** * @notice For exceptional circumstances, it would be prohibitively expensive to run cancellation logic per allocation */ function revokeAll() external; }
pragma solidity ^0.8.24; import {MerkleProof} from "@openzeppelin/utils/cryptography/MerkleProof.sol"; import {InvalidMerkleProof} from "./interfaces/AirlockTypes.sol"; /// @notice Utility contract to verify that a leaf is included in the Merkle tree contract MerkleValidator { /** * @notice Verify verify a leaf is included in the Merkle tree * @dev throws if the verification fails * * @param merkleRoot the root of the Merkle tree * @param leafArguments the leaf that needs to be verified whether it is part of the tree * @param proof the inclusion proof */ function validateLeaf(bytes32 merkleRoot, bytes memory leafArguments, bytes32[] calldata proof) external pure { bytes32 leaf = keccak256(abi.encodePacked(leafArguments)); bool isValidLeaf = MerkleProof.verify(proof, merkleRoot, leaf); if (!isValidLeaf) revert InvalidMerkleProof(); } }
pragma solidity ^0.8.24; import "@openzeppelin/utils/math/Math.sol"; /// @notice Abstract contract to define common behavior for Calender type vesters, specifically to calculate the vested amount abstract contract CalendarVester { /** * @notice Get the vested amount for Calendar type vesters * * @param _unlockTimestamps array of unlock timestamps * @param _unlockAmounts array of unlock amounts * @param _totalAllocation total amount of tokens to be vested * @param _terminatedTimestamp the time when the allocation was terminated * * @return the vested amount */ function _getVestedAmount( uint32[] memory _unlockTimestamps, uint256[] memory _unlockAmounts, uint256 _totalAllocation, uint256 _terminatedTimestamp ) internal view returns (uint256) { uint256 amount; uint32 blockTimestamp = uint32(block.timestamp); uint256 finalTimestamp; if (_terminatedTimestamp == 0) { finalTimestamp = blockTimestamp; } else { finalTimestamp = Math.min(_terminatedTimestamp, blockTimestamp); } for (uint256 i = 0; i < _unlockTimestamps.length; i++) { if (_unlockTimestamps[i] > finalTimestamp) { break; } amount += _unlockAmounts[i]; } // staying on the safe side in the unlikely case that the amounts added up is higher than the _totalAllocation return Math.min(_totalAllocation, amount); } }
pragma solidity ^0.8.24; import "@openzeppelin/utils/math/Math.sol"; import "./IAirlockBase.sol"; /// @notice Abstract contract to define common behavior for Interval type vesters, specifically to calculate the vested amount abstract contract IntervalVester is IAirlockBase { /** * @notice Gets the vested amount of tokens for a schedule * @dev iterates over the pieces and calculates the number of tokens that have vested * * @param interval the interval data for which to calculate vested amount * @param schedule the unlock schedule for which to calculate vested amount, pieces can overlap see details below * * @return amount of tokens vested */ function _getVestedAmount(IntervalAllocation memory interval, IntervalUnlockSchedule memory schedule) internal view returns (uint256) { uint256 finalTimestamp = _getLastVestingTimestamp(interval.distributionState.terminatedTimestamp); uint256 vestingEndTimestamp = _getPieceEndTime(schedule.pieces[schedule.pieces.length - 1]); uint256 currVested; // 1. pieces can overlap, but they must be ordered ascending by their end time (calculated by _getPieceEndTime) // 2. could quit the loop early if blockTimestamp < startDate for the current piece AND all other previous pieces have passed their end time for (uint256 index; index < schedule.pieces.length; index++) { currVested += _componentVested( schedule.pieces[index].startDate, schedule.pieces[index].periodLength, schedule.pieces[index].numberOfPeriods, schedule.pieces[index].amount, finalTimestamp ); } // staying on the safe side in the unlikely case that the amounts added up is higher than the _totalAllocation return Math.min(interval.allocation.totalAllocation, currVested); } /** * @notice Gets the timestamp when the piece is fully vested * * @param piece one piece that makes up the allocation * * @return the timestamp when the piece is fully vested */ function _getPieceEndTime(Piece memory piece) internal pure returns (uint32) { return (piece.startDate + (piece.periodLength * piece.numberOfPeriods)); } /** * @notice Gets the vested amount of tokens for a schedule * @dev calculates the number of tokens that have vested for a single component * * @param startDate the start timestamp of the piece * @param periodLength the length of each period in seconds * @param numberOfPeriods the number of periods in the piece * @param amount the amount of tokens that is released in each piece * @param blockTimestamp the current block timestamp * * @return amount of tokens vested * */ function _componentVested( uint256 startDate, uint256 periodLength, uint256 numberOfPeriods, uint256 amount, uint256 blockTimestamp ) internal pure returns (uint256) { if (blockTimestamp < startDate) { return 0; } uint256 elapsedTime = blockTimestamp - startDate; uint256 fullyVestedPeriods = elapsedTime / periodLength; if (fullyVestedPeriods > numberOfPeriods) { fullyVestedPeriods = numberOfPeriods; } // rounding issues will be accounted for when fullyVestedPeriods = numberOfPeriods return (amount * fullyVestedPeriods) / numberOfPeriods; } /** * @notice Gets the timestamp until the vesting should be calculated * * @param terminatedTimestamp zero if the allocation was not terminated, non-zero if the allocation was terminated denoting the termination time * * @return the timestamp until the vesting should be calculated * */ function _getLastVestingTimestamp(uint256 terminatedTimestamp) internal view returns (uint256) { if (terminatedTimestamp != 0) { return Math.min(block.timestamp, terminatedTimestamp); } else { return block.timestamp; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; import {IERC20Permit} from "../extensions/IERC20Permit.sol"; import {Address} from "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; /** * @dev An operation with an ERC20 token failed. */ error SafeERC20FailedOperation(address token); /** * @dev Indicates a failed `decreaseAllowance` request. */ error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease); /** * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value))); } /** * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful. */ function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value))); } /** * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); forceApprove(token, spender, oldAllowance + value); } /** * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no * value, non-reverting calls are assumed to be successful. */ function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal { unchecked { uint256 currentAllowance = token.allowance(address(this), spender); if (currentAllowance < requestedDecrease) { revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease); } forceApprove(token, spender, currentAllowance - requestedDecrease); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval * to be set to zero before setting it to a non-zero value, such as USDT. */ function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value)); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0))); _callOptionalReturn(token, approvalCall); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data); if (returndata.length != 0 && !abi.decode(returndata, (bool))) { revert SafeERC20FailedOperation(address(token)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). * * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false // and not revert is the subcall reverts. (bool success, bytes memory returndata) = address(token).call(data); return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (utils/Multicall.sol) pragma solidity ^0.8.20; import {Address} from "./Address.sol"; import {Context} from "./Context.sol"; /** * @dev Provides a function to batch together multiple calls in a single external call. * * Consider any assumption about calldata validation performed by the sender may be violated if it's not especially * careful about sending transactions invoking {multicall}. For example, a relay address that filters function * selectors won't filter calls nested within a {multicall} operation. * * NOTE: Since 5.0.1 and 4.9.4, this contract identifies non-canonical contexts (i.e. `msg.sender` is not {_msgSender}). * If a non-canonical context is identified, the following self `delegatecall` appends the last bytes of `msg.data` * to the subcall. This makes it safe to use with {ERC2771Context}. Contexts that don't affect the resolution of * {_msgSender} are not propagated to subcalls. */ abstract contract Multicall is Context { /** * @dev Receives and executes a batch of function calls on this contract. * @custom:oz-upgrades-unsafe-allow-reachable delegatecall */ function multicall(bytes[] calldata data) external virtual returns (bytes[] memory results) { bytes memory context = msg.sender == _msgSender() ? new bytes(0) : msg.data[msg.data.length - _contextSuffixLength():]; results = new bytes[](data.length); for (uint256 i = 0; i < data.length; i++) { results[i] = Address.functionDelegateCall(address(this), bytes.concat(data[i], context)); } return results; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MerkleProof.sol) pragma solidity ^0.8.20; /** * @dev These functions deal with verification of Merkle Tree proofs. * * The tree and the proofs can be generated using our * https://github.com/OpenZeppelin/merkle-tree[JavaScript library]. * You will find a quickstart guide in the readme. * * WARNING: You should avoid using leaf values that are 64 bytes long prior to * hashing, or use a hash function other than keccak256 for hashing leaves. * This is because the concatenation of a sorted pair of internal nodes in * the Merkle tree could be reinterpreted as a leaf value. * OpenZeppelin's JavaScript library generates Merkle trees that are safe * against this attack out of the box. */ library MerkleProof { /** *@dev The multiproof provided is not valid. */ error MerkleProofInvalidMultiproof(); /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) { return processProof(proof, leaf) == root; } /** * @dev Calldata version of {verify} */ function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) internal pure returns (bool) { return processProofCalldata(proof, leaf) == root; } /** * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt * hash matches the root of the tree. When processing the proof, the pairs * of leafs & pre-images are assumed to be sorted. */ function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { computedHash = _hashPair(computedHash, proof[i]); } return computedHash; } /** * @dev Calldata version of {processProof} */ function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { computedHash = _hashPair(computedHash, proof[i]); } return computedHash; } /** * @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}. * * CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details. */ function multiProofVerify( bytes32[] memory proof, bool[] memory proofFlags, bytes32 root, bytes32[] memory leaves ) internal pure returns (bool) { return processMultiProof(proof, proofFlags, leaves) == root; } /** * @dev Calldata version of {multiProofVerify} * * CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details. */ function multiProofVerifyCalldata( bytes32[] calldata proof, bool[] calldata proofFlags, bytes32 root, bytes32[] memory leaves ) internal pure returns (bool) { return processMultiProofCalldata(proof, proofFlags, leaves) == root; } /** * @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction * proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another * leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false * respectively. * * CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree * is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the * tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer). */ function processMultiProof( bytes32[] memory proof, bool[] memory proofFlags, bytes32[] memory leaves ) internal pure returns (bytes32 merkleRoot) { // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of // the Merkle tree. uint256 leavesLen = leaves.length; uint256 proofLen = proof.length; uint256 totalHashes = proofFlags.length; // Check proof validity. if (leavesLen + proofLen != totalHashes + 1) { revert MerkleProofInvalidMultiproof(); } // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop". bytes32[] memory hashes = new bytes32[](totalHashes); uint256 leafPos = 0; uint256 hashPos = 0; uint256 proofPos = 0; // At each step, we compute the next hash using two values: // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we // get the next hash. // - depending on the flag, either another value from the "main queue" (merging branches) or an element from the // `proof` array. for (uint256 i = 0; i < totalHashes; i++) { bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]; bytes32 b = proofFlags[i] ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]) : proof[proofPos++]; hashes[i] = _hashPair(a, b); } if (totalHashes > 0) { if (proofPos != proofLen) { revert MerkleProofInvalidMultiproof(); } unchecked { return hashes[totalHashes - 1]; } } else if (leavesLen > 0) { return leaves[0]; } else { return proof[0]; } } /** * @dev Calldata version of {processMultiProof}. * * CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details. */ function processMultiProofCalldata( bytes32[] calldata proof, bool[] calldata proofFlags, bytes32[] memory leaves ) internal pure returns (bytes32 merkleRoot) { // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of // the Merkle tree. uint256 leavesLen = leaves.length; uint256 proofLen = proof.length; uint256 totalHashes = proofFlags.length; // Check proof validity. if (leavesLen + proofLen != totalHashes + 1) { revert MerkleProofInvalidMultiproof(); } // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop". bytes32[] memory hashes = new bytes32[](totalHashes); uint256 leafPos = 0; uint256 hashPos = 0; uint256 proofPos = 0; // At each step, we compute the next hash using two values: // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we // get the next hash. // - depending on the flag, either another value from the "main queue" (merging branches) or an element from the // `proof` array. for (uint256 i = 0; i < totalHashes; i++) { bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]; bytes32 b = proofFlags[i] ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]) : proof[proofPos++]; hashes[i] = _hashPair(a, b); } if (totalHashes > 0) { if (proofPos != proofLen) { revert MerkleProofInvalidMultiproof(); } unchecked { return hashes[totalHashes - 1]; } } else if (leavesLen > 0) { return leaves[0]; } else { return proof[0]; } } /** * @dev Sorts the pair (a, b) and hashes the result. */ function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) { return a < b ? _efficientHash(a, b) : _efficientHash(b, a); } /** * @dev Implementation of keccak256(abi.encode(a, b)) that doesn't allocate or expand memory. */ function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) { /// @solidity memory-safe-assembly assembly { mstore(0x00, a) mstore(0x20, b) value := keccak256(0x00, 0x40) } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; /// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values. /// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/SafeTransferLib.sol) /// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol) /// @author Permit2 operations from (https://github.com/Uniswap/permit2/blob/main/src/libraries/Permit2Lib.sol) /// /// @dev Note: /// - For ETH transfers, please use `forceSafeTransferETH` for DoS protection. /// - For ERC20s, this implementation won't check that a token has code, /// responsibility is delegated to the caller. library SafeTransferLib { /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CUSTOM ERRORS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev The ETH transfer has failed. error ETHTransferFailed(); /// @dev The ERC20 `transferFrom` has failed. error TransferFromFailed(); /// @dev The ERC20 `transfer` has failed. error TransferFailed(); /// @dev The ERC20 `approve` has failed. error ApproveFailed(); /// @dev The Permit2 operation has failed. error Permit2Failed(); /// @dev The Permit2 amount must be less than `2**160 - 1`. error Permit2AmountOverflow(); /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CONSTANTS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Suggested gas stipend for contract receiving ETH that disallows any storage writes. uint256 internal constant GAS_STIPEND_NO_STORAGE_WRITES = 2300; /// @dev Suggested gas stipend for contract receiving ETH to perform a few /// storage reads and writes, but low enough to prevent griefing. uint256 internal constant GAS_STIPEND_NO_GRIEF = 100000; /// @dev The unique EIP-712 domain domain separator for the DAI token contract. bytes32 internal constant DAI_DOMAIN_SEPARATOR = 0xdbb8cf42e1ecb028be3f3dbc922e1d878b963f411dc388ced501601c60f7c6f7; /// @dev The address for the WETH9 contract on Ethereum mainnet. address internal constant WETH9 = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; /// @dev The canonical Permit2 address. /// [Github](https://github.com/Uniswap/permit2) /// [Etherscan](https://etherscan.io/address/0x000000000022D473030F116dDEE9F6B43aC78BA3) address internal constant PERMIT2 = 0x000000000022D473030F116dDEE9F6B43aC78BA3; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* ETH OPERATIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ // If the ETH transfer MUST succeed with a reasonable gas budget, use the force variants. // // The regular variants: // - Forwards all remaining gas to the target. // - Reverts if the target reverts. // - Reverts if the current contract has insufficient balance. // // The force variants: // - Forwards with an optional gas stipend // (defaults to `GAS_STIPEND_NO_GRIEF`, which is sufficient for most cases). // - If the target reverts, or if the gas stipend is exhausted, // creates a temporary contract to force send the ETH via `SELFDESTRUCT`. // Future compatible with `SENDALL`: https://eips.ethereum.org/EIPS/eip-4758. // - Reverts if the current contract has insufficient balance. // // The try variants: // - Forwards with a mandatory gas stipend. // - Instead of reverting, returns whether the transfer succeeded. /// @dev Sends `amount` (in wei) ETH to `to`. function safeTransferETH(address to, uint256 amount) internal { /// @solidity memory-safe-assembly assembly { if iszero(call(gas(), to, amount, codesize(), 0x00, codesize(), 0x00)) { mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`. revert(0x1c, 0x04) } } } /// @dev Sends all the ETH in the current contract to `to`. function safeTransferAllETH(address to) internal { /// @solidity memory-safe-assembly assembly { // Transfer all the ETH and check if it succeeded or not. if iszero(call(gas(), to, selfbalance(), codesize(), 0x00, codesize(), 0x00)) { mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`. revert(0x1c, 0x04) } } } /// @dev Force sends `amount` (in wei) ETH to `to`, with a `gasStipend`. function forceSafeTransferETH(address to, uint256 amount, uint256 gasStipend) internal { /// @solidity memory-safe-assembly assembly { if lt(selfbalance(), amount) { mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`. revert(0x1c, 0x04) } if iszero(call(gasStipend, to, amount, codesize(), 0x00, codesize(), 0x00)) { mstore(0x00, to) // Store the address in scratch space. mstore8(0x0b, 0x73) // Opcode `PUSH20`. mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`. if iszero(create(amount, 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation. } } } /// @dev Force sends all the ETH in the current contract to `to`, with a `gasStipend`. function forceSafeTransferAllETH(address to, uint256 gasStipend) internal { /// @solidity memory-safe-assembly assembly { if iszero(call(gasStipend, to, selfbalance(), codesize(), 0x00, codesize(), 0x00)) { mstore(0x00, to) // Store the address in scratch space. mstore8(0x0b, 0x73) // Opcode `PUSH20`. mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`. if iszero(create(selfbalance(), 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation. } } } /// @dev Force sends `amount` (in wei) ETH to `to`, with `GAS_STIPEND_NO_GRIEF`. function forceSafeTransferETH(address to, uint256 amount) internal { /// @solidity memory-safe-assembly assembly { if lt(selfbalance(), amount) { mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`. revert(0x1c, 0x04) } if iszero(call(GAS_STIPEND_NO_GRIEF, to, amount, codesize(), 0x00, codesize(), 0x00)) { mstore(0x00, to) // Store the address in scratch space. mstore8(0x0b, 0x73) // Opcode `PUSH20`. mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`. if iszero(create(amount, 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation. } } } /// @dev Force sends all the ETH in the current contract to `to`, with `GAS_STIPEND_NO_GRIEF`. function forceSafeTransferAllETH(address to) internal { /// @solidity memory-safe-assembly assembly { // forgefmt: disable-next-item if iszero(call(GAS_STIPEND_NO_GRIEF, to, selfbalance(), codesize(), 0x00, codesize(), 0x00)) { mstore(0x00, to) // Store the address in scratch space. mstore8(0x0b, 0x73) // Opcode `PUSH20`. mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`. if iszero(create(selfbalance(), 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation. } } } /// @dev Sends `amount` (in wei) ETH to `to`, with a `gasStipend`. function trySafeTransferETH(address to, uint256 amount, uint256 gasStipend) internal returns (bool success) { /// @solidity memory-safe-assembly assembly { success := call(gasStipend, to, amount, codesize(), 0x00, codesize(), 0x00) } } /// @dev Sends all the ETH in the current contract to `to`, with a `gasStipend`. function trySafeTransferAllETH(address to, uint256 gasStipend) internal returns (bool success) { /// @solidity memory-safe-assembly assembly { success := call(gasStipend, to, selfbalance(), codesize(), 0x00, codesize(), 0x00) } } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* ERC20 OPERATIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Sends `amount` of ERC20 `token` from `from` to `to`. /// Reverts upon failure. /// /// The `from` account must have at least `amount` approved for /// the current contract to manage. function safeTransferFrom(address token, address from, address to, uint256 amount) internal { /// @solidity memory-safe-assembly assembly { let m := mload(0x40) // Cache the free memory pointer. mstore(0x60, amount) // Store the `amount` argument. mstore(0x40, to) // Store the `to` argument. mstore(0x2c, shl(96, from)) // Store the `from` argument. mstore(0x0c, 0x23b872dd000000000000000000000000) // `transferFrom(address,address,uint256)`. // Perform the transfer, reverting upon failure. if iszero( and( // The arguments of `and` are evaluated from right to left. or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing. call(gas(), token, 0, 0x1c, 0x64, 0x00, 0x20) ) ) { mstore(0x00, 0x7939f424) // `TransferFromFailed()`. revert(0x1c, 0x04) } mstore(0x60, 0) // Restore the zero slot to zero. mstore(0x40, m) // Restore the free memory pointer. } } /// @dev Sends `amount` of ERC20 `token` from `from` to `to`. /// /// The `from` account must have at least `amount` approved for the current contract to manage. function trySafeTransferFrom(address token, address from, address to, uint256 amount) internal returns (bool success) { /// @solidity memory-safe-assembly assembly { let m := mload(0x40) // Cache the free memory pointer. mstore(0x60, amount) // Store the `amount` argument. mstore(0x40, to) // Store the `to` argument. mstore(0x2c, shl(96, from)) // Store the `from` argument. mstore(0x0c, 0x23b872dd000000000000000000000000) // `transferFrom(address,address,uint256)`. success := and( // The arguments of `and` are evaluated from right to left. or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing. call(gas(), token, 0, 0x1c, 0x64, 0x00, 0x20) ) mstore(0x60, 0) // Restore the zero slot to zero. mstore(0x40, m) // Restore the free memory pointer. } } /// @dev Sends all of ERC20 `token` from `from` to `to`. /// Reverts upon failure. /// /// The `from` account must have their entire balance approved for the current contract to manage. function safeTransferAllFrom(address token, address from, address to) internal returns (uint256 amount) { /// @solidity memory-safe-assembly assembly { let m := mload(0x40) // Cache the free memory pointer. mstore(0x40, to) // Store the `to` argument. mstore(0x2c, shl(96, from)) // Store the `from` argument. mstore(0x0c, 0x70a08231000000000000000000000000) // `balanceOf(address)`. // Read the balance, reverting upon failure. if iszero( and( // The arguments of `and` are evaluated from right to left. gt(returndatasize(), 0x1f), // At least 32 bytes returned. staticcall(gas(), token, 0x1c, 0x24, 0x60, 0x20) ) ) { mstore(0x00, 0x7939f424) // `TransferFromFailed()`. revert(0x1c, 0x04) } mstore(0x00, 0x23b872dd) // `transferFrom(address,address,uint256)`. amount := mload(0x60) // The `amount` is already at 0x60. We'll need to return it. // Perform the transfer, reverting upon failure. if iszero( and( // The arguments of `and` are evaluated from right to left. or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing. call(gas(), token, 0, 0x1c, 0x64, 0x00, 0x20) ) ) { mstore(0x00, 0x7939f424) // `TransferFromFailed()`. revert(0x1c, 0x04) } mstore(0x60, 0) // Restore the zero slot to zero. mstore(0x40, m) // Restore the free memory pointer. } } /// @dev Sends `amount` of ERC20 `token` from the current contract to `to`. /// Reverts upon failure. function safeTransfer(address token, address to, uint256 amount) internal { /// @solidity memory-safe-assembly assembly { mstore(0x14, to) // Store the `to` argument. mstore(0x34, amount) // Store the `amount` argument. mstore(0x00, 0xa9059cbb000000000000000000000000) // `transfer(address,uint256)`. // Perform the transfer, reverting upon failure. if iszero( and( // The arguments of `and` are evaluated from right to left. or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing. call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20) ) ) { mstore(0x00, 0x90b8ec18) // `TransferFailed()`. revert(0x1c, 0x04) } mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten. } } /// @dev Sends all of ERC20 `token` from the current contract to `to`. /// Reverts upon failure. function safeTransferAll(address token, address to) internal returns (uint256 amount) { /// @solidity memory-safe-assembly assembly { mstore(0x00, 0x70a08231) // Store the function selector of `balanceOf(address)`. mstore(0x20, address()) // Store the address of the current contract. // Read the balance, reverting upon failure. if iszero( and( // The arguments of `and` are evaluated from right to left. gt(returndatasize(), 0x1f), // At least 32 bytes returned. staticcall(gas(), token, 0x1c, 0x24, 0x34, 0x20) ) ) { mstore(0x00, 0x90b8ec18) // `TransferFailed()`. revert(0x1c, 0x04) } mstore(0x14, to) // Store the `to` argument. amount := mload(0x34) // The `amount` is already at 0x34. We'll need to return it. mstore(0x00, 0xa9059cbb000000000000000000000000) // `transfer(address,uint256)`. // Perform the transfer, reverting upon failure. if iszero( and( // The arguments of `and` are evaluated from right to left. or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing. call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20) ) ) { mstore(0x00, 0x90b8ec18) // `TransferFailed()`. revert(0x1c, 0x04) } mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten. } } /// @dev Sets `amount` of ERC20 `token` for `to` to manage on behalf of the current contract. /// Reverts upon failure. function safeApprove(address token, address to, uint256 amount) internal { /// @solidity memory-safe-assembly assembly { mstore(0x14, to) // Store the `to` argument. mstore(0x34, amount) // Store the `amount` argument. mstore(0x00, 0x095ea7b3000000000000000000000000) // `approve(address,uint256)`. // Perform the approval, reverting upon failure. if iszero( and( // The arguments of `and` are evaluated from right to left. or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing. call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20) ) ) { mstore(0x00, 0x3e3f8f73) // `ApproveFailed()`. revert(0x1c, 0x04) } mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten. } } /// @dev Sets `amount` of ERC20 `token` for `to` to manage on behalf of the current contract. /// If the initial attempt to approve fails, attempts to reset the approved amount to zero, /// then retries the approval again (some tokens, e.g. USDT, requires this). /// Reverts upon failure. function safeApproveWithRetry(address token, address to, uint256 amount) internal { /// @solidity memory-safe-assembly assembly { mstore(0x14, to) // Store the `to` argument. mstore(0x34, amount) // Store the `amount` argument. mstore(0x00, 0x095ea7b3000000000000000000000000) // `approve(address,uint256)`. // Perform the approval, retrying upon failure. if iszero( and( // The arguments of `and` are evaluated from right to left. or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing. call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20) ) ) { mstore(0x34, 0) // Store 0 for the `amount`. mstore(0x00, 0x095ea7b3000000000000000000000000) // `approve(address,uint256)`. pop(call(gas(), token, 0, 0x10, 0x44, codesize(), 0x00)) // Reset the approval. mstore(0x34, amount) // Store back the original `amount`. // Retry the approval, reverting upon failure. if iszero( and( or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing. call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20) ) ) { mstore(0x00, 0x3e3f8f73) // `ApproveFailed()`. revert(0x1c, 0x04) } } mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten. } } /// @dev Returns the amount of ERC20 `token` owned by `account`. /// Returns zero if the `token` does not exist. function balanceOf(address token, address account) internal view returns (uint256 amount) { /// @solidity memory-safe-assembly assembly { mstore(0x14, account) // Store the `account` argument. mstore(0x00, 0x70a08231000000000000000000000000) // `balanceOf(address)`. amount := mul( // The arguments of `mul` are evaluated from right to left. mload(0x20), and( // The arguments of `and` are evaluated from right to left. gt(returndatasize(), 0x1f), // At least 32 bytes returned. staticcall(gas(), token, 0x10, 0x24, 0x20, 0x20) ) ) } } /// @dev Sends `amount` of ERC20 `token` from `from` to `to`. /// If the initial attempt fails, try to use Permit2 to transfer the token. /// Reverts upon failure. /// /// The `from` account must have at least `amount` approved for the current contract to manage. function safeTransferFrom2(address token, address from, address to, uint256 amount) internal { if (!trySafeTransferFrom(token, from, to, amount)) { permit2TransferFrom(token, from, to, amount); } } /// @dev Sends `amount` of ERC20 `token` from `from` to `to` via Permit2. /// Reverts upon failure. function permit2TransferFrom(address token, address from, address to, uint256 amount) internal { /// @solidity memory-safe-assembly assembly { let m := mload(0x40) mstore(add(m, 0x74), shr(96, shl(96, token))) mstore(add(m, 0x54), amount) mstore(add(m, 0x34), to) mstore(add(m, 0x20), shl(96, from)) // `transferFrom(address,address,uint160,address)`. mstore(m, 0x36c78516000000000000000000000000) let p := PERMIT2 let exists := eq(chainid(), 1) if iszero(exists) { exists := iszero(iszero(extcodesize(p))) } if iszero(and(call(gas(), p, 0, add(m, 0x10), 0x84, codesize(), 0x00), exists)) { mstore(0x00, 0x7939f4248757f0fd) // `TransferFromFailed()` or `Permit2AmountOverflow()`. revert(add(0x18, shl(2, iszero(iszero(shr(160, amount))))), 0x04) } } } /// @dev Permit a user to spend a given amount of /// another user's tokens via native EIP-2612 permit if possible, falling /// back to Permit2 if native permit fails or is not implemented on the token. function permit2( address token, address owner, address spender, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { bool success; /// @solidity memory-safe-assembly assembly { for {} shl(96, xor(token, WETH9)) {} { mstore(0x00, 0x3644e515) // `DOMAIN_SEPARATOR()`. if iszero( and( // The arguments of `and` are evaluated from right to left. lt(iszero(mload(0x00)), eq(returndatasize(), 0x20)), // Returns 1 non-zero word. // Gas stipend to limit gas burn for tokens that don't refund gas when // an non-existing function is called. 5K should be enough for a SLOAD. staticcall(5000, token, 0x1c, 0x04, 0x00, 0x20) ) ) { break } // After here, we can be sure that token is a contract. let m := mload(0x40) mstore(add(m, 0x34), spender) mstore(add(m, 0x20), shl(96, owner)) mstore(add(m, 0x74), deadline) if eq(mload(0x00), DAI_DOMAIN_SEPARATOR) { mstore(0x14, owner) mstore(0x00, 0x7ecebe00000000000000000000000000) // `nonces(address)`. mstore(add(m, 0x94), staticcall(gas(), token, 0x10, 0x24, add(m, 0x54), 0x20)) mstore(m, 0x8fcbaf0c000000000000000000000000) // `IDAIPermit.permit`. // `nonces` is already at `add(m, 0x54)`. // `1` is already stored at `add(m, 0x94)`. mstore(add(m, 0xb4), and(0xff, v)) mstore(add(m, 0xd4), r) mstore(add(m, 0xf4), s) success := call(gas(), token, 0, add(m, 0x10), 0x104, codesize(), 0x00) break } mstore(m, 0xd505accf000000000000000000000000) // `IERC20Permit.permit`. mstore(add(m, 0x54), amount) mstore(add(m, 0x94), and(0xff, v)) mstore(add(m, 0xb4), r) mstore(add(m, 0xd4), s) success := call(gas(), token, 0, add(m, 0x10), 0xe4, codesize(), 0x00) break } } if (!success) simplePermit2(token, owner, spender, amount, deadline, v, r, s); } /// @dev Simple permit on the Permit2 contract. function simplePermit2( address token, address owner, address spender, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { /// @solidity memory-safe-assembly assembly { let m := mload(0x40) mstore(m, 0x927da105) // `allowance(address,address,address)`. { let addressMask := shr(96, not(0)) mstore(add(m, 0x20), and(addressMask, owner)) mstore(add(m, 0x40), and(addressMask, token)) mstore(add(m, 0x60), and(addressMask, spender)) mstore(add(m, 0xc0), and(addressMask, spender)) } let p := mul(PERMIT2, iszero(shr(160, amount))) if iszero( and( // The arguments of `and` are evaluated from right to left. gt(returndatasize(), 0x5f), // Returns 3 words: `amount`, `expiration`, `nonce`. staticcall(gas(), p, add(m, 0x1c), 0x64, add(m, 0x60), 0x60) ) ) { mstore(0x00, 0x6b836e6b8757f0fd) // `Permit2Failed()` or `Permit2AmountOverflow()`. revert(add(0x18, shl(2, iszero(p))), 0x04) } mstore(m, 0x2b67b570) // `Permit2.permit` (PermitSingle variant). // `owner` is already `add(m, 0x20)`. // `token` is already at `add(m, 0x40)`. mstore(add(m, 0x60), amount) mstore(add(m, 0x80), 0xffffffffffff) // `expiration = type(uint48).max`. // `nonce` is already at `add(m, 0xa0)`. // `spender` is already at `add(m, 0xc0)`. mstore(add(m, 0xe0), deadline) mstore(add(m, 0x100), 0x100) // `signature` offset. mstore(add(m, 0x120), 0x41) // `signature` length. mstore(add(m, 0x140), r) mstore(add(m, 0x160), s) mstore(add(m, 0x180), shl(248, v)) if iszero(call(gas(), p, 0, add(m, 0x1c), 0x184, codesize(), 0x00)) { mstore(0x00, 0x6b836e6b) // `Permit2Failed()`. revert(0x1c, 0x04) } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "../token/ERC20/IERC20.sol";
pragma solidity ^0.8.24; import {IPostClaimHandler, DIRECT_CLAIM_HANDLER} from "./IPostClaimHandler.sol"; import "./AirlockTypes.sol"; import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol"; import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; import "@openzeppelin/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/utils/math/Math.sol"; import {EnumerableSet} from "@openzeppelin/utils/structs/EnumerableSet.sol"; /** * @title Defines the common errors, structures, and functions for managing vesting and related actions. */ abstract contract IAirlockBase is AccessControl, ReentrancyGuard { using EnumerableSet for EnumerableSet.AddressSet; /// @dev storing the whitelisted post claim handlers EnumerableSet.AddressSet private postClaimHandlerWhitelist; /// @dev total withdrawn from the vester contract uint256 public totalWithdrawn; /// @dev emitted when an allocation is cancelled /// @param id allocation id event ScheduleCanceled(string id); /// @dev emitted when a schedule is revoked /// @param id allocation id event ScheduleRevoked(string id); /// @dev emitted when the beneficiary is transferred /// @param id allocation id /// @param newBeneficiary the new beneficiary event TransferredBeneficiary(string id, address newBeneficiary); /// @dev the vesting token address public immutable token; /// @dev the role for the benefactor bytes32 public constant BENEFACTOR = keccak256("BENEFACTOR"); /// @dev the role for managing post claim handlers bytes32 public constant POST_CLAIM_HANDLER_MANAGER = keccak256("POST_CLAIM_HANDLER_MANAGER"); /** * @notice Constructor to create an IAirlockBase contract * * @param _token token address this vesting contract will distribute * @param _benefactor inital administator and benefactor of the contract * @param _postClaimHandlers an array of post claim handlers to be whitelisted */ constructor(address _token, address _benefactor, IPostClaimHandler[] memory _postClaimHandlers) { if (_token == address(0)) revert ZeroToken(); if (_benefactor == address(0)) revert ZeroBeneficiary(); token = _token; _grantRole(DEFAULT_ADMIN_ROLE, _benefactor); // The benefactor specified in the deploy can grant and revoke benefactor roles using the AccessControl interface _grantRole(BENEFACTOR, _benefactor); _grantRole(POST_CLAIM_HANDLER_MANAGER, _benefactor); uint256 _postCLaimHandlersLength = _postClaimHandlers.length; for (uint256 i; i < _postCLaimHandlersLength; ++i) { postClaimHandlerWhitelist.add(address(_postClaimHandlers[i])); } } /** * @notice Returns the whitelisted post claim handlers * @dev if the direct claim feature is enabled, this method will return an array containing * a post claim handler with address(0) * * @return postClaimHandlers the whitelisted */ function getPostClaimHandlers() external view returns (address[] memory postClaimHandlers) { uint256 arrLength = postClaimHandlerWhitelist.length(); postClaimHandlers = new address[](arrLength); for (uint256 i; i < arrLength; ++i) { postClaimHandlers[i] = (postClaimHandlerWhitelist.at(i)); } } /** * @notice Adds a post claim handler to the whitelist * * @param postClaimHandler the post claim handler to be whitelisted */ function addPostClaimHandlerToWhitelist(IPostClaimHandler postClaimHandler) external onlyRole(POST_CLAIM_HANDLER_MANAGER) { if (!postClaimHandlerWhitelist.add(address(postClaimHandler))) { revert ClaimHandlerAlreadyWhitelisted(); } } /** * @notice Removes a post claim handler from the whitelist * * @param postClaimHandler the post claim handler to be removed from the whitelist */ function removePostClaimHandlerToWhitelist(IPostClaimHandler postClaimHandler) external onlyRole(POST_CLAIM_HANDLER_MANAGER) { if (!postClaimHandlerWhitelist.remove(address(postClaimHandler))) { revert ClaimHandlerNotYetWhitelisted(); } } /** * @notice Token rescue functionality, allows the benefactor to withdraw any other ERC20 tokens that were sent to the contract by mistake * * @param _errantTokenAddress address of the token to rescue, must not be the token the vesting contract manages * @param _rescueAddress address to send the recovered funds to */ function rescueTokens(address _errantTokenAddress, address _rescueAddress) external nonReentrant onlyRole(BENEFACTOR) { if (_errantTokenAddress == token) revert InvalidToken(); SafeERC20.safeTransfer( IERC20(_errantTokenAddress), _rescueAddress, IERC20(_errantTokenAddress).balanceOf(address(this)) ); } /** * @notice Internal function to update state and withdraw beneficiary funds * * @param allocation the allocation to withdraw from * @param distributionState the storage pointer to the distribution state for the allocation * @param withdrawableAmount amount of tokens that can be withdrawn by the beneficiary * @param requestedWithdrawalAmount amount of tokens beneficiary requested to withdraw, or 0 for all available funds * @param postClaimHandler post claim handler to call as part of the withdrawal process * @param extraData any abi encoded extra data that is necessary for the custom action. For example in case of a custom staking action, the user could state his * staking preference by providing extraData */ function _withdrawToBeneficiary( Allocation memory allocation, DistributionState storage distributionState, uint256 withdrawableAmount, uint256 requestedWithdrawalAmount, IPostClaimHandler postClaimHandler, bytes memory extraData ) internal _validateWithdrawalInvariants(distributionState, allocation, withdrawableAmount) { if (requestedWithdrawalAmount > withdrawableAmount) revert InsufficientFunds(); if (withdrawableAmount == 0) revert AmountZero(); // withdrawal amount is optional, if not provided, withdraw the entire withdrawable amount if (requestedWithdrawalAmount == 0) requestedWithdrawalAmount = withdrawableAmount; withdrawableAmount = Math.min(withdrawableAmount, requestedWithdrawalAmount); // If the withdrawal address (set in the case of beneficiary transfer) is not set, use the original beneficiary address withdrawalAddress = (distributionState.withdrawalAddress == address(0)) ? allocation.originalBeneficiary : distributionState.withdrawalAddress; // Update the state distributionState.withdrawn += withdrawableAmount; totalWithdrawn += withdrawableAmount; if (!postClaimHandlerWhitelist.contains(address(postClaimHandler))) { revert PostClaimHandlerNotWhitelisted(); } // If post claim handler is set to DIRECT_CLAIM_HANDLER, it means the claim token has to be directly transferred to the beneficiary // without any interaction with an integration contract. if (postClaimHandler == DIRECT_CLAIM_HANDLER) { SafeERC20.safeTransfer(IERC20(token), withdrawalAddress, withdrawableAmount); } else { // Claim tokens have to be forwarded to an integration contract. SafeERC20.safeTransfer(IERC20(token), address(postClaimHandler), withdrawableAmount); // any error in the postClam handler will revert the entire transaction including the transfer above postClaimHandler.handlePostClaim( IERC20(token), withdrawableAmount, allocation.originalBeneficiary, withdrawalAddress, allocation.id, extraData ); } } /** * @notice Internal Transfer ownership of a calendar's beneficiary address, authorized by benefactor or beneficiary if enabled * * @param state the storage pointer to the distribution state for the allocation * @param allocation the allocation to withdraw from * @param _newAddress address to transfer ownership to */ function _transferBeneficiaryAddress( DistributionState storage state, Allocation memory allocation, address _newAddress ) internal { if (_newAddress == address(0)) revert ZeroBeneficiary(); if (_newAddress == state.withdrawalAddress) revert SameBeneficiaryAddress(); bool authorizedByAdmin = (AccessControl.hasRole(BENEFACTOR, msg.sender) && allocation.transferableByAdmin); bool authorizedByBeneficiary = (msg.sender == state.withdrawalAddress && allocation.transferableByBeneficiary); if (!(authorizedByAdmin || authorizedByBeneficiary)) revert NotTransferable(); state.withdrawalAddress = _newAddress; emit TransferredBeneficiary(allocation.id, _newAddress); } /** * @notice Internal verification and transfer of funds from the sender to the contract * @dev Should only be called in nonReentrant functions. Additionally as an extra precaution function should be called before mutating state * as a protection against tokens with callbacks see https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/extensions/ERC4626.sol#L240 * @param _amountToFund amount of funds to transfer to the contract */ function _transferInFunds(uint256 _amountToFund) internal { if (_amountToFund == 0) revert AmountZero(); uint256 currentBalance = IERC20(token).balanceOf(address(this)); SafeERC20.safeTransferFrom(IERC20(token), msg.sender, address(this), _amountToFund); if (currentBalance + _amountToFund != IERC20(token).balanceOf(address(this))) { revert DeflationaryTokensNotSupported(); } } /** * @notice Internal withdrawal invariant validation, an additional safety measure against over-withdrawing * * @param state the storage pointer to the distribution state for the allocation * @param allocation the allocation to withdraw from * @param amountWithdrawing the amount to withdraw */ modifier _validateWithdrawalInvariants( DistributionState storage state, Allocation memory allocation, uint256 amountWithdrawing ) { if (state.withdrawn + state.terminatedWithdrawn + amountWithdrawing > allocation.totalAllocation) { revert InvalidWithdrawal(); } _; if (state.withdrawn + state.terminatedWithdrawn > allocation.totalAllocation) revert InvalidWithdrawal(); } }
pragma solidity ^0.8.24; import "@openzeppelin/token/ERC20/utils/SafeERC20.sol"; import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol"; import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; import "@openzeppelin/utils/math/Math.sol"; /// @dev error thrown when token address is 0 error ZeroToken(); /// @dev error thrown when beneficiary address is 0 error ZeroBeneficiary(); /// @dev error thrown when amount is 0 error AmountZero(); /// @dev error thrown when amount is greater than max allocation error AmountGreaterThanMaxAllocation(); /// @dev error thrown when the number of periods is 0 error ZeroPeriods(); /// @dev error thrown when the total percentage doesn't add up to 100 error Not100Percent(); /// @dev error thrown when the address is not the beneficiary error NotBeneficiary(); /// @dev error thrown when the allocation is not cancellable error NotCancellable(); /// @dev error thrown when the allocation is not revokable error NotRevokable(); /// @dev error thrown when the allocation is not transferable error NotTransferable(); /// @dev error thrown when the allocation is not funded error NotFunded(); /// @dev error thrown when the timestamp provided is invalid error InvalidTimestamp(); /// @dev error thrown when to many timestamps are provided error TooManyTimestamps(); /// @dev error thrown when the supplied beneficiary address is the same as an others error SameBeneficiaryAddress(); /// @dev error thrown when a calendar with the same id already exists error CalendarExists(); /// @dev error thrown when a calendar doesn't exist or invalid error InvalidCalendar(); /// @dev error thrown when array length of two or more arrays mismatch error ArrayLengthMismatch(); /// @dev error thrown when array content of two or more arrays mismatch error ArrayMismatch(uint16 errCode, uint16 index); /// @dev error thrown when array length is zero error ZeroArrayLength(); /// @dev error thrown when timestamps are not ordered error UnorderedTimestamp(); /// @dev error thrown when an interval with the same id already exists error IntervalExists(); /// @dev error thrown when an interval doesn't exist or invalid error InvalidInterval(); /// @dev error thrown when an an amount in an interval is invalid error InvalidAmount(); /// @dev error thrown when the cliff in an interval is invalid error InvalidCliff(); /// @dev error thrown when a period in an interval is invalid error InvalidPeriod(); /// @dev error thrown when the withdrawal amount is invalid error InvalidWithdrawal(); /// @dev error thrown when the allocation is already terminated error AlreadyTerminated(); /// @dev error thrown when the allocation is already fully unlocked error AlreadyFullyUnlocked(); /// @dev error thrown when the token is invalid error InvalidToken(); /// @dev error thrown when the allocation type is invalid error InvalidAllocationType(); /// @dev error thrown when the token is deflationary error DeflationaryTokensNotSupported(); /// @dev error thrown when the allocation is invalid error InvalidAllocation(); /// @dev error thrown when the funds are not sufficient error InsufficientFunds(); /// @dev error thrown when Merkle proof is invalid error InvalidMerkleProof(); /// @dev error thrown when the fee collector is invalid error InvalidFeeCollector(); /// @dev error thrown when the fee setter is invalid error InvalidFeeSetter(); /// @dev error thrown when the fees sent with the claim request doesn't match the claim fee error InvalidFeeFundsSent(); /// @dev error thrown when the claim fee is being set to a higher value than the maximum claim fee error ClaimFeeExceedsMaximum(); /// @dev error thrown when the claim fee handler is already whitelisted error ClaimHandlerAlreadyWhitelisted(); /// @dev error thrown when the the claim fee handler is not yet whitelisted error ClaimHandlerNotYetWhitelisted(); /// @dev error thrown when post claim handler is not whitelisted error PostClaimHandlerNotWhitelisted(); /** * @notice The mutable state of an allocation * * @param withdrawalAddress can be overriden when the schedule is transferable * @param terminatedTimestamp Sentinel values: 0 is active, 1 is revoked, any other value is the time the calendar was cancelled * @param withdrawn represents the amount withdrawn by the beneficiary * @param terminatedWithdrawn represents the amount withdrawn from terminated funds, merkle vester does not support funding indivual allocations * @param fundedAmount amount of tokens funded for this distribution, merkle vester does not support funding indivual allocations * @param terminatedAmount amount of tokens terminated for this distribution, merkle vester does not support funding indivual allocations */ struct DistributionState { address withdrawalAddress; uint32 terminatedTimestamp; uint256 withdrawn; uint256 terminatedWithdrawn; uint256 fundedAmount; uint256 terminatedAmount; } /** * @notice The immutable data for an allocation, * @dev solidity does not support immutablability outside of compile time, contracts must not implement mutability * * @param id id of the allocation * @param originalBeneficiary original beneficiary address, withdrawalAddress in DistributionState should be used for transfers * @param totalAllocation total amount of tokens to vest in the allocaiton * @param cancelable flag to allow for the allocation to be cancelled, unvested funds are returned to the benefactor vested funds remain withdrawable by the beneficiary * @param revokable flag to allow for the allocation to be revoked, all funds not already withdrawn are returned to the benefactor * @param transferableByAdmin flag to allow for the allocation to be transferred by the admin * @param transferableByBeneficiary flag to allow for the allocation to be transferred by the beneficiary */ struct Allocation { string id; address originalBeneficiary; uint256 totalAllocation; bool cancelable; bool revokable; bool transferableByAdmin; bool transferableByBeneficiary; } /** * @notice Immutable unlock schedule for calendar allocations * @dev solidity does not support immutablability outside of compile time, contracts must not implement mutability * * @param unlockScheduleId id of the allocation * @param unlockTimestamps sequence of timestamps when funds will unlock * @param unlockAmounts sequence of amounts that unlock at each timestamp */ struct CalendarUnlockSchedule { string unlockScheduleId; // Workaround for Internal or recursive type is not allowed for public state variables uint32[] unlockTimestamps; uint256[] unlockAmounts; } /** * @notice Immutable unlock schedule for interval allocations * @dev solidity does not support immutablability outside of compile time, contracts must not implement mutability * * @param unlockScheduleId id of the allocation * @param pieces sequence of pieces representing phases of the unlock schedule, percents of pieces must sum to 100% */ struct IntervalUnlockSchedule { string unlockScheduleId; // Workaround for Internal or recursive type is not allowed for public state variables Piece[] pieces; } /** * @notice Represents a phase of an interval unlock schedule * @dev solidity does not support immutablability outside of compile time, contracts must not implement mutability * * @param startDate start timestamp of the piece * @param periodLength the length of each period in seconds * @param numberOfPeriods the number of periods in the piece * @param amount the amount of tokens that is released in each piece */ struct Piece { uint32 startDate; uint32 periodLength; uint32 numberOfPeriods; uint256 amount; } /// @notice Holding allocation data for Calendar style vesting, including both immutable and mutable data and a reference to the calendar schedule struct CalendarAllocation { Allocation allocation; // Many allocations share the same unlock schedule so we can save gas by referencing the same schedule // the mapping key could be smaller than string but this will help sync with the web application string calendarUnlockScheduleId; DistributionState distributionState; } /// @notice Holding allocation data for Interval style vesting, including both immutable and mutable data and a reference to the interval schedule struct IntervalAllocation { Allocation allocation; string intervalUnlockScheduleId; DistributionState distributionState; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol) pragma solidity ^0.8.20; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Muldiv operation overflow. */ error MathOverflowedMulDiv(); enum Rounding { Floor, // Toward negative infinity Ceil, // Toward positive infinity Trunc, // Toward zero Expand // Away from zero } /** * @dev Returns the addition of two unsigned integers, with an overflow flag. */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds towards infinity instead * of rounding towards zero. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { if (b == 0) { // Guarantee the same behavior as in a regular Solidity division. return a / b; } // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or * denominator == 0. * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by * Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0 = x * y; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. if (denominator <= prod1) { revert MathOverflowedMulDiv(); } /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. // Always >= 1. See https://cs.stackexchange.com/q/138556/92363. uint256 twos = denominator & (0 - denominator); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also // works in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded * towards zero. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256 of a positive value rounded towards zero. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0); } } /** * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers. */ function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) { return uint8(rounding) % 2 == 1; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the value of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the value of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves a `value` amount of tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 value) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets a `value` amount of tokens as the allowance of `spender` over the * caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the * allowance mechanism. `value` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 value) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * ==== Security Considerations * * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be * considered as an intention to spend the allowance in any specific way. The second is that because permits have * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be * generally recommended is: * * ```solidity * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public { * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {} * doThing(..., value); * } * * function doThing(..., uint256 value) public { * token.safeTransferFrom(msg.sender, address(this), value); * ... * } * ``` * * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also * {SafeERC20-safeTransferFrom}). * * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so * contracts should have entry points that don't rely on permit. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. * * CAUTION: See Security Considerations above. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol) pragma solidity ^0.8.20; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev The ETH balance of the account is not enough to perform the operation. */ error AddressInsufficientBalance(address account); /** * @dev There's no code at `target` (it is not a contract). */ error AddressEmptyCode(address target); /** * @dev A call to an address target failed. The target may have reverted. */ error FailedInnerCall(); /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { if (address(this).balance < amount) { revert AddressInsufficientBalance(address(this)); } (bool success, ) = recipient.call{value: amount}(""); if (!success) { revert FailedInnerCall(); } } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason or custom error, it is bubbled * up by this function (like regular Solidity function calls). However, if * the call reverted with no returned reason, this function reverts with a * {FailedInnerCall} error. * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { if (address(this).balance < value) { revert AddressInsufficientBalance(address(this)); } (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an * unsuccessful call. */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata ) internal view returns (bytes memory) { if (!success) { _revert(returndata); } else { // only check if target is a contract if the call was successful and the return data is empty // otherwise we already know that it was a contract if (returndata.length == 0 && target.code.length == 0) { revert AddressEmptyCode(target); } return returndata; } } /** * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the * revert reason or with a default {FailedInnerCall} error. */ function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) { if (!success) { _revert(returndata); } else { return returndata; } } /** * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}. */ function _revert(bytes memory returndata) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert FailedInnerCall(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol) pragma solidity ^0.8.20; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol) pragma solidity ^0.8.20; import {IAccessControl} from "./IAccessControl.sol"; import {Context} from "../utils/Context.sol"; import {ERC165} from "../utils/introspection/ERC165.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ```solidity * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ```solidity * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules} * to enforce additional security measures for this role. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address account => bool) hasRole; bytes32 adminRole; } mapping(bytes32 role => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with an {AccessControlUnauthorizedAccount} error including the required role. */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual returns (bool) { return _roles[role].hasRole[account]; } /** * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()` * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier. */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account` * is missing `role`. */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert AccessControlUnauthorizedAccount(account, role); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `callerConfirmation`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address callerConfirmation) public virtual { if (callerConfirmation != _msgSender()) { revert AccessControlBadConfirmation(); } _revokeRole(role, callerConfirmation); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual returns (bool) { if (!hasRole(role, account)) { _roles[role].hasRole[account] = true; emit RoleGranted(role, account, _msgSender()); return true; } else { return false; } } /** * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual returns (bool) { if (hasRole(role, account)) { _roles[role].hasRole[account] = false; emit RoleRevoked(role, account, _msgSender()); return true; } else { return false; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol) pragma solidity ^0.8.20; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant NOT_ENTERED = 1; uint256 private constant ENTERED = 2; uint256 private _status; /** * @dev Unauthorized reentrant call. */ error ReentrancyGuardReentrantCall(); constructor() { _status = NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be NOT_ENTERED if (_status == ENTERED) { revert ReentrancyGuardReentrantCall(); } // Any calls to nonReentrant after this point will fail _status = ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = NOT_ENTERED; } /** * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { return _status == ENTERED; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol) // This file was procedurally generated from scripts/generate/templates/EnumerableSet.js. pragma solidity ^0.8.20; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ```solidity * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure * unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an * array of EnumerableSet. * ==== */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position is the index of the value in the `values` array plus 1. // Position 0 is used to mean a value is not in the set. mapping(bytes32 value => uint256) _positions; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._positions[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We cache the value's position to prevent multiple reads from the same storage slot uint256 position = set._positions[value]; if (position != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 valueIndex = position - 1; uint256 lastIndex = set._values.length - 1; if (valueIndex != lastIndex) { bytes32 lastValue = set._values[lastIndex]; // Move the lastValue to the index where the value to delete is set._values[valueIndex] = lastValue; // Update the tracked position of the lastValue (that was just moved) set._positions[lastValue] = position; } // Delete the slot where the moved value was stored set._values.pop(); // Delete the tracked position for the deleted slot delete set._positions[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._positions[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { bytes32[] memory store = _values(set._inner); bytes32[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values in the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol) pragma solidity ^0.8.20; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev The `account` is missing a role. */ error AccessControlUnauthorizedAccount(address account, bytes32 neededRole); /** * @dev The caller of a function is not the expected one. * * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}. */ error AccessControlBadConfirmation(); /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `callerConfirmation`. */ function renounceRole(bytes32 role, address callerConfirmation) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol) pragma solidity ^0.8.20; import {IERC165} from "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
{ "remappings": [ "@openzeppelin/=evm/lib/openzeppelin-contracts/contracts/", "@solady/=evm/lib/solady/src/", "@forge-std/=evm/lib/forge-std/src/", "@openzeppelin/contracts/=evm/lib/openzeppelin-contracts/contracts/", "ds-test/=evm/lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/", "erc4626-tests/=evm/lib/openzeppelin-contracts/lib/erc4626-tests/", "forge-std/=evm/lib/forge-std/src/", "murky/=evm/lib/murky/", "openzeppelin-contracts/=evm/lib/openzeppelin-contracts/", "solady/=evm/lib/solady/src/", "tstorish/=evm/lib/tstorish/src/" ], "optimizer": { "enabled": true, "runs": 200 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "cancun", "viaIR": true, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"benefactor","type":"address"},{"internalType":"uint256","name":"_claimFee","type":"uint256"},{"internalType":"address","name":"_feeCollector","type":"address"},{"internalType":"address","name":"_feeSetter","type":"address"},{"internalType":"contract IPostClaimHandler[]","name":"_postClaimHandlers","type":"address[]"},{"internalType":"uint256","name":"_maxClaimFee","type":"uint256"},{"internalType":"bool","name":"_shouldPayClaimFeeOnlyOnce","type":"bool"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"AlreadyFullyUnlocked","type":"error"},{"inputs":[],"name":"AlreadyTerminated","type":"error"},{"inputs":[],"name":"AmountZero","type":"error"},{"inputs":[],"name":"ClaimFeeExceedsMaximum","type":"error"},{"inputs":[],"name":"ClaimHandlerAlreadyWhitelisted","type":"error"},{"inputs":[],"name":"ClaimHandlerNotYetWhitelisted","type":"error"},{"inputs":[],"name":"DeflationaryTokensNotSupported","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[],"name":"InsufficientFunds","type":"error"},{"inputs":[],"name":"InvalidAllocation","type":"error"},{"inputs":[],"name":"InvalidAllocationType","type":"error"},{"inputs":[],"name":"InvalidFeeCollector","type":"error"},{"inputs":[],"name":"InvalidFeeFundsSent","type":"error"},{"inputs":[],"name":"InvalidFeeSetter","type":"error"},{"inputs":[],"name":"InvalidMerkleProof","type":"error"},{"inputs":[],"name":"InvalidToken","type":"error"},{"inputs":[],"name":"InvalidWithdrawal","type":"error"},{"inputs":[],"name":"NotCancellable","type":"error"},{"inputs":[],"name":"NotRevokable","type":"error"},{"inputs":[],"name":"NotTransferable","type":"error"},{"inputs":[],"name":"PostClaimHandlerNotWhitelisted","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[],"name":"SameBeneficiaryAddress","type":"error"},{"inputs":[],"name":"ZeroBeneficiary","type":"error"},{"inputs":[],"name":"ZeroToken","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"id","type":"string"}],"name":"ScheduleCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"id","type":"string"}],"name":"ScheduleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"id","type":"string"},{"indexed":false,"internalType":"address","name":"newBeneficiary","type":"address"}],"name":"TransferredBeneficiary","type":"event"},{"inputs":[],"name":"BENEFACTOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FEE_SETTER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"POST_CLAIM_HANDLER_MANAGER","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"merkleRoot","type":"bytes32"}],"name":"addAllocationRoot","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IPostClaimHandler","name":"postClaimHandler","type":"address"}],"name":"addPostClaimHandlerToWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"rootIndex","type":"uint32"},{"internalType":"bytes","name":"decodableArgs","type":"bytes"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"name":"cancel","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"defund","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"feeCollector","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeSetter","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"fund","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"rootIndex","type":"uint32"},{"internalType":"bytes","name":"decodableArgs","type":"bytes"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"name":"getCalendarLeafAllocationData","outputs":[{"components":[{"components":[{"internalType":"string","name":"id","type":"string"},{"internalType":"address","name":"originalBeneficiary","type":"address"},{"internalType":"uint256","name":"totalAllocation","type":"uint256"},{"internalType":"bool","name":"cancelable","type":"bool"},{"internalType":"bool","name":"revokable","type":"bool"},{"internalType":"bool","name":"transferableByAdmin","type":"bool"},{"internalType":"bool","name":"transferableByBeneficiary","type":"bool"}],"internalType":"struct Allocation","name":"allocation","type":"tuple"},{"internalType":"string","name":"calendarUnlockScheduleId","type":"string"},{"components":[{"internalType":"address","name":"withdrawalAddress","type":"address"},{"internalType":"uint32","name":"terminatedTimestamp","type":"uint32"},{"internalType":"uint256","name":"withdrawn","type":"uint256"},{"internalType":"uint256","name":"terminatedWithdrawn","type":"uint256"},{"internalType":"uint256","name":"fundedAmount","type":"uint256"},{"internalType":"uint256","name":"terminatedAmount","type":"uint256"}],"internalType":"struct DistributionState","name":"distributionState","type":"tuple"}],"internalType":"struct CalendarAllocation","name":"","type":"tuple"},{"components":[{"internalType":"string","name":"unlockScheduleId","type":"string"},{"internalType":"uint32[]","name":"unlockTimestamps","type":"uint32[]"},{"internalType":"uint256[]","name":"unlockAmounts","type":"uint256[]"}],"internalType":"struct CalendarUnlockSchedule","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"allocationType","type":"string"},{"components":[{"internalType":"string","name":"id","type":"string"},{"internalType":"address","name":"originalBeneficiary","type":"address"},{"internalType":"uint256","name":"totalAllocation","type":"uint256"},{"internalType":"bool","name":"cancelable","type":"bool"},{"internalType":"bool","name":"revokable","type":"bool"},{"internalType":"bool","name":"transferableByAdmin","type":"bool"},{"internalType":"bool","name":"transferableByBeneficiary","type":"bool"}],"internalType":"struct Allocation","name":"allocation","type":"tuple"},{"components":[{"internalType":"string","name":"unlockScheduleId","type":"string"},{"internalType":"uint32[]","name":"unlockTimestamps","type":"uint32[]"},{"internalType":"uint256[]","name":"unlockAmounts","type":"uint256[]"}],"internalType":"struct CalendarUnlockSchedule","name":"unlockSchedule","type":"tuple"}],"name":"getCalendarLeafHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"allocationId","type":"string"}],"name":"getClaimFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"rootIndex","type":"uint32"},{"internalType":"bytes","name":"decodableArgs","type":"bytes"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"name":"getIntervalLeafAllocationData","outputs":[{"components":[{"components":[{"internalType":"string","name":"id","type":"string"},{"internalType":"address","name":"originalBeneficiary","type":"address"},{"internalType":"uint256","name":"totalAllocation","type":"uint256"},{"internalType":"bool","name":"cancelable","type":"bool"},{"internalType":"bool","name":"revokable","type":"bool"},{"internalType":"bool","name":"transferableByAdmin","type":"bool"},{"internalType":"bool","name":"transferableByBeneficiary","type":"bool"}],"internalType":"struct Allocation","name":"allocation","type":"tuple"},{"internalType":"string","name":"intervalUnlockScheduleId","type":"string"},{"components":[{"internalType":"address","name":"withdrawalAddress","type":"address"},{"internalType":"uint32","name":"terminatedTimestamp","type":"uint32"},{"internalType":"uint256","name":"withdrawn","type":"uint256"},{"internalType":"uint256","name":"terminatedWithdrawn","type":"uint256"},{"internalType":"uint256","name":"fundedAmount","type":"uint256"},{"internalType":"uint256","name":"terminatedAmount","type":"uint256"}],"internalType":"struct DistributionState","name":"distributionState","type":"tuple"}],"internalType":"struct IntervalAllocation","name":"","type":"tuple"},{"components":[{"internalType":"string","name":"unlockScheduleId","type":"string"},{"components":[{"internalType":"uint32","name":"startDate","type":"uint32"},{"internalType":"uint32","name":"periodLength","type":"uint32"},{"internalType":"uint32","name":"numberOfPeriods","type":"uint32"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct Piece[]","name":"pieces","type":"tuple[]"}],"internalType":"struct IntervalUnlockSchedule","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"allocationType","type":"string"},{"components":[{"internalType":"string","name":"id","type":"string"},{"internalType":"address","name":"originalBeneficiary","type":"address"},{"internalType":"uint256","name":"totalAllocation","type":"uint256"},{"internalType":"bool","name":"cancelable","type":"bool"},{"internalType":"bool","name":"revokable","type":"bool"},{"internalType":"bool","name":"transferableByAdmin","type":"bool"},{"internalType":"bool","name":"transferableByBeneficiary","type":"bool"}],"internalType":"struct Allocation","name":"allocation","type":"tuple"},{"components":[{"internalType":"string","name":"unlockScheduleId","type":"string"},{"components":[{"internalType":"uint32","name":"startDate","type":"uint32"},{"internalType":"uint32","name":"periodLength","type":"uint32"},{"internalType":"uint32","name":"numberOfPeriods","type":"uint32"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct Piece[]","name":"pieces","type":"tuple[]"}],"internalType":"struct IntervalUnlockSchedule","name":"unlockSchedule","type":"tuple"}],"name":"getIntervalLeafHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint32","name":"rootIndex","type":"uint32"},{"internalType":"bytes","name":"decodableArgs","type":"bytes"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"name":"getLeafJustAllocationData","outputs":[{"components":[{"internalType":"string","name":"id","type":"string"},{"internalType":"address","name":"originalBeneficiary","type":"address"},{"internalType":"uint256","name":"totalAllocation","type":"uint256"},{"internalType":"bool","name":"cancelable","type":"bool"},{"internalType":"bool","name":"revokable","type":"bool"},{"internalType":"bool","name":"transferableByAdmin","type":"bool"},{"internalType":"bool","name":"transferableByBeneficiary","type":"bool"}],"internalType":"struct Allocation","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPostClaimHandlers","outputs":[{"internalType":"address[]","name":"postClaimHandlers","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"merkleRoots","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"multicall","outputs":[{"internalType":"bytes[]","name":"results","type":"bytes[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IPostClaimHandler","name":"postClaimHandler","type":"address"}],"name":"removePostClaimHandlerToWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_errantTokenAddress","type":"address"},{"internalType":"address","name":"_rescueAddress","type":"address"}],"name":"rescueTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"rootIndex","type":"uint32"},{"internalType":"bytes","name":"decodableArgs","type":"bytes"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"name":"revoke","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"revokeAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"}],"name":"schedules","outputs":[{"internalType":"address","name":"withdrawalAddress","type":"address"},{"internalType":"uint32","name":"terminatedTimestamp","type":"uint32"},{"internalType":"uint256","name":"withdrawn","type":"uint256"},{"internalType":"uint256","name":"terminatedWithdrawn","type":"uint256"},{"internalType":"uint256","name":"fundedAmount","type":"uint256"},{"internalType":"uint256","name":"terminatedAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_claimFee","type":"uint256"}],"name":"setClaimFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalWithdrawn","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newBeneficiaryAddress","type":"address"},{"internalType":"uint32","name":"rootIndex","type":"uint32"},{"internalType":"bytes","name":"decodableArgs","type":"bytes"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"name":"transferBeneficiaryAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"merkleRoot","type":"bytes32"},{"internalType":"bytes","name":"leafArguments","type":"bytes"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"name":"validateLeaf","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"withdrawalAmount","type":"uint256"},{"internalType":"uint32","name":"rootIndex","type":"uint32"},{"internalType":"bytes","name":"decodableArgs","type":"bytes"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"},{"internalType":"contract IPostClaimHandler","name":"postClaimHandler","type":"address"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"name":"withdraw","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"withdrawalAmount","type":"uint256"},{"internalType":"uint32","name":"rootIndex","type":"uint32"},{"internalType":"bytes","name":"decodableArgs","type":"bytes"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"name":"withdraw","outputs":[],"stateMutability":"payable","type":"function"}]
Deployed Bytecode
0x6080806040526004361015610012575f80fd5b5f905f3560e01c90816301ffc9a714612eb9575080630b88b8ca14612d645780630d87d62c14612c4f5780632447234a14612c14578063248a9ca314612be95780632e75ab5014612ae35780632f2ff15d14612aa5578063365636c4146128cf57806336568abe1461288a5780633c7c1d89146127f05780633f10db5c1461249957806343a8eb0d14611cd65780634b31971314611cb85780635431c94e14611bd757806354fd4d5014611b84578063639ddaad14611b2c5780636ca1c5bd14611ae2578063704075c914611a9f57806371c5ecb114611a655780638612372a146113c257806386d5e6de146110ad57806387cf3ef41461106857806391d148541461101f57806397866c8a14610f7857806398d6187614610dd257806399d32fc414610db4578063a217fddf14610d98578063a340fff414610cda578063ac9650d814610b33578063c01cb1ea14610886578063c17a656d1461073b578063c415b95c146106f6578063ca1d209d1461055f578063d547741f14610518578063d791b0dd14610413578063daa1f8ae146103d8578063e93476831461039d578063f26baa5114610267578063f68d21c11461021d5763fc0c546a146101d6575f80fd5b3461021a578060031936011261021a576040517f000000000000000000000000b0ffa8000886e57f86dd5264b9582b2ad87b2b916001600160a01b03168152602090f35b80fd5b503461021a57602036600319011261021a5761025061023a6131a2565b6102426137fa565b6001600160a01b0316614190565b156102585780f35b637a849d0360e01b8152600490fd5b503461021a57606036600319011261021a576024356001600160401b03811161039957610298903690600401613034565b6044356001600160401b038111610395576102b7903690600401613078565b916040516102e46020828180820195805191829101875e810188838201520301601f198101835282612ff8565b519020906102f1836136c1565b926102ff6040519485612ff8565b808452602084019060051b82019136831161039157905b8282106103815750505082905b8251821015610365576103368284613777565b5190818110156103545784526020526001604084205b910190610323565b90845260205260016040842061034c565b8390600435036103725780f35b63582f497d60e11b8152600490fd5b8135815260209182019101610316565b8580fd5b8280fd5b5080fd5b503461021a578060031936011261021a5760206040517fe6ad9a47fbda1dc18de1eb5eeb7d935e5e81b4748f3cfc61e233e64f881820608152f35b503461021a578060031936011261021a5760206040517f66fbe0d77ee8b64a048b3986d02e26607f216597947c12d07d7b52245d7487cf8152f35b503461021a578060031936011261021a57600254610430816136c1565b61043d6040519182612ff8565b818152610449826136c1565b602082019290601f1901368437600254845b8281106104b05750505090604051928392602084019060208552518091526040840192915b81811061048e575050500390f35b82516001600160a01b0316845285945060209384019390920191600101610480565b8181101561050457600286527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace81015460019190600388901b1c6001600160a01b03166104fd8287613777565b520161045b565b634e487b7160e01b86526032600452602486fd5b503461021a57604036600319011261021a5761055b60043561053861318c565b90610556610551825f525f602052600160405f20015490565b613869565b61399d565b5080f35b503461021a57602036600319011261021a5760043561057c613929565b80156106e7576040516370a0823160e01b8152306004820152907f000000000000000000000000b0ffa8000886e57f86dd5264b9582b2ad87b2b916001600160a01b031690602083602481855afa9283156106dc5784936106a6575b5061061f60209160249461061a6040516323b872dd60e01b86820152338882015230604482015283606482015260648152610614608482612ff8565b8661401a565b613ef9565b91604051938480926370a0823160e01b82523060048301525afa91821561069b578392610663575b5003610654576001805580f35b631fff570160e01b8152600490fd5b9091506020813d602011610693575b8161067f60209383612ff8565b8101031261068f5751905f610647565b5f80fd5b3d9150610672565b6040513d85823e3d90fd5b92506020833d6020116106d4575b816106c160209383612ff8565b8101031261068f5791519161061f6105d8565b3d91506106b4565b6040513d86823e3d90fd5b6365e52d5160e11b8252600482fd5b503461021a578060031936011261021a576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b503461021a5761077f8161074e366130a8565b61075c959195939293613929565b61076461378b565b604051630361f58b60e21b81529586948594600486016135a7565b0381305afa90811561087b578291610859575b5060208101516001600160a01b03161561084a5760808101511561083b5763ffffffff6107bf82516131cc565b5460a01c1661082c57610822816107f77f0f82d0e25d66c620ba5a555f9a45859c28a70de61213b47f33a1eb73fc818ad493516131cc565b805463ffffffff60a01b1916600160a01b179055516040516020808252909283929091830190613106565b0390a16001805580f35b632aaa685560e11b8252600482fd5b633c34e69d60e01b8252600482fd5b6305d7ba1960e11b8252600482fd5b61087591503d8084833e61086d8183612ff8565b81019061357f565b5f610792565b6040513d84823e3d90fd5b503461021a57610895366130a8565b926108a1929192613929565b6108a961378b565b604051630361f58b60e21b8152938585806108ca84888888600486016135a7565b0381305afa948515610b28578695610b0c575b5060208501516001600160a01b031615610afd57606085015115610aee5763ffffffff61090a86516131cc565b5460a01c16610adf579082916109208794613a1d565b15610a2c57610944906040519586948594630fc436d760e21b8652600486016135a7565b0381305afa801561069b576020918491610a08575b50015180515f198101919082116109f45763ffffffff9161097991613777565b51164210156109e5576108227f9f1d738a56ddc883f3f29598f2e7af90b537ab8374d15368d7c3e05010b54975915b6109b281516131cc565b805463ffffffff60a01b19164260a01b63ffffffff60a01b16179055516040516020808252909283929091830190613106565b636aea161960e01b8252600482fd5b634e487b7160e01b84526011600452602484fd5b610a2491503d8086833e610a1c8183612ff8565b810190613d20565b90505f610959565b610a4b90604051958694859463436af36f60e11b8652600486016135a7565b0381305afa801561069b576020918491610abb575b50015180515f198101919082116109f457610a8363ffffffff92610a8992613777565b51614156565b164210156109e5576108227f9f1d738a56ddc883f3f29598f2e7af90b537ab8374d15368d7c3e05010b54975916109a8565b610ad791503d8086833e610acf8183612ff8565b810190613be8565b90505f610a60565b632aaa685560e11b8652600486fd5b6367909b1560e01b8652600486fd5b6305d7ba1960e11b8652600486fd5b610b219195503d8088833e61086d8183612ff8565b935f6108dd565b6040513d88823e3d90fd5b503461021a57602036600319011261021a576004356001600160401b03811161039957610b64903690600401613078565b906020604051610b748282612ff8565b84815281810191601f198101368437610b8c856136c1565b93610b9a6040519586612ff8565b858552601f19610ba9876136c1565b01875b818110610ccb57505036819003601e190190875b87811015610c6c578060051b82013583811215610c68578201908135916001600160401b038311610c645785018a833603821361021a5780610c489289610c346001978b8e6040519483869484860198893784019083820190898252519283915e010185815203601f198101835282612ff8565b5190305af4610c41613eca565b90306140f8565b610c52828a613777565b52610c5d8189613777565b5001610bc0565b8a80fd5b8980fd5b83898860405191838301848452825180915260408401948060408360051b870101940192955b828710610c9f5785850386f35b909192938280610cbb600193603f198a82030186528851613106565b9601920196019592919092610c92565b60608782018501528301610bac565b503461021a578060031936011261021a57610cf3613929565b610cfb61378b565b6040516370a0823160e01b81523060048201527f000000000000000000000000b0ffa8000886e57f86dd5264b9582b2ad87b2b916001600160a01b0316602082602481845afa90811561069b578391610d62575b610d5b92503390613e88565b6001805580f35b90506020823d602011610d90575b81610d7d60209383612ff8565b8101031261068f57610d5b915190610d4f565b3d9150610d70565b503461021a578060031936011261021a57602090604051908152f35b503461021a578060031936011261021a576020600854604051908152f35b503461021a57606036600319011261021a576004356001600160401b03811161039957610e03903690600401612f0c565b906024356001600160401b038111610f745760e06003198236030112610f7457604435936001600160401b03851161021a57846004019480360392604060031985011261039557610e96610e83610ea492610e6e6040519860208a019a60608c5260808b0191613301565b888103601f190160408a01529060040161335f565b868103601f190160608801529780613321565b604089526040890191613301565b9260248201359060221901811215610395570191602460048401359301956001600160401b038411610395578360071b3603871361039557808203602091820152838252019491905b818110610f1757505050610f0c8160209403601f198101835282612ff8565b519020604051908152f35b90919460808060019263ffffffff610f2e8a612f4c565b16815263ffffffff610f4260208b01612f4c565b16602082015263ffffffff610f5960408b01612f4c565b16604082015260608981013590820152019601929101610eed565b8380fd5b503461021a57602036600319011261021a57610f92613929565b610f9a61378b565b600754600160401b81101561100b57610fbc816001610fd793016007556132c0565b6004929192359083549060031b91821b915f19901b19161790565b90556007545f19810191908211610ff75760208260018055604051908152f35b634e487b7160e01b81526011600452602490fd5b634e487b7160e01b82526041600452602482fd5b503461021a57604036600319011261021a57604061103b61318c565b91600435815280602052209060018060a01b03165f52602052602060ff60405f2054166040519015158152f35b503461021a578060031936011261021a576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b503461021a576110bc366131eb565b949190926110c86135d9565b50606060206040516110d981612fa7565b828152015281810193606082860312610f745781356001600160401b0381116113be5785611108918401613034565b5060208201356001600160401b0381116113be578561112891840161362a565b9660408301356001600160401b03811161039157830196604088880312610391576040519761115689612fa7565b80356001600160401b0381116113ba5788611172918301613034565b89526020810135906001600160401b0382116113ba570187601f820112156113b6578035906111a0826136c1565b986111ae6040519a8b612ff8565b828a526020808b019360071b83010191818311610c6857602001925b82841061135b57505050506111e590602089019788526132c0565b90549060031b1c91303b15610391578593929161121791604051968795869563f26baa5160e01b8752600487016136d8565b0381305afa801561087b57908291611346575b505083929161123c6112bd95516131cc565b60046040519161124b83612f8c565b63ffffffff815460018060a01b038116855260a01c166020840152600181015460408401526002810154606084015260038101546080840152015460a082015283516040519561129a87612f5d565b8652602086015260408501526112d5604051958695604087526040870190613249565b93858503602087015251604085526040850190613106565b905183820360209485015280518083529184019301915b8181106112fa575050500390f35b91935091602060806001926060875163ffffffff815116835263ffffffff85820151168584015263ffffffff6040820151166040840152015160608201520194019101918493926112ec565b8161135091612ff8565b61021a57805f61122a565b608084830312610c6857602060809160405161137681612fc2565b61137f87612f4c565b815261138c838801612f4c565b8382015261139c60408801612f4c565b6040820152606087013560608201528152019301926111ca565b8680fd5b8780fd5b8480fd5b50608036600319011261021a576004356113da612f39565b6044356001600160401b038111610f74576113f9903690600401613034565b926064356001600160401b03811161039957611419903690600401613078565b9490926020958360405161142d8982612ff8565b52611436613929565b61143f83613a1d565b1561178857906114668493926040519687948594630fc436d760e21b8652600486016135a7565b0381305afa92831561177b5781928294611759575b506040858501519401519280519563ffffffff61149d604089015198516131cc565b5460a01c1696849763ffffffff42169080155f1461174357505b85985b88518a1015611730578163ffffffff6114d38c8c613777565b5116116114f9576114f16001916114ea8c8b613777565b5190613ef9565b9901986114ba565b92959850509194506115279295505b8082101561172957505b600161151f8551516131cc565b015490613756565b6040516370a0823160e01b81523060048201527f000000000000000000000000b0ffa8000886e57f86dd5264b9582b2ad87b2b916001600160a01b03169291908281602481875afa90811561171e5787916116f1575b506115888551613949565b808210156116e95750925b61159e815151613f06565b516115a981516131cc565b92600184019384549260028201966115c68161061a8a5488613ef9565b9860408301998a51106116da57808281116116cb5782156116bc579061161d94939291156116b5575b808210156116ab57509586925b546001600160a01b0316806116a2575001516001600160a01b031693613ef9565b845561162b83600454613ef9565b6004555f805260036020527f3617319a054d772f909f7c479a2cebe5066e836a939412e32403c99029b92eff5415611693579161166d91611676959493613e88565b54905490613ef9565b905110611684576001805580f35b63c945242d60e01b8152600490fd5b63ca1517e960e01b8752600487fd5b91505093613ef9565b90509586926115fc565b50806115ef565b6365e52d5160e11b8c5260048cfd5b63356680b760e01b8c5260048cfd5b63c945242d60e01b8b5260048bfd5b905092611593565b90508281813d8311611717575b6117088183612ff8565b8101031261068f57515f61157d565b503d6116fe565b6040513d89823e3d90fd5b9050611512565b9295985050919450611527929550611508565b908082101561175257506114b7565b90506114b7565b9093506117719192503d8084833e610a1c8183612ff8565b919091925f61147b565b50604051903d90823e3d90fd5b906117ac8497949392604051968794859463436af36f60e11b8652600486016135a7565b0381305afa9182156106dc5784908593611a46575b50816117d963ffffffff82604085015101511661424f565b93019081518051905f198201918211611a32576117f991610a8391613777565b5085805b8351805189101561186f5760019161186188888c89606061185863ffffffff604061184c8683806118326118679f8490613777565b51511699611841838a51613777565b510151169651613777565b51015116938d51613777565b51015192614286565b90613ef9565b9701966117fd565b50919450955061189a9150600161151f8551926040840151908082105f14611a2a5750925b516131cc565b6040516370a0823160e01b81523060048201527f000000000000000000000000b0ffa8000886e57f86dd5264b9582b2ad87b2b916001600160a01b03169291908281602481875afa90811561171e5787916119fd575b506118fb8551613949565b808210156119f55750925b611911815151613f06565b5161191c81516131cc565b92600184019384549260028201966119398161061a8a5488613ef9565b9860408301998a51106116da57808281116116cb5782156116bc579061198e94939291156116b557808210156116ab5750958692546001600160a01b0316806116a2575001516001600160a01b031693613ef9565b845561199c83600454613ef9565b6004555f805260036020527f3617319a054d772f909f7c479a2cebe5066e836a939412e32403c99029b92eff5415611693579161166d916119de959493613e88565b90511015610d5b5763c945242d60e01b8152600490fd5b905092611906565b90508281813d8311611a23575b611a148183612ff8565b8101031261068f57515f6118f0565b503d611a0a565b905092611894565b634e487b7160e01b88526011600452602488fd5b9050611a5d9192503d8086833e610acf8183612ff8565b91905f6117c1565b503461021a57602036600319011261021a576004359060075482101561021a576020611a90836132c0565b90549060031b1c604051908152f35b503461021a57602036600319011261021a57600435906001600160401b03821161021a576020611ada611ad53660048601613034565b6136f6565b604051908152f35b503461021a57602036600319011261021a57611b15611aff6131a2565b611b076137fa565b6001600160a01b031661408d565b15611b1d5780f35b6303a049e560e61b8152600490fd5b503461021a57602036600319011261021a57611b46613929565b611b4e61378b565b610d5b600435337f000000000000000000000000b0ffa8000886e57f86dd5264b9582b2ad87b2b916001600160a01b0316613e88565b503461021a578060031936011261021a5750611bd3604051611ba7604082612ff8565b600b81526a3234b9ba2fbb191718971960a91b6020820152604051918291602083526020830190613106565b0390f35b503461021a57604036600319011261021a57611bf16131a2565b611bf961318c565b90611c02613929565b611c0a61378b565b6001600160a01b03908116907f000000000000000000000000b0ffa8000886e57f86dd5264b9582b2ad87b2b91168114611ca9576040516370a0823160e01b815230600482015291602083602481855afa9182156106dc578492611c73575b610d5b9350613e88565b91506020833d602011611ca1575b81611c8e60209383612ff8565b8101031261068f57610d5b925191611c69565b3d9150611c81565b63c1ab6dc160e01b8352600483fd5b503461021a578060031936011261021a576020600454604051908152f35b5060c036600319011261021a57600435611cee612f39565b906044356001600160401b038111610f7457611d0e903690600401613034565b926064356001600160401b03811161039957611d2e903690600401613078565b9290946084359460018060a01b038616809603610f745760a4356001600160401b0381116113be57611d64903690600401613034565b94611d6d613929565b611d7683613a1d565b156121265790611d9d859392604051998a948594630fc436d760e21b8652600486016135a7565b0381305afa93841561087b5782958395612104575b50604060208601519501519580519463ffffffff611dd5604088015197516131cc565b5460a01c1695859663ffffffff42169080155f146120ee57505b86975b89518910156120da578163ffffffff611e0b8b8d613777565b511611611e2a57611e226001916114ea8b8e613777565b980197611df2565b929598505091949750611e4f929550808210156117295750600161151f8551516131cc565b6040516370a0823160e01b81523060048201527f000000000000000000000000b0ffa8000886e57f86dd5264b9582b2ad87b2b916001600160a01b0316929190602081602481875afa9081156120cf57889161209d575b50611eb18551613949565b808210156120955750925b611ec7815151613f06565b5191611ed383516131cc565b9260018401958654936002860196611ef08161061a8a5489613ef9565b99604085019a8b511061208657808281116120775782156120685715612061575b808210156120595750955b546001600160a01b0316868161204f5760208501516001600160a01b031696611f459250613ef9565b8855611f5386600454613ef9565b600455611f6b825f52600360205260405f2054151590565b15612040578992919081611f8c57505050509161166d916116769593613e88565b611f9c8783879994959699613e88565b60018060a01b03602085015116935194833b156113ba57612011889692611fff88946040519a8b998a988997631cd8393d60e31b895260048901526024880152604487015260018060a01b0316606486015260c0608486015260c4850190613106565b8381036003190160a485015290613106565b03925af1801561087b5761202b575b50506116769161166d565b8161203591612ff8565b610f7457835f612020565b63ca1517e960e01b8a5260048afd5b611f459196613ef9565b905095611f1c565b5080611f11565b6365e52d5160e11b8d5260048dfd5b63356680b760e01b8d5260048dfd5b63c945242d60e01b8c5260048cfd5b905092611ebc565b90506020813d6020116120c7575b816120b860209383612ff8565b8101031261068f57515f611ea6565b3d91506120ab565b6040513d8a823e3d90fd5b929598505091949750611e4f929550611508565b90808210156120fd5750611def565b9050611def565b90945061211c9195503d8084833e610a1c8183612ff8565b949094935f611db2565b9061214e859694959392604099989951988994859463436af36f60e11b8652600486016135a7565b0381305afa92831561248d578094819461246b575b50602061217c63ffffffff82604089015101511661424f565b94019283518051905f1982019182116109f45761219c91610a8391613777565b50819682975b855180518a101561220d57600191611861898c8a63ffffffff6121c88361220598613777565b51511691606061185863ffffffff60206121e3858751613777565b510151169263ffffffff60406121fa838851613777565b510151169451613777565b9801976121a2565b50919694509450612239919650600161151f8551926040840151908082105f14611a2a575092516131cc565b6040516370a0823160e01b81523060048201527f000000000000000000000000b0ffa8000886e57f86dd5264b9582b2ad87b2b916001600160a01b0316929190602081602481875afa9081156120cf578891612439575b5061229b8551613949565b808210156124315750925b6122b1815151613f06565b51916122bd83516131cc565b92600184019586549360028601966122da8161061a8a5489613ef9565b99604085019a8b51106120865780828111612077578215612068571561242a575b808210156124225750955b546001600160a01b031686816124185760208501516001600160a01b03169661232f9250613ef9565b885561233d86600454613ef9565b600455612355825f52600360205260405f2054151590565b1561204057899291908161237657505050509161166d916119de9593613e88565b6123868783879994959699613e88565b60018060a01b03602085015116935194833b156113ba576123e9889692611fff88946040519a8b998a988997631cd8393d60e31b895260048901526024880152604487015260018060a01b0316606486015260c0608486015260c4850190613106565b03925af1801561087b57612403575b50506119de9161166d565b8161240d91612ff8565b610f7457835f6123f8565b61232f9196613ef9565b905095612306565b50806122fb565b9050926122a6565b90506020813d602011612463575b8161245460209383612ff8565b8101031261068f57515f612290565b3d9150612447565b9093506124839194503d8085833e610acf8183612ff8565b939093925f612163565b604051903d90823e3d90fd5b503461021a576124a8366131eb565b929094916124b46135d9565b506060604080516124c481612f5d565b828152826020820152015280820191606081840312610f745780356001600160401b0381116113be57836124f9918301613034565b5060208101356001600160401b0381116113be578361251991830161362a565b9660408201356001600160401b03811161039157820195606087860312610391576040519761254789612f5d565b87356001600160401b0381116113ba5786612563918a01613034565b895260208801356001600160401b0381116113ba5788019786601f8a0112156113ba578835986125928a6136c1565b996125a06040519b8c612ff8565b808b526020808c019160051b83010191898311610c6457602001905b8282106127d85750505060208a019889526040810135906001600160401b0382116127d457019580601f880112156113ba5786356125f9816136c1565b97612607604051998a612ff8565b8189526020808a019260051b820101928311610c6857602001905b8282106127c45750505061263c9060408a019687526132c0565b90549060031b1c91303b156113b6578693929161266e91604051968795869563f26baa5160e01b8752600487016136d8565b0381305afa801561069b579083916127af575b50509184939261269461271596516131cc565b6004604051916126a383612f8c565b63ffffffff815460018060a01b038116855260a01c166020840152600181015460408401526002810154606084015260038101546080840152015460a08201528451604051966126f288612f5d565b87526020870152604086015261272d604051968796604088526040880190613249565b94868603602088015251606086526060860190613106565b915191848103602086015260208084519283815201930190845b8181106127905750505051926040818303910152602080845192838152019301915b818110612777575050500390f35b8251845285945060209384019390920191600101612769565b825163ffffffff16855288975060209485019490920191600101612747565b816127b991612ff8565b61039957815f612681565b8135815260209182019101612622565b8880fd5b602080916127e584612f4c565b8152019101906125bc565b503461021a57602036600319011261021a57600435906001600160401b03821161021a5760c06020806128263660048701613034565b604051928184925191829101835e810160068152030190208054906001810154906002810154600460038301549201549263ffffffff6040519560018060a01b038116875260a01c16602086015260408501526060840152608083015260a0820152f35b503461021a57604036600319011261021a576128a461318c565b336001600160a01b038216036128c05761055b9060043561399d565b63334bd91960e11b8252600482fd5b503461021a57608036600319011261021a576128e96131a2565b6128f1612f39565b826044356001600160401b03811161039957612911903690600401613034565b606435926001600160401b0384116103955761293461293f943690600401613078565b610764959195613929565b0381305afa90811561069b578391612a8b575b5061295c81613949565b61296681516131cc565b6001600160a01b03909216918215612a7c5780546001600160a01b0316838114612a6d577f66fbe0d77ee8b64a048b3986d02e26607f216597947c12d07d7b52245d7487cf855260208581526040808720335f908152925290205460ff169081612a5f575b331480612a52575b8115612a4a575b5015612a3b5780546001600160a01b0319168317905551604080518181527f0ddf22a7d2cb2cfefa64b32f2c75bcb30cc2a68208febc823261caaf171219529390928392612a2b9190840190613106565b9060208301520390a16001805580f35b63dc8d8db760e01b8452600484fd5b90505f6129da565b5060c083015115156129d3565b60a0840151151591506129cb565b63036d099b60e51b8552600485fd5b63776cceeb60e01b8452600484fd5b612a9f91503d8085833e61086d8183612ff8565b5f612952565b503461021a57604036600319011261021a5761055b600435612ac561318c565b90612ade610551825f525f602052600160405f20015490565b6138a1565b503461021a57602036600319011261021a577fe6ad9a47fbda1dc18de1eb5eeb7d935e5e81b4748f3cfc61e233e64f88182060815260208181526040808320335f90815292529020546004359060ff1615612bb2577f00000000000000000000000000000000000000000000000000b1a2bc2ec500008111612ba3577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031615612b945760085580f35b63bb0bac9960e01b8252600482fd5b63a1e2d51d60e01b8252600482fd5b63e2517d3f60e01b8252336004527fe6ad9a47fbda1dc18de1eb5eeb7d935e5e81b4748f3cfc61e233e64f88182060602452604482fd5b503461021a57602036600319011261021a576020611ada6004355f525f602052600160405f20015490565b503461021a578060031936011261021a5760206040517f6f51f874e644f7ce58205aa35351ddb40924d1ef8d58d9d6664fb464dc58e4578152f35b503461068f57612c7490612c62366130a8565b91949092612c6e613445565b506132c0565b90549060031b1c90303b1561068f575f91612cc5604051948593849363f26baa5160e01b8552600485015260606024850152612cb3606485018a613106565b84810360031901604486015291613421565b0381305afa8015612d5957612d46575b508151820191604081602085019403126103995760208101516001600160401b03811161039557836020612d0b9284010161347c565b506040810151916001600160401b03831161021a57611bd3612d32856020868601016134e3565b60405191829160208352602083019061312a565b612d5291505f90612ff8565b5f5f612cd5565b6040513d5f823e3d90fd5b3461068f57606036600319011261068f576004356001600160401b03811161068f57612d94903690600401612f0c565b602435916001600160401b03831161068f5760e0600319843603011261068f57604435926001600160401b03841161068f5783600401906060600319863603011261068f57612e0c90612df7604051946020860196606088526080870191613301565b848103601f190160408601529060040161335f565b828103601f1901606084015290612e34612e268280613321565b606085526060850191613301565b946020612e4460248301846133ed565b8589038684015280895297909101965f5b818110612e9457505050602095610f0c93612e7886946044612e869501906133ed565b916040818503910152613421565b03601f198101835282612ff8565b90919760208060019263ffffffff612eab8d612f4c565b168152019901929101612e55565b3461068f57602036600319011261068f576004359063ffffffff60e01b821680920361068f57602091637965db0b60e01b8114908115612efb575b5015158152f35b6301ffc9a760e01b14905083612ef4565b9181601f8401121561068f578235916001600160401b03831161068f576020838186019501011161068f57565b6024359063ffffffff8216820361068f57565b359063ffffffff8216820361068f57565b606081019081106001600160401b03821117612f7857604052565b634e487b7160e01b5f52604160045260245ffd5b60c081019081106001600160401b03821117612f7857604052565b604081019081106001600160401b03821117612f7857604052565b608081019081106001600160401b03821117612f7857604052565b60e081019081106001600160401b03821117612f7857604052565b90601f801991011681019081106001600160401b03821117612f7857604052565b6001600160401b038111612f7857601f01601f191660200190565b81601f8201121561068f5760208135910161304e82613019565b9261305c6040519485612ff8565b8284528282011161068f57815f92602092838601378301015290565b9181601f8401121561068f578235916001600160401b03831161068f576020808501948460051b01011161068f57565b606060031982011261068f5760043563ffffffff8116810361068f57916024356001600160401b03811161068f57826130e391600401613034565b91604435906001600160401b03821161068f5761310291600401613078565b9091565b805180835260209291819084018484015e5f828201840152601f01601f1916010190565b9060c080613141845160e0855260e0850190613106565b9360018060a01b0360208201511660208501526040810151604085015260608101511515606085015260808101511515608085015260a0810151151560a08501520151151591015290565b602435906001600160a01b038216820361068f57565b600435906001600160a01b038216820361068f57565b35906001600160a01b038216820361068f57565b60208091604051928184925191829101835e8101600681520301902090565b90606060031983011261068f5760043563ffffffff8116810361068f57916024356001600160401b03811161068f578161322791600401612f0c565b92909291604435906001600160401b03821161068f5761310291600401613078565b9060e060a0604061327a6132688651610100875261010087019061312a565b60208701518682036020880152613106565b940151600180831b03815116604085015263ffffffff602082015116606085015260408101516080850152606081015182850152608081015160c0850152015191015290565b6007548110156132d85760075f5260205f2001905f90565b634e487b7160e01b5f52603260045260245ffd5b80548210156132d8575f5260205f2001905f90565b908060209392818452848401375f828201840152601f01601f1916010190565b9035601e198236030181121561068f5701602081359101916001600160401b03821161068f57813603831361068f57565b3590811515820361068f57565b9060c06133e5816133816133738680613321565b60e0875260e0870191613301565b946001600160a01b03613396602083016131b8565b166020860152604081013560408601526133b260608201613352565b151560608601526133c560808201613352565b151560808601526133d860a08201613352565b151560a086015201613352565b151591015290565b9035601e198236030181121561068f5701602081359101916001600160401b03821161068f578160051b3603831361068f57565b81835290916001600160fb1b03831161068f5760209260051b809284830137010190565b6040519061345282612fdd565b5f60c083606081528260208201528260408201528260608201528260808201528260a08201520152565b81601f8201121561068f5780519061349382613019565b926134a16040519485612ff8565b8284526020838301011161068f57815f9260208093018386015e8301015290565b51906001600160a01b038216820361068f57565b5190811515820361068f57565b91909160e08184031261068f57604051906134fd82612fdd565b81938151906001600160401b03821161068f578261352460c0949261357a9486940161347c565b8552613532602082016134c2565b60208601526040810151604086015261354d606082016134d6565b606086015261355e608082016134d6565b608086015261356f60a082016134d6565b60a0860152016134d6565b910152565b9060208282031261068f5781516001600160401b03811161068f576135a492016134e3565b90565b92906135a4949263ffffffff6135cb92168552606060208601526060850190613106565b926040818503910152613421565b604051906135e682612f5d565b816135ef613445565b815260606020820152604080519161360683612f8c565b5f83525f60208401525f828401525f60608401525f60808401525f60a08401520152565b91909160e08184031261068f576040519061364482612fdd565b81938135906001600160401b03821161068f578261366b60c0949261357a94869401613034565b8552613679602082016131b8565b60208601526040810135604086015261369460608201613352565b60608601526136a560808201613352565b60808601526136b660a08201613352565b60a086015201613352565b6001600160401b038111612f785760051b60200190565b93916135a495936135cb928652606060208701526060860191613301565b7f0000000000000000000000000000000000000000000000000000000000000000908161372e575b5015613728575f90565b60085490565b60ff915060208091604051928184925191829101835e8101600581520301902054165f61371e565b9190820391821161376357565b634e487b7160e01b5f52601160045260245ffd5b80518210156132d85760209160051b010190565b335f9081527f8f5170a001e97aa525d58a8c34652d2ff9db2c32fed46a283422af1e3fc4a2c2602052604090205460ff16156137c357565b63e2517d3f60e01b5f52336004527f66fbe0d77ee8b64a048b3986d02e26607f216597947c12d07d7b52245d7487cf60245260445ffd5b335f9081527feb089f16d6d7e6682dd1727a34ecfcdaa39ebda2bc4bbfc29fb27179c2ad905f602052604090205460ff161561383257565b63e2517d3f60e01b5f52336004527f6f51f874e644f7ce58205aa35351ddb40924d1ef8d58d9d6664fb464dc58e45760245260445ffd5b5f8181526020818152604080832033845290915290205460ff161561388b5750565b63e2517d3f60e01b5f523360045260245260445ffd5b5f818152602081815260408083206001600160a01b038616845290915290205460ff16613923575f818152602081815260408083206001600160a01b0395909516808452949091528120805460ff19166001179055339291907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9080a4600190565b50505f90565b60026001541461393a576002600155565b633ee5aeb560e01b5f5260045ffd5b80516001600160a01b039061395d906131cc565b5416156139675750565b61397e60018060a01b0360208301511691516131cc565b80546001600160a01b0319166001600160a01b03909216919091179055565b5f818152602081815260408083206001600160a01b038616845290915290205460ff1615613923575f818152602081815260408083206001600160a01b0395909516808452949091528120805460ff19169055339291907ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9080a4600190565b805181019060208183031261068f576020810151916001600160401b03831161068f57613a5192602080920192010161347c565b604051907ff12295c6cff7c66c50482f7bee8dd63da0f387f76819ffea278d69c8f37485d160208301825193613aa1602082818701978089875e81015f838201520301601f198101835282612ff8565b51902003613ab0575050600190565b7f60dde57ea82e6110c36e701060809f1f9246f49c2b2791e1f1dc6a5b15927a2991613afb6020604051809382820195518091875e81015f838201520301601f198101835282612ff8565b51902003613b07575f90565b6331e650b960e11b5f5260045ffd5b519063ffffffff8216820361068f57565b8082039291610100841261068f5760405190613b4282612f5d565b819483516001600160401b03811161068f5782613b609186016134e3565b835260208401516001600160401b03811161068f5760c092613b8391860161347c565b6020840152603f19011261068f5760409060e0825193613ba285612f8c565b613bad8482016134c2565b8552613bbb60608201613b16565b602086015260808101518486015260a0810151606086015260c08101516080860152015160a08401520152565b919060408382031261068f5782516001600160401b03811161068f5781613c10918501613b27565b926020810151906001600160401b03821161068f57019060408282031261068f5760405191613c3e83612fa7565b80516001600160401b03811161068f5782613c5a91830161347c565b83526020810151906001600160401b03821161068f570181601f8201121561068f57805190613c88826136c1565b92613c966040519485612ff8565b82845260208085019360071b8301019181831161068f57602001925b828410613cc55750505050602082015290565b60808483031261068f576020608091604051613ce081612fc2565b613ce987613b16565b8152613cf6838801613b16565b83820152613d0660408801613b16565b604082015260608701516060820152815201930192613cb2565b919060408382031261068f5782516001600160401b03811161068f5781613d48918501613b27565b926020810151906001600160401b03821161068f57019060608282031261068f5760405191613d7683612f5d565b80516001600160401b03811161068f5782613d9291830161347c565b835260208101516001600160401b03811161068f57810182601f8201121561068f57805190613dc0826136c1565b91613dce6040519384612ff8565b80835260208084019160051b8301019185831161068f57602001905b828210613e705750505060208401526040810151906001600160401b03821161068f57019080601f8301121561068f578151613e25816136c1565b92613e336040519485612ff8565b81845260208085019260051b82010192831161068f57602001905b828210613e6057505050604082015290565b8151815260209182019101613e4e565b60208091613e7d84613b16565b815201910190613dea565b60405163a9059cbb60e01b60208201526001600160a01b039092166024830152604480830193909352918152613ec891613ec3606483612ff8565b61401a565b565b3d15613ef4573d90613edb82613019565b91613ee96040519384612ff8565b82523d5f602084013e565b606090565b9190820180921161376357565b5f907f000000000000000000000000000000000000000000000000000000000000000015614010576040519060ff815192602081818501958087835e8101600581520301902054161580614005575b613fd6575b50505b803403613fc75780613f6c5750565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03811615613fb8575f80809338935af115613fab57565b63b12d13eb5f526004601cfd5b63bb0bac9960e01b5f5260045ffd5b6326ecf91160e01b5f5260045ffd5b6020919250604051928391518091835e81016005815203019020600160ff198254161790556008545f80613f5a565b506008541515613f55565b5050600854613f5d565b5f806140429260018060a01b03169360208151910182865af161403b613eca565b90836140f8565b805190811515918261406a575b50506140585750565b635274afe760e01b5f5260045260245ffd5b819250906020918101031261068f57602061408591016134d6565b155f8061404f565b805f52600360205260405f2054155f146140f357600254600160401b811015612f78576140dc6140c682600185940160025560026132ec565b819391549060031b91821b915f19901b19161790565b9055600254905f52600360205260405f2055600190565b505f90565b9061411c575080511561410d57805190602001fd5b630a12f52160e11b5f5260045ffd5b8151158061414d575b61412d575090565b639996b31560e01b5f9081526001600160a01b0391909116600452602490fd5b50803b15614125565b63ffffffff8151169063ffffffff60408160208401511692015116029063ffffffff8216918203613763570163ffffffff81116137635790565b5f818152600360205260409020548015613923575f198101818111613763576002545f1981019190821161376357818103614217575b5050506002548015614203575f19016141e08160026132ec565b8154905f199060031b1b191690556002555f5260036020525f6040812055600190565b634e487b7160e01b5f52603160045260245ffd5b6142396142286140c69360026132ec565b90549060031b1c92839260026132ec565b90555f52600360205260405f20555f80806141c6565b8015614263578042105f146135a457504290565b504290565b8115614272570490565b634e487b7160e01b5f52601260045260245ffd5b9192938281106142cd576142a29261429d91613756565b614268565b918183116142c4575b828102928184041490151715613763576135a491614268565b915080916142ab565b50505050505f9056fea26469706673582212207e9e1205e1ac5f20c7182d406f8a394fb7298b359ad37b5008866408563e0b6c64736f6c634300081b0033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 34 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|---|---|---|---|---|
BASE | 100.00% | $0.082589 | 11,398,781.0976 | $941,413.93 |
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.