More Info
Private Name Tags
ContractCreator
Latest 25 from a total of 47 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Claim | 20925648 | 25 hrs ago | IN | 0 ETH | 0.00096045 | ||||
Claim | 20920224 | 44 hrs ago | IN | 0 ETH | 0.00128494 | ||||
Claim | 20916093 | 2 days ago | IN | 0 ETH | 0.00332508 | ||||
Claim | 20903333 | 4 days ago | IN | 0 ETH | 0.00068414 | ||||
Claim | 20863842 | 9 days ago | IN | 0 ETH | 0.00106643 | ||||
Claim | 20856165 | 10 days ago | IN | 0 ETH | 0.0005822 | ||||
Claim | 20856163 | 10 days ago | IN | 0 ETH | 0.00056973 | ||||
Claim | 20851378 | 11 days ago | IN | 0 ETH | 0.0010285 | ||||
Claim | 20847630 | 11 days ago | IN | 0 ETH | 0.00073215 | ||||
Claim | 20842627 | 12 days ago | IN | 0 ETH | 0.00181646 | ||||
Claim | 20838431 | 13 days ago | IN | 0 ETH | 0.00129281 | ||||
Claim | 20838166 | 13 days ago | IN | 0 ETH | 0.00135839 | ||||
Claim | 20838075 | 13 days ago | IN | 0 ETH | 0.00183102 | ||||
Claim | 20837848 | 13 days ago | IN | 0 ETH | 0.00102753 | ||||
Claim | 20837276 | 13 days ago | IN | 0 ETH | 0.00316303 | ||||
Claim | 20837076 | 13 days ago | IN | 0 ETH | 0.00213527 | ||||
Claim | 20836894 | 13 days ago | IN | 0 ETH | 0.00192407 | ||||
Claim | 20836770 | 13 days ago | IN | 0 ETH | 0.00202917 | ||||
Claim | 20836107 | 13 days ago | IN | 0 ETH | 0.00398476 | ||||
Claim | 20836083 | 13 days ago | IN | 0 ETH | 0.00308778 | ||||
Claim | 20835310 | 13 days ago | IN | 0 ETH | 0.00375198 | ||||
Claim | 20834095 | 13 days ago | IN | 0 ETH | 0.00115502 | ||||
Claim | 20833535 | 13 days ago | IN | 0 ETH | 0.00148078 | ||||
Claim | 20833129 | 13 days ago | IN | 0 ETH | 0.00340455 | ||||
Claim | 20833127 | 13 days ago | IN | 0 ETH | 0.00324734 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
Claim
Compiler Version
v0.8.24+commit.e11b9ed9
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: NO-LICENSE pragma solidity 0.8.24; import { Pausable } from '@openzeppelin/contracts/utils/Pausable.sol'; import { Ownable, Ownable2Step } from '@openzeppelin/contracts/access/Ownable2Step.sol'; import { ReentrancyGuard } from '@openzeppelin/contracts/utils/ReentrancyGuard.sol'; import { EIP712 } from '@openzeppelin/contracts/utils/cryptography/EIP712.sol'; import { ECDSA } from '@openzeppelin/contracts/utils/cryptography/ECDSA.sol'; import { SafeERC20, IERC20 } from '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol'; import { IClaim } from './IClaim.sol'; import { WalletAllocation } from './WalletAllocation.sol'; import { Math } from '@openzeppelin/contracts/utils/math/Math.sol'; /** * @title Claim * @notice A token vesting and claiming contract with signature based allocation verification. * * This contract allows beneficiaries to claim their allocated tokens based on a vesting schedule. */ contract Claim is IClaim, Pausable, Ownable2Step, ReentrancyGuard, EIP712 { using SafeERC20 for IERC20; /** * @dev Used to handle 2 decimals in percentages (e.g., 0.55%). * The denominator is represented as basis points (BPS) to avoid floating-point arithmetic. */ uint256 private constant __DENOMINATOR_BPS = 10_000; /** * @dev EIP712 domain separator name */ string private constant __EIP712_NAME = 'ClaimContractNamespace'; /** * @dev EIP712 domain separator version */ string private constant __EIP712VERSION = '1'; /** * @dev claim typehash for EIP712 signatures */ bytes32 private constant __CLAIM_TYPEHASH = keccak256( 'WalletAllocation(address wallet,uint256 tokenAllocated,uint256 releasedAtTGEPercentage)' ); /// @dev Precision factor for fixed-point arithmetic uint256 private constant __PRECISION = 1e36; /// @dev The ERC20 token being vested and claimed IERC20 public override token; /// @dev The start timestamp of the vesting period uint256 public override startTimestamp; /// @dev The end timestamp of the vesting period uint256 public override endTimestamp; /// @dev The total amount of tokens vested in the contract uint256 public override totalVested; /// @dev The total amount of tokens claimed by beneficiaries uint256 public override totalClaimed; /// @dev Mapping to store the claimed amounts for each beneficiary wallet mapping(address => uint256) public override walletClaims; address private immutable __signer; /** * @notice Constructor function * @param signer_ The address of the signer * @param startTimestamp_ The start timestamp of the vesting period * @param endTimestamp_ The end timestamp of the vesting period */ constructor( address signer_, uint256 startTimestamp_, uint256 endTimestamp_ ) Ownable(msg.sender) EIP712(__EIP712_NAME, __EIP712VERSION) { startTimestamp = startTimestamp_; endTimestamp = endTimestamp_; __signer = signer_; } /* * Admin functions */ /** * @notice Deposit tokens into the contract for vesting * @param amount The amount of tokens to deposit * @return A boolean indicating the success of the operation */ function deposit(uint256 amount) external override onlyOwner returns (bool) { totalVested += amount; token.safeTransferFrom(msg.sender, address(this), amount); emit Deposited(amount); return true; } /** * @notice Withdraw tokens from the contract * @param amount The amount of tokens to withdraw * @return A boolean indicating the success of the operation */ function withdraw(uint256 amount) external override onlyOwner returns (bool) { totalVested -= amount; token.safeTransfer(msg.sender, amount); emit Withdrawn(amount); return true; } /** * @notice Update the start timestamp of the vesting period * @param startTimestamp_ The new start timestamp * @return A boolean indicating the success of the operation */ function updateStartTimestamp( uint256 startTimestamp_ ) external override onlyOwner returns (bool) { if (startTimestamp_ < block.timestamp) { revert InvalidTimings(); } startTimestamp = startTimestamp_; emit StartTimestampUpdated(startTimestamp); return true; } /** * @notice Update the end timestamp of the vesting period * @param endTimestamp_ The new end timestamp * @return A boolean indicating the success of the operation */ function updateEndTimestamp( uint256 endTimestamp_ ) external override onlyOwner returns (bool) { if ( (endTimestamp_ <= block.timestamp) || (endTimestamp_ <= startTimestamp) ) { revert InvalidTimings(); } endTimestamp = endTimestamp_; emit EndTimestampUpdated(endTimestamp); return true; } /** * @notice Pause the contract, preventing claims */ function pause() external onlyOwner { _pause(); } /** * @notice Unpause the contract, allowing claims */ function unpause() external onlyOwner { _unpause(); } /** * @dev Set the token address * @param _token The address of the token */ function setToken(IERC20 _token) external onlyOwner { token = _token; } /** * @dev Set the total vested tokens * @param amount The total vested amount */ function setTotalVested( uint256 amount ) external override onlyOwner returns (bool) { totalVested = amount; return true; } /* * End of Admin functions */ /** * * @param data WalletAllocation - * @return bytes32 - The hash of the payload * @notice - This function is used to hash the payload for signature verification (EIP-712) * */ function _hash( WalletAllocation calldata data ) private view returns (bytes32) { return _hashTypedDataV4( keccak256( abi.encode( __CLAIM_TYPEHASH, data.wallet, data.tokenAllocated, data.releasedAtTGEPercentage ) ) ); } /** * * @param data WalletAllocation - The payload for minting the NFT * @notice This function takes the data coming from the payload and recovers the address of the signer */ function _recover( WalletAllocation calldata data, bytes memory signature ) private view returns (address) { bytes32 digest = _hash(data); return ECDSA.recover(digest, signature); } /** * @notice Claim tokens for a beneficiary based on their allocation * @param signature bytes32 EIP712 signature for the wallet allocation * @param walletAllocation The wallet allocation struct containing the beneficiary's address, allocated amount, and released at TGE percentage * @return A boolean indicating the success of the operation */ function claim( bytes memory signature, WalletAllocation calldata walletAllocation ) external override nonReentrant whenNotPaused returns (bool) { if (_recover(walletAllocation, signature) != __signer) { revert InvalidSignature(); } if (walletAllocation.wallet != msg.sender) { revert InvalidWallet(); } uint256 claimableAmount = getClaimableAmount(walletAllocation); if (claimableAmount == 0) { revert NoTokensToClaim(); } walletClaims[walletAllocation.wallet] += claimableAmount; totalClaimed += claimableAmount; token.safeTransfer(walletAllocation.wallet, claimableAmount); emit Claimed(address(token), walletAllocation.wallet, claimableAmount); return true; } /** * @notice Calculate the claimable amount of tokens for a beneficiary at the current time * @param walletAllocation The wallet allocation struct containing the beneficiary's address, allocated amount, and released at TGE percentage * @return claimableAmount The amount of tokens claimable by the beneficiary * This function calculates the claimable amount based on the vesting schedule and the beneficiary's allocation. * It takes into account the tokens already claimed by the beneficiary. */ function getClaimableAmount( WalletAllocation calldata walletAllocation ) public view override returns (uint256 claimableAmount) { uint256 tokenAllocated = walletAllocation.tokenAllocated; uint256 releasedAtTGEAmount = _getReleasedAtTGEAmount(walletAllocation); if (block.timestamp <= startTimestamp) { /// @notice Allow claiming the released at TGE amount before the start timestamp claimableAmount = releasedAtTGEAmount; } else if (block.timestamp >= endTimestamp) { /// @notice Fully vested, all tokens are claimable claimableAmount = tokenAllocated; } else { /// @notice Vesting is in progress, calculate the vested amount based on time passed uint256 timePassed = block.timestamp - startTimestamp; uint256 totalTime = endTimestamp - startTimestamp; uint256 timePassedRatio = (timePassed * __PRECISION) / totalTime; uint256 vestedAmount = tokenAllocated - releasedAtTGEAmount; uint256 vestedClaimableAmount = (vestedAmount * timePassedRatio) / __PRECISION; claimableAmount = vestedClaimableAmount + releasedAtTGEAmount; } // Subtract the tokens already claimed by the beneficiary claimableAmount -= walletClaims[walletAllocation.wallet]; } /** * @notice Calculate the amount of tokens released at TGE for a beneficiary * @param walletAllocation The wallet allocation struct containing the beneficiary's address, allocated amount, and released at TGE percentage * @return The amount of tokens released at TGE for the beneficiary */ function _getReleasedAtTGEAmount( WalletAllocation calldata walletAllocation ) internal pure returns (uint256) { return (walletAllocation.tokenAllocated * walletAllocation.releasedAtTGEPercentage) / __DENOMINATOR_BPS; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol) pragma solidity ^0.8.20; import {Context} from "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * The initial owner is set to the address provided by the deployer. This can * later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; /** * @dev The caller account is not authorized to perform an operation. */ error OwnableUnauthorizedAccount(address account); /** * @dev The owner is not a valid owner account. (eg. `address(0)`) */ error OwnableInvalidOwner(address owner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the address provided by the deployer as the initial owner. */ constructor(address initialOwner) { if (initialOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(initialOwner); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { if (owner() != _msgSender()) { revert OwnableUnauthorizedAccount(_msgSender()); } } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { if (newOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable2Step.sol) pragma solidity ^0.8.20; import {Ownable} from "./Ownable.sol"; /** * @dev Contract module which provides access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * The initial owner is specified at deployment time in the constructor for `Ownable`. This * can later be changed with {transferOwnership} and {acceptOwnership}. * * This module is used through inheritance. It will make available all functions * from parent (Ownable). */ abstract contract Ownable2Step is Ownable { address private _pendingOwner; event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner); /** * @dev Returns the address of the pending owner. */ function pendingOwner() public view virtual returns (address) { return _pendingOwner; } /** * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual override onlyOwner { _pendingOwner = newOwner; emit OwnershipTransferStarted(owner(), newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner. * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual override { delete _pendingOwner; super._transferOwnership(newOwner); } /** * @dev The new owner accepts the ownership transfer. */ function acceptOwnership() public virtual { address sender = _msgSender(); if (pendingOwner() != sender) { revert OwnableUnauthorizedAccount(sender); } _transferOwnership(sender); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5267.sol) pragma solidity ^0.8.20; interface IERC5267 { /** * @dev MAY be emitted to signal that the domain could have changed. */ event EIP712DomainChanged(); /** * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712 * signature. */ function eip712Domain() external view returns ( bytes1 fields, string memory name, string memory version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] memory extensions ); }
// 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) (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/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.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) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.20; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS } /** * @dev The signature derives the `address(0)`. */ error ECDSAInvalidSignature(); /** * @dev The signature has an invalid length. */ error ECDSAInvalidSignatureLength(uint256 length); /** * @dev The signature has an S value that is in the upper half order. */ error ECDSAInvalidSignatureS(bytes32 s); /** * @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not * return address(0) without also returning an error description. Errors are documented using an enum (error type) * and a bytes32 providing additional information about the error. * * If no error is returned, then the address can be used for verification purposes. * * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError, bytes32) { if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. /// @solidity memory-safe-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else { return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length)); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature); _throwError(error, errorArg); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] */ function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError, bytes32) { unchecked { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); // We do not check for an overflow here since the shift operation results in 0 or 1. uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); } } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. */ function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) { (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs); _throwError(error, errorArg); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError, bytes32) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS, s); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature, bytes32(0)); } return (signer, RecoverError.NoError, bytes32(0)); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) { (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s); _throwError(error, errorArg); return recovered; } /** * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided. */ function _throwError(RecoverError error, bytes32 errorArg) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert ECDSAInvalidSignature(); } else if (error == RecoverError.InvalidSignatureLength) { revert ECDSAInvalidSignatureLength(uint256(errorArg)); } else if (error == RecoverError.InvalidSignatureS) { revert ECDSAInvalidSignatureS(errorArg); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/EIP712.sol) pragma solidity ^0.8.20; import {MessageHashUtils} from "./MessageHashUtils.sol"; import {ShortStrings, ShortString} from "../ShortStrings.sol"; import {IERC5267} from "../../interfaces/IERC5267.sol"; /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding scheme specified in the EIP requires a domain separator and a hash of the typed structured data, whose * encoding is very generic and therefore its implementation in Solidity is not feasible, thus this contract * does not implement the encoding itself. Protocols need to implement the type-specific encoding they need in order to * produce the hash of their typed data using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain * separator of the implementation contract. This will cause the {_domainSeparatorV4} function to always rebuild the * separator from the immutable values, which is cheaper than accessing a cached version in cold storage. * * @custom:oz-upgrades-unsafe-allow state-variable-immutable */ abstract contract EIP712 is IERC5267 { using ShortStrings for *; bytes32 private constant TYPE_HASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"); // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to // invalidate the cached domain separator if the chain id changes. bytes32 private immutable _cachedDomainSeparator; uint256 private immutable _cachedChainId; address private immutable _cachedThis; bytes32 private immutable _hashedName; bytes32 private immutable _hashedVersion; ShortString private immutable _name; ShortString private immutable _version; string private _nameFallback; string private _versionFallback; /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ constructor(string memory name, string memory version) { _name = name.toShortStringWithFallback(_nameFallback); _version = version.toShortStringWithFallback(_versionFallback); _hashedName = keccak256(bytes(name)); _hashedVersion = keccak256(bytes(version)); _cachedChainId = block.chainid; _cachedDomainSeparator = _buildDomainSeparator(); _cachedThis = address(this); } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view returns (bytes32) { if (address(this) == _cachedThis && block.chainid == _cachedChainId) { return _cachedDomainSeparator; } else { return _buildDomainSeparator(); } } function _buildDomainSeparator() private view returns (bytes32) { return keccak256(abi.encode(TYPE_HASH, _hashedName, _hashedVersion, block.chainid, address(this))); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return MessageHashUtils.toTypedDataHash(_domainSeparatorV4(), structHash); } /** * @dev See {IERC-5267}. */ function eip712Domain() public view virtual returns ( bytes1 fields, string memory name, string memory version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] memory extensions ) { return ( hex"0f", // 01111 _EIP712Name(), _EIP712Version(), block.chainid, address(this), bytes32(0), new uint256[](0) ); } /** * @dev The name parameter for the EIP712 domain. * * NOTE: By default this function reads _name which is an immutable value. * It only reads from storage if necessary (in case the value is too large to fit in a ShortString). */ // solhint-disable-next-line func-name-mixedcase function _EIP712Name() internal view returns (string memory) { return _name.toStringWithFallback(_nameFallback); } /** * @dev The version parameter for the EIP712 domain. * * NOTE: By default this function reads _version which is an immutable value. * It only reads from storage if necessary (in case the value is too large to fit in a ShortString). */ // solhint-disable-next-line func-name-mixedcase function _EIP712Version() internal view returns (string memory) { return _version.toStringWithFallback(_versionFallback); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MessageHashUtils.sol) pragma solidity ^0.8.20; import {Strings} from "../Strings.sol"; /** * @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing. * * The library provides methods for generating a hash of a message that conforms to the * https://eips.ethereum.org/EIPS/eip-191[EIP 191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712] * specifications. */ library MessageHashUtils { /** * @dev Returns the keccak256 digest of an EIP-191 signed data with version * `0x45` (`personal_sign` messages). * * The digest is calculated by prefixing a bytes32 `messageHash` with * `"\x19Ethereum Signed Message:\n32"` and hashing the result. It corresponds with the * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method. * * NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with * keccak256, although any bytes32 value can be safely used because the final digest will * be re-hashed. * * See {ECDSA-recover}. */ function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) { /// @solidity memory-safe-assembly assembly { mstore(0x00, "\x19Ethereum Signed Message:\n32") // 32 is the bytes-length of messageHash mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20) } } /** * @dev Returns the keccak256 digest of an EIP-191 signed data with version * `0x45` (`personal_sign` messages). * * The digest is calculated by prefixing an arbitrary `message` with * `"\x19Ethereum Signed Message:\n" + len(message)` and hashing the result. It corresponds with the * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method. * * See {ECDSA-recover}. */ function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) { return keccak256(bytes.concat("\x19Ethereum Signed Message:\n", bytes(Strings.toString(message.length)), message)); } /** * @dev Returns the keccak256 digest of an EIP-191 signed data with version * `0x00` (data with intended validator). * * The digest is calculated by prefixing an arbitrary `data` with `"\x19\x00"` and the intended * `validator` address. Then hashing the result. * * See {ECDSA-recover}. */ function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) { return keccak256(abi.encodePacked(hex"19_00", validator, data)); } /** * @dev Returns the keccak256 digest of an EIP-712 typed data (EIP-191 version `0x01`). * * The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with * `\x19\x01` and hashing the result. It corresponds to the hash signed by the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712. * * See {ECDSA-recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) { /// @solidity memory-safe-assembly assembly { let ptr := mload(0x40) mstore(ptr, hex"19_01") mstore(add(ptr, 0x02), domainSeparator) mstore(add(ptr, 0x22), structHash) digest := keccak256(ptr, 0x42) } } }
// 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) (utils/math/SignedMath.sol) pragma solidity ^0.8.20; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMath { /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return a > b ? a : b; } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return a < b ? a : b; } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // must be unchecked in order to support `n = type(int256).min` return uint256(n >= 0 ? n : -n); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol) pragma solidity ^0.8.20; import {Context} from "../utils/Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { bool private _paused; /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); /** * @dev The operation failed because the contract is paused. */ error EnforcedPause(); /** * @dev The operation failed because the contract is not paused. */ error ExpectedPause(); /** * @dev Initializes the contract in unpaused state. */ constructor() { _paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { if (paused()) { revert EnforcedPause(); } } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { if (!paused()) { revert ExpectedPause(); } } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } }
// 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/ShortStrings.sol) pragma solidity ^0.8.20; import {StorageSlot} from "./StorageSlot.sol"; // | string | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA | // | length | 0x BB | type ShortString is bytes32; /** * @dev This library provides functions to convert short memory strings * into a `ShortString` type that can be used as an immutable variable. * * Strings of arbitrary length can be optimized using this library if * they are short enough (up to 31 bytes) by packing them with their * length (1 byte) in a single EVM word (32 bytes). Additionally, a * fallback mechanism can be used for every other case. * * Usage example: * * ```solidity * contract Named { * using ShortStrings for *; * * ShortString private immutable _name; * string private _nameFallback; * * constructor(string memory contractName) { * _name = contractName.toShortStringWithFallback(_nameFallback); * } * * function name() external view returns (string memory) { * return _name.toStringWithFallback(_nameFallback); * } * } * ``` */ library ShortStrings { // Used as an identifier for strings longer than 31 bytes. bytes32 private constant FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF; error StringTooLong(string str); error InvalidShortString(); /** * @dev Encode a string of at most 31 chars into a `ShortString`. * * This will trigger a `StringTooLong` error is the input string is too long. */ function toShortString(string memory str) internal pure returns (ShortString) { bytes memory bstr = bytes(str); if (bstr.length > 31) { revert StringTooLong(str); } return ShortString.wrap(bytes32(uint256(bytes32(bstr)) | bstr.length)); } /** * @dev Decode a `ShortString` back to a "normal" string. */ function toString(ShortString sstr) internal pure returns (string memory) { uint256 len = byteLength(sstr); // using `new string(len)` would work locally but is not memory safe. string memory str = new string(32); /// @solidity memory-safe-assembly assembly { mstore(str, len) mstore(add(str, 0x20), sstr) } return str; } /** * @dev Return the length of a `ShortString`. */ function byteLength(ShortString sstr) internal pure returns (uint256) { uint256 result = uint256(ShortString.unwrap(sstr)) & 0xFF; if (result > 31) { revert InvalidShortString(); } return result; } /** * @dev Encode a string into a `ShortString`, or write it to storage if it is too long. */ function toShortStringWithFallback(string memory value, string storage store) internal returns (ShortString) { if (bytes(value).length < 32) { return toShortString(value); } else { StorageSlot.getStringSlot(store).value = value; return ShortString.wrap(FALLBACK_SENTINEL); } } /** * @dev Decode a string that was encoded to `ShortString` or written to storage using {setWithFallback}. */ function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory) { if (ShortString.unwrap(value) != FALLBACK_SENTINEL) { return toString(value); } else { return store; } } /** * @dev Return the length of a string that was encoded to `ShortString` or written to storage using * {setWithFallback}. * * WARNING: This will return the "byte length" of the string. This may not reflect the actual length in terms of * actual characters as the UTF-8 encoding of a single character can span over multiple bytes. */ function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) { if (ShortString.unwrap(value) != FALLBACK_SENTINEL) { return byteLength(value); } else { return bytes(store).length; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol) // This file was procedurally generated from scripts/generate/templates/StorageSlot.js. pragma solidity ^0.8.20; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ```solidity * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(newImplementation.code.length > 0); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } struct StringSlot { string value; } struct BytesSlot { bytes value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `StringSlot` with member `value` located at `slot`. */ function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `StringSlot` representation of the string storage pointer `store`. */ function getStringSlot(string storage store) internal pure returns (StringSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } /** * @dev Returns an `BytesSlot` with member `value` located at `slot`. */ function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`. */ function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol) pragma solidity ^0.8.20; import {Math} from "./math/Math.sol"; import {SignedMath} from "./math/SignedMath.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant HEX_DIGITS = "0123456789abcdef"; uint8 private constant ADDRESS_LENGTH = 20; /** * @dev The `value` string doesn't fit in the specified `length`. */ error StringsInsufficientHexLength(uint256 value, uint256 length); /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), HEX_DIGITS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `int256` to its ASCII `string` decimal representation. */ function toStringSigned(int256 value) internal pure returns (string memory) { return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value))); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { uint256 localValue = value; bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = HEX_DIGITS[localValue & 0xf]; localValue >>= 4; } if (localValue != 0) { revert StringsInsufficientHexLength(value, length); } return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal * representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH); } /** * @dev Returns true if the two strings are equal. */ function equal(string memory a, string memory b) internal pure returns (bool) { return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b)); } }
// SPDX-License-Identifier: NO-LICENSE pragma solidity 0.8.24; import { WalletAllocation } from './WalletAllocation.sol'; import { IERC20 } from '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol'; /** * @title IClaim * @notice Interface for the Claim contract */ interface IClaim { /** * @notice Emitted when tokens are claimed by a beneficiary * @param token The address of the claimed token * @param wallet The address of the beneficiary's wallet * @param amount The amount of tokens claimed */ event Claimed(address indexed token, address indexed wallet, uint256 amount); /** * @notice Emitted when the start timestamp of the vesting period is updated * @param startTimestamp The new start timestamp */ event StartTimestampUpdated(uint256 startTimestamp); /** * @notice Emitted when the end timestamp of the vesting period is updated * @param endTimestamp The new end timestamp */ event EndTimestampUpdated(uint256 endTimestamp); /** * @notice Emitted when tokens are deposited into the contract * @param amount The amount of tokens deposited */ event Deposited(uint256 amount); /** * @notice Emitted when tokens are withdrawn from the contract * @param amount The amount of tokens withdrawn */ event Withdrawn(uint256 amount); /** * this error is thrown when the provided signature is invalid */ error InvalidSignature(); /** * @dev Error thrown when the provided timestamps are invalid */ error InvalidTimings(); /** * @dev Error thrown when there are no tokens to claim for a beneficiary */ error NoTokensToClaim(); /** * @dev Error thrown when the token address is set to the zero address */ error ZeroTokenAddress(); /** * @dev Error thrown when an invalid beneficiary wallet address is provided */ error InvalidWallet(); /** * @notice Get the ERC20 token address that is being vested */ function token() external view returns (IERC20); /** * @notice Get the total amount of tokens vested in the contract * @return The total vested amount */ function totalVested() external view returns (uint256); /** * @notice Get the total amount of tokens claimed by beneficiaries * @return The total claimed amount */ function totalClaimed() external view returns (uint256); /** * @notice Get the start timestamp of the vesting period * @return The start timestamp */ function startTimestamp() external view returns (uint256); /** * @notice Get the end timestamp of the vesting period * @return The end timestamp */ function endTimestamp() external view returns (uint256); /** * @notice Get the claimed amount of tokens for a specific beneficiary wallet * @param wallet The address of the beneficiary's wallet * @return The claimed amount of tokens for the wallet */ function walletClaims(address wallet) external view returns (uint256); /** * @notice Claim tokens for a beneficiary based on their allocation * @param signature bytes32 EIP712 signature for the wallet allocation * @param walletAllocation The wallet allocation struct containing the beneficiary's address, allocated amount, and released at TGE percentage * @return A boolean indicating the success of the operation */ function claim( bytes memory signature, WalletAllocation calldata walletAllocation ) external returns (bool); /** * @notice Calculate the claimable amount of tokens for a beneficiary at the current time * @param walletAllocation The wallet allocation struct containing the beneficiary's address, allocated amount, and released at TGE percentage * @return claimableAmount The amount of tokens claimable by the beneficiary */ function getClaimableAmount( WalletAllocation calldata walletAllocation ) external view returns (uint256 claimableAmount); /** * @notice Update the start timestamp of the vesting period * @param startTimestamp_ The new start timestamp * @return A boolean indicating the success of the operation */ function updateStartTimestamp( uint256 startTimestamp_ ) external returns (bool); /** * @notice Update the end timestamp of the vesting period * @param endTimestamp_ The new end timestamp * @return A boolean indicating the success of the operation */ function updateEndTimestamp(uint256 endTimestamp_) external returns (bool); /** * @notice Deposit tokens into the contract for vesting * @param amount The amount of tokens to deposit * @return A boolean indicating the success of the operation */ function deposit(uint256 amount) external returns (bool); /** * @notice Set vested tokens * @param amount The amount of vested tokens * @return A boolean indicating the success of the operation */ function setTotalVested(uint256 amount) external returns (bool); /** * @notice Withdraw tokens from the contract * @param amount The amount of tokens to withdraw * @return A boolean indicating the success of the operation */ function withdraw(uint256 amount) external returns (bool); }
// SPDX-License-Identifier: NO-LICENSE pragma solidity 0.8.24; /** * @title WalletAllocation * @notice Struct representing the allocation of tokens to a beneficiary wallet. */ struct WalletAllocation { /// @notice The address of the beneficiary's wallet. address wallet; /** * @notice The amount of tokens allocated to the wallet. * @dev Expressed with 18 decimals. For example, an allocation of 1 token is represented as 1e18. */ uint256 tokenAllocated; /** * @notice The percentage of the allocated tokens that will be released at TGE (Token Generation Event). * @dev Expressed in basis points (BPS), where 1 BPS = 0.01%. * For example, a release percentage of 1000 BPS represents 10% of the allocated tokens being released at TGE. */ uint256 releasedAtTGEPercentage; }
{ "optimizer": { "enabled": true, "runs": 200 }, "evmVersion": "paris", "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"signer_","type":"address"},{"internalType":"uint256","name":"startTimestamp_","type":"uint256"},{"internalType":"uint256","name":"endTimestamp_","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"ECDSAInvalidSignature","type":"error"},{"inputs":[{"internalType":"uint256","name":"length","type":"uint256"}],"name":"ECDSAInvalidSignatureLength","type":"error"},{"inputs":[{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"ECDSAInvalidSignatureS","type":"error"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[],"name":"InvalidShortString","type":"error"},{"inputs":[],"name":"InvalidSignature","type":"error"},{"inputs":[],"name":"InvalidTimings","type":"error"},{"inputs":[],"name":"InvalidWallet","type":"error"},{"inputs":[],"name":"NoTokensToClaim","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[{"internalType":"string","name":"str","type":"string"}],"name":"StringTooLong","type":"error"},{"inputs":[],"name":"ZeroTokenAddress","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"wallet","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Claimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Deposited","type":"event"},{"anonymous":false,"inputs":[],"name":"EIP712DomainChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"endTimestamp","type":"uint256"}],"name":"EndTimestampUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"startTimestamp","type":"uint256"}],"name":"StartTimestampUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"signature","type":"bytes"},{"components":[{"internalType":"address","name":"wallet","type":"address"},{"internalType":"uint256","name":"tokenAllocated","type":"uint256"},{"internalType":"uint256","name":"releasedAtTGEPercentage","type":"uint256"}],"internalType":"struct WalletAllocation","name":"walletAllocation","type":"tuple"}],"name":"claim","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"deposit","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"eip712Domain","outputs":[{"internalType":"bytes1","name":"fields","type":"bytes1"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"version","type":"string"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"verifyingContract","type":"address"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"uint256[]","name":"extensions","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"endTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"wallet","type":"address"},{"internalType":"uint256","name":"tokenAllocated","type":"uint256"},{"internalType":"uint256","name":"releasedAtTGEPercentage","type":"uint256"}],"internalType":"struct WalletAllocation","name":"walletAllocation","type":"tuple"}],"name":"getClaimableAmount","outputs":[{"internalType":"uint256","name":"claimableAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_token","type":"address"}],"name":"setToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"setTotalVested","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"startTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalClaimed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalVested","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"endTimestamp_","type":"uint256"}],"name":"updateEndTimestamp","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"startTimestamp_","type":"uint256"}],"name":"updateStartTimestamp","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"walletClaims","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
6101806040523480156200001257600080fd5b5060405162001ad338038062001ad3833981016040819052620000359162000289565b604080518082018252601681527f436c61696d436f6e74726163744e616d65737061636500000000000000000000602080830191909152825180840190935260018352603160f81b908301526000805460ff19169055903380620000b457604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b620000bf8162000196565b506001600255620000d2826003620001b4565b61012052620000e3816004620001b4565b61014052815160208084019190912060e052815190820120610100524660a0526200017160e05161010051604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201529081019290925260608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b60805250503060c0526006919091556007556001600160a01b031661016052620004b7565b600180546001600160a01b0319169055620001b181620001ed565b50565b6000602083511015620001d457620001cc8362000246565b9050620001e7565b81620001e1848262000375565b5060ff90505b92915050565b600080546001600160a01b03838116610100818102610100600160a81b0319851617855560405193049190911692909183917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a35050565b600080829050601f8151111562000274578260405163305a27a960e01b8152600401620000ab919062000441565b8051620002818262000492565b179392505050565b6000806000606084860312156200029f57600080fd5b83516001600160a01b0381168114620002b757600080fd5b602085015160409095015190969495509392505050565b634e487b7160e01b600052604160045260246000fd5b600181811c90821680620002f957607f821691505b6020821081036200031a57634e487b7160e01b600052602260045260246000fd5b50919050565b601f82111562000370576000816000526020600020601f850160051c810160208610156200034b5750805b601f850160051c820191505b818110156200036c5782815560010162000357565b5050505b505050565b81516001600160401b03811115620003915762000391620002ce565b620003a981620003a28454620002e4565b8462000320565b602080601f831160018114620003e15760008415620003c85750858301515b600019600386901b1c1916600185901b1785556200036c565b600085815260208120601f198616915b828110156200041257888601518255948401946001909101908401620003f1565b5085821015620004315787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60006020808352835180602085015260005b81811015620004715785810183015185820160400152820162000453565b506000604082860101526040601f19601f8301168501019250505092915050565b805160208083015191908110156200031a5760001960209190910360031b1b16919050565b60805160a05160c05160e051610100516101205161014051610160516115b66200051d60003960006103be01526000610aba01526000610a88015260006110750152600061104d01526000610fa801526000610fd201526000610ffc01526115b66000f3fe608060405234801561001057600080fd5b506004361061014d5760003560e01c80638da5cb5b116100c3578063d54ad2a11161007c578063d54ad2a11461029e578063e30c3978146102a7578063e67151ae146102b8578063e6fd48bc146102cb578063f2fde38b146102d4578063fc0c546a146102e757600080fd5b80638da5cb5b146102125780639e9fbdb71461023c578063a85adeab1461024f578063b6b55f2514610258578063c8761d241461026b578063cb93bca01461028b57600080fd5b80635c975abb116101155780635c975abb146101c15780636e1613fb146101cc578063715018a6146101df57806379ba5097146101e75780638456cb59146101ef57806384b0196e146101f757600080fd5b8063144fa6d714610152578063199cbc54146101675780632e1a7d4d146101835780633f4ba83a146101a657806353beff55146101ae575b600080fd5b610165610160366004611257565b6102fa565b005b61017060085481565b6040519081526020015b60405180910390f35b610196610191366004611274565b610324565b604051901515815260200161017a565b610165610398565b6101966101bc3660046112bb565b6103aa565b60005460ff16610196565b6101966101da366004611274565b610564565b6101656105d2565b6101656105e4565b61016561062d565b6101ff61063d565b60405161017a97969594939291906113ce565b60005461010090046001600160a01b03165b6040516001600160a01b03909116815260200161017a565b61019661024a366004611274565b610683565b61017060075481565b610196610266366004611274565b610696565b610170610279366004611257565b600a6020526000908152604090205481565b610170610299366004611467565b6106ff565b61017060095481565b6001546001600160a01b0316610224565b6101966102c6366004611274565b610807565b61017060065481565b6101656102e2366004611257565b610867565b600554610224906001600160a01b031681565b6103026108de565b600580546001600160a01b0319166001600160a01b0392909216919091179055565b600061032e6108de565b81600860008282546103409190611499565b909155505060055461035c906001600160a01b03163384610911565b6040518281527f430648de173157e069201c943adb2d4e340e7cf5b27b1b09c9cb852f03d63b56906020015b60405180910390a1506001919050565b6103a06108de565b6103a8610975565b565b60006103b46109c7565b6103bc6109ef565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166103f08385610a13565b6001600160a01b03161461041757604051638baa579f60e01b815260040160405180910390fd5b336104256020840184611257565b6001600160a01b03161461044c576040516323455ba160e01b815260040160405180910390fd5b6000610457836106ff565b9050806000036104795760405162f3f86160e41b815260040160405180910390fd5b80600a600061048b6020870187611257565b6001600160a01b03166001600160a01b0316815260200190815260200160002060008282546104ba91906114ac565b9250508190555080600960008282546104d391906114ac565b909155506104fc90506104e96020850185611257565b6005546001600160a01b03169083610911565b6105096020840184611257565b6005546040518381526001600160a01b0392831692909116907ff7a40077ff7a04c7e61f6f26fb13774259ddf1b6bce9ecf26a8276cdd39926839060200160405180910390a3600191505061055e6001600255565b92915050565b600061056e6108de565b428211158061057f57506006548211155b1561059d5760405163c6e369f960e01b815260040160405180910390fd5b60078290556040518281527fa3ea21afc186bdd87bec6b4cbf15d90b2276674b095c1e9ffbab7ffcff0ac6c090602001610388565b6105da6108de565b6103a86000610a2b565b60015433906001600160a01b031681146106215760405163118cdaa760e01b81526001600160a01b03821660048201526024015b60405180910390fd5b61062a81610a2b565b50565b6106356108de565b6103a8610a44565b600060608060008060006060610651610a81565b610659610ab3565b60408051600080825260208201909252600f60f81b9b939a50919850469750309650945092509050565b600061068d6108de565b50600855600190565b60006106a06108de565b81600860008282546106b291906114ac565b90915550506005546106cf906001600160a01b0316333085610ae0565b6040518281527f2a89b2e3d580398d6dc2db5e0f336b52602bbaa51afa9bb5cdf59239cf0d2bea90602001610388565b600060208201358161071084610b1f565b90506006544211610723578092506107ca565b6007544210610734578192506107ca565b6000600654426107449190611499565b905060006006546007546107589190611499565b90506000816107766ec097ce7bc90715b34b9f1000000000856114bf565b61078091906114d6565b9050600061078e8587611499565b905060006ec097ce7bc90715b34b9f10000000006107ac84846114bf565b6107b691906114d6565b90506107c286826114ac565b975050505050505b600a60006107db6020870187611257565b6001600160a01b031681526020810191909152604001600020546107ff9084611499565b949350505050565b60006108116108de565b428210156108325760405163c6e369f960e01b815260040160405180910390fd5b60068290556040518281527f07cd07ffd137c726a01cf58e28440d541645e57385351a90e509539bbde40f5490602001610388565b61086f6108de565b600180546001600160a01b0383166001600160a01b031990911681179091556108a66000546001600160a01b036101009091041690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6000546001600160a01b036101009091041633146103a85760405163118cdaa760e01b8152336004820152602401610618565b6040516001600160a01b0383811660248301526044820183905261097091859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050610b40565b505050565b61097d610ba3565b6000805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b60028054036109e957604051633ee5aeb560e01b815260040160405180910390fd5b60028055565b60005460ff16156103a85760405163d93c066560e01b815260040160405180910390fd5b600080610a1f84610bc6565b90506107ff8184610c45565b600180546001600160a01b031916905561062a81610c6f565b610a4c6109ef565b6000805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586109aa3390565b6060610aae7f00000000000000000000000000000000000000000000000000000000000000006003610cc8565b905090565b6060610aae7f00000000000000000000000000000000000000000000000000000000000000006004610cc8565b6040516001600160a01b038481166024830152838116604483015260648201839052610b199186918216906323b872dd9060840161093e565b50505050565b6000612710610b36604084013560208501356114bf565b61055e91906114d6565b6000610b556001600160a01b03841683610d73565b90508051600014158015610b7a575080806020019051810190610b7891906114f8565b155b1561097057604051635274afe760e01b81526001600160a01b0384166004820152602401610618565b60005460ff166103a857604051638dfc202b60e01b815260040160405180910390fd5b600061055e7f4a7775d9f0286e47df63ac682cb4717b698b6cdec36c24dd6538b62402b8ad4c610bf96020850185611257565b604080516020818101949094526001600160a01b039092168282015291850135606082015290840135608082015260a00160405160208183030381529060405280519060200120610d88565b600080600080610c558686610db5565b925092509250610c658282610e02565b5090949350505050565b600080546001600160a01b03838116610100818102610100600160a81b0319851617855560405193049190911692909183917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a35050565b606060ff8314610ce257610cdb83610ebf565b905061055e565b818054610cee9061151a565b80601f0160208091040260200160405190810160405280929190818152602001828054610d1a9061151a565b8015610d675780601f10610d3c57610100808354040283529160200191610d67565b820191906000526020600020905b815481529060010190602001808311610d4a57829003601f168201915b5050505050905061055e565b6060610d8183836000610efe565b9392505050565b600061055e610d95610f9b565b8360405161190160f01b8152600281019290925260228201526042902090565b60008060008351604103610def5760208401516040850151606086015160001a610de1888285856110c6565b955095509550505050610dfb565b50508151600091506002905b9250925092565b6000826003811115610e1657610e1661154e565b03610e1f575050565b6001826003811115610e3357610e3361154e565b03610e515760405163f645eedf60e01b815260040160405180910390fd5b6002826003811115610e6557610e6561154e565b03610e865760405163fce698f760e01b815260048101829052602401610618565b6003826003811115610e9a57610e9a61154e565b03610ebb576040516335e2f38360e21b815260048101829052602401610618565b5050565b60606000610ecc83611195565b604080516020808252818301909252919250600091906020820181803683375050509182525060208101929092525090565b606081471015610f235760405163cd78605960e01b8152306004820152602401610618565b600080856001600160a01b03168486604051610f3f9190611564565b60006040518083038185875af1925050503d8060008114610f7c576040519150601f19603f3d011682016040523d82523d6000602084013e610f81565b606091505b5091509150610f918683836111bd565b9695505050505050565b6000306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016148015610ff457507f000000000000000000000000000000000000000000000000000000000000000046145b1561101e57507f000000000000000000000000000000000000000000000000000000000000000090565b610aae604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527f0000000000000000000000000000000000000000000000000000000000000000918101919091527f000000000000000000000000000000000000000000000000000000000000000060608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b600080807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0841115611101575060009150600390508261118b565b604080516000808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa158015611155573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166111815750600092506001915082905061118b565b9250600091508190505b9450945094915050565b600060ff8216601f81111561055e57604051632cd44ac360e21b815260040160405180910390fd5b6060826111d2576111cd82611219565b610d81565b81511580156111e957506001600160a01b0384163b155b1561121257604051639996b31560e01b81526001600160a01b0385166004820152602401610618565b5080610d81565b8051156112295780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b6001600160a01b038116811461062a57600080fd5b60006020828403121561126957600080fd5b8135610d8181611242565b60006020828403121561128657600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b6000606082840312156112b557600080fd5b50919050565b600080608083850312156112ce57600080fd5b823567ffffffffffffffff808211156112e657600080fd5b818501915085601f8301126112fa57600080fd5b81358181111561130c5761130c61128d565b604051601f8201601f19908116603f011681019083821181831017156113345761133461128d565b8160405282815288602084870101111561134d57600080fd5b82602086016020830137600060208483010152809650505050505061137584602085016112a3565b90509250929050565b60005b83811015611399578181015183820152602001611381565b50506000910152565b600081518084526113ba81602086016020860161137e565b601f01601f19169290920160200192915050565b60ff60f81b881681526000602060e060208401526113ef60e084018a6113a2565b8381036040850152611401818a6113a2565b606085018990526001600160a01b038816608086015260a0850187905284810360c08601528551808252602080880193509091019060005b8181101561145557835183529284019291840191600101611439565b50909c9b505050505050505050505050565b60006060828403121561147957600080fd5b610d8183836112a3565b634e487b7160e01b600052601160045260246000fd5b8181038181111561055e5761055e611483565b8082018082111561055e5761055e611483565b808202811582820484141761055e5761055e611483565b6000826114f357634e487b7160e01b600052601260045260246000fd5b500490565b60006020828403121561150a57600080fd5b81518015158114610d8157600080fd5b600181811c9082168061152e57607f821691505b6020821081036112b557634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b6000825161157681846020870161137e565b919091019291505056fea2646970667358221220dd46319a01d088ef8c7040abfd57b77a020070af96d66bfde521f77e958e785364736f6c634300081800330000000000000000000000003cad2c29e3d480c123aa29277171f9ffffe682c80000000000000000000000000000000000000000000000000000000066f19e900000000000000000000000000000000000000000000000000000000067192b90
Deployed Bytecode
0x608060405234801561001057600080fd5b506004361061014d5760003560e01c80638da5cb5b116100c3578063d54ad2a11161007c578063d54ad2a11461029e578063e30c3978146102a7578063e67151ae146102b8578063e6fd48bc146102cb578063f2fde38b146102d4578063fc0c546a146102e757600080fd5b80638da5cb5b146102125780639e9fbdb71461023c578063a85adeab1461024f578063b6b55f2514610258578063c8761d241461026b578063cb93bca01461028b57600080fd5b80635c975abb116101155780635c975abb146101c15780636e1613fb146101cc578063715018a6146101df57806379ba5097146101e75780638456cb59146101ef57806384b0196e146101f757600080fd5b8063144fa6d714610152578063199cbc54146101675780632e1a7d4d146101835780633f4ba83a146101a657806353beff55146101ae575b600080fd5b610165610160366004611257565b6102fa565b005b61017060085481565b6040519081526020015b60405180910390f35b610196610191366004611274565b610324565b604051901515815260200161017a565b610165610398565b6101966101bc3660046112bb565b6103aa565b60005460ff16610196565b6101966101da366004611274565b610564565b6101656105d2565b6101656105e4565b61016561062d565b6101ff61063d565b60405161017a97969594939291906113ce565b60005461010090046001600160a01b03165b6040516001600160a01b03909116815260200161017a565b61019661024a366004611274565b610683565b61017060075481565b610196610266366004611274565b610696565b610170610279366004611257565b600a6020526000908152604090205481565b610170610299366004611467565b6106ff565b61017060095481565b6001546001600160a01b0316610224565b6101966102c6366004611274565b610807565b61017060065481565b6101656102e2366004611257565b610867565b600554610224906001600160a01b031681565b6103026108de565b600580546001600160a01b0319166001600160a01b0392909216919091179055565b600061032e6108de565b81600860008282546103409190611499565b909155505060055461035c906001600160a01b03163384610911565b6040518281527f430648de173157e069201c943adb2d4e340e7cf5b27b1b09c9cb852f03d63b56906020015b60405180910390a1506001919050565b6103a06108de565b6103a8610975565b565b60006103b46109c7565b6103bc6109ef565b7f0000000000000000000000003cad2c29e3d480c123aa29277171f9ffffe682c86001600160a01b03166103f08385610a13565b6001600160a01b03161461041757604051638baa579f60e01b815260040160405180910390fd5b336104256020840184611257565b6001600160a01b03161461044c576040516323455ba160e01b815260040160405180910390fd5b6000610457836106ff565b9050806000036104795760405162f3f86160e41b815260040160405180910390fd5b80600a600061048b6020870187611257565b6001600160a01b03166001600160a01b0316815260200190815260200160002060008282546104ba91906114ac565b9250508190555080600960008282546104d391906114ac565b909155506104fc90506104e96020850185611257565b6005546001600160a01b03169083610911565b6105096020840184611257565b6005546040518381526001600160a01b0392831692909116907ff7a40077ff7a04c7e61f6f26fb13774259ddf1b6bce9ecf26a8276cdd39926839060200160405180910390a3600191505061055e6001600255565b92915050565b600061056e6108de565b428211158061057f57506006548211155b1561059d5760405163c6e369f960e01b815260040160405180910390fd5b60078290556040518281527fa3ea21afc186bdd87bec6b4cbf15d90b2276674b095c1e9ffbab7ffcff0ac6c090602001610388565b6105da6108de565b6103a86000610a2b565b60015433906001600160a01b031681146106215760405163118cdaa760e01b81526001600160a01b03821660048201526024015b60405180910390fd5b61062a81610a2b565b50565b6106356108de565b6103a8610a44565b600060608060008060006060610651610a81565b610659610ab3565b60408051600080825260208201909252600f60f81b9b939a50919850469750309650945092509050565b600061068d6108de565b50600855600190565b60006106a06108de565b81600860008282546106b291906114ac565b90915550506005546106cf906001600160a01b0316333085610ae0565b6040518281527f2a89b2e3d580398d6dc2db5e0f336b52602bbaa51afa9bb5cdf59239cf0d2bea90602001610388565b600060208201358161071084610b1f565b90506006544211610723578092506107ca565b6007544210610734578192506107ca565b6000600654426107449190611499565b905060006006546007546107589190611499565b90506000816107766ec097ce7bc90715b34b9f1000000000856114bf565b61078091906114d6565b9050600061078e8587611499565b905060006ec097ce7bc90715b34b9f10000000006107ac84846114bf565b6107b691906114d6565b90506107c286826114ac565b975050505050505b600a60006107db6020870187611257565b6001600160a01b031681526020810191909152604001600020546107ff9084611499565b949350505050565b60006108116108de565b428210156108325760405163c6e369f960e01b815260040160405180910390fd5b60068290556040518281527f07cd07ffd137c726a01cf58e28440d541645e57385351a90e509539bbde40f5490602001610388565b61086f6108de565b600180546001600160a01b0383166001600160a01b031990911681179091556108a66000546001600160a01b036101009091041690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6000546001600160a01b036101009091041633146103a85760405163118cdaa760e01b8152336004820152602401610618565b6040516001600160a01b0383811660248301526044820183905261097091859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050610b40565b505050565b61097d610ba3565b6000805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b60028054036109e957604051633ee5aeb560e01b815260040160405180910390fd5b60028055565b60005460ff16156103a85760405163d93c066560e01b815260040160405180910390fd5b600080610a1f84610bc6565b90506107ff8184610c45565b600180546001600160a01b031916905561062a81610c6f565b610a4c6109ef565b6000805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586109aa3390565b6060610aae7f436c61696d436f6e74726163744e616d657370616365000000000000000000166003610cc8565b905090565b6060610aae7f31000000000000000000000000000000000000000000000000000000000000016004610cc8565b6040516001600160a01b038481166024830152838116604483015260648201839052610b199186918216906323b872dd9060840161093e565b50505050565b6000612710610b36604084013560208501356114bf565b61055e91906114d6565b6000610b556001600160a01b03841683610d73565b90508051600014158015610b7a575080806020019051810190610b7891906114f8565b155b1561097057604051635274afe760e01b81526001600160a01b0384166004820152602401610618565b60005460ff166103a857604051638dfc202b60e01b815260040160405180910390fd5b600061055e7f4a7775d9f0286e47df63ac682cb4717b698b6cdec36c24dd6538b62402b8ad4c610bf96020850185611257565b604080516020818101949094526001600160a01b039092168282015291850135606082015290840135608082015260a00160405160208183030381529060405280519060200120610d88565b600080600080610c558686610db5565b925092509250610c658282610e02565b5090949350505050565b600080546001600160a01b03838116610100818102610100600160a81b0319851617855560405193049190911692909183917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a35050565b606060ff8314610ce257610cdb83610ebf565b905061055e565b818054610cee9061151a565b80601f0160208091040260200160405190810160405280929190818152602001828054610d1a9061151a565b8015610d675780601f10610d3c57610100808354040283529160200191610d67565b820191906000526020600020905b815481529060010190602001808311610d4a57829003601f168201915b5050505050905061055e565b6060610d8183836000610efe565b9392505050565b600061055e610d95610f9b565b8360405161190160f01b8152600281019290925260228201526042902090565b60008060008351604103610def5760208401516040850151606086015160001a610de1888285856110c6565b955095509550505050610dfb565b50508151600091506002905b9250925092565b6000826003811115610e1657610e1661154e565b03610e1f575050565b6001826003811115610e3357610e3361154e565b03610e515760405163f645eedf60e01b815260040160405180910390fd5b6002826003811115610e6557610e6561154e565b03610e865760405163fce698f760e01b815260048101829052602401610618565b6003826003811115610e9a57610e9a61154e565b03610ebb576040516335e2f38360e21b815260048101829052602401610618565b5050565b60606000610ecc83611195565b604080516020808252818301909252919250600091906020820181803683375050509182525060208101929092525090565b606081471015610f235760405163cd78605960e01b8152306004820152602401610618565b600080856001600160a01b03168486604051610f3f9190611564565b60006040518083038185875af1925050503d8060008114610f7c576040519150601f19603f3d011682016040523d82523d6000602084013e610f81565b606091505b5091509150610f918683836111bd565b9695505050505050565b6000306001600160a01b037f00000000000000000000000023cb75adc58f2e9a7b3ebf4fb734e8e8d30b684616148015610ff457507f000000000000000000000000000000000000000000000000000000000000000146145b1561101e57507f8a8dca4127d5150ce5eb7f05e4d0bcb0a95abf422049d73f5ccaf4610767d47590565b610aae604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527ffb4aeeb59dd57c1bbd04311a80653528d9510e8ef37eaef5a005161a72e264bf918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b600080807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0841115611101575060009150600390508261118b565b604080516000808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa158015611155573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166111815750600092506001915082905061118b565b9250600091508190505b9450945094915050565b600060ff8216601f81111561055e57604051632cd44ac360e21b815260040160405180910390fd5b6060826111d2576111cd82611219565b610d81565b81511580156111e957506001600160a01b0384163b155b1561121257604051639996b31560e01b81526001600160a01b0385166004820152602401610618565b5080610d81565b8051156112295780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b6001600160a01b038116811461062a57600080fd5b60006020828403121561126957600080fd5b8135610d8181611242565b60006020828403121561128657600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b6000606082840312156112b557600080fd5b50919050565b600080608083850312156112ce57600080fd5b823567ffffffffffffffff808211156112e657600080fd5b818501915085601f8301126112fa57600080fd5b81358181111561130c5761130c61128d565b604051601f8201601f19908116603f011681019083821181831017156113345761133461128d565b8160405282815288602084870101111561134d57600080fd5b82602086016020830137600060208483010152809650505050505061137584602085016112a3565b90509250929050565b60005b83811015611399578181015183820152602001611381565b50506000910152565b600081518084526113ba81602086016020860161137e565b601f01601f19169290920160200192915050565b60ff60f81b881681526000602060e060208401526113ef60e084018a6113a2565b8381036040850152611401818a6113a2565b606085018990526001600160a01b038816608086015260a0850187905284810360c08601528551808252602080880193509091019060005b8181101561145557835183529284019291840191600101611439565b50909c9b505050505050505050505050565b60006060828403121561147957600080fd5b610d8183836112a3565b634e487b7160e01b600052601160045260246000fd5b8181038181111561055e5761055e611483565b8082018082111561055e5761055e611483565b808202811582820484141761055e5761055e611483565b6000826114f357634e487b7160e01b600052601260045260246000fd5b500490565b60006020828403121561150a57600080fd5b81518015158114610d8157600080fd5b600181811c9082168061152e57607f821691505b6020821081036112b557634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b6000825161157681846020870161137e565b919091019291505056fea2646970667358221220dd46319a01d088ef8c7040abfd57b77a020070af96d66bfde521f77e958e785364736f6c63430008180033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000003cad2c29e3d480c123aa29277171f9ffffe682c80000000000000000000000000000000000000000000000000000000066f19e900000000000000000000000000000000000000000000000000000000067192b90
-----Decoded View---------------
Arg [0] : signer_ (address): 0x3CaD2C29e3D480C123Aa29277171f9ffffE682c8
Arg [1] : startTimestamp_ (uint256): 1727110800
Arg [2] : endTimestamp_ (uint256): 1729702800
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 0000000000000000000000003cad2c29e3d480c123aa29277171f9ffffe682c8
Arg [1] : 0000000000000000000000000000000000000000000000000000000066f19e90
Arg [2] : 0000000000000000000000000000000000000000000000000000000067192b90
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 27 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ 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.