More Info
Private Name Tags
ContractCreator
Latest 25 from a total of 459 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Claim Multiple R... | 8344576 | 1 hr ago | IN | 0 APE | 0.00211256 | ||||
Claim Multiple R... | 8272471 | 35 hrs ago | IN | 0 APE | 0.00211309 | ||||
Claim Multiple R... | 8259585 | 41 hrs ago | IN | 0 APE | 0.00211273 | ||||
Claim Multiple R... | 8235940 | 2 days ago | IN | 0 APE | 0.00211365 | ||||
Claim Multiple R... | 8142796 | 3 days ago | IN | 0 APE | 0.00209425 | ||||
Claim Multiple R... | 7802558 | 8 days ago | IN | 0 APE | 0.00209303 | ||||
Claim Multiple R... | 7790060 | 9 days ago | IN | 0 APE | 0.00211362 | ||||
Claim Multiple R... | 7746164 | 9 days ago | IN | 0 APE | 0.00211304 | ||||
Claim Multiple R... | 7694399 | 10 days ago | IN | 0 APE | 0.00211281 | ||||
Claim Multiple R... | 7693464 | 10 days ago | IN | 0 APE | 0.00211251 | ||||
Claim Multiple R... | 7420679 | 16 days ago | IN | 0 APE | 0.002094 | ||||
Claim Multiple R... | 7406480 | 16 days ago | IN | 0 APE | 0.00211245 | ||||
Claim Multiple R... | 7404417 | 16 days ago | IN | 0 APE | 0.00211296 | ||||
Claim Multiple R... | 7402987 | 16 days ago | IN | 0 APE | 0.00211334 | ||||
Claim Multiple R... | 7401498 | 17 days ago | IN | 0 APE | 0.00211339 | ||||
Claim Multiple R... | 7381716 | 17 days ago | IN | 0 APE | 0.00209415 | ||||
Claim Multiple R... | 7322614 | 19 days ago | IN | 0 APE | 0.00211362 | ||||
Claim Multiple R... | 7269613 | 20 days ago | IN | 0 APE | 0.0021136 | ||||
Claim Multiple R... | 7260211 | 21 days ago | IN | 0 APE | 0.00211339 | ||||
Claim Multiple R... | 7230949 | 22 days ago | IN | 0 APE | 0.00211228 | ||||
Claim Multiple R... | 7194631 | 23 days ago | IN | 0 APE | 0.00211301 | ||||
Claim Multiple R... | 7181344 | 23 days ago | IN | 0 APE | 0.00211334 | ||||
Claim Multiple R... | 7177436 | 24 days ago | IN | 0 APE | 0.00209362 | ||||
Claim Multiple R... | 7169169 | 24 days ago | IN | 0 APE | 0.00211256 | ||||
Claim Multiple R... | 7161641 | 24 days ago | IN | 0 APE | 0.002094 |
Latest 25 internal transactions (View All)
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
8344576 | 1 hr ago | 0.25345215 APE | ||||
8344576 | 1 hr ago | 0.25345215 APE | ||||
8272471 | 35 hrs ago | 0.3724275 APE | ||||
8272471 | 35 hrs ago | 0.3724275 APE | ||||
8259585 | 41 hrs ago | 10.39430229 APE | ||||
8259585 | 41 hrs ago | 10.39430229 APE | ||||
8235940 | 2 days ago | 78.62570253 APE | ||||
8235940 | 2 days ago | 78.62570253 APE | ||||
8142796 | 3 days ago | 4.48751969 APE | ||||
8142796 | 3 days ago | 4.48751969 APE | ||||
7802558 | 8 days ago | 1.73411263 APE | ||||
7802558 | 8 days ago | 1.73411263 APE | ||||
7790060 | 9 days ago | 4.22006306 APE | ||||
7790060 | 9 days ago | 4.22006306 APE | ||||
7746164 | 9 days ago | 7.63114111 APE | ||||
7746164 | 9 days ago | 7.63114111 APE | ||||
7694399 | 10 days ago | 10.06987642 APE | ||||
7694399 | 10 days ago | 10.06987642 APE | ||||
7693464 | 10 days ago | 44.81580269 APE | ||||
7693464 | 10 days ago | 44.81580269 APE | ||||
7420679 | 16 days ago | 5.10343638 APE | ||||
7420679 | 16 days ago | 5.10343638 APE | ||||
7406480 | 16 days ago | 9.35642597 APE | ||||
7406480 | 16 days ago | 9.35642597 APE | ||||
7404417 | 16 days ago | 368.4019587 APE |
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
EpochBasedTokenClaim
Compiler Version
v0.8.23+commit.f704f362
Optimization Enabled:
Yes with 800 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.8.23; import {MerkleProof} from "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; import {Ownable2Step} from "@openzeppelin/contracts/access/Ownable2Step.sol"; import "../interfaces/IERC20.sol"; import "../libraries/ChainUtils.sol"; import "../libraries/TokenTransferUtils.sol"; /** * @dev Contract to claim rewards based on epoch and merkle tree (used for Arbitrum STIP trading incentives) */ contract EpochBasedTokenClaim is Ownable2Step { using TokenTransferUtils for address; uint256 private constant MAX_NATIVE_TRANSFER_GAS_LIMIT = 40_000; // the amount of gas to forward on native token transfers address public immutable rewardToken; address public manager; mapping(uint256 => bytes32) public epochRoots; // epoch => root mapping(uint256 => string) public epochCids; // epoch => ipfs cid mapping(uint256 => mapping(address => bool)) public epochTraderClaimed; // epoch => trader => claimed event ManagerUpdated(address newManager); event TokensWithdrawn(); event EpochMerkleRootSet(uint256 indexed epoch, bytes32 root, uint256 totalRewards, string cid); event TokensClaimed(uint256 indexed epoch, address indexed user, uint256 rewardAmount); event TokensClaimed(uint256[] epochs, address indexed user, uint256 rewardAmount); error AddressZero(); error NotManager(); error RootAlreadySet(); error RootZero(); error RewardsZero(); error CidZero(); error InvalidEpochs(); error ArrayLengthMismatch(); error EpochNotSet(); error NotEnoughBalance(); error AlreadyClaimed(); error InvalidProof(); constructor(address _rewardToken, address _owner, address _manager) { if (_rewardToken == address(0) || _owner == address(0) || _manager == address(0)) revert AddressZero(); rewardToken = _rewardToken; manager = _manager; _transferOwnership(_owner); } /** * @dev Accepts native token transfers */ receive() external payable {} modifier onlyManager() { if (msg.sender != manager) revert NotManager(); _; } /** * @dev Sets manager address to `_manager`. Only callable by `owner()` (multisig) */ function setManager(address _manager) external onlyOwner { if (_manager == address(0)) revert AddressZero(); manager = _manager; emit ManagerUpdated(_manager); } /** * @dev Sets Merkle Tree `_root` and '_cid' for an `_epoch` and transfers `_totalRewards` from the `owner()` (multisig) to this * contract. Only callable by `manager`. */ function setRoot(uint256 _epoch, bytes32 _root, uint256 _totalRewards, string memory _cid) external onlyManager { if (epochRoots[_epoch] != bytes32(0)) revert RootAlreadySet(); if (_root == bytes32(0)) revert RootZero(); if (_totalRewards == 0) revert RewardsZero(); if (bytes(_cid).length == 0) revert CidZero(); rewardToken.transferFrom(owner(), address(this), _totalRewards); epochRoots[_epoch] = _root; epochCids[_epoch] = _cid; emit EpochMerkleRootSet(_epoch, _root, _totalRewards, _cid); } /** * @dev Prevents stuck tokens in case of misconfiguration; Only `owner()` (multisig) can claim the tokens back */ function withdrawTokens() external onlyOwner { rewardToken.transfer(msg.sender, IERC20(rewardToken).balanceOf(address(this))); emit TokensWithdrawn(); } /** * @dev Claims trader rewards for a specific `_epoch` */ function claimRewards(uint256 _epoch, uint256 _rewardAmount, bytes32[] calldata _proof) external { address trader = msg.sender; _validateClaim(_epoch, trader, _rewardAmount, _proof); epochTraderClaimed[_epoch][trader] = true; // Transfer rewards to trader, unwrapping when possible _transferRewards(trader, _rewardAmount); emit TokensClaimed(_epoch, trader, _rewardAmount); } /** * @dev Claims trader rewards for multiple `_epochs` */ function claimMultipleRewards( uint256[] calldata _epochs, uint256[] calldata _rewardAmounts, bytes32[][] calldata _proofs ) external { if (_epochs.length == 0) revert InvalidEpochs(); if ((_epochs.length != _rewardAmounts.length) || (_rewardAmounts.length != _proofs.length)) revert ArrayLengthMismatch(); address trader = msg.sender; uint256 totalAmount; for (uint256 i; i < _epochs.length; ) { _validateClaim(_epochs[i], trader, _rewardAmounts[i], _proofs[i]); epochTraderClaimed[_epochs[i]][trader] = true; totalAmount += _rewardAmounts[i]; unchecked { ++i; } } _transferRewards(trader, totalAmount); emit TokensClaimed(_epochs, trader, totalAmount); } /** * @dev Transfer reward tokens to user. Unwraps token if `rewardToken` is a native token. */ function _transferRewards(address _user, uint256 _amount) internal { if (ChainUtils.isWrappedNativeToken(rewardToken)) { rewardToken.unwrapAndTransferNative(_user, _amount, MAX_NATIVE_TRANSFER_GAS_LIMIT); } else { rewardToken.transfer(_user, _amount); } } /** * @dev Returns a hashed leaf of `_user` + `_amount` */ function _hashLeaf(address _user, uint256 _amount) internal pure returns (bytes32) { return keccak256(bytes.concat(keccak256(abi.encode(_user, _amount)))); } /** * @dev Validates that: * 1) The `_epoch` merkle tree root is set * 2) There are enough token rewards in the contract * 3) Rewards for leaf are unclaimed * 4) The `leaf` and `_proof` validate against `epochRoot` */ function _validateClaim( uint256 _epoch, address _trader, uint256 _rewardAmount, bytes32[] calldata _proof ) internal view { bytes32 epochRoot = epochRoots[_epoch]; bytes32 leaf = _hashLeaf(_trader, _rewardAmount); if (epochRoot == bytes32(0)) revert EpochNotSet(); if (_rewardAmount > IERC20(rewardToken).balanceOf(address(this))) revert NotEnoughBalance(); if (epochTraderClaimed[_epoch][_trader]) revert AlreadyClaimed(); if (!MerkleProof.verifyCalldata(_proof, epochRoot, leaf)) revert InvalidProof(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../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. * * By default, the owner account will be the one that deploys the contract. 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; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @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 { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @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 { require(newOwner != address(0), "Ownable: new owner is the zero address"); _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 v4.9.0) (access/Ownable2Step.sol) pragma solidity ^0.8.0; import "./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. * * By default, the owner account will be the one that deploys the contract. 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(); require(pendingOwner() == sender, "Ownable2Step: caller is not the new owner"); _transferOwnership(sender); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.0; /** * @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 v4.9.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @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 amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` 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 amount) 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 `amount` 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 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` 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 amount) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../extensions/IERC20Permit.sol"; import "../../../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 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.encodeWithSelector(token.transfer.selector, 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.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 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); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value)); } /** * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value)); } } /** * @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.encodeWithSelector(token.approve.selector, spender, value); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0)); _callOptionalReturn(token, approvalCall); } } /** * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`. * Revert on invalid signature. */ function safePermit( IERC20Permit token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @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, "SafeERC20: low-level call failed"); require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } /** * @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.isContract(address(token)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @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.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @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, it is bubbled up by this * function (like regular Solidity function calls). * * 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. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @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`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) 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(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol) pragma solidity ^0.8.0; /** * @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 v4.9.2) (utils/cryptography/MerkleProof.sol) pragma solidity ^0.8.0; /** * @dev These functions deal with verification of Merkle Tree proofs. * * The tree and the proofs can be generated using our * https://github.com/OpenZeppelin/merkle-tree[JavaScript library]. * You will find a quickstart guide in the readme. * * WARNING: You should avoid using leaf values that are 64 bytes long prior to * hashing, or use a hash function other than keccak256 for hashing leaves. * This is because the concatenation of a sorted pair of internal nodes in * the merkle tree could be reinterpreted as a leaf value. * OpenZeppelin's JavaScript library generates merkle trees that are safe * against this attack out of the box. */ library MerkleProof { /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) { return processProof(proof, leaf) == root; } /** * @dev Calldata version of {verify} * * _Available since v4.7._ */ function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) internal pure returns (bool) { return processProofCalldata(proof, leaf) == root; } /** * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt * hash matches the root of the tree. When processing the proof, the pairs * of leafs & pre-images are assumed to be sorted. * * _Available since v4.4._ */ function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { computedHash = _hashPair(computedHash, proof[i]); } return computedHash; } /** * @dev Calldata version of {processProof} * * _Available since v4.7._ */ function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { computedHash = _hashPair(computedHash, proof[i]); } return computedHash; } /** * @dev Returns true if the `leaves` can be simultaneously proven to be a part of a merkle tree defined by * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}. * * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details. * * _Available since v4.7._ */ function multiProofVerify( bytes32[] memory proof, bool[] memory proofFlags, bytes32 root, bytes32[] memory leaves ) internal pure returns (bool) { return processMultiProof(proof, proofFlags, leaves) == root; } /** * @dev Calldata version of {multiProofVerify} * * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details. * * _Available since v4.7._ */ function multiProofVerifyCalldata( bytes32[] calldata proof, bool[] calldata proofFlags, bytes32 root, bytes32[] memory leaves ) internal pure returns (bool) { return processMultiProofCalldata(proof, proofFlags, leaves) == root; } /** * @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction * proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another * leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false * respectively. * * CAUTION: Not all merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree * is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the * tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer). * * _Available since v4.7._ */ function processMultiProof( bytes32[] memory proof, bool[] memory proofFlags, bytes32[] memory leaves ) internal pure returns (bytes32 merkleRoot) { // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of // the merkle tree. uint256 leavesLen = leaves.length; uint256 proofLen = proof.length; uint256 totalHashes = proofFlags.length; // Check proof validity. require(leavesLen + proofLen - 1 == totalHashes, "MerkleProof: invalid multiproof"); // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop". bytes32[] memory hashes = new bytes32[](totalHashes); uint256 leafPos = 0; uint256 hashPos = 0; uint256 proofPos = 0; // At each step, we compute the next hash using two values: // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we // get the next hash. // - depending on the flag, either another value from the "main queue" (merging branches) or an element from the // `proof` array. for (uint256 i = 0; i < totalHashes; i++) { bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]; bytes32 b = proofFlags[i] ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]) : proof[proofPos++]; hashes[i] = _hashPair(a, b); } if (totalHashes > 0) { require(proofPos == proofLen, "MerkleProof: invalid multiproof"); unchecked { return hashes[totalHashes - 1]; } } else if (leavesLen > 0) { return leaves[0]; } else { return proof[0]; } } /** * @dev Calldata version of {processMultiProof}. * * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details. * * _Available since v4.7._ */ function processMultiProofCalldata( bytes32[] calldata proof, bool[] calldata proofFlags, bytes32[] memory leaves ) internal pure returns (bytes32 merkleRoot) { // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of // the merkle tree. uint256 leavesLen = leaves.length; uint256 proofLen = proof.length; uint256 totalHashes = proofFlags.length; // Check proof validity. require(leavesLen + proofLen - 1 == totalHashes, "MerkleProof: invalid multiproof"); // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop". bytes32[] memory hashes = new bytes32[](totalHashes); uint256 leafPos = 0; uint256 hashPos = 0; uint256 proofPos = 0; // At each step, we compute the next hash using two values: // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we // get the next hash. // - depending on the flag, either another value from the "main queue" (merging branches) or an element from the // `proof` array. for (uint256 i = 0; i < totalHashes; i++) { bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]; bytes32 b = proofFlags[i] ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]) : proof[proofPos++]; hashes[i] = _hashPair(a, b); } if (totalHashes > 0) { require(proofPos == proofLen, "MerkleProof: invalid multiproof"); unchecked { return hashes[totalHashes - 1]; } } else if (leavesLen > 0) { return leaves[0]; } else { return proof[0]; } } function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) { return a < b ? _efficientHash(a, b) : _efficientHash(b, a); } function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) { /// @solidity memory-safe-assembly assembly { mstore(0x00, a) mstore(0x20, b) value := keccak256(0x00, 0x40) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @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 up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (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; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) 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. require(denominator > prod1, "Math: mulDiv overflow"); /////////////////////////////////////////////// // 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. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); 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 (rounding == Rounding.Up && 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 down. * * 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 + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * 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 + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * 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 + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * 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 + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.23; /** * @dev Interface for Arbitrum special l2 functions */ interface IArbSys { function arbBlockNumber() external view returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.23; import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; /** * @dev Interface for ERC20 tokens */ interface IERC20 is IERC20Metadata { function burn(address, uint256) external; function mint(address, uint256) external; function hasRole(bytes32, address) external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.23; /** * @dev Interface for errors potentially used in all libraries (general names) */ interface IGeneralErrors { error InitError(); error InvalidAddresses(); error InvalidAddress(); error InvalidInputLength(); error InvalidCollateralIndex(); error WrongParams(); error WrongLength(); error WrongOrder(); error WrongIndex(); error BlockOrder(); error Overflow(); error ZeroAddress(); error ZeroValue(); error AlreadyExists(); error DoesntExist(); error Paused(); error BelowMin(); error AboveMax(); error NotAuthorized(); error WrongTradeType(); error WrongOrderType(); error InsufficientBalance(); error UnsupportedChain(); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.23; /** * @dev Interface for WETH9 token */ interface IWETH9 { function approve(address spender, uint256 amount) external returns (bool); function transfer(address to, uint256 amount) external returns (bool); function deposit() external payable; function withdraw(uint256) external; function balanceOf(address account) external view returns (uint256); event Approval(address indexed src, address indexed guy, uint256 wad); event Transfer(address indexed src, address indexed dst, uint256 wad); event Deposit(address indexed dst, uint256 wad); event Withdrawal(address indexed src, uint256 wad); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.23; /** * @dev Interface for BlockManager_Mock contract (test helper) */ interface IBlockManager_Mock { function getBlockNumber() external view returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.23; import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; import "../interfaces/IArbSys.sol"; import "../interfaces/IGeneralErrors.sol"; import "../interfaces/mock/IBlockManager_Mock.sol"; /** * @dev Chain helpers internal library */ library ChainUtils { // Supported chains uint256 internal constant ARBITRUM_MAINNET = 42161; uint256 internal constant ARBITRUM_SEPOLIA = 421614; uint256 internal constant POLYGON_MAINNET = 137; uint256 internal constant BASE_MAINNET = 8453; uint256 internal constant APECHAIN_MAINNET = 33139; uint256 internal constant TESTNET = 31337; // Wrapped native tokens address private constant ARBITRUM_MAINNET_WETH = 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1; address private constant ARBITRUM_SEPOLIA_WETH = 0x980B62Da83eFf3D4576C647993b0c1D7faf17c73; address private constant POLYGON_MAINNET_WMATIC = 0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270; address private constant BASE_MAINNET_WETH = 0x4200000000000000000000000000000000000006; address private constant APECHAIN_MAINNET_WAPE = 0x00000000000f7e000644657dC9417b185962645a; // Custom non-rebasing WAPE IArbSys private constant ARB_SYS = IArbSys(address(100)); error Overflow(); /** * @dev Returns the current block number (l2 block for arbitrum) */ function getBlockNumber() internal view returns (uint256) { if ( block.chainid == ARBITRUM_MAINNET || block.chainid == APECHAIN_MAINNET || block.chainid == ARBITRUM_SEPOLIA ) { return ARB_SYS.arbBlockNumber(); } if (block.chainid == TESTNET) { return IBlockManager_Mock(address(420)).getBlockNumber(); } return block.number; } /** * @dev Returns blockNumber converted to uint48 * @param blockNumber block number to convert */ function getUint48BlockNumber(uint256 blockNumber) internal pure returns (uint48) { if (blockNumber > type(uint48).max) revert Overflow(); return uint48(blockNumber); } /** * @dev Returns the wrapped native token address for the current chain */ function getWrappedNativeToken() internal view returns (address) { if (block.chainid == ARBITRUM_MAINNET) { return ARBITRUM_MAINNET_WETH; } if (block.chainid == BASE_MAINNET) { return BASE_MAINNET_WETH; } if (block.chainid == APECHAIN_MAINNET) { return APECHAIN_MAINNET_WAPE; } if (block.chainid == POLYGON_MAINNET) { return POLYGON_MAINNET_WMATIC; } if (block.chainid == ARBITRUM_SEPOLIA) { return ARBITRUM_SEPOLIA_WETH; } if (block.chainid == TESTNET) { return address(421); } return address(0); } /** * @dev Returns whether a token is the wrapped native token for the current chain * @param _token token address to check */ function isWrappedNativeToken(address _token) internal view returns (bool) { return _token != address(0) && _token == getWrappedNativeToken(); } /** * @dev Converts blocks to seconds for the current chain. * @dev Important: the result is an estimation and may not be accurate. Use with caution. * @param _blocks block count to convert to seconds */ function convertBlocksToSeconds(uint256 _blocks) internal view returns (uint256) { uint256 millisecondsPerBlock; if (block.chainid == ARBITRUM_MAINNET || block.chainid == ARBITRUM_SEPOLIA) { millisecondsPerBlock = 300; // 0.3 seconds per block } else if (block.chainid == BASE_MAINNET) { millisecondsPerBlock = 2000; // 2 seconds per block } else if (block.chainid == POLYGON_MAINNET) { millisecondsPerBlock = 2200; // 2.2 seconds per block } else if (block.chainid == APECHAIN_MAINNET) { millisecondsPerBlock = 1000; // apechain blocktime is variable; this will be updated over time as averages change } else if (block.chainid == TESTNET) { millisecondsPerBlock = 1000; // 1 second per block } else { revert IGeneralErrors.UnsupportedChain(); } return Math.mulDiv(_blocks, millisecondsPerBlock, 1000, Math.Rounding.Up); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.23; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "../interfaces/IWETH9.sol"; import "../interfaces/IERC20.sol"; /** * @dev Library to handle transfers of tokens, including native tokens. */ library TokenTransferUtils { using SafeERC20 for IERC20; /** * @dev Unwraps and transfers `_amount` of native tokens to a recipient, `_to`. * * IMPORTANT: * If the recipient does not accept the native transfer then the tokens are re-wrapped and transferred as ERC20. * Always ensure CEI pattern is followed or reentrancy guards are in place before performing native transfers. * * @param _token the wrapped native token address * @param _to the recipient * @param _amount the amount of tokens to transfer * @param _gasLimit how much gas to forward. */ function unwrapAndTransferNative(address _token, address _to, uint256 _amount, uint256 _gasLimit) internal { // 1. Unwrap `_amount` of `_token` IWETH9(_token).withdraw(_amount); // 2. Attempt to transfer native tokens // Uses low-level call and loads no return data into memory to prevent `returnbomb` attacks // See https://gist.github.com/pcaversaccio/3b487a24922c839df22f925babd3c809 for an example bool success; assembly { // call(gas, address, value, argsOffset, argsSize, retOffset, retSize) success := call(_gasLimit, _to, _amount, 0, 0, 0, 0) } // 3. If the native transfer was successful, return if (success) return; // 4. Otherwise re-wrap `_amount` of `_token` IWETH9(_token).deposit{value: _amount}(); // 5. Send with an ERC20 transfer transfer(_token, _to, _amount); } /** * @dev Transfers `_amount` of `_token` to a recipient, `to` * @param _token the token address * @param _to the recipient * @param _amount amount of tokens to transfer */ function transfer(address _token, address _to, uint256 _amount) internal { IERC20(_token).safeTransfer(_to, _amount); } /** * @dev Transfers `_amount` of `_token` from a sender, `_from`, to a recipient, `to`. * @param _token the token address * @param _from the sender * @param _to the recipient * @param _amount amount of tokens to transfer */ function transferFrom(address _token, address _from, address _to, uint256 _amount) internal { IERC20(_token).safeTransferFrom(_from, _to, _amount); } }
{ "optimizer": { "enabled": true, "runs": 800 }, "evmVersion": "paris", "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_rewardToken","type":"address"},{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_manager","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AddressZero","type":"error"},{"inputs":[],"name":"AlreadyClaimed","type":"error"},{"inputs":[],"name":"ArrayLengthMismatch","type":"error"},{"inputs":[],"name":"CidZero","type":"error"},{"inputs":[],"name":"EpochNotSet","type":"error"},{"inputs":[],"name":"InvalidEpochs","type":"error"},{"inputs":[],"name":"InvalidProof","type":"error"},{"inputs":[],"name":"NotEnoughBalance","type":"error"},{"inputs":[],"name":"NotManager","type":"error"},{"inputs":[],"name":"RewardsZero","type":"error"},{"inputs":[],"name":"RootAlreadySet","type":"error"},{"inputs":[],"name":"RootZero","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"epoch","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"root","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"totalRewards","type":"uint256"},{"indexed":false,"internalType":"string","name":"cid","type":"string"}],"name":"EpochMerkleRootSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newManager","type":"address"}],"name":"ManagerUpdated","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":true,"internalType":"uint256","name":"epoch","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"rewardAmount","type":"uint256"}],"name":"TokensClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256[]","name":"epochs","type":"uint256[]"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"rewardAmount","type":"uint256"}],"name":"TokensClaimed","type":"event"},{"anonymous":false,"inputs":[],"name":"TokensWithdrawn","type":"event"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_epochs","type":"uint256[]"},{"internalType":"uint256[]","name":"_rewardAmounts","type":"uint256[]"},{"internalType":"bytes32[][]","name":"_proofs","type":"bytes32[][]"}],"name":"claimMultipleRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_epoch","type":"uint256"},{"internalType":"uint256","name":"_rewardAmount","type":"uint256"},{"internalType":"bytes32[]","name":"_proof","type":"bytes32[]"}],"name":"claimRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"epochCids","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"epochRoots","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"epochTraderClaimed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[],"name":"rewardToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_manager","type":"address"}],"name":"setManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_epoch","type":"uint256"},{"internalType":"bytes32","name":"_root","type":"bytes32"},{"internalType":"uint256","name":"_totalRewards","type":"uint256"},{"internalType":"string","name":"_cid","type":"string"}],"name":"setRoot","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
60a06040523480156200001157600080fd5b5060405162001aa038038062001aa0833981016040819052620000349162000153565b6200003f33620000c8565b6001600160a01b03831615806200005d57506001600160a01b038216155b806200007057506001600160a01b038116155b156200008f57604051639fabe1c160e01b815260040160405180910390fd5b6001600160a01b03838116608052600280546001600160a01b031916918316919091179055620000bf82620000c8565b5050506200019d565b600180546001600160a01b0319169055620000e381620000e6565b50565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80516001600160a01b03811681146200014e57600080fd5b919050565b6000806000606084860312156200016957600080fd5b620001748462000136565b9250620001846020850162000136565b9150620001946040850162000136565b90509250925092565b6080516118b6620001ea600039600081816102f701528181610411015281816106030152818161067801528181610a5b01528181610b6901528181610b9f0152610bda01526118b66000f3fe6080604052600436106100ec5760003560e01c80638d8f2adb1161008a578063e30c397811610059578063e30c3978146102a7578063f2fde38b146102c5578063f7c618c1146102e5578063ff91bb341461031957600080fd5b80638d8f2adb146102275780638da5cb5b1461023c578063bfbf2cdc1461025a578063d0ebdbe71461028757600080fd5b806355deccc1116100c657806355deccc1146101a257806366351b94146101dd578063715018a6146101fd57806379ba50971461021257600080fd5b80632b27fd4e146100f8578063481c6a751461011a5780634dee862d1461015757600080fd5b366100f357005b600080fd5b34801561010457600080fd5b506101186101133660046112f9565b610339565b005b34801561012657600080fd5b5060025461013a906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561016357600080fd5b506101926101723660046113e3565b600560209081526000928352604080842090915290825290205460ff1681565b604051901515815260200161014e565b3480156101ae57600080fd5b506101cf6101bd36600461140f565b60036020526000908152604090205481565b60405190815260200161014e565b3480156101e957600080fd5b506101186101f8366004611474565b6104a1565b34801561020957600080fd5b50610118610531565b34801561021e57600080fd5b50610118610545565b34801561023357600080fd5b506101186105d8565b34801561024857600080fd5b506000546001600160a01b031661013a565b34801561026657600080fd5b5061027a61027536600461140f565b6106ca565b60405161014e9190611517565b34801561029357600080fd5b506101186102a236600461152a565b610764565b3480156102b357600080fd5b506001546001600160a01b031661013a565b3480156102d157600080fd5b506101186102e036600461152a565b6107e7565b3480156102f157600080fd5b5061013a7f000000000000000000000000000000000000000000000000000000000000000081565b34801561032557600080fd5b50610118610334366004611545565b610858565b6002546001600160a01b031633146103645760405163607e454560e11b815260040160405180910390fd5b600084815260036020526040902054156103915760405163b466ddbf60e01b815260040160405180910390fd5b826103af57604051636fe692dd60e11b815260040160405180910390fd5b816000036103d057604051638d5a0e4760e01b815260040160405180910390fd5b80516000036103f25760405163765d5ee960e11b815260040160405180910390fd5b6104396104076000546001600160a01b031690565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169030856109f1565b60008481526003602090815260408083208690556004909152902061045e8282611669565b50837f7f4ca57908e4d558d66b88b26566b795d2b370ea9c5dee78beac454898324a6084848460405161049393929190611729565b60405180910390a250505050565b336104af8582868686610a0c565b60008581526005602090815260408083206001600160a01b03851684529091529020805460ff191660011790556104e68185610b64565b806001600160a01b0316857f880f2ef2613b092f1a0a819f294155c98667eb294b7e6bf7a3810278142c1a1c8660405161052291815260200190565b60405180910390a35050505050565b610539610c01565b6105436000610c5b565b565b60015433906001600160a01b031681146105cc5760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f74207468652060448201527f6e6577206f776e6572000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b6105d581610c5b565b50565b6105e0610c01565b6040516370a0823160e01b815230600482015261069f9033906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a0823190602401602060405180830381865afa15801561064a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061066e9190611751565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169190610c74565b6040517f75c111ce67858e12d7a8820645ab89a73cdac9c8247242a82a3ec701a230ce9b90600090a1565b600460205260009081526040902080546106e3906115df565b80601f016020809104026020016040519081016040528092919081815260200182805461070f906115df565b801561075c5780601f106107315761010080835404028352916020019161075c565b820191906000526020600020905b81548152906001019060200180831161073f57829003601f168201915b505050505081565b61076c610c01565b6001600160a01b03811661079357604051639fabe1c160e01b815260040160405180910390fd5b600280546001600160a01b0319166001600160a01b0383169081179091556040519081527f2c1c11af44aa5608f1dca38c00275c30ea091e02417d36e70e9a1538689c433d9060200160405180910390a150565b6107ef610c01565b600180546001600160a01b0383166001600160a01b031990911681179091556108206000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b600085900361087a576040516311345b8f60e01b815260040160405180910390fd5b84831415806108895750828114155b156108a75760405163512509d360e11b815260040160405180910390fd5b336000805b87811015610997576109138989838181106108c9576108c961176a565b90506020020135848989858181106108e3576108e361176a565b905060200201358888868181106108fc576108fc61176a565b905060200281019061090e9190611780565b610a0c565b6001600560008b8b8581811061092b5761092b61176a565b6020908102929092013583525081810192909252604090810160009081206001600160a01b03881682529092529020805460ff191691151591909117905586868281811061097b5761097b61176a565b905060200201358261098d91906117ca565b91506001016108ac565b506109a28282610b64565b816001600160a01b03167f066c4cea5e76b8edc858edefb01e1f7d9f5e4680ff6366ed4460e354d99bfc2d8989846040516109df939291906117eb565b60405180910390a25050505050505050565b610a066001600160a01b038516848484610c8d565b50505050565b60008581526003602052604081205490610a268686610d25565b905081610a4657604051631d0c7a9f60e21b815260040160405180910390fd5b6040516370a0823160e01b81523060048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa158015610aaa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ace9190611751565b851115610aee5760405163569d45cf60e11b815260040160405180910390fd5b60008781526005602090815260408083206001600160a01b038a16845290915290205460ff1615610b3257604051630c8d9eab60e31b815260040160405180910390fd5b610b3e84848484610d80565b610b5b576040516309bde33960e01b815260040160405180910390fd5b50505050505050565b610b8d7f0000000000000000000000000000000000000000000000000000000000000000610d9a565b15610bcd57610bc96001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168383619c40610dd1565b5050565b610bc96001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168383610c74565b6000546001600160a01b031633146105435760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016105c3565b600180546001600160a01b03191690556105d581610eab565b610c886001600160a01b0384168383610efb565b505050565b6040516001600160a01b0380851660248301528316604482015260648101829052610a069085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152610f2b565b604080516001600160a01b038416602082015290810182905260009060600160408051601f19818403018152828252805160209182012090830152016040516020818303038152906040528051906020012090505b92915050565b600082610d8e868685611013565b1490505b949350505050565b60006001600160a01b03821615801590610d7a5750610db7611055565b6001600160a01b0316826001600160a01b03161492915050565b604051632e1a7d4d60e01b8152600481018390526001600160a01b03851690632e1a7d4d90602401600060405180830381600087803b158015610e1357600080fd5b505af1158015610e27573d6000803e3d6000fd5b505050506000806000806000868887f190508015610e455750610a06565b846001600160a01b031663d0e30db0846040518263ffffffff1660e01b81526004016000604051808303818588803b158015610e8057600080fd5b505af1158015610e94573d6000803e3d6000fd5b5050505050610ea4858585610c74565b5050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6040516001600160a01b038316602482015260448101829052610c8890849063a9059cbb60e01b90606401610cc1565b6000610f80826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166111129092919063ffffffff16565b9050805160001480610fa1575080806020019051810190610fa19190611842565b610c885760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016105c3565b600081815b8481101561104c57611042828787848181106110365761103661176a565b90506020020135611121565b9150600101611018565b50949350505050565b600061a4b1460361107957507382af49447d8a07e3bd95bd0d56f35241523fbab190565b612105460361109b575073420000000000000000000000000000000000000690565b61817346036110b857506e0f7e000644657dc9417b185962645a90565b608946036110d95750730d500b1d8e8ef31e21c99d1db9a6444d3adf127090565b62066eee46036110fc575073980b62da83eff3d4576c647993b0c1d7faf17c7390565b617a69460361110c57506101a590565b50600090565b6060610d928484600085611153565b600081831061113d57600082815260208490526040902061114c565b60008381526020839052604090205b9392505050565b6060824710156111cb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016105c3565b600080866001600160a01b031685876040516111e79190611864565b60006040518083038185875af1925050503d8060008114611224576040519150601f19603f3d011682016040523d82523d6000602084013e611229565b606091505b509150915061123a87838387611245565b979650505050505050565b606083156112b45782516000036112ad576001600160a01b0385163b6112ad5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016105c3565b5081610d92565b610d9283838151156112c95781518083602001fd5b8060405162461bcd60e51b81526004016105c39190611517565b634e487b7160e01b600052604160045260246000fd5b6000806000806080858703121561130f57600080fd5b843593506020850135925060408501359150606085013567ffffffffffffffff8082111561133c57600080fd5b818701915087601f83011261135057600080fd5b813581811115611362576113626112e3565b604051601f8201601f19908116603f0116810190838211818310171561138a5761138a6112e3565b816040528281528a60208487010111156113a357600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b80356001600160a01b03811681146113de57600080fd5b919050565b600080604083850312156113f657600080fd5b82359150611406602084016113c7565b90509250929050565b60006020828403121561142157600080fd5b5035919050565b60008083601f84011261143a57600080fd5b50813567ffffffffffffffff81111561145257600080fd5b6020830191508360208260051b850101111561146d57600080fd5b9250929050565b6000806000806060858703121561148a57600080fd5b8435935060208501359250604085013567ffffffffffffffff8111156114af57600080fd5b6114bb87828801611428565b95989497509550505050565b60005b838110156114e25781810151838201526020016114ca565b50506000910152565b600081518084526115038160208601602086016114c7565b601f01601f19169290920160200192915050565b60208152600061114c60208301846114eb565b60006020828403121561153c57600080fd5b61114c826113c7565b6000806000806000806060878903121561155e57600080fd5b863567ffffffffffffffff8082111561157657600080fd5b6115828a838b01611428565b9098509650602089013591508082111561159b57600080fd5b6115a78a838b01611428565b909650945060408901359150808211156115c057600080fd5b506115cd89828a01611428565b979a9699509497509295939492505050565b600181811c908216806115f357607f821691505b60208210810361161357634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115610c88576000816000526020600020601f850160051c810160208610156116425750805b601f850160051c820191505b818110156116615782815560010161164e565b505050505050565b815167ffffffffffffffff811115611683576116836112e3565b6116978161169184546115df565b84611619565b602080601f8311600181146116cc57600084156116b45750858301515b600019600386901b1c1916600185901b178555611661565b600085815260208120601f198616915b828110156116fb578886015182559484019460019091019084016116dc565b50858210156117195787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b83815282602082015260606040820152600061174860608301846114eb565b95945050505050565b60006020828403121561176357600080fd5b5051919050565b634e487b7160e01b600052603260045260246000fd5b6000808335601e1984360301811261179757600080fd5b83018035915067ffffffffffffffff8211156117b257600080fd5b6020019150600581901b360382131561146d57600080fd5b80820180821115610d7a57634e487b7160e01b600052601160045260246000fd5b6040815282604082015260007f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff84111561182457600080fd5b8360051b808660608501376020830193909352500160600192915050565b60006020828403121561185457600080fd5b8151801515811461114c57600080fd5b600082516118768184602087016114c7565b919091019291505056fea26469706673582212205e440e839071cdd2e5336af7bd232a553cd7e5f2a609f2b0e710c4aaff0b4ef364736f6c6343000817003300000000000000000000000000000000000f7e000644657dc9417b185962645a00000000000000000000000034f4911911a0883856e8d15e99fda2d8e0fdbf60000000000000000000000000e72dfec45ccc0b5571d659cb8b482523c45439db
Deployed Bytecode
0x6080604052600436106100ec5760003560e01c80638d8f2adb1161008a578063e30c397811610059578063e30c3978146102a7578063f2fde38b146102c5578063f7c618c1146102e5578063ff91bb341461031957600080fd5b80638d8f2adb146102275780638da5cb5b1461023c578063bfbf2cdc1461025a578063d0ebdbe71461028757600080fd5b806355deccc1116100c657806355deccc1146101a257806366351b94146101dd578063715018a6146101fd57806379ba50971461021257600080fd5b80632b27fd4e146100f8578063481c6a751461011a5780634dee862d1461015757600080fd5b366100f357005b600080fd5b34801561010457600080fd5b506101186101133660046112f9565b610339565b005b34801561012657600080fd5b5060025461013a906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561016357600080fd5b506101926101723660046113e3565b600560209081526000928352604080842090915290825290205460ff1681565b604051901515815260200161014e565b3480156101ae57600080fd5b506101cf6101bd36600461140f565b60036020526000908152604090205481565b60405190815260200161014e565b3480156101e957600080fd5b506101186101f8366004611474565b6104a1565b34801561020957600080fd5b50610118610531565b34801561021e57600080fd5b50610118610545565b34801561023357600080fd5b506101186105d8565b34801561024857600080fd5b506000546001600160a01b031661013a565b34801561026657600080fd5b5061027a61027536600461140f565b6106ca565b60405161014e9190611517565b34801561029357600080fd5b506101186102a236600461152a565b610764565b3480156102b357600080fd5b506001546001600160a01b031661013a565b3480156102d157600080fd5b506101186102e036600461152a565b6107e7565b3480156102f157600080fd5b5061013a7f00000000000000000000000000000000000f7e000644657dc9417b185962645a81565b34801561032557600080fd5b50610118610334366004611545565b610858565b6002546001600160a01b031633146103645760405163607e454560e11b815260040160405180910390fd5b600084815260036020526040902054156103915760405163b466ddbf60e01b815260040160405180910390fd5b826103af57604051636fe692dd60e11b815260040160405180910390fd5b816000036103d057604051638d5a0e4760e01b815260040160405180910390fd5b80516000036103f25760405163765d5ee960e11b815260040160405180910390fd5b6104396104076000546001600160a01b031690565b6001600160a01b037f00000000000000000000000000000000000f7e000644657dc9417b185962645a169030856109f1565b60008481526003602090815260408083208690556004909152902061045e8282611669565b50837f7f4ca57908e4d558d66b88b26566b795d2b370ea9c5dee78beac454898324a6084848460405161049393929190611729565b60405180910390a250505050565b336104af8582868686610a0c565b60008581526005602090815260408083206001600160a01b03851684529091529020805460ff191660011790556104e68185610b64565b806001600160a01b0316857f880f2ef2613b092f1a0a819f294155c98667eb294b7e6bf7a3810278142c1a1c8660405161052291815260200190565b60405180910390a35050505050565b610539610c01565b6105436000610c5b565b565b60015433906001600160a01b031681146105cc5760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f74207468652060448201527f6e6577206f776e6572000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b6105d581610c5b565b50565b6105e0610c01565b6040516370a0823160e01b815230600482015261069f9033906001600160a01b037f00000000000000000000000000000000000f7e000644657dc9417b185962645a16906370a0823190602401602060405180830381865afa15801561064a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061066e9190611751565b6001600160a01b037f00000000000000000000000000000000000f7e000644657dc9417b185962645a169190610c74565b6040517f75c111ce67858e12d7a8820645ab89a73cdac9c8247242a82a3ec701a230ce9b90600090a1565b600460205260009081526040902080546106e3906115df565b80601f016020809104026020016040519081016040528092919081815260200182805461070f906115df565b801561075c5780601f106107315761010080835404028352916020019161075c565b820191906000526020600020905b81548152906001019060200180831161073f57829003601f168201915b505050505081565b61076c610c01565b6001600160a01b03811661079357604051639fabe1c160e01b815260040160405180910390fd5b600280546001600160a01b0319166001600160a01b0383169081179091556040519081527f2c1c11af44aa5608f1dca38c00275c30ea091e02417d36e70e9a1538689c433d9060200160405180910390a150565b6107ef610c01565b600180546001600160a01b0383166001600160a01b031990911681179091556108206000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b600085900361087a576040516311345b8f60e01b815260040160405180910390fd5b84831415806108895750828114155b156108a75760405163512509d360e11b815260040160405180910390fd5b336000805b87811015610997576109138989838181106108c9576108c961176a565b90506020020135848989858181106108e3576108e361176a565b905060200201358888868181106108fc576108fc61176a565b905060200281019061090e9190611780565b610a0c565b6001600560008b8b8581811061092b5761092b61176a565b6020908102929092013583525081810192909252604090810160009081206001600160a01b03881682529092529020805460ff191691151591909117905586868281811061097b5761097b61176a565b905060200201358261098d91906117ca565b91506001016108ac565b506109a28282610b64565b816001600160a01b03167f066c4cea5e76b8edc858edefb01e1f7d9f5e4680ff6366ed4460e354d99bfc2d8989846040516109df939291906117eb565b60405180910390a25050505050505050565b610a066001600160a01b038516848484610c8d565b50505050565b60008581526003602052604081205490610a268686610d25565b905081610a4657604051631d0c7a9f60e21b815260040160405180910390fd5b6040516370a0823160e01b81523060048201527f00000000000000000000000000000000000f7e000644657dc9417b185962645a6001600160a01b0316906370a0823190602401602060405180830381865afa158015610aaa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ace9190611751565b851115610aee5760405163569d45cf60e11b815260040160405180910390fd5b60008781526005602090815260408083206001600160a01b038a16845290915290205460ff1615610b3257604051630c8d9eab60e31b815260040160405180910390fd5b610b3e84848484610d80565b610b5b576040516309bde33960e01b815260040160405180910390fd5b50505050505050565b610b8d7f00000000000000000000000000000000000f7e000644657dc9417b185962645a610d9a565b15610bcd57610bc96001600160a01b037f00000000000000000000000000000000000f7e000644657dc9417b185962645a168383619c40610dd1565b5050565b610bc96001600160a01b037f00000000000000000000000000000000000f7e000644657dc9417b185962645a168383610c74565b6000546001600160a01b031633146105435760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016105c3565b600180546001600160a01b03191690556105d581610eab565b610c886001600160a01b0384168383610efb565b505050565b6040516001600160a01b0380851660248301528316604482015260648101829052610a069085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152610f2b565b604080516001600160a01b038416602082015290810182905260009060600160408051601f19818403018152828252805160209182012090830152016040516020818303038152906040528051906020012090505b92915050565b600082610d8e868685611013565b1490505b949350505050565b60006001600160a01b03821615801590610d7a5750610db7611055565b6001600160a01b0316826001600160a01b03161492915050565b604051632e1a7d4d60e01b8152600481018390526001600160a01b03851690632e1a7d4d90602401600060405180830381600087803b158015610e1357600080fd5b505af1158015610e27573d6000803e3d6000fd5b505050506000806000806000868887f190508015610e455750610a06565b846001600160a01b031663d0e30db0846040518263ffffffff1660e01b81526004016000604051808303818588803b158015610e8057600080fd5b505af1158015610e94573d6000803e3d6000fd5b5050505050610ea4858585610c74565b5050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6040516001600160a01b038316602482015260448101829052610c8890849063a9059cbb60e01b90606401610cc1565b6000610f80826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166111129092919063ffffffff16565b9050805160001480610fa1575080806020019051810190610fa19190611842565b610c885760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016105c3565b600081815b8481101561104c57611042828787848181106110365761103661176a565b90506020020135611121565b9150600101611018565b50949350505050565b600061a4b1460361107957507382af49447d8a07e3bd95bd0d56f35241523fbab190565b612105460361109b575073420000000000000000000000000000000000000690565b61817346036110b857506e0f7e000644657dc9417b185962645a90565b608946036110d95750730d500b1d8e8ef31e21c99d1db9a6444d3adf127090565b62066eee46036110fc575073980b62da83eff3d4576c647993b0c1d7faf17c7390565b617a69460361110c57506101a590565b50600090565b6060610d928484600085611153565b600081831061113d57600082815260208490526040902061114c565b60008381526020839052604090205b9392505050565b6060824710156111cb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016105c3565b600080866001600160a01b031685876040516111e79190611864565b60006040518083038185875af1925050503d8060008114611224576040519150601f19603f3d011682016040523d82523d6000602084013e611229565b606091505b509150915061123a87838387611245565b979650505050505050565b606083156112b45782516000036112ad576001600160a01b0385163b6112ad5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016105c3565b5081610d92565b610d9283838151156112c95781518083602001fd5b8060405162461bcd60e51b81526004016105c39190611517565b634e487b7160e01b600052604160045260246000fd5b6000806000806080858703121561130f57600080fd5b843593506020850135925060408501359150606085013567ffffffffffffffff8082111561133c57600080fd5b818701915087601f83011261135057600080fd5b813581811115611362576113626112e3565b604051601f8201601f19908116603f0116810190838211818310171561138a5761138a6112e3565b816040528281528a60208487010111156113a357600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b80356001600160a01b03811681146113de57600080fd5b919050565b600080604083850312156113f657600080fd5b82359150611406602084016113c7565b90509250929050565b60006020828403121561142157600080fd5b5035919050565b60008083601f84011261143a57600080fd5b50813567ffffffffffffffff81111561145257600080fd5b6020830191508360208260051b850101111561146d57600080fd5b9250929050565b6000806000806060858703121561148a57600080fd5b8435935060208501359250604085013567ffffffffffffffff8111156114af57600080fd5b6114bb87828801611428565b95989497509550505050565b60005b838110156114e25781810151838201526020016114ca565b50506000910152565b600081518084526115038160208601602086016114c7565b601f01601f19169290920160200192915050565b60208152600061114c60208301846114eb565b60006020828403121561153c57600080fd5b61114c826113c7565b6000806000806000806060878903121561155e57600080fd5b863567ffffffffffffffff8082111561157657600080fd5b6115828a838b01611428565b9098509650602089013591508082111561159b57600080fd5b6115a78a838b01611428565b909650945060408901359150808211156115c057600080fd5b506115cd89828a01611428565b979a9699509497509295939492505050565b600181811c908216806115f357607f821691505b60208210810361161357634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115610c88576000816000526020600020601f850160051c810160208610156116425750805b601f850160051c820191505b818110156116615782815560010161164e565b505050505050565b815167ffffffffffffffff811115611683576116836112e3565b6116978161169184546115df565b84611619565b602080601f8311600181146116cc57600084156116b45750858301515b600019600386901b1c1916600185901b178555611661565b600085815260208120601f198616915b828110156116fb578886015182559484019460019091019084016116dc565b50858210156117195787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b83815282602082015260606040820152600061174860608301846114eb565b95945050505050565b60006020828403121561176357600080fd5b5051919050565b634e487b7160e01b600052603260045260246000fd5b6000808335601e1984360301811261179757600080fd5b83018035915067ffffffffffffffff8211156117b257600080fd5b6020019150600581901b360382131561146d57600080fd5b80820180821115610d7a57634e487b7160e01b600052601160045260246000fd5b6040815282604082015260007f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff84111561182457600080fd5b8360051b808660608501376020830193909352500160600192915050565b60006020828403121561185457600080fd5b8151801515811461114c57600080fd5b600082516118768184602087016114c7565b919091019291505056fea26469706673582212205e440e839071cdd2e5336af7bd232a553cd7e5f2a609f2b0e710c4aaff0b4ef364736f6c63430008170033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000000000000000f7e000644657dc9417b185962645a00000000000000000000000034f4911911a0883856e8d15e99fda2d8e0fdbf60000000000000000000000000e72dfec45ccc0b5571d659cb8b482523c45439db
-----Decoded View---------------
Arg [0] : _rewardToken (address): 0x00000000000f7e000644657dC9417b185962645a
Arg [1] : _owner (address): 0x34F4911911a0883856E8D15E99fda2d8E0FDBF60
Arg [2] : _manager (address): 0xE72DfEC45cCc0B5571D659Cb8B482523C45439dB
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 00000000000000000000000000000000000f7e000644657dc9417b185962645a
Arg [1] : 00000000000000000000000034f4911911a0883856e8d15e99fda2d8e0fdbf60
Arg [2] : 000000000000000000000000e72dfec45ccc0b5571d659cb8b482523c45439db
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.