More Info
Private Name Tags
ContractCreator
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
0xb96c91257b3980336d29a772048d390c3457bb9311d20c24891be25da74f7e4d | Deposit ETH For | (pending) | 5 days ago | IN | 0.0010148756 ETH | (Pending) | |||
Withdraw | 21854244 | 16 mins ago | IN | 0 ETH | 0.00005317 | ||||
Deposit For | 21854160 | 32 mins ago | IN | 0 ETH | 0.00006574 | ||||
Withdraw | 21854079 | 49 mins ago | IN | 0 ETH | 0.0000922 | ||||
Withdraw | 21853972 | 1 hr ago | IN | 0 ETH | 0.00006171 | ||||
Withdraw | 21853727 | 2 hrs ago | IN | 0 ETH | 0.00006536 | ||||
Withdraw | 21853712 | 2 hrs ago | IN | 0 ETH | 0.00009435 | ||||
Withdraw | 21853710 | 2 hrs ago | IN | 0 ETH | 0.00007112 | ||||
Withdraw | 21853708 | 2 hrs ago | IN | 0 ETH | 0.00008814 | ||||
Withdraw | 21853706 | 2 hrs ago | IN | 0 ETH | 0.00008691 | ||||
Deposit ETH For | 21853328 | 3 hrs ago | IN | 1 ETH | 0.00010292 | ||||
Deposit For | 21853325 | 3 hrs ago | IN | 0 ETH | 0.00006743 | ||||
Withdraw | 21853319 | 3 hrs ago | IN | 0 ETH | 0.00003366 | ||||
Deposit For | 21853318 | 3 hrs ago | IN | 0 ETH | 0.00006852 | ||||
Withdraw | 21853292 | 3 hrs ago | IN | 0 ETH | 0.00009934 | ||||
Withdraw | 21853218 | 3 hrs ago | IN | 0 ETH | 0.00006775 | ||||
Withdraw | 21853215 | 3 hrs ago | IN | 0 ETH | 0.00006968 | ||||
Withdraw | 21853112 | 4 hrs ago | IN | 0 ETH | 0.00006073 | ||||
Withdraw | 21853060 | 4 hrs ago | IN | 0 ETH | 0.00009194 | ||||
Deposit For | 21852909 | 4 hrs ago | IN | 0 ETH | 0.00007698 | ||||
Withdraw | 21852843 | 4 hrs ago | IN | 0 ETH | 0.00006165 | ||||
Withdraw | 21852793 | 5 hrs ago | IN | 0 ETH | 0.00007562 | ||||
Deposit For | 21852779 | 5 hrs ago | IN | 0 ETH | 0.00007517 | ||||
Deposit For | 21852771 | 5 hrs ago | IN | 0 ETH | 0.00006624 | ||||
Withdraw | 21852742 | 5 hrs ago | IN | 0 ETH | 0.00005558 |
Latest 25 internal transactions (View All)
Advanced mode:
Parent Transaction Hash | Block |
From
|
To
|
|||
---|---|---|---|---|---|---|
21853328 | 3 hrs ago | 1 ETH | ||||
21852532 | 6 hrs ago | 0.00001 ETH | ||||
21852187 | 7 hrs ago | 0.00684602 ETH | ||||
21851938 | 8 hrs ago | 0.0001 ETH | ||||
21851720 | 8 hrs ago | 0.00001 ETH | ||||
21851214 | 10 hrs ago | 0.00001 ETH | ||||
21849749 | 15 hrs ago | 0.01054 ETH | ||||
21849709 | 15 hrs ago | 0.01091 ETH | ||||
21849220 | 17 hrs ago | 0.0005 ETH | ||||
21840642 | 46 hrs ago | 0.0001 ETH | ||||
21832361 | 3 days ago | 0.00019827 ETH | ||||
21831368 | 3 days ago | 0.001 ETH | ||||
21830377 | 3 days ago | 0.0001 ETH | ||||
21830359 | 3 days ago | 0.006 ETH | ||||
21829457 | 3 days ago | 0.8 ETH | ||||
21827092 | 3 days ago | 0.0001 ETH | ||||
21826388 | 3 days ago | 0.0001 ETH | ||||
21824443 | 4 days ago | 0.0002 ETH | ||||
21824396 | 4 days ago | 0.001 ETH | ||||
21823221 | 4 days ago | 0.000001 ETH | ||||
21821568 | 4 days ago | 0.009602 ETH | ||||
21818983 | 4 days ago | 0.00001 ETH | ||||
21814727 | 5 days ago | 0.0010187 ETH | ||||
21814496 | 5 days ago | 0.009804 ETH | ||||
21811081 | 6 days ago | 0.00000003 ETH |
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
ZtakingPool
Compiler Version
v0.8.24+commit.e11b9ed9
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.24; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {Ownable2Step} from "@openzeppelin/contracts/access/Ownable2Step.sol"; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; import {SignatureChecker} from "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol"; import {Pausable} from "@openzeppelin/contracts/utils/Pausable.sol"; import {EIP712} from "@openzeppelin/contracts/utils/cryptography/EIP712.sol"; import {Nonces} from "@openzeppelin/contracts/utils/Nonces.sol"; import "./interface/IWETH.sol"; import "./interface/IMigrator.sol"; import "./interface/IZtakingPool.sol"; /// @title Ztaking Pool /// @notice A staking pool for liquid restaking token holders which rewards stakers with points from multiple platforms contract ZtakingPool is IZtakingPool, Ownable2Step, Pausable, EIP712, Nonces { using SafeERC20 for IERC20; bytes32 private constant MIGRATE_TYPEHASH = keccak256("Migrate(address user,address migratorContract,address destination,address[] tokens,uint256 signatureExpiry,uint256 nonce)"); // (tokenAddress => isAllowedForStaking) mapping(address => bool) public tokenAllowlist; // (tokenAddress => stakerAddress => stakedAmount) mapping(address => mapping(address => uint256)) public balance; // (migratorContract => isBlocklisted) mapping(address => bool) public migratorBlocklist; // Next eventId to emit uint256 private eventId; // Required signer for the migration message address public zircuitSigner; // ETH's special address address immutable WETH_ADDRESS; constructor(address _signer, address[] memory _tokensAllowed, address _weth) Ownable(msg.sender) EIP712("ZtakingPool", "1"){ if (_signer == address(0)) revert SignerCannotBeZeroAddress(); if (_weth == address(0)) revert WETHCannotBeZeroAddress(); WETH_ADDRESS = _weth; zircuitSigner = _signer; uint256 length = _tokensAllowed.length; for(uint256 i; i < length; ++i){ if (_tokensAllowed[i] == address(0)) revert TokenCannotBeZeroAddress(); tokenAllowlist[_tokensAllowed[i]] = true; } } /*////////////////////////////////////////////////////////////// Staker Functions //////////////////////////////////////////////////////////////*/ /** * @inheritdoc IZtakingPool */ function depositFor(address _token, address _for, uint256 _amount) whenNotPaused external { if (_amount == 0) revert DepositAmountCannotBeZero(); if (_for== address(0)) revert CannotDepositForZeroAddress(); if (!tokenAllowlist[_token]) revert TokenNotAllowedForStaking(); balance[_token][_for] += _amount; emit Deposit(++eventId, _for, _token, _amount); IERC20(_token).safeTransferFrom(msg.sender, address(this), _amount); } function depositETHFor(address _for) whenNotPaused payable external { if (msg.value == 0) revert DepositAmountCannotBeZero(); if (_for== address(0)) revert CannotDepositForZeroAddress(); if (!tokenAllowlist[WETH_ADDRESS]) revert TokenNotAllowedForStaking(); balance[WETH_ADDRESS][_for] += msg.value; emit Deposit(++eventId, _for, WETH_ADDRESS, msg.value); IWETH(WETH_ADDRESS).deposit{value:msg.value}(); } /** * @inheritdoc IZtakingPool */ function withdraw(address _token, uint256 _amount) external { if (_amount == 0) revert WithdrawAmountCannotBeZero(); balance[_token][msg.sender] -= _amount; //Will underfow if the staker has insufficient balance emit Withdraw(++eventId, msg.sender, _token, _amount); IERC20(_token).safeTransfer(msg.sender, _amount); } /** * @inheritdoc IZtakingPool */ function migrateWithSig( address _user, address[] calldata _tokens, address _migratorContract, address _destination, uint256 _signatureExpiry, bytes memory _stakerSignature ) onlyOwner external{ { bytes32 structHash = keccak256(abi.encode( MIGRATE_TYPEHASH, _user, _migratorContract, _destination, //The array values are encoded as the keccak256 hash of the concatenated encodeData of their contents //Ref: https://eips.ethereum.org/EIPS/eip-712#definition-of-encodedata keccak256(abi.encodePacked(_tokens)), _signatureExpiry, _useNonce(_user) )); bytes32 constructedHash = _hashTypedDataV4(structHash); if (!SignatureChecker.isValidSignatureNow(_user, constructedHash, _stakerSignature)){ revert SignatureInvalid(); } } uint256[] memory _amounts = _migrateChecks(_user, _tokens, _signatureExpiry, _migratorContract); _migrate(_user, _destination, _migratorContract, _tokens, _amounts); } /** * @inheritdoc IZtakingPool */ function migrate( address[] calldata _tokens, address _migratorContract, address _destination, uint256 _signatureExpiry, bytes calldata _authorizationSignatureFromZircuit ) external { uint256[] memory _amounts = _migrateChecks(msg.sender, _tokens, _signatureExpiry, _migratorContract); bytes32 constructedHash = keccak256( abi.encodePacked( '\x19Ethereum Signed Message:\n32', keccak256( abi.encodePacked( _migratorContract, _signatureExpiry, address(this), block.chainid ) ) ) ); // verify that the migrator’s address is signed in the authorization signature by the correct signer (zircuitSigner) if (!SignatureChecker.isValidSignatureNow(zircuitSigner, constructedHash, _authorizationSignatureFromZircuit)){ revert SignatureInvalid(); } _migrate(msg.sender, _destination, _migratorContract, _tokens, _amounts); } function _migrateChecks(address _user, address[] calldata _tokens, uint256 _signatureExpiry, address _migratorContract) internal view returns (uint256[] memory _amounts){ uint256 length = _tokens.length; if (length == 0) revert TokenArrayCannotBeEmpty(); _amounts = new uint256[](length); for(uint256 i; i < length; ++i){ _amounts[i] = balance[_tokens[i]][_user]; if (_amounts[i] == 0) revert UserDoesNotHaveStake(); } if (block.timestamp >= _signatureExpiry) revert SignatureExpired();// allows us to invalidate signature by having it expired if (migratorBlocklist[_migratorContract]) revert MigratorBlocked(); } function _migrate( address _user, address _destination, address _migratorContract, address[] calldata _tokens, uint256[] memory _amounts) internal { uint256 length = _tokens.length; //effects for-loop (state changes) for(uint256 i; i < length; ++i){ //if the balance has been already set to zero, then _tokens[i] is a duplicate of a previous token in the array if (balance[_tokens[i]][_user] == 0) revert DuplicateToken(); balance[_tokens[i]][_user] = 0; } emit Migrate (++eventId, _user, _tokens, _destination, _migratorContract, _amounts); //interactions for-loop (external calls) for(uint256 i; i < length; ++i){ IERC20(_tokens[i]).approve(_migratorContract, _amounts[i]); } IMigrator(_migratorContract).migrate(_user, _tokens, _destination, _amounts); } /*////////////////////////////////////////////////////////////// Admin Functions //////////////////////////////////////////////////////////////*/ /** * @inheritdoc IZtakingPool */ function setZircuitSigner(address _signer) external onlyOwner { if (_signer == address(0)) revert SignerCannotBeZeroAddress(); if (_signer == zircuitSigner) revert SignerAlreadySetToAddress(); zircuitSigner = _signer; emit SignerChanged(_signer); } /** * @inheritdoc IZtakingPool */ function setStakable(address _token, bool _canStake) external onlyOwner { if (_token == address(0)) revert TokenCannotBeZeroAddress(); if (tokenAllowlist[_token] == _canStake) revert TokenAlreadyConfiguredWithState(); tokenAllowlist[_token] = _canStake; emit TokenStakabilityChanged(_token, _canStake); } /** * @inheritdoc IZtakingPool */ function blockMigrator(address _migrator, bool _blocklisted) external onlyOwner { if (_migrator == address(0)) revert MigratorCannotBeZeroAddress(); if (migratorBlocklist[_migrator] == _blocklisted) revert MigratorAlreadyAllowedOrBlocked(); migratorBlocklist[_migrator] = _blocklisted; emit BlocklistChanged(_migrator, _blocklisted); } /** * @inheritdoc IZtakingPool */ function pause() external onlyOwner whenNotPaused { _pause(); } /** * @inheritdoc IZtakingPool */ function unpause() external onlyOwner whenPaused{ _unpause(); } function renounceOwnership() public override{ revert CannotRenounceOwnership(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol) pragma solidity ^0.8.20; import {Context} from "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * The initial owner is set to the address provided by the deployer. This can * later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; /** * @dev The caller account is not authorized to perform an operation. */ error OwnableUnauthorizedAccount(address account); /** * @dev The owner is not a valid owner account. (eg. `address(0)`) */ error OwnableInvalidOwner(address owner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the address provided by the deployer as the initial owner. */ constructor(address initialOwner) { if (initialOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(initialOwner); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { if (owner() != _msgSender()) { revert OwnableUnauthorizedAccount(_msgSender()); } } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { if (newOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable2Step.sol) pragma solidity ^0.8.20; import {Ownable} from "./Ownable.sol"; /** * @dev Contract module which provides access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * The initial owner is specified at deployment time in the constructor for `Ownable`. This * can later be changed with {transferOwnership} and {acceptOwnership}. * * This module is used through inheritance. It will make available all functions * from parent (Ownable). */ abstract contract Ownable2Step is Ownable { address private _pendingOwner; event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner); /** * @dev Returns the address of the pending owner. */ function pendingOwner() public view virtual returns (address) { return _pendingOwner; } /** * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual override onlyOwner { _pendingOwner = newOwner; emit OwnershipTransferStarted(owner(), newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner. * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual override { delete _pendingOwner; super._transferOwnership(newOwner); } /** * @dev The new owner accepts the ownership transfer. */ function acceptOwnership() public virtual { address sender = _msgSender(); if (pendingOwner() != sender) { revert OwnableUnauthorizedAccount(sender); } _transferOwnership(sender); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC1271.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC1271 standard signature validation method for * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271]. */ interface IERC1271 { /** * @dev Should return whether the signature provided is valid for the provided data * @param hash Hash of the data to be signed * @param signature Signature byte array associated with _data */ function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5267.sol) pragma solidity ^0.8.20; interface IERC5267 { /** * @dev MAY be emitted to signal that the domain could have changed. */ event EIP712DomainChanged(); /** * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712 * signature. */ function eip712Domain() external view returns ( bytes1 fields, string memory name, string memory version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] memory extensions ); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * ==== Security Considerations * * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be * considered as an intention to spend the allowance in any specific way. The second is that because permits have * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be * generally recommended is: * * ```solidity * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public { * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {} * doThing(..., value); * } * * function doThing(..., uint256 value) public { * token.safeTransferFrom(msg.sender, address(this), value); * ... * } * ``` * * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also * {SafeERC20-safeTransferFrom}). * * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so * contracts should have entry points that don't rely on permit. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. * * CAUTION: See Security Considerations above. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the value of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the value of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves a `value` amount of tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 value) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets a `value` amount of tokens as the allowance of `spender` over the * caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the * allowance mechanism. `value` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 value) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; import {IERC20Permit} from "../extensions/IERC20Permit.sol"; import {Address} from "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; /** * @dev An operation with an ERC20 token failed. */ error SafeERC20FailedOperation(address token); /** * @dev Indicates a failed `decreaseAllowance` request. */ error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease); /** * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value))); } /** * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful. */ function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value))); } /** * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); forceApprove(token, spender, oldAllowance + value); } /** * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no * value, non-reverting calls are assumed to be successful. */ function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal { unchecked { uint256 currentAllowance = token.allowance(address(this), spender); if (currentAllowance < requestedDecrease) { revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease); } forceApprove(token, spender, currentAllowance - requestedDecrease); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval * to be set to zero before setting it to a non-zero value, such as USDT. */ function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value)); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0))); _callOptionalReturn(token, approvalCall); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data); if (returndata.length != 0 && !abi.decode(returndata, (bool))) { revert SafeERC20FailedOperation(address(token)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). * * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false // and not revert is the subcall reverts. (bool success, bytes memory returndata) = address(token).call(data); return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol) pragma solidity ^0.8.20; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev The ETH balance of the account is not enough to perform the operation. */ error AddressInsufficientBalance(address account); /** * @dev There's no code at `target` (it is not a contract). */ error AddressEmptyCode(address target); /** * @dev A call to an address target failed. The target may have reverted. */ error FailedInnerCall(); /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { if (address(this).balance < amount) { revert AddressInsufficientBalance(address(this)); } (bool success, ) = recipient.call{value: amount}(""); if (!success) { revert FailedInnerCall(); } } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason or custom error, it is bubbled * up by this function (like regular Solidity function calls). However, if * the call reverted with no returned reason, this function reverts with a * {FailedInnerCall} error. * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { if (address(this).balance < value) { revert AddressInsufficientBalance(address(this)); } (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an * unsuccessful call. */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata ) internal view returns (bytes memory) { if (!success) { _revert(returndata); } else { // only check if target is a contract if the call was successful and the return data is empty // otherwise we already know that it was a contract if (returndata.length == 0 && target.code.length == 0) { revert AddressEmptyCode(target); } return returndata; } } /** * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the * revert reason or with a default {FailedInnerCall} error. */ function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) { if (!success) { _revert(returndata); } else { return returndata; } } /** * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}. */ function _revert(bytes memory returndata) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert FailedInnerCall(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol) pragma solidity ^0.8.20; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.20; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS } /** * @dev The signature derives the `address(0)`. */ error ECDSAInvalidSignature(); /** * @dev The signature has an invalid length. */ error ECDSAInvalidSignatureLength(uint256 length); /** * @dev The signature has an S value that is in the upper half order. */ error ECDSAInvalidSignatureS(bytes32 s); /** * @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not * return address(0) without also returning an error description. Errors are documented using an enum (error type) * and a bytes32 providing additional information about the error. * * If no error is returned, then the address can be used for verification purposes. * * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError, bytes32) { if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. /// @solidity memory-safe-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else { return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length)); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature); _throwError(error, errorArg); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] */ function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError, bytes32) { unchecked { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); // We do not check for an overflow here since the shift operation results in 0 or 1. uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); } } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. */ function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) { (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs); _throwError(error, errorArg); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError, bytes32) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS, s); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature, bytes32(0)); } return (signer, RecoverError.NoError, bytes32(0)); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) { (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s); _throwError(error, errorArg); return recovered; } /** * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided. */ function _throwError(RecoverError error, bytes32 errorArg) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert ECDSAInvalidSignature(); } else if (error == RecoverError.InvalidSignatureLength) { revert ECDSAInvalidSignatureLength(uint256(errorArg)); } else if (error == RecoverError.InvalidSignatureS) { revert ECDSAInvalidSignatureS(errorArg); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/EIP712.sol) pragma solidity ^0.8.20; import {MessageHashUtils} from "./MessageHashUtils.sol"; import {ShortStrings, ShortString} from "../ShortStrings.sol"; import {IERC5267} from "../../interfaces/IERC5267.sol"; /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding scheme specified in the EIP requires a domain separator and a hash of the typed structured data, whose * encoding is very generic and therefore its implementation in Solidity is not feasible, thus this contract * does not implement the encoding itself. Protocols need to implement the type-specific encoding they need in order to * produce the hash of their typed data using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain * separator of the implementation contract. This will cause the {_domainSeparatorV4} function to always rebuild the * separator from the immutable values, which is cheaper than accessing a cached version in cold storage. * * @custom:oz-upgrades-unsafe-allow state-variable-immutable */ abstract contract EIP712 is IERC5267 { using ShortStrings for *; bytes32 private constant TYPE_HASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"); // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to // invalidate the cached domain separator if the chain id changes. bytes32 private immutable _cachedDomainSeparator; uint256 private immutable _cachedChainId; address private immutable _cachedThis; bytes32 private immutable _hashedName; bytes32 private immutable _hashedVersion; ShortString private immutable _name; ShortString private immutable _version; string private _nameFallback; string private _versionFallback; /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ constructor(string memory name, string memory version) { _name = name.toShortStringWithFallback(_nameFallback); _version = version.toShortStringWithFallback(_versionFallback); _hashedName = keccak256(bytes(name)); _hashedVersion = keccak256(bytes(version)); _cachedChainId = block.chainid; _cachedDomainSeparator = _buildDomainSeparator(); _cachedThis = address(this); } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view returns (bytes32) { if (address(this) == _cachedThis && block.chainid == _cachedChainId) { return _cachedDomainSeparator; } else { return _buildDomainSeparator(); } } function _buildDomainSeparator() private view returns (bytes32) { return keccak256(abi.encode(TYPE_HASH, _hashedName, _hashedVersion, block.chainid, address(this))); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return MessageHashUtils.toTypedDataHash(_domainSeparatorV4(), structHash); } /** * @dev See {IERC-5267}. */ function eip712Domain() public view virtual returns ( bytes1 fields, string memory name, string memory version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] memory extensions ) { return ( hex"0f", // 01111 _EIP712Name(), _EIP712Version(), block.chainid, address(this), bytes32(0), new uint256[](0) ); } /** * @dev The name parameter for the EIP712 domain. * * NOTE: By default this function reads _name which is an immutable value. * It only reads from storage if necessary (in case the value is too large to fit in a ShortString). */ // solhint-disable-next-line func-name-mixedcase function _EIP712Name() internal view returns (string memory) { return _name.toStringWithFallback(_nameFallback); } /** * @dev The version parameter for the EIP712 domain. * * NOTE: By default this function reads _version which is an immutable value. * It only reads from storage if necessary (in case the value is too large to fit in a ShortString). */ // solhint-disable-next-line func-name-mixedcase function _EIP712Version() internal view returns (string memory) { return _version.toStringWithFallback(_versionFallback); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MessageHashUtils.sol) pragma solidity ^0.8.20; import {Strings} from "../Strings.sol"; /** * @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing. * * The library provides methods for generating a hash of a message that conforms to the * https://eips.ethereum.org/EIPS/eip-191[EIP 191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712] * specifications. */ library MessageHashUtils { /** * @dev Returns the keccak256 digest of an EIP-191 signed data with version * `0x45` (`personal_sign` messages). * * The digest is calculated by prefixing a bytes32 `messageHash` with * `"\x19Ethereum Signed Message:\n32"` and hashing the result. It corresponds with the * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method. * * NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with * keccak256, although any bytes32 value can be safely used because the final digest will * be re-hashed. * * See {ECDSA-recover}. */ function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) { /// @solidity memory-safe-assembly assembly { mstore(0x00, "\x19Ethereum Signed Message:\n32") // 32 is the bytes-length of messageHash mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20) } } /** * @dev Returns the keccak256 digest of an EIP-191 signed data with version * `0x45` (`personal_sign` messages). * * The digest is calculated by prefixing an arbitrary `message` with * `"\x19Ethereum Signed Message:\n" + len(message)` and hashing the result. It corresponds with the * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method. * * See {ECDSA-recover}. */ function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) { return keccak256(bytes.concat("\x19Ethereum Signed Message:\n", bytes(Strings.toString(message.length)), message)); } /** * @dev Returns the keccak256 digest of an EIP-191 signed data with version * `0x00` (data with intended validator). * * The digest is calculated by prefixing an arbitrary `data` with `"\x19\x00"` and the intended * `validator` address. Then hashing the result. * * See {ECDSA-recover}. */ function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) { return keccak256(abi.encodePacked(hex"19_00", validator, data)); } /** * @dev Returns the keccak256 digest of an EIP-712 typed data (EIP-191 version `0x01`). * * The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with * `\x19\x01` and hashing the result. It corresponds to the hash signed by the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712. * * See {ECDSA-recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) { /// @solidity memory-safe-assembly assembly { let ptr := mload(0x40) mstore(ptr, hex"19_01") mstore(add(ptr, 0x02), domainSeparator) mstore(add(ptr, 0x22), structHash) digest := keccak256(ptr, 0x42) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/SignatureChecker.sol) pragma solidity ^0.8.20; import {ECDSA} from "./ECDSA.sol"; import {IERC1271} from "../../interfaces/IERC1271.sol"; /** * @dev Signature verification helper that can be used instead of `ECDSA.recover` to seamlessly support both ECDSA * signatures from externally owned accounts (EOAs) as well as ERC1271 signatures from smart contract wallets like * Argent and Safe Wallet (previously Gnosis Safe). */ library SignatureChecker { /** * @dev Checks if a signature is valid for a given signer and data hash. If the signer is a smart contract, the * signature is validated against that smart contract using ERC1271, otherwise it's validated using `ECDSA.recover`. * * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus * change through time. It could return true at block N and false at block N+1 (or the opposite). */ function isValidSignatureNow(address signer, bytes32 hash, bytes memory signature) internal view returns (bool) { (address recovered, ECDSA.RecoverError error, ) = ECDSA.tryRecover(hash, signature); return (error == ECDSA.RecoverError.NoError && recovered == signer) || isValidERC1271SignatureNow(signer, hash, signature); } /** * @dev Checks if a signature is valid for a given signer and data hash. The signature is validated * against the signer smart contract using ERC1271. * * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus * change through time. It could return true at block N and false at block N+1 (or the opposite). */ function isValidERC1271SignatureNow( address signer, bytes32 hash, bytes memory signature ) internal view returns (bool) { (bool success, bytes memory result) = signer.staticcall( abi.encodeCall(IERC1271.isValidSignature, (hash, signature)) ); return (success && result.length >= 32 && abi.decode(result, (bytes32)) == bytes32(IERC1271.isValidSignature.selector)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol) pragma solidity ^0.8.20; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Muldiv operation overflow. */ error MathOverflowedMulDiv(); enum Rounding { Floor, // Toward negative infinity Ceil, // Toward positive infinity Trunc, // Toward zero Expand // Away from zero } /** * @dev Returns the addition of two unsigned integers, with an overflow flag. */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds towards infinity instead * of rounding towards zero. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { if (b == 0) { // Guarantee the same behavior as in a regular Solidity division. return a / b; } // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or * denominator == 0. * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by * Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0 = x * y; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. if (denominator <= prod1) { revert MathOverflowedMulDiv(); } /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. // Always >= 1. See https://cs.stackexchange.com/q/138556/92363. uint256 twos = denominator & (0 - denominator); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also // works in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded * towards zero. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256 of a positive value rounded towards zero. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0); } } /** * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers. */ function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) { return uint8(rounding) % 2 == 1; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.20; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMath { /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return a > b ? a : b; } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return a < b ? a : b; } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // must be unchecked in order to support `n = type(int256).min` return uint256(n >= 0 ? n : -n); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Nonces.sol) pragma solidity ^0.8.20; /** * @dev Provides tracking nonces for addresses. Nonces will only increment. */ abstract contract Nonces { /** * @dev The nonce used for an `account` is not the expected current nonce. */ error InvalidAccountNonce(address account, uint256 currentNonce); mapping(address account => uint256) private _nonces; /** * @dev Returns the next unused nonce for an address. */ function nonces(address owner) public view virtual returns (uint256) { return _nonces[owner]; } /** * @dev Consumes a nonce. * * Returns the current value and increments nonce. */ function _useNonce(address owner) internal virtual returns (uint256) { // For each account, the nonce has an initial value of 0, can only be incremented by one, and cannot be // decremented or reset. This guarantees that the nonce never overflows. unchecked { // It is important to do x++ and not ++x here. return _nonces[owner]++; } } /** * @dev Same as {_useNonce} but checking that `nonce` is the next valid for `owner`. */ function _useCheckedNonce(address owner, uint256 nonce) internal virtual { uint256 current = _useNonce(owner); if (nonce != current) { revert InvalidAccountNonce(owner, current); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol) pragma solidity ^0.8.20; import {Context} from "../utils/Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { bool private _paused; /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); /** * @dev The operation failed because the contract is paused. */ error EnforcedPause(); /** * @dev The operation failed because the contract is not paused. */ error ExpectedPause(); /** * @dev Initializes the contract in unpaused state. */ constructor() { _paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { if (paused()) { revert EnforcedPause(); } } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { if (!paused()) { revert ExpectedPause(); } } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/ShortStrings.sol) pragma solidity ^0.8.20; import {StorageSlot} from "./StorageSlot.sol"; // | string | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA | // | length | 0x BB | type ShortString is bytes32; /** * @dev This library provides functions to convert short memory strings * into a `ShortString` type that can be used as an immutable variable. * * Strings of arbitrary length can be optimized using this library if * they are short enough (up to 31 bytes) by packing them with their * length (1 byte) in a single EVM word (32 bytes). Additionally, a * fallback mechanism can be used for every other case. * * Usage example: * * ```solidity * contract Named { * using ShortStrings for *; * * ShortString private immutable _name; * string private _nameFallback; * * constructor(string memory contractName) { * _name = contractName.toShortStringWithFallback(_nameFallback); * } * * function name() external view returns (string memory) { * return _name.toStringWithFallback(_nameFallback); * } * } * ``` */ library ShortStrings { // Used as an identifier for strings longer than 31 bytes. bytes32 private constant FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF; error StringTooLong(string str); error InvalidShortString(); /** * @dev Encode a string of at most 31 chars into a `ShortString`. * * This will trigger a `StringTooLong` error is the input string is too long. */ function toShortString(string memory str) internal pure returns (ShortString) { bytes memory bstr = bytes(str); if (bstr.length > 31) { revert StringTooLong(str); } return ShortString.wrap(bytes32(uint256(bytes32(bstr)) | bstr.length)); } /** * @dev Decode a `ShortString` back to a "normal" string. */ function toString(ShortString sstr) internal pure returns (string memory) { uint256 len = byteLength(sstr); // using `new string(len)` would work locally but is not memory safe. string memory str = new string(32); /// @solidity memory-safe-assembly assembly { mstore(str, len) mstore(add(str, 0x20), sstr) } return str; } /** * @dev Return the length of a `ShortString`. */ function byteLength(ShortString sstr) internal pure returns (uint256) { uint256 result = uint256(ShortString.unwrap(sstr)) & 0xFF; if (result > 31) { revert InvalidShortString(); } return result; } /** * @dev Encode a string into a `ShortString`, or write it to storage if it is too long. */ function toShortStringWithFallback(string memory value, string storage store) internal returns (ShortString) { if (bytes(value).length < 32) { return toShortString(value); } else { StorageSlot.getStringSlot(store).value = value; return ShortString.wrap(FALLBACK_SENTINEL); } } /** * @dev Decode a string that was encoded to `ShortString` or written to storage using {setWithFallback}. */ function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory) { if (ShortString.unwrap(value) != FALLBACK_SENTINEL) { return toString(value); } else { return store; } } /** * @dev Return the length of a string that was encoded to `ShortString` or written to storage using * {setWithFallback}. * * WARNING: This will return the "byte length" of the string. This may not reflect the actual length in terms of * actual characters as the UTF-8 encoding of a single character can span over multiple bytes. */ function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) { if (ShortString.unwrap(value) != FALLBACK_SENTINEL) { return byteLength(value); } else { return bytes(store).length; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol) // This file was procedurally generated from scripts/generate/templates/StorageSlot.js. pragma solidity ^0.8.20; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ```solidity * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(newImplementation.code.length > 0); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } struct StringSlot { string value; } struct BytesSlot { bytes value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `StringSlot` with member `value` located at `slot`. */ function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `StringSlot` representation of the string storage pointer `store`. */ function getStringSlot(string storage store) internal pure returns (StringSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } /** * @dev Returns an `BytesSlot` with member `value` located at `slot`. */ function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`. */ function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol) pragma solidity ^0.8.20; import {Math} from "./math/Math.sol"; import {SignedMath} from "./math/SignedMath.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant HEX_DIGITS = "0123456789abcdef"; uint8 private constant ADDRESS_LENGTH = 20; /** * @dev The `value` string doesn't fit in the specified `length`. */ error StringsInsufficientHexLength(uint256 value, uint256 length); /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), HEX_DIGITS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `int256` to its ASCII `string` decimal representation. */ function toStringSigned(int256 value) internal pure returns (string memory) { return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value))); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { uint256 localValue = value; bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = HEX_DIGITS[localValue & 0xf]; localValue >>= 4; } if (localValue != 0) { revert StringsInsufficientHexLength(value, length); } return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal * representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH); } /** * @dev Returns true if the two strings are equal. */ function equal(string memory a, string memory b) internal pure returns (bool) { return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b)); } }
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.24; /// @title Migrator Interface /// @notice Interface for the Migrator contract called by the Ztaking Pool's migrate() function interface IMigrator { ///@notice Function called by the Ztaking Pool to facilitate migration of staked tokens from the Ztaking Pool to Zircuit ///@param _user The address of the user whose staked funds are being migrated to Zircuit ///@param _tokens The tokens being migrated to Zircuit from the Ztaking Pool ///@param _destination The address which will be credited the tokens on Zircuit ///@param _amounts The amounts of each token to be migrated to Zircuit for the _user function migrate( address _user, address[] calldata _tokens, address _destination, uint256[] calldata _amounts ) external; }
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.24; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IWETH is IERC20 { function deposit() external payable; }
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.24; /// @title Ztaking Pool Interface /// @notice An interface containing externally accessible functions of the ZtakingPool contract /// @dev The automatically generated public view functions for the state variables and mappings are not included in the interface interface IZtakingPool { /*////////////////////////////////////////////////////////////// Errors //////////////////////////////////////////////////////////////*/ error SignerCannotBeZeroAddress(); //Thrown when proposed signer is the zero address error SignerAlreadySetToAddress(); //Thrown when proposed signer is already set error SignatureInvalid(); // Thrown when the migration signature is invalid error SignatureExpired(); // Thrown when the migration signature has expired error TokenCannotBeZeroAddress(); // Thrown when the specified token is the zero address error WETHCannotBeZeroAddress(); // Thrown when the specified token is the zero address error TokenAlreadyConfiguredWithState(); //Thrown if the token as already been enabled or disabled error DepositAmountCannotBeZero(); // Thrown if staker attempts to call deposit() with zero amount error WithdrawAmountCannotBeZero(); //Thrown if staker attempts to call withdraw() with zero amount error TokenNotAllowedForStaking(); // Thrown if staker attempts to stake unsupported token (or token disabled for staking) error UserDoesNotHaveStake(); //Thrown if the staker is attempting to migrate with no stake error MigratorCannotBeZeroAddress(); //Thrown if the provided migrator is the zero address error MigratorAlreadyAllowedOrBlocked(); //Thrown if attempting to block a migrator which has already been blocked or attempting to allow a migrator which is already allowed error MigratorBlocked(); //Thrown if the provided migrator contract has been blacklisted. error CannotDepositForZeroAddress(); //Thrown if caller tries to deposit on behalf of the zero address error CannotRenounceOwnership(); //Thrown if the renounceOwnership() function is called error DuplicateToken(); //Thrown when there is a duplicate in the provided token address array error TokenArrayCannotBeEmpty(); //Thrown when the provided token address array is empty /*////////////////////////////////////////////////////////////// Staker Events //////////////////////////////////////////////////////////////*/ ///@notice Emitted when a staker deposits/stakes a supported token into the Ztaking Pool ///@param eventId The unique event Id associated with the Deposit event ///@param depositor The address of the depositer/staker transfering funds to the Ztaking Pool ///@param token The address of the token deposited/staked into the pool ///@param amount The amount of token deposited/staked into the pool event Deposit( uint256 indexed eventId, address indexed depositor, address indexed token, uint256 amount ); ///@notice Emitted when a staker withdraws a previously staked tokens from the Ztaking Pool ///@param eventId The unique event Id associated with the Withdraw event ///@param withdrawer The address of the staker withdrawing funds from the Ztaking Pool ///@param token The address of the token being withdrawn from the pool ///@param amount The amount of tokens withdrawn the pool event Withdraw(uint256 indexed eventId, address indexed withdrawer, address indexed token, uint256 amount); ///@notice Emitted when a staker migrates their tokens from the ZtakingPool to Zircuit. ///@param eventId The unique event Id associated with the Migrate event ///@param user The address of the staker migrating funds to Zircuit ///@param tokens The addresses of the tokens being being migrated from the ZtakingPool to Zircuit ///@param destination The address which the tokens will be transferred to on Zircuit ///@param migrator The address of the migrator contract which initially receives the migrated tokens ///@param amounts The amounts of each token migrated to Zircuit event Migrate( uint256 indexed eventId, address indexed user, address[] tokens, address destination, address migrator, uint256[] amounts ); /*////////////////////////////////////////////////////////////// Admin Events //////////////////////////////////////////////////////////////*/ ///@notice Emitted when the required signer for the migration signature is changed ///@param newSigner The address of the new signer which must sign the migration signature event SignerChanged(address newSigner); ///@notice Emitted when a token has been enabled or disabled for staking ///@param token The address of the token which has been enabled/disabled for staking ///@param enabled Is true if the token is being enabled and false if the token is being disabled event TokenStakabilityChanged(address token, bool enabled); ///@notice Emitted when a migrator has been added or removed from the blocklist ///@param migrator The address of the migrator which has been added or removed from the blocklist ///@param blocked Is true if the migrator was added to the blocklist, and false if it was removed from the blocklist event BlocklistChanged(address migrator, bool blocked); /*////////////////////////////////////////////////////////////// Staker Functions //////////////////////////////////////////////////////////////*/ ///@notice Stake a specified amount of a particular supported token into the Ztaking Pool ///@param _token The token to deposit/stake in the Ztaking Pool ///@param _for The user to deposit/stake on behalf of ///@param _amount The amount of token to deposit/stake into the Ztaking Pool function depositFor(address _token, address _for, uint256 _amount) external; ///@notice Stake a specified amount of ether into the Ztaking Pool ///@param _for The user to deposit/stake on behalf of ///@dev the amount deposited is specified by msg.value function depositETHFor(address _for) payable external; ///@notice Withdraw a specified amount of a particular supported token previously staked into the Ztaking Pool ///@param _token The token to withdraw from the Ztaking Pool ///@param _amount The amount of token to withdraw from the Ztaking Pool function withdraw(address _token, uint256 _amount) external; ///@notice Migrate the staked tokens for the caller from the Ztaking Pool to Zircuit ///@dev called by the staker ///@param _tokens The tokens to migrate to Zircuit from the Ztaking Pool ///@param _migratorContract The migrator contract which will initially receive the migrated tokens before moving them to Zircuit ///@param _destination The address which will receive the migrated tokens on Zircuit ///@param _signatureExpiry The timestamp at which the signature in _authorizationSignatureFromZircuit expires ///@param _authorizationSignatureFromZircuit The authorization signature which is signed by the zircuit signer and indicates the correct migrator contract function migrate( address[] calldata _tokens, address _migratorContract, address _destination, uint256 _signatureExpiry, bytes memory _authorizationSignatureFromZircuit ) external; ///@notice Migrate the staked tokens for the caller from the Ztaking Pool to Zircuit ///@param _user The staker to migrate tokens for ///@param _tokens The tokens to migrate to Zircuit from the Ztaking Pool ///@param _migratorContract The migrator contract which will initially receive the migrated tokens before moving them to Zircuit ///@param _destination The address which will receive the migrated tokens on Zircuit ///@param _signatureExpiry The timestamp at which the signature in _authorizationSignatureFromZircuit expires ///@param _stakerSignature The signature from the staker authorizing the migration of their tokens function migrateWithSig( address _user, address[] calldata _tokens, address _migratorContract, address _destination, uint256 _signatureExpiry, bytes memory _stakerSignature ) external; /*////////////////////////////////////////////////////////////// Admin Functions //////////////////////////////////////////////////////////////*/ ///@notice Set/Change the required signer for the migration signature (_authorizationSignatureFromZircuit in the migrate() function) ///@param _signer The address of the new signer for the migration signature ///@dev Only callable by the owner function setZircuitSigner(address _signer) external; ///@notice Enable or disable the specified token for staking ///@param _token The token to enable or disable for staking ///@param _canStake If true, then staking is to be enabled. If false, then staking will be disabled. ///@dev Only callable by the owner function setStakable(address _token, bool _canStake) external; ///@notice Add or remove the migrator to/from the blocklist, such that it can no longer be used from migrating tokens from the staking pool ///@param _migrator The migrator contract to add or remove from the blocklist ///@param _blocklisted If true, then add the migrator to the blocklist. If false, then remove the migrator from the blocklist. ///@dev Only callable by the owner function blockMigrator(address _migrator, bool _blocklisted) external; ///@notice Pause further staking through the deposit function. ///@dev Only callable by the owner. Withdrawals and migrations will still be possible when paused function pause() external; ///@notice Unpause staking allowing the deposit function to be used again ///@dev Only callable by the owner function unpause() external; }
{ "optimizer": { "enabled": true, "runs": 200 }, "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":"_signer","type":"address"},{"internalType":"address[]","name":"_tokensAllowed","type":"address[]"},{"internalType":"address","name":"_weth","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"CannotDepositForZeroAddress","type":"error"},{"inputs":[],"name":"CannotRenounceOwnership","type":"error"},{"inputs":[],"name":"DepositAmountCannotBeZero","type":"error"},{"inputs":[],"name":"DuplicateToken","type":"error"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"currentNonce","type":"uint256"}],"name":"InvalidAccountNonce","type":"error"},{"inputs":[],"name":"InvalidShortString","type":"error"},{"inputs":[],"name":"MigratorAlreadyAllowedOrBlocked","type":"error"},{"inputs":[],"name":"MigratorBlocked","type":"error"},{"inputs":[],"name":"MigratorCannotBeZeroAddress","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[],"name":"SignatureExpired","type":"error"},{"inputs":[],"name":"SignatureInvalid","type":"error"},{"inputs":[],"name":"SignerAlreadySetToAddress","type":"error"},{"inputs":[],"name":"SignerCannotBeZeroAddress","type":"error"},{"inputs":[{"internalType":"string","name":"str","type":"string"}],"name":"StringTooLong","type":"error"},{"inputs":[],"name":"TokenAlreadyConfiguredWithState","type":"error"},{"inputs":[],"name":"TokenArrayCannotBeEmpty","type":"error"},{"inputs":[],"name":"TokenCannotBeZeroAddress","type":"error"},{"inputs":[],"name":"TokenNotAllowedForStaking","type":"error"},{"inputs":[],"name":"UserDoesNotHaveStake","type":"error"},{"inputs":[],"name":"WETHCannotBeZeroAddress","type":"error"},{"inputs":[],"name":"WithdrawAmountCannotBeZero","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"migrator","type":"address"},{"indexed":false,"internalType":"bool","name":"blocked","type":"bool"}],"name":"BlocklistChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"eventId","type":"uint256"},{"indexed":true,"internalType":"address","name":"depositor","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[],"name":"EIP712DomainChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"eventId","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"address[]","name":"tokens","type":"address[]"},{"indexed":false,"internalType":"address","name":"destination","type":"address"},{"indexed":false,"internalType":"address","name":"migrator","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"Migrate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newSigner","type":"address"}],"name":"SignerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"bool","name":"enabled","type":"bool"}],"name":"TokenStakabilityChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"eventId","type":"uint256"},{"indexed":true,"internalType":"address","name":"withdrawer","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdraw","type":"event"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"balance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_migrator","type":"address"},{"internalType":"bool","name":"_blocklisted","type":"bool"}],"name":"blockMigrator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_for","type":"address"}],"name":"depositETHFor","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_for","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"depositFor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"eip712Domain","outputs":[{"internalType":"bytes1","name":"fields","type":"bytes1"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"version","type":"string"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"verifyingContract","type":"address"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"uint256[]","name":"extensions","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_tokens","type":"address[]"},{"internalType":"address","name":"_migratorContract","type":"address"},{"internalType":"address","name":"_destination","type":"address"},{"internalType":"uint256","name":"_signatureExpiry","type":"uint256"},{"internalType":"bytes","name":"_authorizationSignatureFromZircuit","type":"bytes"}],"name":"migrate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"address[]","name":"_tokens","type":"address[]"},{"internalType":"address","name":"_migratorContract","type":"address"},{"internalType":"address","name":"_destination","type":"address"},{"internalType":"uint256","name":"_signatureExpiry","type":"uint256"},{"internalType":"bytes","name":"_stakerSignature","type":"bytes"}],"name":"migrateWithSig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"migratorBlocklist","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"bool","name":"_canStake","type":"bool"}],"name":"setStakable","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_signer","type":"address"}],"name":"setZircuitSigner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"tokenAllowlist","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"zircuitSigner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
6101806040523480156200001257600080fd5b5060405162002927380380620029278339810160408190526200003591620003b8565b604080518082018252600b81526a169d185ada5b99d41bdbdb60aa1b602080830191909152825180840190935260018352603160f81b908301529033806200009857604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b620000a3816200029b565b506001805460ff60a01b19169055620000be826002620002b9565b61012052620000cf816003620002b9565b61014052815160208084019190912060e052815190820120610100524660a0526200015d60e05161010051604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201529081019290925260608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b60805250503060c0526001600160a01b0383166200018e576040516367db084560e11b815260040160405180910390fd5b6001600160a01b038116620001b657604051632911293960e01b815260040160405180910390fd5b6001600160a01b0381811661016052600980546001600160a01b031916918516919091179055815160005b81811015620002905760006001600160a01b03168482815181106200020a576200020a620004b3565b60200260200101516001600160a01b0316036200023a57604051635f5d339960e01b815260040160405180910390fd5b600160056000868481518110620002555762000255620004b3565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff1916911515919091179055600101620001e1565b50505050506200069c565b600180546001600160a01b0319169055620002b681620002f2565b50565b6000602083511015620002d957620002d18362000342565b9050620002ec565b81620002e684826200055a565b5060ff90505b92915050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600080829050601f8151111562000370578260405163305a27a960e01b81526004016200008f919062000626565b80516200037d8262000677565b179392505050565b80516001600160a01b03811681146200039d57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b600080600060608486031215620003ce57600080fd5b620003d98462000385565b602085810151919450906001600160401b0380821115620003f957600080fd5b818701915087601f8301126200040e57600080fd5b815181811115620004235762000423620003a2565b8060051b604051601f19603f830116810181811085821117156200044b576200044b620003a2565b60405291825284820192508381018501918a8311156200046a57600080fd5b938501935b828510156200049357620004838562000385565b845293850193928501926200046f565b809750505050505050620004aa6040850162000385565b90509250925092565b634e487b7160e01b600052603260045260246000fd5b600181811c90821680620004de57607f821691505b602082108103620004ff57634e487b7160e01b600052602260045260246000fd5b50919050565b601f82111562000555576000816000526020600020601f850160051c81016020861015620005305750805b601f850160051c820191505b8181101562000551578281556001016200053c565b5050505b505050565b81516001600160401b03811115620005765762000576620003a2565b6200058e81620005878454620004c9565b8462000505565b602080601f831160018114620005c65760008415620005ad5750858301515b600019600386901b1c1916600185901b17855562000551565b600085815260208120601f198616915b82811015620005f757888601518255948401946001909101908401620005d6565b5085821015620006165787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60006020808352835180602085015260005b81811015620006565785810183015185820160400152820162000638565b506000604082860101526040601f19601f8301168501019250505092915050565b80516020808301519190811015620004ff5760001960209190910360031b1b16919050565b60805160a05160c05160e051610100516101205161014051610160516122106200071760003960008181610ca701528181610d0001528181610d560152610dd101526000610fb201526000610f8001526000611712015260006116ea015260006116450152600061166f0152600061169901526122106000f3fe6080604052600436106101355760003560e01c8063a5a21fdf116100ab578063e3c342161161006f578063e3c3421614610398578063e63b81a6146103b8578063f03639e3146103d8578063f2fde38b146103f8578063f3fef3a314610418578063f6203e351461043857600080fd5b8063a5a21fdf146102e2578063b203bb9914610302578063b3db428b1461033a578063da3a3a881461035a578063e30c39781461037a57600080fd5b806379ba5097116100fd57806379ba5097146101fe5780637ecebe00146102135780638135369a146102575780638456cb591461028757806384b0196e1461029c5780638da5cb5b146102c457600080fd5b80633f4ba83a1461013a57806344e7cb13146101515780635c975abb1461018e578063715018a6146101b957806379a26cd0146101ce575b600080fd5b34801561014657600080fd5b5061014f61044b565b005b34801561015d57600080fd5b50600954610171906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561019a57600080fd5b50600154600160a01b900460ff165b6040519015158152602001610185565b3480156101c557600080fd5b5061014f610465565b3480156101da57600080fd5b506101a96101e9366004611b61565b60076020526000908152604090205460ff1681565b34801561020a57600080fd5b5061014f61047e565b34801561021f57600080fd5b5061024961022e366004611b61565b6001600160a01b031660009081526004602052604090205490565b604051908152602001610185565b34801561026357600080fd5b506101a9610272366004611b61565b60056020526000908152604090205460ff1681565b34801561029357600080fd5b5061014f6104c7565b3480156102a857600080fd5b506102b16104df565b6040516101859796959493929190611c08565b3480156102d057600080fd5b506000546001600160a01b0316610171565b3480156102ee57600080fd5b5061014f6102fd366004611cda565b610525565b34801561030e57600080fd5b5061024961031d366004611df4565b600660209081526000928352604080842090915290825290205481565b34801561034657600080fd5b5061014f610355366004611e27565b61065e565b34801561036657600080fd5b5061014f610375366004611b61565b610799565b34801561038657600080fd5b506001546001600160a01b0316610171565b3480156103a457600080fd5b5061014f6103b3366004611e63565b61084b565b3480156103c457600080fd5b5061014f6103d3366004611f3c565b610977565b3480156103e457600080fd5b5061014f6103f3366004611f3c565b610a4b565b34801561040457600080fd5b5061014f610413366004611b61565b610b17565b34801561042457600080fd5b5061014f610433366004611f73565b610b88565b61014f610446366004611b61565b610c4e565b610453610e46565b61045b610e73565b610463610e9d565b565b6040516377aeb0ad60e01b815260040160405180910390fd5b60015433906001600160a01b031681146104bb5760405163118cdaa760e01b81526001600160a01b03821660048201526024015b60405180910390fd5b6104c481610ef2565b50565b6104cf610e46565b6104d7610f0b565b610463610f36565b6000606080600080600060606104f3610f79565b6104fb610fab565b60408051600080825260208201909252600f60f81b9b939a50919850469750309650945092509050565b61052d610e46565b60007fe08f530a0e71c7f642d765489160fd44eac817278745c067606534c347d9a2ec8886868a8a604051602001610566929190611f9d565b60405160208183030381529060405280519060200120876105a48e6001600160a01b0316600090815260046020526040902080546001810190915590565b6040805160208101989098526001600160a01b0396871690880152938516606087015293909116608085015260a084015260c083019190915260e082015261010001604051602081830303815290604052805190602001209050600061060982610fd8565b905061061689828561100b565b610633576040516337e8456b60e01b815260040160405180910390fd5b50506000610644888888868961106f565b90506106548885878a8a86611218565b5050505050505050565b610666610f0b565b80600003610687576040516318bb758960e11b815260040160405180910390fd5b6001600160a01b0382166106ad5760405162bbe08560e31b815260040160405180910390fd5b6001600160a01b03831660009081526005602052604090205460ff166106e65760405163072b889f60e11b815260040160405180910390fd5b6001600160a01b0380841660009081526006602090815260408083209386168352929052908120805483929061071d908490611ff3565b92505081905550826001600160a01b0316826001600160a01b031660086000815461074790612006565b91829055506040518481527f2c0f148b435140de488c1b34647f1511c646f7077e87007bacf22ef9977a16d89060200160405180910390a46107946001600160a01b03841633308461149e565b505050565b6107a1610e46565b6001600160a01b0381166107c8576040516367db084560e11b815260040160405180910390fd5b6009546001600160a01b03908116908216036107f75760405163c0af9fdf60e01b815260040160405180910390fd5b600980546001600160a01b0319166001600160a01b0383169081179091556040519081527f5719a5656c5cfdaafa148ecf366fd3b0a7fae06449ce2a46225977fb7417e29d9060200160405180910390a150565b600061085a338989878a61106f565b6040516bffffffffffffffffffffffff19606089811b821660208401526034830188905230901b16605482015246606882015290915060009060880160408051601f198184030181529082905280516020918201207f19457468657265756d205369676e6564204d6573736167653a0a33320000000091830191909152603c820152605c0160408051601f198184030181528282528051602091820120600954601f88018390048302850183019093528684529350610941926001600160a01b03909216918491889088908190840183828082843760009201919091525061100b92505050565b61095e576040516337e8456b60e01b815260040160405180910390fd5b61096c3387898c8c87611218565b505050505050505050565b61097f610e46565b6001600160a01b0382166109a657604051635f5d339960e01b815260040160405180910390fd5b6001600160a01b03821660009081526005602052604090205481151560ff9091161515036109e757604051637565bf8f60e11b815260040160405180910390fd5b6001600160a01b038216600081815260056020908152604091829020805460ff19168515159081179091558251938452908301527f303d37f32762627f23f474bb09535b3c1c7cb4f0f75c8960c42512b046ee24a891015b60405180910390a15050565b610a53610e46565b6001600160a01b038216610a7a57604051631a86f04560e01b815260040160405180910390fd5b6001600160a01b03821660009081526007602052604090205481151560ff909116151503610abb57604051631e5a976960e31b815260040160405180910390fd5b6001600160a01b038216600081815260076020908152604091829020805460ff19168515159081179091558251938452908301527f939ba97d9885a19f5539df8bc7d0698b79b1361793009861943fdd98060480339101610a3f565b610b1f610e46565b600180546001600160a01b0383166001600160a01b03199091168117909155610b506000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b80600003610ba95760405163b8fc0f3b60e01b815260040160405180910390fd5b6001600160a01b038216600090815260066020908152604080832033845290915281208054839290610bdc90849061201f565b9091555050600880546001600160a01b038416913391600090610bfe90612006565b91829055506040518481527ffeb2000dca3e617cd6f3a8bbb63014bb54a124aac6ccbf73ee7229b4cd01f1209060200160405180910390a4610c4a6001600160a01b038316338361150b565b5050565b610c56610f0b565b34600003610c77576040516318bb758960e11b815260040160405180910390fd5b6001600160a01b038116610c9d5760405162bbe08560e31b815260040160405180910390fd5b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001660009081526005602052604090205460ff16610cf65760405163072b889f60e11b815260040160405180910390fd5b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116600090815260066020908152604080832093851683529290529081208054349290610d4d908490611ff3565b925050819055507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316816001600160a01b0316600860008154610d9790612006565b91829055506040513481527f2c0f148b435140de488c1b34647f1511c646f7077e87007bacf22ef9977a16d89060200160405180910390a47f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b158015610e2a57600080fd5b505af1158015610e3e573d6000803e3d6000fd5b505050505050565b6000546001600160a01b031633146104635760405163118cdaa760e01b81523360048201526024016104b2565b600154600160a01b900460ff1661046357604051638dfc202b60e01b815260040160405180910390fd5b610ea5610e73565b6001805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b600180546001600160a01b03191690556104c48161153c565b600154600160a01b900460ff16156104635760405163d93c066560e01b815260040160405180910390fd5b610f3e610f0b565b6001805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258610ed53390565b6060610fa67f0000000000000000000000000000000000000000000000000000000000000000600261158c565b905090565b6060610fa67f0000000000000000000000000000000000000000000000000000000000000000600361158c565b6000611005610fe5611638565b8360405161190160f01b8152600281019290925260228201526042902090565b92915050565b600080600061101a8585611763565b509092509050600081600381111561103457611034612032565b1480156110525750856001600160a01b0316826001600160a01b0316145b8061106357506110638686866117b0565b925050505b9392505050565b60608360008190036110945760405163e78703a360e01b815260040160405180910390fd5b8067ffffffffffffffff8111156110ad576110ad611cc4565b6040519080825280602002602001820160405280156110d6578160200160208202803683370190505b50915060005b818110156111b357600660008888848181106110fa576110fa612048565b905060200201602081019061110f9190611b61565b6001600160a01b03166001600160a01b031681526020019081526020016000206000896001600160a01b03166001600160a01b031681526020019081526020016000205483828151811061116557611165612048565b60200260200101818152505082818151811061118357611183612048565b60200260200101516000036111ab5760405163a809389f60e01b815260040160405180910390fd5b6001016110dc565b508342106111d457604051630819bdcd60e01b815260040160405180910390fd5b6001600160a01b03831660009081526007602052604090205460ff161561120e57604051639997d66560e01b815260040160405180910390fd5b5095945050505050565b8160005b818110156112f7576006600086868481811061123a5761123a612048565b905060200201602081019061124f9190611b61565b6001600160a01b03908116825260208083019390935260409182016000908120918c16815292528120549003611298576040516323271fb560e11b815260040160405180910390fd5b6000600660008787858181106112b0576112b0612048565b90506020020160208101906112c59190611b61565b6001600160a01b03908116825260208083019390935260409182016000908120918d168152925290205560010161121c565b50866001600160a01b031660086000815461131190612006565b9190508190557f8ec7c0970f810f90b2e926cd4ee4f32efff0ef16fb5e08617c11b9fad14dfc0086868a8a8860405161134e95949392919061209a565b60405180910390a360005b8181101561142e5784848281811061137357611373612048565b90506020020160208101906113889190611b61565b6001600160a01b031663095ea7b3878584815181106113a9576113a9612048565b60200260200101516040518363ffffffff1660e01b81526004016113e29291906001600160a01b03929092168252602082015260400190565b6020604051808303816000875af1158015611401573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061142591906120e3565b50600101611359565b506040516355e663bf60e11b81526001600160a01b0386169063abccc77e90611463908a90889088908c908990600401612100565b600060405180830381600087803b15801561147d57600080fd5b505af1158015611491573d6000803e3d6000fd5b5050505050505050505050565b6040516001600160a01b0384811660248301528381166044830152606482018390526115059186918216906323b872dd906084015b604051602081830303815290604052915060e01b6020820180516001600160e01b03838183161783525050505061188b565b50505050565b6040516001600160a01b0383811660248301526044820183905261079491859182169063a9059cbb906064016114d3565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b606060ff83146115a65761159f836118ee565b9050611005565b8180546115b29061214a565b80601f01602080910402602001604051908101604052809291908181526020018280546115de9061214a565b801561162b5780601f106116005761010080835404028352916020019161162b565b820191906000526020600020905b81548152906001019060200180831161160e57829003601f168201915b5050505050905092915050565b6000306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614801561169157507f000000000000000000000000000000000000000000000000000000000000000046145b156116bb57507f000000000000000000000000000000000000000000000000000000000000000090565b610fa6604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527f0000000000000000000000000000000000000000000000000000000000000000918101919091527f000000000000000000000000000000000000000000000000000000000000000060608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b6000806000835160410361179d5760208401516040850151606086015160001a61178f8882858561192d565b9550955095505050506117a9565b50508151600091506002905b9250925092565b6000806000856001600160a01b031685856040516024016117d2929190612184565b60408051601f198184030181529181526020820180516001600160e01b0316630b135d3f60e11b1790525161180791906121a5565b600060405180830381855afa9150503d8060008114611842576040519150601f19603f3d011682016040523d82523d6000602084013e611847565b606091505b509150915081801561185b57506020815110155b801561106357508051630b135d3f60e11b9061188090830160209081019084016121c1565b149695505050505050565b60006118a06001600160a01b038416836119fc565b905080516000141580156118c55750808060200190518101906118c391906120e3565b155b1561079457604051635274afe760e01b81526001600160a01b03841660048201526024016104b2565b606060006118fb83611a0a565b604080516020808252818301909252919250600091906020820181803683375050509182525060208101929092525090565b600080807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a084111561196857506000915060039050826119f2565b604080516000808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa1580156119bc573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166119e8575060009250600191508290506119f2565b9250600091508190505b9450945094915050565b606061106883836000611a32565b600060ff8216601f81111561100557604051632cd44ac360e21b815260040160405180910390fd5b606081471015611a575760405163cd78605960e01b81523060048201526024016104b2565b600080856001600160a01b03168486604051611a7391906121a5565b60006040518083038185875af1925050503d8060008114611ab0576040519150601f19603f3d011682016040523d82523d6000602084013e611ab5565b606091505b5091509150611063868383606082611ad557611ad082611b1c565b611068565b8151158015611aec57506001600160a01b0384163b155b15611b1557604051639996b31560e01b81526001600160a01b03851660048201526024016104b2565b5080611068565b805115611b2c5780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b80356001600160a01b0381168114611b5c57600080fd5b919050565b600060208284031215611b7357600080fd5b61106882611b45565b60005b83811015611b97578181015183820152602001611b7f565b50506000910152565b60008151808452611bb8816020860160208601611b7c565b601f01601f19169290920160200192915050565b60008151808452602080850194506020840160005b83811015611bfd57815187529582019590820190600101611be1565b509495945050505050565b60ff60f81b8816815260e060208201526000611c2760e0830189611ba0565b8281036040840152611c398189611ba0565b606084018890526001600160a01b038716608085015260a0840186905283810360c08501529050611c6a8185611bcc565b9a9950505050505050505050565b60008083601f840112611c8a57600080fd5b50813567ffffffffffffffff811115611ca257600080fd5b6020830191508360208260051b8501011115611cbd57600080fd5b9250929050565b634e487b7160e01b600052604160045260246000fd5b600080600080600080600060c0888a031215611cf557600080fd5b611cfe88611b45565b9650602088013567ffffffffffffffff80821115611d1b57600080fd5b611d278b838c01611c78565b9098509650869150611d3b60408b01611b45565b9550611d4960608b01611b45565b945060808a0135935060a08a0135915080821115611d6657600080fd5b818a0191508a601f830112611d7a57600080fd5b813581811115611d8c57611d8c611cc4565b604051601f8201601f19908116603f01168101908382118183101715611db457611db4611cc4565b816040528281528d6020848701011115611dcd57600080fd5b82602086016020830137600060208483010152809550505050505092959891949750929550565b60008060408385031215611e0757600080fd5b611e1083611b45565b9150611e1e60208401611b45565b90509250929050565b600080600060608486031215611e3c57600080fd5b611e4584611b45565b9250611e5360208501611b45565b9150604084013590509250925092565b600080600080600080600060a0888a031215611e7e57600080fd5b873567ffffffffffffffff80821115611e9657600080fd5b611ea28b838c01611c78565b9099509750879150611eb660208b01611b45565b9650611ec460408b01611b45565b955060608a0135945060808a0135915080821115611ee157600080fd5b818a0191508a601f830112611ef557600080fd5b813581811115611f0457600080fd5b8b6020828501011115611f1657600080fd5b60208301945080935050505092959891949750929550565b80151581146104c457600080fd5b60008060408385031215611f4f57600080fd5b611f5883611b45565b91506020830135611f6881611f2e565b809150509250929050565b60008060408385031215611f8657600080fd5b611f8f83611b45565b946020939093013593505050565b60008184825b85811015611fd2576001600160a01b03611fbc83611b45565b1683526020928301929190910190600101611fa3565b509095945050505050565b634e487b7160e01b600052601160045260246000fd5b8082018082111561100557611005611fdd565b60006001820161201857612018611fdd565b5060010190565b8181038181111561100557611005611fdd565b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b8183526000602080850194508260005b85811015611bfd576001600160a01b0361208783611b45565b168752958201959082019060010161206e565b6080815260006120ae60808301878961205e565b6001600160a01b0386811660208501528516604084015282810360608401526120d78185611bcc565b98975050505050505050565b6000602082840312156120f557600080fd5b815161106881611f2e565b600060018060a01b0380881683526080602084015261212360808401878961205e565b8186166040850152838103606085015261213d8186611bcc565b9998505050505050505050565b600181811c9082168061215e57607f821691505b60208210810361217e57634e487b7160e01b600052602260045260246000fd5b50919050565b82815260406020820152600061219d6040830184611ba0565b949350505050565b600082516121b7818460208701611b7c565b9190910192915050565b6000602082840312156121d357600080fd5b505191905056fea2646970667358221220f7bfc87400d175520d3a2e90e3041f83766bb8dbee0c14db0db8f342806dde8964736f6c63430008180033000000000000000000000000e42a95c84f9dd116066effb733e8294931967a0d0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000002000000000000000000000000bf5495efe5db9ce00f80364c8b423567e58d2110000000000000000000000000a1290d69c65a6fe4df752f95823fae25cb99e5a7
Deployed Bytecode
0x6080604052600436106101355760003560e01c8063a5a21fdf116100ab578063e3c342161161006f578063e3c3421614610398578063e63b81a6146103b8578063f03639e3146103d8578063f2fde38b146103f8578063f3fef3a314610418578063f6203e351461043857600080fd5b8063a5a21fdf146102e2578063b203bb9914610302578063b3db428b1461033a578063da3a3a881461035a578063e30c39781461037a57600080fd5b806379ba5097116100fd57806379ba5097146101fe5780637ecebe00146102135780638135369a146102575780638456cb591461028757806384b0196e1461029c5780638da5cb5b146102c457600080fd5b80633f4ba83a1461013a57806344e7cb13146101515780635c975abb1461018e578063715018a6146101b957806379a26cd0146101ce575b600080fd5b34801561014657600080fd5b5061014f61044b565b005b34801561015d57600080fd5b50600954610171906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561019a57600080fd5b50600154600160a01b900460ff165b6040519015158152602001610185565b3480156101c557600080fd5b5061014f610465565b3480156101da57600080fd5b506101a96101e9366004611b61565b60076020526000908152604090205460ff1681565b34801561020a57600080fd5b5061014f61047e565b34801561021f57600080fd5b5061024961022e366004611b61565b6001600160a01b031660009081526004602052604090205490565b604051908152602001610185565b34801561026357600080fd5b506101a9610272366004611b61565b60056020526000908152604090205460ff1681565b34801561029357600080fd5b5061014f6104c7565b3480156102a857600080fd5b506102b16104df565b6040516101859796959493929190611c08565b3480156102d057600080fd5b506000546001600160a01b0316610171565b3480156102ee57600080fd5b5061014f6102fd366004611cda565b610525565b34801561030e57600080fd5b5061024961031d366004611df4565b600660209081526000928352604080842090915290825290205481565b34801561034657600080fd5b5061014f610355366004611e27565b61065e565b34801561036657600080fd5b5061014f610375366004611b61565b610799565b34801561038657600080fd5b506001546001600160a01b0316610171565b3480156103a457600080fd5b5061014f6103b3366004611e63565b61084b565b3480156103c457600080fd5b5061014f6103d3366004611f3c565b610977565b3480156103e457600080fd5b5061014f6103f3366004611f3c565b610a4b565b34801561040457600080fd5b5061014f610413366004611b61565b610b17565b34801561042457600080fd5b5061014f610433366004611f73565b610b88565b61014f610446366004611b61565b610c4e565b610453610e46565b61045b610e73565b610463610e9d565b565b6040516377aeb0ad60e01b815260040160405180910390fd5b60015433906001600160a01b031681146104bb5760405163118cdaa760e01b81526001600160a01b03821660048201526024015b60405180910390fd5b6104c481610ef2565b50565b6104cf610e46565b6104d7610f0b565b610463610f36565b6000606080600080600060606104f3610f79565b6104fb610fab565b60408051600080825260208201909252600f60f81b9b939a50919850469750309650945092509050565b61052d610e46565b60007fe08f530a0e71c7f642d765489160fd44eac817278745c067606534c347d9a2ec8886868a8a604051602001610566929190611f9d565b60405160208183030381529060405280519060200120876105a48e6001600160a01b0316600090815260046020526040902080546001810190915590565b6040805160208101989098526001600160a01b0396871690880152938516606087015293909116608085015260a084015260c083019190915260e082015261010001604051602081830303815290604052805190602001209050600061060982610fd8565b905061061689828561100b565b610633576040516337e8456b60e01b815260040160405180910390fd5b50506000610644888888868961106f565b90506106548885878a8a86611218565b5050505050505050565b610666610f0b565b80600003610687576040516318bb758960e11b815260040160405180910390fd5b6001600160a01b0382166106ad5760405162bbe08560e31b815260040160405180910390fd5b6001600160a01b03831660009081526005602052604090205460ff166106e65760405163072b889f60e11b815260040160405180910390fd5b6001600160a01b0380841660009081526006602090815260408083209386168352929052908120805483929061071d908490611ff3565b92505081905550826001600160a01b0316826001600160a01b031660086000815461074790612006565b91829055506040518481527f2c0f148b435140de488c1b34647f1511c646f7077e87007bacf22ef9977a16d89060200160405180910390a46107946001600160a01b03841633308461149e565b505050565b6107a1610e46565b6001600160a01b0381166107c8576040516367db084560e11b815260040160405180910390fd5b6009546001600160a01b03908116908216036107f75760405163c0af9fdf60e01b815260040160405180910390fd5b600980546001600160a01b0319166001600160a01b0383169081179091556040519081527f5719a5656c5cfdaafa148ecf366fd3b0a7fae06449ce2a46225977fb7417e29d9060200160405180910390a150565b600061085a338989878a61106f565b6040516bffffffffffffffffffffffff19606089811b821660208401526034830188905230901b16605482015246606882015290915060009060880160408051601f198184030181529082905280516020918201207f19457468657265756d205369676e6564204d6573736167653a0a33320000000091830191909152603c820152605c0160408051601f198184030181528282528051602091820120600954601f88018390048302850183019093528684529350610941926001600160a01b03909216918491889088908190840183828082843760009201919091525061100b92505050565b61095e576040516337e8456b60e01b815260040160405180910390fd5b61096c3387898c8c87611218565b505050505050505050565b61097f610e46565b6001600160a01b0382166109a657604051635f5d339960e01b815260040160405180910390fd5b6001600160a01b03821660009081526005602052604090205481151560ff9091161515036109e757604051637565bf8f60e11b815260040160405180910390fd5b6001600160a01b038216600081815260056020908152604091829020805460ff19168515159081179091558251938452908301527f303d37f32762627f23f474bb09535b3c1c7cb4f0f75c8960c42512b046ee24a891015b60405180910390a15050565b610a53610e46565b6001600160a01b038216610a7a57604051631a86f04560e01b815260040160405180910390fd5b6001600160a01b03821660009081526007602052604090205481151560ff909116151503610abb57604051631e5a976960e31b815260040160405180910390fd5b6001600160a01b038216600081815260076020908152604091829020805460ff19168515159081179091558251938452908301527f939ba97d9885a19f5539df8bc7d0698b79b1361793009861943fdd98060480339101610a3f565b610b1f610e46565b600180546001600160a01b0383166001600160a01b03199091168117909155610b506000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b80600003610ba95760405163b8fc0f3b60e01b815260040160405180910390fd5b6001600160a01b038216600090815260066020908152604080832033845290915281208054839290610bdc90849061201f565b9091555050600880546001600160a01b038416913391600090610bfe90612006565b91829055506040518481527ffeb2000dca3e617cd6f3a8bbb63014bb54a124aac6ccbf73ee7229b4cd01f1209060200160405180910390a4610c4a6001600160a01b038316338361150b565b5050565b610c56610f0b565b34600003610c77576040516318bb758960e11b815260040160405180910390fd5b6001600160a01b038116610c9d5760405162bbe08560e31b815260040160405180910390fd5b6001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21660009081526005602052604090205460ff16610cf65760405163072b889f60e11b815260040160405180910390fd5b6001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28116600090815260066020908152604080832093851683529290529081208054349290610d4d908490611ff3565b925050819055507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316816001600160a01b0316600860008154610d9790612006565b91829055506040513481527f2c0f148b435140de488c1b34647f1511c646f7077e87007bacf22ef9977a16d89060200160405180910390a47f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b158015610e2a57600080fd5b505af1158015610e3e573d6000803e3d6000fd5b505050505050565b6000546001600160a01b031633146104635760405163118cdaa760e01b81523360048201526024016104b2565b600154600160a01b900460ff1661046357604051638dfc202b60e01b815260040160405180910390fd5b610ea5610e73565b6001805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b600180546001600160a01b03191690556104c48161153c565b600154600160a01b900460ff16156104635760405163d93c066560e01b815260040160405180910390fd5b610f3e610f0b565b6001805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258610ed53390565b6060610fa67f5a74616b696e67506f6f6c00000000000000000000000000000000000000000b600261158c565b905090565b6060610fa67f3100000000000000000000000000000000000000000000000000000000000001600361158c565b6000611005610fe5611638565b8360405161190160f01b8152600281019290925260228201526042902090565b92915050565b600080600061101a8585611763565b509092509050600081600381111561103457611034612032565b1480156110525750856001600160a01b0316826001600160a01b0316145b8061106357506110638686866117b0565b925050505b9392505050565b60608360008190036110945760405163e78703a360e01b815260040160405180910390fd5b8067ffffffffffffffff8111156110ad576110ad611cc4565b6040519080825280602002602001820160405280156110d6578160200160208202803683370190505b50915060005b818110156111b357600660008888848181106110fa576110fa612048565b905060200201602081019061110f9190611b61565b6001600160a01b03166001600160a01b031681526020019081526020016000206000896001600160a01b03166001600160a01b031681526020019081526020016000205483828151811061116557611165612048565b60200260200101818152505082818151811061118357611183612048565b60200260200101516000036111ab5760405163a809389f60e01b815260040160405180910390fd5b6001016110dc565b508342106111d457604051630819bdcd60e01b815260040160405180910390fd5b6001600160a01b03831660009081526007602052604090205460ff161561120e57604051639997d66560e01b815260040160405180910390fd5b5095945050505050565b8160005b818110156112f7576006600086868481811061123a5761123a612048565b905060200201602081019061124f9190611b61565b6001600160a01b03908116825260208083019390935260409182016000908120918c16815292528120549003611298576040516323271fb560e11b815260040160405180910390fd5b6000600660008787858181106112b0576112b0612048565b90506020020160208101906112c59190611b61565b6001600160a01b03908116825260208083019390935260409182016000908120918d168152925290205560010161121c565b50866001600160a01b031660086000815461131190612006565b9190508190557f8ec7c0970f810f90b2e926cd4ee4f32efff0ef16fb5e08617c11b9fad14dfc0086868a8a8860405161134e95949392919061209a565b60405180910390a360005b8181101561142e5784848281811061137357611373612048565b90506020020160208101906113889190611b61565b6001600160a01b031663095ea7b3878584815181106113a9576113a9612048565b60200260200101516040518363ffffffff1660e01b81526004016113e29291906001600160a01b03929092168252602082015260400190565b6020604051808303816000875af1158015611401573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061142591906120e3565b50600101611359565b506040516355e663bf60e11b81526001600160a01b0386169063abccc77e90611463908a90889088908c908990600401612100565b600060405180830381600087803b15801561147d57600080fd5b505af1158015611491573d6000803e3d6000fd5b5050505050505050505050565b6040516001600160a01b0384811660248301528381166044830152606482018390526115059186918216906323b872dd906084015b604051602081830303815290604052915060e01b6020820180516001600160e01b03838183161783525050505061188b565b50505050565b6040516001600160a01b0383811660248301526044820183905261079491859182169063a9059cbb906064016114d3565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b606060ff83146115a65761159f836118ee565b9050611005565b8180546115b29061214a565b80601f01602080910402602001604051908101604052809291908181526020018280546115de9061214a565b801561162b5780601f106116005761010080835404028352916020019161162b565b820191906000526020600020905b81548152906001019060200180831161160e57829003601f168201915b5050505050905092915050565b6000306001600160a01b037f000000000000000000000000f047ab4c75cebf0eb9ed34ae2c186f3611aeafa61614801561169157507f000000000000000000000000000000000000000000000000000000000000000146145b156116bb57507f60f132f61eb52350d38debb9545285dbe460422d845fc94e3c03e39d35fe23fd90565b610fa6604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527fcf7936818770c7c65596ab2682c0a2826f5f1e1aaa24c0b6acd2ee27ef08e64c918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b6000806000835160410361179d5760208401516040850151606086015160001a61178f8882858561192d565b9550955095505050506117a9565b50508151600091506002905b9250925092565b6000806000856001600160a01b031685856040516024016117d2929190612184565b60408051601f198184030181529181526020820180516001600160e01b0316630b135d3f60e11b1790525161180791906121a5565b600060405180830381855afa9150503d8060008114611842576040519150601f19603f3d011682016040523d82523d6000602084013e611847565b606091505b509150915081801561185b57506020815110155b801561106357508051630b135d3f60e11b9061188090830160209081019084016121c1565b149695505050505050565b60006118a06001600160a01b038416836119fc565b905080516000141580156118c55750808060200190518101906118c391906120e3565b155b1561079457604051635274afe760e01b81526001600160a01b03841660048201526024016104b2565b606060006118fb83611a0a565b604080516020808252818301909252919250600091906020820181803683375050509182525060208101929092525090565b600080807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a084111561196857506000915060039050826119f2565b604080516000808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa1580156119bc573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166119e8575060009250600191508290506119f2565b9250600091508190505b9450945094915050565b606061106883836000611a32565b600060ff8216601f81111561100557604051632cd44ac360e21b815260040160405180910390fd5b606081471015611a575760405163cd78605960e01b81523060048201526024016104b2565b600080856001600160a01b03168486604051611a7391906121a5565b60006040518083038185875af1925050503d8060008114611ab0576040519150601f19603f3d011682016040523d82523d6000602084013e611ab5565b606091505b5091509150611063868383606082611ad557611ad082611b1c565b611068565b8151158015611aec57506001600160a01b0384163b155b15611b1557604051639996b31560e01b81526001600160a01b03851660048201526024016104b2565b5080611068565b805115611b2c5780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b80356001600160a01b0381168114611b5c57600080fd5b919050565b600060208284031215611b7357600080fd5b61106882611b45565b60005b83811015611b97578181015183820152602001611b7f565b50506000910152565b60008151808452611bb8816020860160208601611b7c565b601f01601f19169290920160200192915050565b60008151808452602080850194506020840160005b83811015611bfd57815187529582019590820190600101611be1565b509495945050505050565b60ff60f81b8816815260e060208201526000611c2760e0830189611ba0565b8281036040840152611c398189611ba0565b606084018890526001600160a01b038716608085015260a0840186905283810360c08501529050611c6a8185611bcc565b9a9950505050505050505050565b60008083601f840112611c8a57600080fd5b50813567ffffffffffffffff811115611ca257600080fd5b6020830191508360208260051b8501011115611cbd57600080fd5b9250929050565b634e487b7160e01b600052604160045260246000fd5b600080600080600080600060c0888a031215611cf557600080fd5b611cfe88611b45565b9650602088013567ffffffffffffffff80821115611d1b57600080fd5b611d278b838c01611c78565b9098509650869150611d3b60408b01611b45565b9550611d4960608b01611b45565b945060808a0135935060a08a0135915080821115611d6657600080fd5b818a0191508a601f830112611d7a57600080fd5b813581811115611d8c57611d8c611cc4565b604051601f8201601f19908116603f01168101908382118183101715611db457611db4611cc4565b816040528281528d6020848701011115611dcd57600080fd5b82602086016020830137600060208483010152809550505050505092959891949750929550565b60008060408385031215611e0757600080fd5b611e1083611b45565b9150611e1e60208401611b45565b90509250929050565b600080600060608486031215611e3c57600080fd5b611e4584611b45565b9250611e5360208501611b45565b9150604084013590509250925092565b600080600080600080600060a0888a031215611e7e57600080fd5b873567ffffffffffffffff80821115611e9657600080fd5b611ea28b838c01611c78565b9099509750879150611eb660208b01611b45565b9650611ec460408b01611b45565b955060608a0135945060808a0135915080821115611ee157600080fd5b818a0191508a601f830112611ef557600080fd5b813581811115611f0457600080fd5b8b6020828501011115611f1657600080fd5b60208301945080935050505092959891949750929550565b80151581146104c457600080fd5b60008060408385031215611f4f57600080fd5b611f5883611b45565b91506020830135611f6881611f2e565b809150509250929050565b60008060408385031215611f8657600080fd5b611f8f83611b45565b946020939093013593505050565b60008184825b85811015611fd2576001600160a01b03611fbc83611b45565b1683526020928301929190910190600101611fa3565b509095945050505050565b634e487b7160e01b600052601160045260246000fd5b8082018082111561100557611005611fdd565b60006001820161201857612018611fdd565b5060010190565b8181038181111561100557611005611fdd565b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b8183526000602080850194508260005b85811015611bfd576001600160a01b0361208783611b45565b168752958201959082019060010161206e565b6080815260006120ae60808301878961205e565b6001600160a01b0386811660208501528516604084015282810360608401526120d78185611bcc565b98975050505050505050565b6000602082840312156120f557600080fd5b815161106881611f2e565b600060018060a01b0380881683526080602084015261212360808401878961205e565b8186166040850152838103606085015261213d8186611bcc565b9998505050505050505050565b600181811c9082168061215e57607f821691505b60208210810361217e57634e487b7160e01b600052602260045260246000fd5b50919050565b82815260406020820152600061219d6040830184611ba0565b949350505050565b600082516121b7818460208701611b7c565b9190910192915050565b6000602082840312156121d357600080fd5b505191905056fea2646970667358221220f7bfc87400d175520d3a2e90e3041f83766bb8dbee0c14db0db8f342806dde8964736f6c63430008180033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000e42a95c84f9dd116066effb733e8294931967a0d0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000002000000000000000000000000bf5495efe5db9ce00f80364c8b423567e58d2110000000000000000000000000a1290d69c65a6fe4df752f95823fae25cb99e5a7
-----Decoded View---------------
Arg [0] : _signer (address): 0xE42A95c84f9dd116066Effb733e8294931967a0d
Arg [1] : _tokensAllowed (address[]): 0xbf5495Efe5DB9ce00f80364C8B423567e58d2110,0xA1290d69c65A6Fe4DF752f95823fae25cB99e5A7
Arg [2] : _weth (address): 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
-----Encoded View---------------
6 Constructor Arguments found :
Arg [0] : 000000000000000000000000e42a95c84f9dd116066effb733e8294931967a0d
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000060
Arg [2] : 000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000002
Arg [4] : 000000000000000000000000bf5495efe5db9ce00f80364c8b423567e58d2110
Arg [5] : 000000000000000000000000a1290d69c65a6fe4df752f95823fae25cb99e5a7
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 31 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|---|---|---|---|---|
ETH | 43.94% | $2,848.04 | 49,517.0418 | $141,026,515.83 | |
ETH | 29.91% | $3,208.25 | 29,915.6567 | $95,976,905.65 | |
ETH | 7.04% | $2,904.33 | 7,775.0002 | $22,581,166.42 | |
ETH | 5.48% | $2,808.95 | 6,257.5926 | $17,577,264.81 | |
ETH | 4.95% | $3,184.04 | 4,985.6307 | $15,874,447.64 | |
ETH | 3.49% | $2,783.63 | 4,025.7627 | $11,206,233.83 | |
ETH | 1.42% | $2,794 | 1,632.311 | $4,560,678.34 | |
ETH | 0.76% | $0.999488 | 2,431,863.5265 | $2,430,618.41 | |
ETH | 0.75% | $2,779.86 | 862.7416 | $2,398,300.92 | |
ETH | 0.62% | $97,333 | 20.2882 | $1,974,709.5 | |
ETH | 0.48% | $2,768.34 | 561.6607 | $1,554,867.32 | |
ETH | 0.37% | $2,680.24 | 438.8168 | $1,176,133.92 | |
ETH | 0.35% | $2,841.97 | 389.8265 | $1,107,875.19 | |
ETH | 0.28% | $2,875.96 | 313.3203 | $901,096.75 | |
ETH | 0.13% | $2,909.01 | 143.1337 | $416,376.73 | |
ETH | 0.04% | $95,137.26 | 1.4366 | $136,676.09 | |
ETH | <0.01% | $97,515 | 0.132 | $12,874.4 | |
ETH | <0.01% | $97,514 | 0.0411 | $4,012.39 | |
ETH | <0.01% | $2,360.86 | 0.2 | $472.17 | |
ETH | <0.01% | $1 | 270.6918 | $270.69 | |
ETH | <0.01% | $0.170723 | 100 | $17.07 | |
ETH | <0.01% | $0.999954 | 5 | $5 | |
ETH | <0.01% | $1.61 | 2.4988 | $4.02 | |
BSC | <0.01% | $1.86 | 5,130.5617 | $9,563.65 | |
BSC | <0.01% | $657.98 | 0.1182 | $77.76 | |
ARB | <0.01% | $2,680.27 | 0.1628 | $436.27 | |
LINEA | <0.01% | $2,680.24 | 0.0216 | $57.92 | |
SCROLL | <0.01% | $2,680.24 | 0.014 | $37.52 | |
BLAST | <0.01% | $2,680.24 | 0.0073237 | $19.63 | |
OPBNB | <0.01% | $657.85 | 0.00273342 | $1.8 | |
OP | <0.01% | $2,680.04 | 0.00041 | $1.1 | |
ZKSYNC | <0.01% | $2,680.24 | 0.00029356 | $0.78682 | |
POL | <0.01% | $0.315393 | 0.00358331 | $0.00113 | |
MANTLE | <0.01% | $1.03 | 0.00035375 | $0.000365 |
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.