Overview
ETH Balance
ETH Value
$0.00Latest 1 from a total of 1 transactions
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| Set Fee Treasury | 19907679 | 11 days ago | IN | 0 ETH | 0.00000139 |
Latest 1 internal transaction
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 19907676 | 11 days ago | Contract Creation | 0 ETH |
Cross-Chain Transactions
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import { Clones } from "@openzeppelin/contracts/proxy/Clones.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { TokenClaim } from "./TokenClaim.sol";
/**
* @title TokenClaimFactory
* @dev Factory contract for deploying minimal proxy clones of TokenClaim contracts.
* Uses EIP-1167 for gas-efficient deployments.
*/
contract TokenClaimFactory is Ownable {
enum FeeTier {
NoFee,
PointOnePercent,
OnePercent
}
/// @notice The implementation contract that all clones will delegate to
address public immutable implementation;
/// @notice Counter for deployed clones
uint256 public cloneCount;
/// @notice Treasury address that receives native currency payments during deployment
address public feeTreasury;
/// @notice Optional oracle address for future price validation
address public priceOracle;
/// @notice Mapping to track if an address is a clone deployed by this factory
mapping(address => bool) public isClone;
/// @notice Array of all deployed clone addresses for enumeration
address[] public clones;
/// @notice Mapping from deployer address to array of clone addresses
mapping(address => address[]) private deployerToClones;
/// @notice Emitted when a new TokenClaim clone is deployed
event CloneDeployed(
address indexed clone,
address indexed deployer,
address indexed token,
address treasury,
bytes32 merkleRoot,
uint256 claimStart,
uint256 claimEnd,
uint256 cloneNumber,
address owner,
FeeTier feeTier,
uint256 nativeFeePaid
);
/// @notice Emitted when K9 treasury claim data is recorded for a clone.
/// @dev Non-indexed k9Amount and k9Proof are ABI-encoded in full (not hashed).
/// This allows K9 treasury to retrieve their merkle proof from event logs.
event K9ClaimDataRecorded(
address indexed clone,
address indexed k9Treasury,
uint256 k9Amount,
bytes32[] k9Proof
);
event FeeTreasuryUpdated(address indexed newFeeTreasury);
event PriceOracleUpdated(address indexed newPriceOracle);
/**
* @dev Constructor deploys the implementation contract and stores its address.
*/
constructor() Ownable(msg.sender) {
implementation = address(new TokenClaim());
}
/**
* @dev Deploy a new TokenClaim clone with the specified parameters.
* @param _token Address of the ERC20 token to be claimed.
* @param _treasury Address holding the tokens and that has approved spending.
* @param _merkleRoot The Merkle root representing the full airdrop data.
* @param _claimStart Timestamp when claims can begin.
* @param _claimEnd Timestamp when claims end.
* @param _owner Address that will own the deployed TokenClaim instance.
* @param _feeTier Selected fee tier for observability (front-end enforced).
* @return clone Address of the newly deployed TokenClaim clone.
*/
function deployTokenClaim(
IERC20 _token,
address _treasury,
bytes32 _merkleRoot,
uint256 _claimStart,
uint256 _claimEnd,
address _owner,
FeeTier _feeTier
) public payable returns (address clone) {
// Input validation
require(address(_token) != address(0), "Token address cannot be zero");
require(_treasury != address(0), "Treasury address cannot be zero");
require(_owner != address(0), "Owner address cannot be zero");
require(_merkleRoot != bytes32(0), "Merkle root cannot be zero");
require(_claimStart < _claimEnd, "Invalid claim window");
// Deploy the clone
clone = Clones.clone(implementation);
// Initialize the clone
TokenClaim(payable(clone)).initialize(_token, _treasury, _merkleRoot, _claimStart, _claimEnd, _owner);
// Update state
cloneCount++;
isClone[clone] = true;
clones.push(clone);
deployerToClones[msg.sender].push(clone);
_forwardPayment();
// Emit event
emit CloneDeployed(
clone,
msg.sender,
address(_token),
_treasury,
_merkleRoot,
_claimStart,
_claimEnd,
cloneCount,
_owner,
_feeTier,
msg.value
);
return clone;
}
/**
* @dev Deploy a new TokenClaim clone with the specified parameters.
* @param _token Address of the ERC20 token to be claimed.
* @param _treasury Address holding the tokens and that has approved spending.
* @param _merkleRoot The Merkle root representing the full airdrop data.
* @param _claimStart Timestamp when claims can begin.
* @param _claimEnd Timestamp when claims end.
* @param _owner Address that will own the deployed TokenClaim instance.
* @return clone Address of the newly deployed TokenClaim clone.
*/
function deployTokenClaim(
IERC20 _token,
address _treasury,
bytes32 _merkleRoot,
uint256 _claimStart,
uint256 _claimEnd,
address _owner
) external payable returns (address clone) {
return deployTokenClaim(_token, _treasury, _merkleRoot, _claimStart, _claimEnd, _owner, FeeTier.NoFee);
}
/**
* @dev Deploy a new TokenClaim clone and record K9 treasury claim data.
* Use this when deploying with a fee tier that includes K9 treasury allocation.
* The K9 claim data is emitted as an event for off-chain retrieval.
* @param _token Address of the ERC20 token to be claimed.
* @param _treasury Address holding the tokens and that has approved spending.
* @param _merkleRoot The Merkle root representing the full airdrop data.
* @param _claimStart Timestamp when claims can begin.
* @param _claimEnd Timestamp when claims end.
* @param _owner Address that will own the deployed TokenClaim instance.
* @param _feeTier Selected fee tier for observability.
* @param _k9Treasury Address of the K9 treasury that will claim the fee allocation.
* @param _k9Amount Amount of tokens allocated to K9 treasury.
* @param _k9Proof Merkle proof for K9 treasury to claim their allocation.
* @return clone Address of the newly deployed TokenClaim clone.
*/
function deployTokenClaimWithK9Data(
IERC20 _token,
address _treasury,
bytes32 _merkleRoot,
uint256 _claimStart,
uint256 _claimEnd,
address _owner,
FeeTier _feeTier,
address _k9Treasury,
uint256 _k9Amount,
bytes32[] calldata _k9Proof
) external payable returns (address clone) {
// Deploy using existing logic
clone = deployTokenClaim(_token, _treasury, _merkleRoot, _claimStart, _claimEnd, _owner, _feeTier);
// Emit K9 claim data if provided
if (_k9Amount > 0) {
require(_k9Treasury != address(0), "K9 treasury cannot be zero");
require(_k9Proof.length > 0, "K9 proof cannot be empty");
emit K9ClaimDataRecorded(clone, _k9Treasury, _k9Amount, _k9Proof);
}
return clone;
}
/**
* @dev Deploy a new TokenClaim clone with deterministic address using CREATE2.
* @param _token Address of the ERC20 token to be claimed.
* @param _treasury Address holding the tokens and that has approved spending.
* @param _merkleRoot The Merkle root representing the full airdrop data.
* @param _claimStart Timestamp when claims can begin.
* @param _claimEnd Timestamp when claims end.
* @param _owner Address that will own the deployed TokenClaim instance.
* @param _salt Salt value for deterministic address generation.
* @return clone Address of the newly deployed TokenClaim clone.
*/
function deployTokenClaimDeterministic(
IERC20 _token,
address _treasury,
bytes32 _merkleRoot,
uint256 _claimStart,
uint256 _claimEnd,
address _owner,
bytes32 _salt
) external payable returns (address clone) {
return
deployTokenClaimDeterministic(
_token,
_treasury,
_merkleRoot,
_claimStart,
_claimEnd,
_owner,
_salt,
FeeTier.NoFee
);
}
/**
* @dev Deploy a new TokenClaim clone with deterministic address using CREATE2.
* @param _token Address of the ERC20 token to be claimed.
* @param _treasury Address holding the tokens and that has approved spending.
* @param _merkleRoot The Merkle root representing the full airdrop data.
* @param _claimStart Timestamp when claims can begin.
* @param _claimEnd Timestamp when claims end.
* @param _owner Address that will own the deployed TokenClaim instance.
* @param _salt Salt value for deterministic address generation.
* @param _feeTier Selected fee tier for observability (front-end enforced).
* @return clone Address of the newly deployed TokenClaim clone.
*/
function deployTokenClaimDeterministic(
IERC20 _token,
address _treasury,
bytes32 _merkleRoot,
uint256 _claimStart,
uint256 _claimEnd,
address _owner,
bytes32 _salt,
FeeTier _feeTier
) public payable returns (address clone) {
// Input validation
require(address(_token) != address(0), "Token address cannot be zero");
require(_treasury != address(0), "Treasury address cannot be zero");
require(_owner != address(0), "Owner address cannot be zero");
require(_merkleRoot != bytes32(0), "Merkle root cannot be zero");
require(_claimStart < _claimEnd, "Invalid claim window");
// Deploy the clone deterministically
clone = Clones.cloneDeterministic(implementation, _salt);
// Initialize the clone
TokenClaim(payable(clone)).initialize(_token, _treasury, _merkleRoot, _claimStart, _claimEnd, _owner);
// Update state
cloneCount++;
isClone[clone] = true;
clones.push(clone);
deployerToClones[msg.sender].push(clone);
_forwardPayment();
// Emit event
emit CloneDeployed(
clone,
msg.sender,
address(_token),
_treasury,
_merkleRoot,
_claimStart,
_claimEnd,
cloneCount,
_owner,
_feeTier,
msg.value
);
return clone;
}
/**
* @dev Deploy a new TokenClaim clone with deterministic address and record K9 treasury claim data.
* Use this when deploying with a fee tier that includes K9 treasury allocation.
* The K9 claim data is emitted as an event for off-chain retrieval.
* @param _token Address of the ERC20 token to be claimed.
* @param _treasury Address holding the tokens and that has approved spending.
* @param _merkleRoot The Merkle root representing the full airdrop data.
* @param _claimStart Timestamp when claims can begin.
* @param _claimEnd Timestamp when claims end.
* @param _owner Address that will own the deployed TokenClaim instance.
* @param _salt Salt value for deterministic address generation.
* @param _feeTier Selected fee tier for observability.
* @param _k9Treasury Address of the K9 treasury that will claim the fee allocation.
* @param _k9Amount Amount of tokens allocated to K9 treasury.
* @param _k9Proof Merkle proof for K9 treasury to claim their allocation.
* @return clone Address of the newly deployed TokenClaim clone.
*/
function deployTokenClaimDeterministicWithK9Data(
IERC20 _token,
address _treasury,
bytes32 _merkleRoot,
uint256 _claimStart,
uint256 _claimEnd,
address _owner,
bytes32 _salt,
FeeTier _feeTier,
address _k9Treasury,
uint256 _k9Amount,
bytes32[] calldata _k9Proof
) external payable returns (address clone) {
// Deploy using existing deterministic logic
clone = deployTokenClaimDeterministic(
_token,
_treasury,
_merkleRoot,
_claimStart,
_claimEnd,
_owner,
_salt,
_feeTier
);
// Emit K9 claim data if provided
if (_k9Amount > 0) {
require(_k9Treasury != address(0), "K9 treasury cannot be zero");
require(_k9Proof.length > 0, "K9 proof cannot be empty");
emit K9ClaimDataRecorded(clone, _k9Treasury, _k9Amount, _k9Proof);
}
return clone;
}
/**
* @dev Predict the address of a clone that would be deployed with the given salt.
* @param _salt Salt value for deterministic address generation.
* @return predicted The address where the clone would be deployed.
*/
function predictDeterministicAddress(bytes32 _salt) external view returns (address predicted) {
return Clones.predictDeterministicAddress(implementation, _salt, address(this));
}
/**
* @dev Get all deployed clone addresses.
* @return Array of all clone addresses deployed by this factory.
*/
function getAllClones() external view returns (address[] memory) {
return clones;
}
/**
* @dev Get all clone addresses deployed by a specific address.
* @param _deployer Address of the deployer to query.
* @return Array of clone addresses deployed by the given address.
*/
function getClonesByDeployer(address _deployer) external view returns (address[] memory) {
return deployerToClones[_deployer];
}
/**
* @dev Get a range of clone addresses for pagination.
* @param _start Starting index (inclusive).
* @param _end Ending index (exclusive).
* @return Array of clone addresses in the specified range.
*/
function getClones(uint256 _start, uint256 _end) external view returns (address[] memory) {
require(_start < _end, "Invalid range");
require(_end <= clones.length, "End index out of bounds");
require(_end - _start <= 1000, "Range too large");
address[] memory result = new address[](_end - _start);
for (uint256 i = _start; i < _end; i++) {
result[i - _start] = clones[i];
}
return result;
}
/**
* @dev Get the latest deployed clones.
* @param _count Number of latest clones to return.
* @return Array of the latest clone addresses.
*/
function getLatestClones(uint256 _count) external view returns (address[] memory) {
require(_count <= 1000, "Count too large");
if (_count > clones.length) {
_count = clones.length;
}
address[] memory result = new address[](_count);
uint256 startIndex = clones.length - _count;
for (uint256 i = 0; i < _count; i++) {
result[i] = clones[startIndex + i];
}
return result;
}
/// @notice Sets the fee treasury that receives native payments during deployments.
/// @param _feeTreasury Address of the treasury that collects fees.
function setFeeTreasury(address _feeTreasury) external onlyOwner {
require(_feeTreasury != address(0), "Treasury address cannot be zero");
feeTreasury = _feeTreasury;
emit FeeTreasuryUpdated(_feeTreasury);
}
/// @notice Sets the oracle address for future on-chain fee validation.
/// @param _priceOracle Address of the oracle contract.
function setPriceOracle(address _priceOracle) external onlyOwner {
require(_priceOracle != address(0), "Oracle address cannot be zero");
priceOracle = _priceOracle;
emit PriceOracleUpdated(_priceOracle);
}
function _forwardPayment() private {
if (msg.value == 0) {
return;
}
address treasury = feeTreasury;
require(treasury != address(0), "Fee treasury not set");
(bool success, ) = treasury.call{ value: msg.value }("");
require(success, "Treasury payment failed");
}
}// 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.1.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.
*
* This extension of the {Ownable} contract includes a two-step mechanism to transfer
* ownership, where the new owner must call {acceptOwnership} in order to replace the
* old one. This can help prevent common mistakes, such as transfers of ownership to
* incorrect accounts, or to contracts that are unable to interact with the
* permission system.
*
* 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.
*
* Setting `newOwner` to the zero address is allowed; this can be used to cancel an initiated ownership transfer.
*/
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.4.0) (interfaces/IERC1363.sol)
pragma solidity >=0.6.2;
import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";
/**
* @title IERC1363
* @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
*
* Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
* after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
*/
interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0xb0202a11.
* 0xb0202a11 ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @param data Additional data with no specified format, sent in call to `spender`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC165.sol)
pragma solidity >=0.4.16;
import {IERC165} from "../utils/introspection/IERC165.sol";// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC20.sol)
pragma solidity >=0.4.16;
import {IERC20} from "../token/ERC20/IERC20.sol";// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (proxy/Clones.sol)
pragma solidity ^0.8.20;
import {Create2} from "../utils/Create2.sol";
import {Errors} from "../utils/Errors.sol";
/**
* @dev https://eips.ethereum.org/EIPS/eip-1167[ERC-1167] is a standard for
* deploying minimal proxy contracts, also known as "clones".
*
* > To simply and cheaply clone contract functionality in an immutable way, this standard specifies
* > a minimal bytecode implementation that delegates all calls to a known, fixed address.
*
* The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2`
* (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the
* deterministic method.
*/
library Clones {
error CloneArgumentsTooLong();
/**
* @dev Deploys and returns the address of a clone that mimics the behavior of `implementation`.
*
* This function uses the create opcode, which should never revert.
*
* WARNING: This function does not check if `implementation` has code. A clone that points to an address
* without code cannot be initialized. Initialization calls may appear to be successful when, in reality, they
* have no effect and leave the clone uninitialized, allowing a third party to initialize it later.
*/
function clone(address implementation) internal returns (address instance) {
return clone(implementation, 0);
}
/**
* @dev Same as {xref-Clones-clone-address-}[clone], but with a `value` parameter to send native currency
* to the new contract.
*
* WARNING: This function does not check if `implementation` has code. A clone that points to an address
* without code cannot be initialized. Initialization calls may appear to be successful when, in reality, they
* have no effect and leave the clone uninitialized, allowing a third party to initialize it later.
*
* NOTE: Using a non-zero value at creation will require the contract using this function (e.g. a factory)
* to always have enough balance for new deployments. Consider exposing this function under a payable method.
*/
function clone(address implementation, uint256 value) internal returns (address instance) {
if (address(this).balance < value) {
revert Errors.InsufficientBalance(address(this).balance, value);
}
assembly ("memory-safe") {
// Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes
// of the `implementation` address with the bytecode before the address.
mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000))
// Packs the remaining 17 bytes of `implementation` with the bytecode after the address.
mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3))
instance := create(value, 0x09, 0x37)
}
if (instance == address(0)) {
revert Errors.FailedDeployment();
}
}
/**
* @dev Deploys and returns the address of a clone that mimics the behavior of `implementation`.
*
* This function uses the create2 opcode and a `salt` to deterministically deploy
* the clone. Using the same `implementation` and `salt` multiple times will revert, since
* the clones cannot be deployed twice at the same address.
*
* WARNING: This function does not check if `implementation` has code. A clone that points to an address
* without code cannot be initialized. Initialization calls may appear to be successful when, in reality, they
* have no effect and leave the clone uninitialized, allowing a third party to initialize it later.
*/
function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) {
return cloneDeterministic(implementation, salt, 0);
}
/**
* @dev Same as {xref-Clones-cloneDeterministic-address-bytes32-}[cloneDeterministic], but with
* a `value` parameter to send native currency to the new contract.
*
* WARNING: This function does not check if `implementation` has code. A clone that points to an address
* without code cannot be initialized. Initialization calls may appear to be successful when, in reality, they
* have no effect and leave the clone uninitialized, allowing a third party to initialize it later.
*
* NOTE: Using a non-zero value at creation will require the contract using this function (e.g. a factory)
* to always have enough balance for new deployments. Consider exposing this function under a payable method.
*/
function cloneDeterministic(
address implementation,
bytes32 salt,
uint256 value
) internal returns (address instance) {
if (address(this).balance < value) {
revert Errors.InsufficientBalance(address(this).balance, value);
}
assembly ("memory-safe") {
// Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes
// of the `implementation` address with the bytecode before the address.
mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000))
// Packs the remaining 17 bytes of `implementation` with the bytecode after the address.
mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3))
instance := create2(value, 0x09, 0x37, salt)
}
if (instance == address(0)) {
revert Errors.FailedDeployment();
}
}
/**
* @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
*/
function predictDeterministicAddress(
address implementation,
bytes32 salt,
address deployer
) internal pure returns (address predicted) {
assembly ("memory-safe") {
let ptr := mload(0x40)
mstore(add(ptr, 0x38), deployer)
mstore(add(ptr, 0x24), 0x5af43d82803e903d91602b57fd5bf3ff)
mstore(add(ptr, 0x14), implementation)
mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73)
mstore(add(ptr, 0x58), salt)
mstore(add(ptr, 0x78), keccak256(add(ptr, 0x0c), 0x37))
predicted := and(keccak256(add(ptr, 0x43), 0x55), 0xffffffffffffffffffffffffffffffffffffffff)
}
}
/**
* @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
*/
function predictDeterministicAddress(
address implementation,
bytes32 salt
) internal view returns (address predicted) {
return predictDeterministicAddress(implementation, salt, address(this));
}
/**
* @dev Deploys and returns the address of a clone that mimics the behavior of `implementation` with custom
* immutable arguments. These are provided through `args` and cannot be changed after deployment. To
* access the arguments within the implementation, use {fetchCloneArgs}.
*
* This function uses the create opcode, which should never revert.
*
* WARNING: This function does not check if `implementation` has code. A clone that points to an address
* without code cannot be initialized. Initialization calls may appear to be successful when, in reality, they
* have no effect and leave the clone uninitialized, allowing a third party to initialize it later.
*/
function cloneWithImmutableArgs(address implementation, bytes memory args) internal returns (address instance) {
return cloneWithImmutableArgs(implementation, args, 0);
}
/**
* @dev Same as {xref-Clones-cloneWithImmutableArgs-address-bytes-}[cloneWithImmutableArgs], but with a `value`
* parameter to send native currency to the new contract.
*
* WARNING: This function does not check if `implementation` has code. A clone that points to an address
* without code cannot be initialized. Initialization calls may appear to be successful when, in reality, they
* have no effect and leave the clone uninitialized, allowing a third party to initialize it later.
*
* NOTE: Using a non-zero value at creation will require the contract using this function (e.g. a factory)
* to always have enough balance for new deployments. Consider exposing this function under a payable method.
*/
function cloneWithImmutableArgs(
address implementation,
bytes memory args,
uint256 value
) internal returns (address instance) {
if (address(this).balance < value) {
revert Errors.InsufficientBalance(address(this).balance, value);
}
bytes memory bytecode = _cloneCodeWithImmutableArgs(implementation, args);
assembly ("memory-safe") {
instance := create(value, add(bytecode, 0x20), mload(bytecode))
}
if (instance == address(0)) {
revert Errors.FailedDeployment();
}
}
/**
* @dev Deploys and returns the address of a clone that mimics the behavior of `implementation` with custom
* immutable arguments. These are provided through `args` and cannot be changed after deployment. To
* access the arguments within the implementation, use {fetchCloneArgs}.
*
* This function uses the create2 opcode and a `salt` to deterministically deploy the clone. Using the same
* `implementation`, `args` and `salt` multiple times will revert, since the clones cannot be deployed twice
* at the same address.
*
* WARNING: This function does not check if `implementation` has code. A clone that points to an address
* without code cannot be initialized. Initialization calls may appear to be successful when, in reality, they
* have no effect and leave the clone uninitialized, allowing a third party to initialize it later.
*/
function cloneDeterministicWithImmutableArgs(
address implementation,
bytes memory args,
bytes32 salt
) internal returns (address instance) {
return cloneDeterministicWithImmutableArgs(implementation, args, salt, 0);
}
/**
* @dev Same as {xref-Clones-cloneDeterministicWithImmutableArgs-address-bytes-bytes32-}[cloneDeterministicWithImmutableArgs],
* but with a `value` parameter to send native currency to the new contract.
*
* WARNING: This function does not check if `implementation` has code. A clone that points to an address
* without code cannot be initialized. Initialization calls may appear to be successful when, in reality, they
* have no effect and leave the clone uninitialized, allowing a third party to initialize it later.
*
* NOTE: Using a non-zero value at creation will require the contract using this function (e.g. a factory)
* to always have enough balance for new deployments. Consider exposing this function under a payable method.
*/
function cloneDeterministicWithImmutableArgs(
address implementation,
bytes memory args,
bytes32 salt,
uint256 value
) internal returns (address instance) {
bytes memory bytecode = _cloneCodeWithImmutableArgs(implementation, args);
return Create2.deploy(value, salt, bytecode);
}
/**
* @dev Computes the address of a clone deployed using {Clones-cloneDeterministicWithImmutableArgs}.
*/
function predictDeterministicAddressWithImmutableArgs(
address implementation,
bytes memory args,
bytes32 salt,
address deployer
) internal pure returns (address predicted) {
bytes memory bytecode = _cloneCodeWithImmutableArgs(implementation, args);
return Create2.computeAddress(salt, keccak256(bytecode), deployer);
}
/**
* @dev Computes the address of a clone deployed using {Clones-cloneDeterministicWithImmutableArgs}.
*/
function predictDeterministicAddressWithImmutableArgs(
address implementation,
bytes memory args,
bytes32 salt
) internal view returns (address predicted) {
return predictDeterministicAddressWithImmutableArgs(implementation, args, salt, address(this));
}
/**
* @dev Get the immutable args attached to a clone.
*
* - If `instance` is a clone that was deployed using `clone` or `cloneDeterministic`, this
* function will return an empty array.
* - If `instance` is a clone that was deployed using `cloneWithImmutableArgs` or
* `cloneDeterministicWithImmutableArgs`, this function will return the args array used at
* creation.
* - If `instance` is NOT a clone deployed using this library, the behavior is undefined. This
* function should only be used to check addresses that are known to be clones.
*/
function fetchCloneArgs(address instance) internal view returns (bytes memory) {
bytes memory result = new bytes(instance.code.length - 45); // revert if length is too short
assembly ("memory-safe") {
extcodecopy(instance, add(result, 32), 45, mload(result))
}
return result;
}
/**
* @dev Helper that prepares the initcode of the proxy with immutable args.
*
* An assembly variant of this function requires copying the `args` array, which can be efficiently done using
* `mcopy`. Unfortunately, that opcode is not available before cancun. A pure solidity implementation using
* abi.encodePacked is more expensive but also more portable and easier to review.
*
* NOTE: https://eips.ethereum.org/EIPS/eip-170[EIP-170] limits the length of the contract code to 24576 bytes.
* With the proxy code taking 45 bytes, that limits the length of the immutable args to 24531 bytes.
*/
function _cloneCodeWithImmutableArgs(
address implementation,
bytes memory args
) private pure returns (bytes memory) {
if (args.length > 24531) revert CloneArgumentsTooLong();
return
abi.encodePacked(
hex"61",
uint16(args.length + 45),
hex"3d81600a3d39f3363d3d373d3d3d363d73",
implementation,
hex"5af43d82803e903d91602b57fd5bf3",
args
);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/IERC20.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
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.3.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC-20 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 {
/**
* @dev An operation with an ERC-20 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 Variant of {safeTransfer} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransfer(IERC20 token, address to, uint256 value) internal returns (bool) {
return _callOptionalReturnBool(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Variant of {safeTransferFrom} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransferFrom(IERC20 token, address from, address to, uint256 value) internal returns (bool) {
return _callOptionalReturnBool(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.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
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.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
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.
*
* NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
* only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
* set here.
*/
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 Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
safeTransfer(token, to, value);
} else if (!token.transferAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
* has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferFromAndCallRelaxed(
IERC1363 token,
address from,
address to,
uint256 value,
bytes memory data
) internal {
if (to.code.length == 0) {
safeTransferFrom(token, from, to, value);
} else if (!token.transferFromAndCall(from, to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
* Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
* once without retrying, and relies on the returned value to be true.
*
* Reverts if the returned value is other than `true`.
*/
function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
forceApprove(token, to, value);
} else if (!token.approveAndCall(to, value, data)) {
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 {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
// bubble errors
if iszero(success) {
let ptr := mload(0x40)
returndatacopy(ptr, 0, returndatasize())
revert(ptr, returndatasize())
}
returnSize := returndatasize()
returnValue := mload(0)
}
if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
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 silently catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
bool success;
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
returnSize := returndatasize()
returnValue := mload(0)
}
return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
}
}// 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.1.0) (utils/Create2.sol)
pragma solidity ^0.8.20;
import {Errors} from "./Errors.sol";
/**
* @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer.
* `CREATE2` can be used to compute in advance the address where a smart
* contract will be deployed, which allows for interesting new mechanisms known
* as 'counterfactual interactions'.
*
* See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more
* information.
*/
library Create2 {
/**
* @dev There's no code to deploy.
*/
error Create2EmptyBytecode();
/**
* @dev Deploys a contract using `CREATE2`. The address where the contract
* will be deployed can be known in advance via {computeAddress}.
*
* The bytecode for a contract can be obtained from Solidity with
* `type(contractName).creationCode`.
*
* Requirements:
*
* - `bytecode` must not be empty.
* - `salt` must have not been used for `bytecode` already.
* - the factory must have a balance of at least `amount`.
* - if `amount` is non-zero, `bytecode` must have a `payable` constructor.
*/
function deploy(uint256 amount, bytes32 salt, bytes memory bytecode) internal returns (address addr) {
if (address(this).balance < amount) {
revert Errors.InsufficientBalance(address(this).balance, amount);
}
if (bytecode.length == 0) {
revert Create2EmptyBytecode();
}
assembly ("memory-safe") {
addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt)
// if no address was created, and returndata is not empty, bubble revert
if and(iszero(addr), not(iszero(returndatasize()))) {
let p := mload(0x40)
returndatacopy(p, 0, returndatasize())
revert(p, returndatasize())
}
}
if (addr == address(0)) {
revert Errors.FailedDeployment();
}
}
/**
* @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the
* `bytecodeHash` or `salt` will result in a new destination address.
*/
function computeAddress(bytes32 salt, bytes32 bytecodeHash) internal view returns (address) {
return computeAddress(salt, bytecodeHash, address(this));
}
/**
* @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at
* `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}.
*/
function computeAddress(bytes32 salt, bytes32 bytecodeHash, address deployer) internal pure returns (address addr) {
assembly ("memory-safe") {
let ptr := mload(0x40) // Get free memory pointer
// | | ↓ ptr ... ↓ ptr + 0x0B (start) ... ↓ ptr + 0x20 ... ↓ ptr + 0x40 ... |
// |-------------------|---------------------------------------------------------------------------|
// | bytecodeHash | CCCCCCCCCCCCC...CC |
// | salt | BBBBBBBBBBBBB...BB |
// | deployer | 000000...0000AAAAAAAAAAAAAAAAAAA...AA |
// | 0xFF | FF |
// |-------------------|---------------------------------------------------------------------------|
// | memory | 000000...00FFAAAAAAAAAAAAAAAAAAA...AABBBBBBBBBBBBB...BBCCCCCCCCCCCCC...CC |
// | keccak(start, 85) | ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ |
mstore(add(ptr, 0x40), bytecodeHash)
mstore(add(ptr, 0x20), salt)
mstore(ptr, deployer) // Right-aligned with 12 preceding garbage bytes
let start := add(ptr, 0x0b) // The hashed data starts at the final garbage byte which we will set to 0xff
mstore8(start, 0xff)
addr := and(keccak256(start, 85), 0xffffffffffffffffffffffffffffffffffffffff)
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/cryptography/Hashes.sol)
pragma solidity ^0.8.20;
/**
* @dev Library of standard hash functions.
*
* _Available since v5.1._
*/
library Hashes {
/**
* @dev Commutative Keccak256 hash of a sorted pair of bytes32. Frequently used when working with merkle proofs.
*
* NOTE: Equivalent to the `standardNodeHash` in our https://github.com/OpenZeppelin/merkle-tree[JavaScript library].
*/
function commutativeKeccak256(bytes32 a, bytes32 b) internal pure returns (bytes32) {
return a < b ? efficientKeccak256(a, b) : efficientKeccak256(b, a);
}
/**
* @dev Implementation of keccak256(abi.encode(a, b)) that doesn't allocate or expand memory.
*/
function efficientKeccak256(bytes32 a, bytes32 b) internal pure returns (bytes32 value) {
assembly ("memory-safe") {
mstore(0x00, a)
mstore(0x20, b)
value := keccak256(0x00, 0x40)
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/cryptography/MerkleProof.sol)
// This file was procedurally generated from scripts/generate/templates/MerkleProof.js.
pragma solidity ^0.8.20;
import {Hashes} from "./Hashes.sol";
/**
* @dev These functions deal with verification of Merkle Tree proofs.
*
* The tree and the proofs can be generated using our
* https://github.com/OpenZeppelin/merkle-tree[JavaScript library].
* You will find a quickstart guide in the readme.
*
* WARNING: You should avoid using leaf values that are 64 bytes long prior to
* hashing, or use a hash function other than keccak256 for hashing leaves.
* This is because the concatenation of a sorted pair of internal nodes in
* the Merkle tree could be reinterpreted as a leaf value.
* OpenZeppelin's JavaScript library generates Merkle trees that are safe
* against this attack out of the box.
*
* IMPORTANT: Consider memory side-effects when using custom hashing functions
* that access memory in an unsafe way.
*
* NOTE: This library supports proof verification for merkle trees built using
* custom _commutative_ hashing functions (i.e. `H(a, b) == H(b, a)`). Proving
* leaf inclusion in trees built using non-commutative hashing functions requires
* additional logic that is not supported by this library.
*/
library MerkleProof {
/**
*@dev The multiproof provided is not valid.
*/
error MerkleProofInvalidMultiproof();
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*
* This version handles proofs in memory with the default hashing function.
*/
function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
return processProof(proof, leaf) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leaves & pre-images are assumed to be sorted.
*
* This version handles proofs in memory with the default hashing function.
*/
function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = Hashes.commutativeKeccak256(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*
* This version handles proofs in memory with a custom hashing function.
*/
function verify(
bytes32[] memory proof,
bytes32 root,
bytes32 leaf,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bool) {
return processProof(proof, leaf, hasher) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leaves & pre-images are assumed to be sorted.
*
* This version handles proofs in memory with a custom hashing function.
*/
function processProof(
bytes32[] memory proof,
bytes32 leaf,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = hasher(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*
* This version handles proofs in calldata with the default hashing function.
*/
function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
return processProofCalldata(proof, leaf) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leaves & pre-images are assumed to be sorted.
*
* This version handles proofs in calldata with the default hashing function.
*/
function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = Hashes.commutativeKeccak256(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*
* This version handles proofs in calldata with a custom hashing function.
*/
function verifyCalldata(
bytes32[] calldata proof,
bytes32 root,
bytes32 leaf,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bool) {
return processProofCalldata(proof, leaf, hasher) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leaves & pre-images are assumed to be sorted.
*
* This version handles proofs in calldata with a custom hashing function.
*/
function processProofCalldata(
bytes32[] calldata proof,
bytes32 leaf,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = hasher(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by
* `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
*
* This version handles multiproofs in memory with the default hashing function.
*
* CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
*
* NOTE: Consider the case where `root == proof[0] && leaves.length == 0` as it will return `true`.
* The `leaves` must be validated independently. See {processMultiProof}.
*/
function multiProofVerify(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool) {
return processMultiProof(proof, proofFlags, leaves) == root;
}
/**
* @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
* proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
* leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
* respectively.
*
* This version handles multiproofs in memory with the default hashing function.
*
* CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
* is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
* tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
*
* NOTE: The _empty set_ (i.e. the case where `proof.length == 1 && leaves.length == 0`) is considered a no-op,
* and therefore a valid multiproof (i.e. it returns `proof[0]`). Consider disallowing this case if you're not
* validating the leaves elsewhere.
*/
function processMultiProof(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32[] memory leaves
) internal pure returns (bytes32 merkleRoot) {
// This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the Merkle tree.
uint256 leavesLen = leaves.length;
uint256 proofFlagsLen = proofFlags.length;
// Check proof validity.
if (leavesLen + proof.length != proofFlagsLen + 1) {
revert MerkleProofInvalidMultiproof();
}
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](proofFlagsLen);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < proofFlagsLen; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i]
? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
: proof[proofPos++];
hashes[i] = Hashes.commutativeKeccak256(a, b);
}
if (proofFlagsLen > 0) {
if (proofPos != proof.length) {
revert MerkleProofInvalidMultiproof();
}
unchecked {
return hashes[proofFlagsLen - 1];
}
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
/**
* @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by
* `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
*
* This version handles multiproofs in memory with a custom hashing function.
*
* CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
*
* NOTE: Consider the case where `root == proof[0] && leaves.length == 0` as it will return `true`.
* The `leaves` must be validated independently. See {processMultiProof}.
*/
function multiProofVerify(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32 root,
bytes32[] memory leaves,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bool) {
return processMultiProof(proof, proofFlags, leaves, hasher) == root;
}
/**
* @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
* proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
* leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
* respectively.
*
* This version handles multiproofs in memory with a custom hashing function.
*
* CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
* is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
* tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
*
* NOTE: The _empty set_ (i.e. the case where `proof.length == 1 && leaves.length == 0`) is considered a no-op,
* and therefore a valid multiproof (i.e. it returns `proof[0]`). Consider disallowing this case if you're not
* validating the leaves elsewhere.
*/
function processMultiProof(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32[] memory leaves,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bytes32 merkleRoot) {
// This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the Merkle tree.
uint256 leavesLen = leaves.length;
uint256 proofFlagsLen = proofFlags.length;
// Check proof validity.
if (leavesLen + proof.length != proofFlagsLen + 1) {
revert MerkleProofInvalidMultiproof();
}
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](proofFlagsLen);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < proofFlagsLen; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i]
? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
: proof[proofPos++];
hashes[i] = hasher(a, b);
}
if (proofFlagsLen > 0) {
if (proofPos != proof.length) {
revert MerkleProofInvalidMultiproof();
}
unchecked {
return hashes[proofFlagsLen - 1];
}
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
/**
* @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by
* `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
*
* This version handles multiproofs in calldata with the default hashing function.
*
* CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
*
* NOTE: Consider the case where `root == proof[0] && leaves.length == 0` as it will return `true`.
* The `leaves` must be validated independently. See {processMultiProofCalldata}.
*/
function multiProofVerifyCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool) {
return processMultiProofCalldata(proof, proofFlags, leaves) == root;
}
/**
* @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
* proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
* leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
* respectively.
*
* This version handles multiproofs in calldata with the default hashing function.
*
* CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
* is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
* tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
*
* NOTE: The _empty set_ (i.e. the case where `proof.length == 1 && leaves.length == 0`) is considered a no-op,
* and therefore a valid multiproof (i.e. it returns `proof[0]`). Consider disallowing this case if you're not
* validating the leaves elsewhere.
*/
function processMultiProofCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32[] memory leaves
) internal pure returns (bytes32 merkleRoot) {
// This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the Merkle tree.
uint256 leavesLen = leaves.length;
uint256 proofFlagsLen = proofFlags.length;
// Check proof validity.
if (leavesLen + proof.length != proofFlagsLen + 1) {
revert MerkleProofInvalidMultiproof();
}
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](proofFlagsLen);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < proofFlagsLen; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i]
? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
: proof[proofPos++];
hashes[i] = Hashes.commutativeKeccak256(a, b);
}
if (proofFlagsLen > 0) {
if (proofPos != proof.length) {
revert MerkleProofInvalidMultiproof();
}
unchecked {
return hashes[proofFlagsLen - 1];
}
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
/**
* @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by
* `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
*
* This version handles multiproofs in calldata with a custom hashing function.
*
* CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
*
* NOTE: Consider the case where `root == proof[0] && leaves.length == 0` as it will return `true`.
* The `leaves` must be validated independently. See {processMultiProofCalldata}.
*/
function multiProofVerifyCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32 root,
bytes32[] memory leaves,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bool) {
return processMultiProofCalldata(proof, proofFlags, leaves, hasher) == root;
}
/**
* @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
* proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
* leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
* respectively.
*
* This version handles multiproofs in calldata with a custom hashing function.
*
* CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
* is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
* tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
*
* NOTE: The _empty set_ (i.e. the case where `proof.length == 1 && leaves.length == 0`) is considered a no-op,
* and therefore a valid multiproof (i.e. it returns `proof[0]`). Consider disallowing this case if you're not
* validating the leaves elsewhere.
*/
function processMultiProofCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32[] memory leaves,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bytes32 merkleRoot) {
// This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the Merkle tree.
uint256 leavesLen = leaves.length;
uint256 proofFlagsLen = proofFlags.length;
// Check proof validity.
if (leavesLen + proof.length != proofFlagsLen + 1) {
revert MerkleProofInvalidMultiproof();
}
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](proofFlagsLen);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < proofFlagsLen; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i]
? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
: proof[proofPos++];
hashes[i] = hasher(a, b);
}
if (proofFlagsLen > 0) {
if (proofPos != proof.length) {
revert MerkleProofInvalidMultiproof();
}
unchecked {
return hashes[proofFlagsLen - 1];
}
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of common custom errors used in multiple contracts
*
* IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library.
* It is recommended to avoid relying on the error API for critical functionality.
*
* _Available since v5.1._
*/
library Errors {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error InsufficientBalance(uint256 balance, uint256 needed);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedCall();
/**
* @dev The deployment failed.
*/
error FailedDeployment();
/**
* @dev A necessary precompile is missing.
*/
error MissingPrecompile(address);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/IERC165.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import { MerkleProof } from "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { Ownable2Step } from "@openzeppelin/contracts/access/Ownable2Step.sol";
contract TokenClaim is Ownable2Step {
using SafeERC20 for IERC20;
IERC20 public token;
address public treasury;
bytes32 public merkleRoot;
uint256 public claimStart;
uint256 public claimEnd;
bool private initialized;
// Tracks if an address has claimed their tokens.
mapping(address => bool) public claimed;
event Claimed(address indexed claimant, uint256 amount);
event RecoveredToken(address tokenAddress, uint256 amount);
event RecoveredEther(uint256 amount);
/**
* @dev Constructor for implementation contract (disabled).
*/
constructor() Ownable(msg.sender) {
// The implementation contract is locked by setting initialized to true.
// The owner is the deployer, but it cannot call initialize.
initialized = true;
}
/**
* @dev Initialize the clone with token, treasury, merkle root, and claim window.
* @param _token Address of the ERC20 token.
* @param _treasury Address holding the tokens and that has approved spending.
* @param _merkleRoot The Merkle root representing the full airdrop data.
* @param _claimStart Timestamp when claims can begin.
* @param _claimEnd Timestamp when claims end.
* @param _owner Address that will own this TokenClaim instance.
*/
function initialize(
IERC20 _token,
address _treasury,
bytes32 _merkleRoot,
uint256 _claimStart,
uint256 _claimEnd,
address _owner
) external {
require(!initialized, "Already initialized");
require(_claimStart < _claimEnd, "Invalid claim window");
require(_owner != address(0), "Owner cannot be zero address");
initialized = true;
token = _token;
treasury = _treasury;
merkleRoot = _merkleRoot;
claimStart = _claimStart;
claimEnd = _claimEnd;
_transferOwnership(_owner);
}
/**
* @dev Allows eligible users to claim their tokens.
* @param amount The claimable token amount.
* @param proof The Merkle proof validating the claim.
*/
function claim(uint256 amount, bytes32[] calldata proof) external {
require(block.timestamp >= claimStart, "Claim period not started");
require(block.timestamp <= claimEnd, "Claim period ended");
require(!claimed[msg.sender], "Already claimed");
// Recreate the leaf from the sender's address and amount.
bytes32 leaf = keccak256(abi.encodePacked(msg.sender, amount));
require(MerkleProof.verify(proof, merkleRoot, leaf), "Invalid Merkle proof");
// Mark as claimed
claimed[msg.sender] = true;
// Transfer tokens from the treasury wallet to the claimant.
token.safeTransferFrom(treasury, msg.sender, amount);
emit Claimed(msg.sender, amount);
}
/**
* @dev Recover any ERC20 tokens accidentally sent to the contract.
* @param _tokenAddress The address of the ERC20 token to recover.
*/
function recoverToken(address _tokenAddress) external onlyOwner {
IERC20 tokenToRecover = IERC20(_tokenAddress);
uint256 balance = tokenToRecover.balanceOf(address(this));
require(balance > 0, "No tokens to recover");
tokenToRecover.safeTransfer(owner(), balance);
emit RecoveredToken(_tokenAddress, balance);
}
/**
* @dev Recover any Ether accidentally sent to the contract.
*/
function recoverEther() external onlyOwner {
uint256 balance = address(this).balance;
require(balance > 0, "No ether to recover");
(bool success, ) = payable(owner()).call{ value: balance }("");
require(success, "ETH transfer failed");
emit RecoveredEther(balance);
}
// Allow the contract to receive Ether.
receive() external payable {}
}{
"optimizer": {
"enabled": true,
"runs": 5000
},
"evmVersion": "paris",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"metadata": {
"useLiteralContent": true
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"FailedDeployment","type":"error"},{"inputs":[{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"InsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"clone","type":"address"},{"indexed":true,"internalType":"address","name":"deployer","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"address","name":"treasury","type":"address"},{"indexed":false,"internalType":"bytes32","name":"merkleRoot","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"claimStart","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"claimEnd","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"cloneNumber","type":"uint256"},{"indexed":false,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"enum TokenClaimFactory.FeeTier","name":"feeTier","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"nativeFeePaid","type":"uint256"}],"name":"CloneDeployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newFeeTreasury","type":"address"}],"name":"FeeTreasuryUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"clone","type":"address"},{"indexed":true,"internalType":"address","name":"k9Treasury","type":"address"},{"indexed":false,"internalType":"uint256","name":"k9Amount","type":"uint256"},{"indexed":false,"internalType":"bytes32[]","name":"k9Proof","type":"bytes32[]"}],"name":"K9ClaimDataRecorded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newPriceOracle","type":"address"}],"name":"PriceOracleUpdated","type":"event"},{"inputs":[],"name":"cloneCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"clones","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_token","type":"address"},{"internalType":"address","name":"_treasury","type":"address"},{"internalType":"bytes32","name":"_merkleRoot","type":"bytes32"},{"internalType":"uint256","name":"_claimStart","type":"uint256"},{"internalType":"uint256","name":"_claimEnd","type":"uint256"},{"internalType":"address","name":"_owner","type":"address"},{"internalType":"enum TokenClaimFactory.FeeTier","name":"_feeTier","type":"uint8"}],"name":"deployTokenClaim","outputs":[{"internalType":"address","name":"clone","type":"address"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_token","type":"address"},{"internalType":"address","name":"_treasury","type":"address"},{"internalType":"bytes32","name":"_merkleRoot","type":"bytes32"},{"internalType":"uint256","name":"_claimStart","type":"uint256"},{"internalType":"uint256","name":"_claimEnd","type":"uint256"},{"internalType":"address","name":"_owner","type":"address"}],"name":"deployTokenClaim","outputs":[{"internalType":"address","name":"clone","type":"address"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_token","type":"address"},{"internalType":"address","name":"_treasury","type":"address"},{"internalType":"bytes32","name":"_merkleRoot","type":"bytes32"},{"internalType":"uint256","name":"_claimStart","type":"uint256"},{"internalType":"uint256","name":"_claimEnd","type":"uint256"},{"internalType":"address","name":"_owner","type":"address"},{"internalType":"bytes32","name":"_salt","type":"bytes32"},{"internalType":"enum TokenClaimFactory.FeeTier","name":"_feeTier","type":"uint8"}],"name":"deployTokenClaimDeterministic","outputs":[{"internalType":"address","name":"clone","type":"address"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_token","type":"address"},{"internalType":"address","name":"_treasury","type":"address"},{"internalType":"bytes32","name":"_merkleRoot","type":"bytes32"},{"internalType":"uint256","name":"_claimStart","type":"uint256"},{"internalType":"uint256","name":"_claimEnd","type":"uint256"},{"internalType":"address","name":"_owner","type":"address"},{"internalType":"bytes32","name":"_salt","type":"bytes32"}],"name":"deployTokenClaimDeterministic","outputs":[{"internalType":"address","name":"clone","type":"address"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_token","type":"address"},{"internalType":"address","name":"_treasury","type":"address"},{"internalType":"bytes32","name":"_merkleRoot","type":"bytes32"},{"internalType":"uint256","name":"_claimStart","type":"uint256"},{"internalType":"uint256","name":"_claimEnd","type":"uint256"},{"internalType":"address","name":"_owner","type":"address"},{"internalType":"bytes32","name":"_salt","type":"bytes32"},{"internalType":"enum TokenClaimFactory.FeeTier","name":"_feeTier","type":"uint8"},{"internalType":"address","name":"_k9Treasury","type":"address"},{"internalType":"uint256","name":"_k9Amount","type":"uint256"},{"internalType":"bytes32[]","name":"_k9Proof","type":"bytes32[]"}],"name":"deployTokenClaimDeterministicWithK9Data","outputs":[{"internalType":"address","name":"clone","type":"address"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_token","type":"address"},{"internalType":"address","name":"_treasury","type":"address"},{"internalType":"bytes32","name":"_merkleRoot","type":"bytes32"},{"internalType":"uint256","name":"_claimStart","type":"uint256"},{"internalType":"uint256","name":"_claimEnd","type":"uint256"},{"internalType":"address","name":"_owner","type":"address"},{"internalType":"enum TokenClaimFactory.FeeTier","name":"_feeTier","type":"uint8"},{"internalType":"address","name":"_k9Treasury","type":"address"},{"internalType":"uint256","name":"_k9Amount","type":"uint256"},{"internalType":"bytes32[]","name":"_k9Proof","type":"bytes32[]"}],"name":"deployTokenClaimWithK9Data","outputs":[{"internalType":"address","name":"clone","type":"address"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"feeTreasury","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAllClones","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_start","type":"uint256"},{"internalType":"uint256","name":"_end","type":"uint256"}],"name":"getClones","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_deployer","type":"address"}],"name":"getClonesByDeployer","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_count","type":"uint256"}],"name":"getLatestClones","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"implementation","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isClone","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_salt","type":"bytes32"}],"name":"predictDeterministicAddress","outputs":[{"internalType":"address","name":"predicted","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"priceOracle","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_feeTreasury","type":"address"}],"name":"setFeeTreasury","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_priceOracle","type":"address"}],"name":"setPriceOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
60a06040523480156200001157600080fd5b5033806200003957604051631e4fbdf760e01b81526000600482015260240160405180910390fd5b620000448162000083565b506040516200005390620000d3565b604051809103906000f08015801562000070573d6000803e3d6000fd5b506001600160a01b0316608052620000e1565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b610f708062001fa483390190565b608051611e9262000112600039600081816102df0152818161082201528181610b140152610d220152611e926000f3fe6080604052600436106101745760003560e01c80635e9ce84b116100cb5780638da5cb5b1161007f578063be4f221f11610059578063be4f221f146103e4578063bfa37e37146103f7578063f2fde38b1461041757600080fd5b80638da5cb5b146103825780639529b922146103a0578063b85f8fc5146103c457600080fd5b806367f841d0116100b057806367f841d014610347578063715018a61461035a57806372b6737c1461036f57600080fd5b80635e9ce84b1461031457806360dc23401461032757600080fd5b806327831ee01161012d5780635414dff0116101075780635414dff0146102ad5780635c60da1b146102cd5780635cca70c41461030157600080fd5b806327831ee014610263578063451cb43714610278578063530e784f1461028b57600080fd5b80630ff744591161015e5780630ff74459146101f657806321d012b5146102235780632630c12f1461024357600080fd5b8062ae3676146101795780630e039916146101be575b600080fd5b34801561018557600080fd5b506101a9610194366004611823565b60046020526000908152604090205460ff1681565b60405190151581526020015b60405180910390f35b3480156101ca57600080fd5b506101de6101d9366004611840565b610437565b6040516001600160a01b0390911681526020016101b5565b34801561020257600080fd5b50610216610211366004611823565b610461565b6040516101b59190611859565b34801561022f57600080fd5b5061021661023e366004611840565b6104d7565b34801561024f57600080fd5b506003546101de906001600160a01b031681565b34801561026f57600080fd5b5061021661061b565b6101de6102863660046118b5565b61067d565b34801561029757600080fd5b506102ab6102a6366004611823565b610a33565b005b3480156102b957600080fd5b506101de6102c8366004611840565b610af3565b3480156102d957600080fd5b506101de7f000000000000000000000000000000000000000000000000000000000000000081565b6101de61030f366004611936565b610b7d565b6101de6103223660046119ad565b610f31565b34801561033357600080fd5b506002546101de906001600160a01b031681565b6101de610355366004611a6b565b610f50565b34801561036657600080fd5b506102ab61106d565b6101de61037d366004611b42565b611081565b34801561038e57600080fd5b506000546001600160a01b03166101de565b3480156103ac57600080fd5b506103b660015481565b6040519081526020016101b5565b3480156103d057600080fd5b506102166103df366004611ba9565b61109e565b6101de6103f2366004611bcb565b611261565b34801561040357600080fd5b506102ab610412366004611823565b61137c565b34801561042357600080fd5b506102ab610432366004611823565b61143c565b6005818154811061044757600080fd5b6000918252602090912001546001600160a01b0316905081565b6001600160a01b0381166000908152600660209081526040918290208054835181840281018401909452808452606093928301828280156104cb57602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116104ad575b50505050509050919050565b60606103e88211156105305760405162461bcd60e51b815260206004820152600f60248201527f436f756e7420746f6f206c61726765000000000000000000000000000000000060448201526064015b60405180910390fd5b6005548211156105405760055491505b60008267ffffffffffffffff81111561055b5761055b611c96565b604051908082528060200260200182016040528015610584578160200160208202803683370190505b50600554909150600090610599908590611cf4565b905060005b848110156106125760056105b28284611d07565b815481106105c2576105c2611d1a565b9060005260206000200160009054906101000a90046001600160a01b03168382815181106105f2576105f2611d1a565b6001600160a01b039092166020928302919091019091015260010161059e565b50909392505050565b6060600580548060200260200160405190810160405280929190818152602001828054801561067357602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610655575b5050505050905090565b60006001600160a01b0389166106d55760405162461bcd60e51b815260206004820152601c60248201527f546f6b656e20616464726573732063616e6e6f74206265207a65726f000000006044820152606401610527565b6001600160a01b03881661072b5760405162461bcd60e51b815260206004820152601f60248201527f547265617375727920616464726573732063616e6e6f74206265207a65726f006044820152606401610527565b6001600160a01b0384166107815760405162461bcd60e51b815260206004820152601c60248201527f4f776e657220616464726573732063616e6e6f74206265207a65726f000000006044820152606401610527565b866107ce5760405162461bcd60e51b815260206004820152601a60248201527f4d65726b6c6520726f6f742063616e6e6f74206265207a65726f0000000000006044820152606401610527565b84861061081d5760405162461bcd60e51b815260206004820152601460248201527f496e76616c696420636c61696d2077696e646f770000000000000000000000006044820152606401610527565b6108477f000000000000000000000000000000000000000000000000000000000000000084611493565b6040517fca8fe4d20000000000000000000000000000000000000000000000000000000081526001600160a01b038b811660048301528a81166024830152604482018a9052606482018990526084820188905286811660a48301529192509082169063ca8fe4d29060c401600060405180830381600087803b1580156108cc57600080fd5b505af11580156108e0573d6000803e3d6000fd5b5050600180549250905060006108f583611d49565b90915550506001600160a01b038116600081815260046020908152604080832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001908117909155600580548083019091557f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db00180547fffffffffffffffffffffffff00000000000000000000000000000000000000009081168717909155338552600684529184208054918201815584529190922001805490911690911790556109c26114a8565b886001600160a01b0316336001600160a01b0316826001600160a01b03167f51a821a79e9dbea65e60b966e10914ec1ed7d2efd0f78aca8d6e0e008f2f2e588b8b8b8b6001548c8b34604051610a1f989796959493929190611d81565b60405180910390a498975050505050505050565b610a3b6115b2565b6001600160a01b038116610a915760405162461bcd60e51b815260206004820152601d60248201527f4f7261636c6520616464726573732063616e6e6f74206265207a65726f0000006044820152606401610527565b600380547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040517fefe8ab924ca486283a79dc604baa67add51afb82af1db8ac386ebbba643cdffd90600090a250565b6040513060388201526f5af43d82803e903d91602b57fd5bf3ff60248201527f00000000000000000000000000000000000000000000000000000000000000006014820152733d602d80600a3d3981f3363d3d373d3d3d363d738152605881018290526037600c820120607882015260556043909101206000906001600160a01b03165b92915050565b60006001600160a01b038816610bd55760405162461bcd60e51b815260206004820152601c60248201527f546f6b656e20616464726573732063616e6e6f74206265207a65726f000000006044820152606401610527565b6001600160a01b038716610c2b5760405162461bcd60e51b815260206004820152601f60248201527f547265617375727920616464726573732063616e6e6f74206265207a65726f006044820152606401610527565b6001600160a01b038316610c815760405162461bcd60e51b815260206004820152601c60248201527f4f776e657220616464726573732063616e6e6f74206265207a65726f000000006044820152606401610527565b85610cce5760405162461bcd60e51b815260206004820152601a60248201527f4d65726b6c6520726f6f742063616e6e6f74206265207a65726f0000000000006044820152606401610527565b838510610d1d5760405162461bcd60e51b815260206004820152601460248201527f496e76616c696420636c61696d2077696e646f770000000000000000000000006044820152606401610527565b610d467f00000000000000000000000000000000000000000000000000000000000000006115f8565b6040517fca8fe4d20000000000000000000000000000000000000000000000000000000081526001600160a01b038a81166004830152898116602483015260448201899052606482018890526084820187905285811660a48301529192509082169063ca8fe4d29060c401600060405180830381600087803b158015610dcb57600080fd5b505af1158015610ddf573d6000803e3d6000fd5b505060018054925090506000610df483611d49565b90915550506001600160a01b038116600081815260046020908152604080832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001908117909155600580548083019091557f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db00180547fffffffffffffffffffffffff0000000000000000000000000000000000000000908116871790915533855260068452918420805491820181558452919092200180549091169091179055610ec16114a8565b876001600160a01b0316336001600160a01b0316826001600160a01b03167f51a821a79e9dbea65e60b966e10914ec1ed7d2efd0f78aca8d6e0e008f2f2e588a8a8a8a6001548b8b34604051610f1e989796959493929190611d81565b60405180910390a4979650505050505050565b6000610f4488888888888888600061067d565b98975050505050505050565b6000610f628d8d8d8d8d8d8d8d61067d565b9050831561105d576001600160a01b038516610fc05760405162461bcd60e51b815260206004820152601a60248201527f4b392074726561737572792063616e6e6f74206265207a65726f0000000000006044820152606401610527565b8161100d5760405162461bcd60e51b815260206004820152601860248201527f4b392070726f6f662063616e6e6f7420626520656d70747900000000000000006044820152606401610527565b846001600160a01b0316816001600160a01b03167ff7518c88dcaaba2ca509ed09a08c7bcf8b8548e961f1ffe3f8eb5b2d77e7788786868660405161105493929190611e03565b60405180910390a35b9c9b505050505050505050505050565b6110756115b2565b61107f6000611605565b565b60006110938787878787876000610b7d565b979650505050505050565b60608183106110ef5760405162461bcd60e51b815260206004820152600d60248201527f496e76616c69642072616e6765000000000000000000000000000000000000006044820152606401610527565b6005548211156111415760405162461bcd60e51b815260206004820152601760248201527f456e6420696e646578206f7574206f6620626f756e64730000000000000000006044820152606401610527565b6103e861114e8484611cf4565b111561119c5760405162461bcd60e51b815260206004820152600f60248201527f52616e676520746f6f206c6172676500000000000000000000000000000000006044820152606401610527565b60006111a88484611cf4565b67ffffffffffffffff8111156111c0576111c0611c96565b6040519080825280602002602001820160405280156111e9578160200160208202803683370190505b509050835b83811015611259576005818154811061120957611209611d1a565b6000918252602090912001546001600160a01b0316826112298784611cf4565b8151811061123957611239611d1a565b6001600160a01b03909216602092830291909101909101526001016111ee565b509392505050565b60006112728c8c8c8c8c8c8c610b7d565b9050831561136d576001600160a01b0385166112d05760405162461bcd60e51b815260206004820152601a60248201527f4b392074726561737572792063616e6e6f74206265207a65726f0000000000006044820152606401610527565b8161131d5760405162461bcd60e51b815260206004820152601860248201527f4b392070726f6f662063616e6e6f7420626520656d70747900000000000000006044820152606401610527565b846001600160a01b0316816001600160a01b03167ff7518c88dcaaba2ca509ed09a08c7bcf8b8548e961f1ffe3f8eb5b2d77e7788786868660405161136493929190611e03565b60405180910390a35b9b9a5050505050505050505050565b6113846115b2565b6001600160a01b0381166113da5760405162461bcd60e51b815260206004820152601f60248201527f547265617375727920616464726573732063616e6e6f74206265207a65726f006044820152606401610527565b600280547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040517f10d6c00fd9d176c2872e8e72b76641ca85aba29bb682a658aeedbc38814fe45f90600090a250565b6114446115b2565b6001600160a01b038116611487576040517f1e4fbdf700000000000000000000000000000000000000000000000000000000815260006004820152602401610527565b61149081611605565b50565b60006114a18383600061166d565b9392505050565b346000036114b257565b6002546001600160a01b03168061150b5760405162461bcd60e51b815260206004820152601460248201527f466565207472656173757279206e6f74207365740000000000000000000000006044820152606401610527565b6000816001600160a01b03163460405160006040518083038185875af1925050503d8060008114611558576040519150601f19603f3d011682016040523d82523d6000602084013e61155d565b606091505b50509050806115ae5760405162461bcd60e51b815260206004820152601760248201527f5472656173757279207061796d656e74206661696c65640000000000000000006044820152606401610527565b5050565b6000546001600160a01b0316331461107f576040517f118cdaa7000000000000000000000000000000000000000000000000000000008152336004820152602401610527565b6000610b77826000611736565b600080546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000814710156116b2576040517fcf47918100000000000000000000000000000000000000000000000000000000815247600482015260248101839052604401610527565b763d602d80600a3d3981f3363d3d373d3d3d363d730000008460601b60e81c176000526e5af43d82803e903d91602b57fd5bf38460781b17602052826037600984f590506001600160a01b0381166114a1576040517fb06ebf3d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008147101561177b576040517fcf47918100000000000000000000000000000000000000000000000000000000815247600482015260248101839052604401610527565b763d602d80600a3d3981f3363d3d373d3d3d363d730000008360601b60e81c176000526e5af43d82803e903d91602b57fd5bf38360781b176020526037600983f090506001600160a01b038116610b77576040517fb06ebf3d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b038116811461149057600080fd5b803561181e816117fe565b919050565b60006020828403121561183557600080fd5b81356114a1816117fe565b60006020828403121561185257600080fd5b5035919050565b6020808252825182820181905260009190848201906040850190845b8181101561189a5783516001600160a01b031683529284019291840191600101611875565b50909695505050505050565b80356003811061181e57600080fd5b600080600080600080600080610100898b0312156118d257600080fd5b88356118dd816117fe565b975060208901356118ed816117fe565b965060408901359550606089013594506080890135935060a0890135611912816117fe565b925060c0890135915061192760e08a016118a6565b90509295985092959890939650565b600080600080600080600060e0888a03121561195157600080fd5b873561195c816117fe565b9650602088013561196c816117fe565b955060408801359450606088013593506080880135925060a0880135611991816117fe565b915061199f60c089016118a6565b905092959891949750929550565b600080600080600080600060e0888a0312156119c857600080fd5b87356119d3816117fe565b965060208801356119e3816117fe565b955060408801359450606088013593506080880135925060a0880135611a08816117fe565b8092505060c0880135905092959891949750929550565b60008083601f840112611a3157600080fd5b50813567ffffffffffffffff811115611a4957600080fd5b6020830191508360208260051b8501011115611a6457600080fd5b9250929050565b6000806000806000806000806000806000806101608d8f031215611a8e57600080fd5b611a988d356117fe565b8c359b50611aa960208e01356117fe565b60208d01359a5060408d0135995060608d0135985060808d01359750611ad160a08e01611813565b965060c08d01359550611ae660e08e016118a6565b9450611af56101008e01611813565b93506101208d0135925067ffffffffffffffff6101408e01351115611b1957600080fd5b611b2a8e6101408f01358f01611a1f565b81935080925050509295989b509295989b509295989b565b60008060008060008060c08789031215611b5b57600080fd5b8635611b66816117fe565b95506020870135611b76816117fe565b945060408701359350606087013592506080870135915060a0870135611b9b816117fe565b809150509295509295509295565b60008060408385031215611bbc57600080fd5b50508035926020909101359150565b60008060008060008060008060008060006101408c8e031215611bed57600080fd5b8b35611bf8816117fe565b9a5060208c0135611c08816117fe565b995060408c0135985060608c0135975060808c0135965060a08c0135611c2d816117fe565b9550611c3b60c08d016118a6565b945060e08c0135611c4b816117fe565b93506101008c013592506101208c013567ffffffffffffffff811115611c7057600080fd5b611c7c8e828f01611a1f565b915080935050809150509295989b509295989b9093969950565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b81810381811115610b7757610b77611cc5565b80820180821115610b7757610b77611cc5565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203611d7a57611d7a611cc5565b5060010190565b6001600160a01b03898116825260208201899052604082018890526060820187905260808201869052841660a0820152610100810160038410611ded577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b60c082019390935260e001529695505050505050565b8381526040602082015281604082015260007f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff831115611e4257600080fd5b8260051b808560608501379190910160600194935050505056fea2646970667358221220f1b08fc0bb73927973a4d2415cb768480586640333ba1a353774b179b836c35864736f6c63430008180033608060405234801561001057600080fd5b50338061003757604051631e4fbdf760e01b81526000600482015260240160405180910390fd5b61004081610053565b506007805460ff191660011790556100bf565b600180546001600160a01b031916905561006c8161006f565b50565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b610ea2806100ce6000396000f3fe6080604052600436106100ec5760003560e01c80638da5cb5b1161008a578063e30c397811610059578063e30c39781461026e578063f04d688f1461028c578063f2fde38b146102a2578063fc0c546a146102c257600080fd5b80638da5cb5b146101d05780639be65a60146101ee578063c884ef831461020e578063ca8fe4d21461024e57600080fd5b806352d8bfc2116100c657806352d8bfc21461015957806361d027b31461016e578063715018a6146101a657806379ba5097146101bb57600080fd5b80632eb4a7ab146100f85780632f52ebb7146101215780633ccfa92f1461014357600080fd5b366100f357005b600080fd5b34801561010457600080fd5b5061010e60045481565b6040519081526020015b60405180910390f35b34801561012d57600080fd5b5061014161013c366004610d0c565b6102e2565b005b34801561014f57600080fd5b5061010e60065481565b34801561016557600080fd5b5061014161055e565b34801561017a57600080fd5b5060035461018e906001600160a01b031681565b6040516001600160a01b039091168152602001610118565b3480156101b257600080fd5b5061014161068e565b3480156101c757600080fd5b506101416106a2565b3480156101dc57600080fd5b506000546001600160a01b031661018e565b3480156101fa57600080fd5b50610141610209366004610da0565b6106ff565b34801561021a57600080fd5b5061023e610229366004610da0565b60086020526000908152604090205460ff1681565b6040519015158152602001610118565b34801561025a57600080fd5b50610141610269366004610dbd565b61084c565b34801561027a57600080fd5b506001546001600160a01b031661018e565b34801561029857600080fd5b5061010e60055481565b3480156102ae57600080fd5b506101416102bd366004610da0565b6109d7565b3480156102ce57600080fd5b5060025461018e906001600160a01b031681565b6005544210156103395760405162461bcd60e51b815260206004820152601860248201527f436c61696d20706572696f64206e6f742073746172746564000000000000000060448201526064015b60405180910390fd5b60065442111561038b5760405162461bcd60e51b815260206004820152601260248201527f436c61696d20706572696f6420656e64656400000000000000000000000000006044820152606401610330565b3360009081526008602052604090205460ff16156103eb5760405162461bcd60e51b815260206004820152600f60248201527f416c726561647920636c61696d656400000000000000000000000000000000006044820152606401610330565b6040517fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003360601b1660208201526034810184905260009060540160405160208183030381529060405280519060200120905061047f838380806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250506004549150849050610a60565b6104cb5760405162461bcd60e51b815260206004820152601460248201527f496e76616c6964204d65726b6c652070726f6f660000000000000000000000006044820152606401610330565b33600081815260086020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055600354600254610523926001600160a01b03918216929091169087610a76565b60405184815233907fd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a9060200160405180910390a250505050565b610566610af8565b47806105b45760405162461bcd60e51b815260206004820152601360248201527f4e6f20657468657220746f207265636f766572000000000000000000000000006044820152606401610330565b600080546040516001600160a01b039091169083908381818185875af1925050503d8060008114610601576040519150601f19603f3d011682016040523d82523d6000602084013e610606565b606091505b50509050806106575760405162461bcd60e51b815260206004820152601360248201527f455448207472616e73666572206661696c6564000000000000000000000000006044820152606401610330565b6040518281527f80f057f7fe3fc69b26bb7a2659eec1acd410d9c72d07624699c50cb7b15f20469060200160405180910390a15050565b610696610af8565b6106a06000610b3e565b565b60015433906001600160a01b031681146106f3576040517f118cdaa70000000000000000000000000000000000000000000000000000000081526001600160a01b0382166004820152602401610330565b6106fc81610b3e565b50565b610707610af8565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015281906000906001600160a01b038316906370a0823190602401602060405180830381865afa158015610769573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061078d9190610e24565b9050600081116107df5760405162461bcd60e51b815260206004820152601460248201527f4e6f20746f6b656e7320746f207265636f7665720000000000000000000000006044820152606401610330565b6108056107f46000546001600160a01b031690565b6001600160a01b0384169083610b6f565b604080516001600160a01b0385168152602081018390527f6de8b63479ce07cf2dfc515e20a5c88a3a5bab6cbd76f753388b77e244ca7071910160405180910390a1505050565b60075460ff161561089f5760405162461bcd60e51b815260206004820152601360248201527f416c726561647920696e697469616c697a6564000000000000000000000000006044820152606401610330565b8183106108ee5760405162461bcd60e51b815260206004820152601460248201527f496e76616c696420636c61696d2077696e646f770000000000000000000000006044820152606401610330565b6001600160a01b0381166109445760405162461bcd60e51b815260206004820152601c60248201527f4f776e65722063616e6e6f74206265207a65726f2061646472657373000000006044820152606401610330565b600780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055600280546001600160a01b038089167fffffffffffffffffffffffff00000000000000000000000000000000000000009283161790925560038054928816929091169190911790556004849055600583905560068290556109cf81610b3e565b505050505050565b6109df610af8565b600180546001600160a01b0383167fffffffffffffffffffffffff00000000000000000000000000000000000000009091168117909155610a286000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b600082610a6d8584610ba5565b14949350505050565b6040516001600160a01b038481166024830152838116604483015260648201839052610af29186918216906323b872dd906084015b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050610be8565b50505050565b6000546001600160a01b031633146106a0576040517f118cdaa7000000000000000000000000000000000000000000000000000000008152336004820152602401610330565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001690556106fc81610c72565b6040516001600160a01b03838116602483015260448201839052610ba091859182169063a9059cbb90606401610aab565b505050565b600081815b8451811015610be057610bd682868381518110610bc957610bc9610e3d565b6020026020010151610cda565b9150600101610baa565b509392505050565b600080602060008451602086016000885af180610c0b576040513d6000823e3d81fd5b50506000513d91508115610c23578060011415610c30565b6001600160a01b0384163b155b15610af2576040517f5274afe70000000000000000000000000000000000000000000000000000000081526001600160a01b0385166004820152602401610330565b600080546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000818310610cf6576000828152602084905260409020610d05565b60008381526020839052604090205b9392505050565b600080600060408486031215610d2157600080fd5b83359250602084013567ffffffffffffffff80821115610d4057600080fd5b818601915086601f830112610d5457600080fd5b813581811115610d6357600080fd5b8760208260051b8501011115610d7857600080fd5b6020830194508093505050509250925092565b6001600160a01b03811681146106fc57600080fd5b600060208284031215610db257600080fd5b8135610d0581610d8b565b60008060008060008060c08789031215610dd657600080fd5b8635610de181610d8b565b95506020870135610df181610d8b565b945060408701359350606087013592506080870135915060a0870135610e1681610d8b565b809150509295509295509295565b600060208284031215610e3657600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fdfea2646970667358221220a61c1747b6be0f43186c07aefe6457e32b8cc1ff01251ad4f36da095c5f3f0a964736f6c63430008180033
Deployed Bytecode
0x6080604052600436106101745760003560e01c80635e9ce84b116100cb5780638da5cb5b1161007f578063be4f221f11610059578063be4f221f146103e4578063bfa37e37146103f7578063f2fde38b1461041757600080fd5b80638da5cb5b146103825780639529b922146103a0578063b85f8fc5146103c457600080fd5b806367f841d0116100b057806367f841d014610347578063715018a61461035a57806372b6737c1461036f57600080fd5b80635e9ce84b1461031457806360dc23401461032757600080fd5b806327831ee01161012d5780635414dff0116101075780635414dff0146102ad5780635c60da1b146102cd5780635cca70c41461030157600080fd5b806327831ee014610263578063451cb43714610278578063530e784f1461028b57600080fd5b80630ff744591161015e5780630ff74459146101f657806321d012b5146102235780632630c12f1461024357600080fd5b8062ae3676146101795780630e039916146101be575b600080fd5b34801561018557600080fd5b506101a9610194366004611823565b60046020526000908152604090205460ff1681565b60405190151581526020015b60405180910390f35b3480156101ca57600080fd5b506101de6101d9366004611840565b610437565b6040516001600160a01b0390911681526020016101b5565b34801561020257600080fd5b50610216610211366004611823565b610461565b6040516101b59190611859565b34801561022f57600080fd5b5061021661023e366004611840565b6104d7565b34801561024f57600080fd5b506003546101de906001600160a01b031681565b34801561026f57600080fd5b5061021661061b565b6101de6102863660046118b5565b61067d565b34801561029757600080fd5b506102ab6102a6366004611823565b610a33565b005b3480156102b957600080fd5b506101de6102c8366004611840565b610af3565b3480156102d957600080fd5b506101de7f00000000000000000000000013c90f0e4b3046a6945d0f11c13ee3edf24ba91781565b6101de61030f366004611936565b610b7d565b6101de6103223660046119ad565b610f31565b34801561033357600080fd5b506002546101de906001600160a01b031681565b6101de610355366004611a6b565b610f50565b34801561036657600080fd5b506102ab61106d565b6101de61037d366004611b42565b611081565b34801561038e57600080fd5b506000546001600160a01b03166101de565b3480156103ac57600080fd5b506103b660015481565b6040519081526020016101b5565b3480156103d057600080fd5b506102166103df366004611ba9565b61109e565b6101de6103f2366004611bcb565b611261565b34801561040357600080fd5b506102ab610412366004611823565b61137c565b34801561042357600080fd5b506102ab610432366004611823565b61143c565b6005818154811061044757600080fd5b6000918252602090912001546001600160a01b0316905081565b6001600160a01b0381166000908152600660209081526040918290208054835181840281018401909452808452606093928301828280156104cb57602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116104ad575b50505050509050919050565b60606103e88211156105305760405162461bcd60e51b815260206004820152600f60248201527f436f756e7420746f6f206c61726765000000000000000000000000000000000060448201526064015b60405180910390fd5b6005548211156105405760055491505b60008267ffffffffffffffff81111561055b5761055b611c96565b604051908082528060200260200182016040528015610584578160200160208202803683370190505b50600554909150600090610599908590611cf4565b905060005b848110156106125760056105b28284611d07565b815481106105c2576105c2611d1a565b9060005260206000200160009054906101000a90046001600160a01b03168382815181106105f2576105f2611d1a565b6001600160a01b039092166020928302919091019091015260010161059e565b50909392505050565b6060600580548060200260200160405190810160405280929190818152602001828054801561067357602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610655575b5050505050905090565b60006001600160a01b0389166106d55760405162461bcd60e51b815260206004820152601c60248201527f546f6b656e20616464726573732063616e6e6f74206265207a65726f000000006044820152606401610527565b6001600160a01b03881661072b5760405162461bcd60e51b815260206004820152601f60248201527f547265617375727920616464726573732063616e6e6f74206265207a65726f006044820152606401610527565b6001600160a01b0384166107815760405162461bcd60e51b815260206004820152601c60248201527f4f776e657220616464726573732063616e6e6f74206265207a65726f000000006044820152606401610527565b866107ce5760405162461bcd60e51b815260206004820152601a60248201527f4d65726b6c6520726f6f742063616e6e6f74206265207a65726f0000000000006044820152606401610527565b84861061081d5760405162461bcd60e51b815260206004820152601460248201527f496e76616c696420636c61696d2077696e646f770000000000000000000000006044820152606401610527565b6108477f00000000000000000000000013c90f0e4b3046a6945d0f11c13ee3edf24ba91784611493565b6040517fca8fe4d20000000000000000000000000000000000000000000000000000000081526001600160a01b038b811660048301528a81166024830152604482018a9052606482018990526084820188905286811660a48301529192509082169063ca8fe4d29060c401600060405180830381600087803b1580156108cc57600080fd5b505af11580156108e0573d6000803e3d6000fd5b5050600180549250905060006108f583611d49565b90915550506001600160a01b038116600081815260046020908152604080832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001908117909155600580548083019091557f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db00180547fffffffffffffffffffffffff00000000000000000000000000000000000000009081168717909155338552600684529184208054918201815584529190922001805490911690911790556109c26114a8565b886001600160a01b0316336001600160a01b0316826001600160a01b03167f51a821a79e9dbea65e60b966e10914ec1ed7d2efd0f78aca8d6e0e008f2f2e588b8b8b8b6001548c8b34604051610a1f989796959493929190611d81565b60405180910390a498975050505050505050565b610a3b6115b2565b6001600160a01b038116610a915760405162461bcd60e51b815260206004820152601d60248201527f4f7261636c6520616464726573732063616e6e6f74206265207a65726f0000006044820152606401610527565b600380547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040517fefe8ab924ca486283a79dc604baa67add51afb82af1db8ac386ebbba643cdffd90600090a250565b6040513060388201526f5af43d82803e903d91602b57fd5bf3ff60248201527f00000000000000000000000013c90f0e4b3046a6945d0f11c13ee3edf24ba9176014820152733d602d80600a3d3981f3363d3d373d3d3d363d738152605881018290526037600c820120607882015260556043909101206000906001600160a01b03165b92915050565b60006001600160a01b038816610bd55760405162461bcd60e51b815260206004820152601c60248201527f546f6b656e20616464726573732063616e6e6f74206265207a65726f000000006044820152606401610527565b6001600160a01b038716610c2b5760405162461bcd60e51b815260206004820152601f60248201527f547265617375727920616464726573732063616e6e6f74206265207a65726f006044820152606401610527565b6001600160a01b038316610c815760405162461bcd60e51b815260206004820152601c60248201527f4f776e657220616464726573732063616e6e6f74206265207a65726f000000006044820152606401610527565b85610cce5760405162461bcd60e51b815260206004820152601a60248201527f4d65726b6c6520726f6f742063616e6e6f74206265207a65726f0000000000006044820152606401610527565b838510610d1d5760405162461bcd60e51b815260206004820152601460248201527f496e76616c696420636c61696d2077696e646f770000000000000000000000006044820152606401610527565b610d467f00000000000000000000000013c90f0e4b3046a6945d0f11c13ee3edf24ba9176115f8565b6040517fca8fe4d20000000000000000000000000000000000000000000000000000000081526001600160a01b038a81166004830152898116602483015260448201899052606482018890526084820187905285811660a48301529192509082169063ca8fe4d29060c401600060405180830381600087803b158015610dcb57600080fd5b505af1158015610ddf573d6000803e3d6000fd5b505060018054925090506000610df483611d49565b90915550506001600160a01b038116600081815260046020908152604080832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001908117909155600580548083019091557f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db00180547fffffffffffffffffffffffff0000000000000000000000000000000000000000908116871790915533855260068452918420805491820181558452919092200180549091169091179055610ec16114a8565b876001600160a01b0316336001600160a01b0316826001600160a01b03167f51a821a79e9dbea65e60b966e10914ec1ed7d2efd0f78aca8d6e0e008f2f2e588a8a8a8a6001548b8b34604051610f1e989796959493929190611d81565b60405180910390a4979650505050505050565b6000610f4488888888888888600061067d565b98975050505050505050565b6000610f628d8d8d8d8d8d8d8d61067d565b9050831561105d576001600160a01b038516610fc05760405162461bcd60e51b815260206004820152601a60248201527f4b392074726561737572792063616e6e6f74206265207a65726f0000000000006044820152606401610527565b8161100d5760405162461bcd60e51b815260206004820152601860248201527f4b392070726f6f662063616e6e6f7420626520656d70747900000000000000006044820152606401610527565b846001600160a01b0316816001600160a01b03167ff7518c88dcaaba2ca509ed09a08c7bcf8b8548e961f1ffe3f8eb5b2d77e7788786868660405161105493929190611e03565b60405180910390a35b9c9b505050505050505050505050565b6110756115b2565b61107f6000611605565b565b60006110938787878787876000610b7d565b979650505050505050565b60608183106110ef5760405162461bcd60e51b815260206004820152600d60248201527f496e76616c69642072616e6765000000000000000000000000000000000000006044820152606401610527565b6005548211156111415760405162461bcd60e51b815260206004820152601760248201527f456e6420696e646578206f7574206f6620626f756e64730000000000000000006044820152606401610527565b6103e861114e8484611cf4565b111561119c5760405162461bcd60e51b815260206004820152600f60248201527f52616e676520746f6f206c6172676500000000000000000000000000000000006044820152606401610527565b60006111a88484611cf4565b67ffffffffffffffff8111156111c0576111c0611c96565b6040519080825280602002602001820160405280156111e9578160200160208202803683370190505b509050835b83811015611259576005818154811061120957611209611d1a565b6000918252602090912001546001600160a01b0316826112298784611cf4565b8151811061123957611239611d1a565b6001600160a01b03909216602092830291909101909101526001016111ee565b509392505050565b60006112728c8c8c8c8c8c8c610b7d565b9050831561136d576001600160a01b0385166112d05760405162461bcd60e51b815260206004820152601a60248201527f4b392074726561737572792063616e6e6f74206265207a65726f0000000000006044820152606401610527565b8161131d5760405162461bcd60e51b815260206004820152601860248201527f4b392070726f6f662063616e6e6f7420626520656d70747900000000000000006044820152606401610527565b846001600160a01b0316816001600160a01b03167ff7518c88dcaaba2ca509ed09a08c7bcf8b8548e961f1ffe3f8eb5b2d77e7788786868660405161136493929190611e03565b60405180910390a35b9b9a5050505050505050505050565b6113846115b2565b6001600160a01b0381166113da5760405162461bcd60e51b815260206004820152601f60248201527f547265617375727920616464726573732063616e6e6f74206265207a65726f006044820152606401610527565b600280547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040517f10d6c00fd9d176c2872e8e72b76641ca85aba29bb682a658aeedbc38814fe45f90600090a250565b6114446115b2565b6001600160a01b038116611487576040517f1e4fbdf700000000000000000000000000000000000000000000000000000000815260006004820152602401610527565b61149081611605565b50565b60006114a18383600061166d565b9392505050565b346000036114b257565b6002546001600160a01b03168061150b5760405162461bcd60e51b815260206004820152601460248201527f466565207472656173757279206e6f74207365740000000000000000000000006044820152606401610527565b6000816001600160a01b03163460405160006040518083038185875af1925050503d8060008114611558576040519150601f19603f3d011682016040523d82523d6000602084013e61155d565b606091505b50509050806115ae5760405162461bcd60e51b815260206004820152601760248201527f5472656173757279207061796d656e74206661696c65640000000000000000006044820152606401610527565b5050565b6000546001600160a01b0316331461107f576040517f118cdaa7000000000000000000000000000000000000000000000000000000008152336004820152602401610527565b6000610b77826000611736565b600080546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000814710156116b2576040517fcf47918100000000000000000000000000000000000000000000000000000000815247600482015260248101839052604401610527565b763d602d80600a3d3981f3363d3d373d3d3d363d730000008460601b60e81c176000526e5af43d82803e903d91602b57fd5bf38460781b17602052826037600984f590506001600160a01b0381166114a1576040517fb06ebf3d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008147101561177b576040517fcf47918100000000000000000000000000000000000000000000000000000000815247600482015260248101839052604401610527565b763d602d80600a3d3981f3363d3d373d3d3d363d730000008360601b60e81c176000526e5af43d82803e903d91602b57fd5bf38360781b176020526037600983f090506001600160a01b038116610b77576040517fb06ebf3d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b038116811461149057600080fd5b803561181e816117fe565b919050565b60006020828403121561183557600080fd5b81356114a1816117fe565b60006020828403121561185257600080fd5b5035919050565b6020808252825182820181905260009190848201906040850190845b8181101561189a5783516001600160a01b031683529284019291840191600101611875565b50909695505050505050565b80356003811061181e57600080fd5b600080600080600080600080610100898b0312156118d257600080fd5b88356118dd816117fe565b975060208901356118ed816117fe565b965060408901359550606089013594506080890135935060a0890135611912816117fe565b925060c0890135915061192760e08a016118a6565b90509295985092959890939650565b600080600080600080600060e0888a03121561195157600080fd5b873561195c816117fe565b9650602088013561196c816117fe565b955060408801359450606088013593506080880135925060a0880135611991816117fe565b915061199f60c089016118a6565b905092959891949750929550565b600080600080600080600060e0888a0312156119c857600080fd5b87356119d3816117fe565b965060208801356119e3816117fe565b955060408801359450606088013593506080880135925060a0880135611a08816117fe565b8092505060c0880135905092959891949750929550565b60008083601f840112611a3157600080fd5b50813567ffffffffffffffff811115611a4957600080fd5b6020830191508360208260051b8501011115611a6457600080fd5b9250929050565b6000806000806000806000806000806000806101608d8f031215611a8e57600080fd5b611a988d356117fe565b8c359b50611aa960208e01356117fe565b60208d01359a5060408d0135995060608d0135985060808d01359750611ad160a08e01611813565b965060c08d01359550611ae660e08e016118a6565b9450611af56101008e01611813565b93506101208d0135925067ffffffffffffffff6101408e01351115611b1957600080fd5b611b2a8e6101408f01358f01611a1f565b81935080925050509295989b509295989b509295989b565b60008060008060008060c08789031215611b5b57600080fd5b8635611b66816117fe565b95506020870135611b76816117fe565b945060408701359350606087013592506080870135915060a0870135611b9b816117fe565b809150509295509295509295565b60008060408385031215611bbc57600080fd5b50508035926020909101359150565b60008060008060008060008060008060006101408c8e031215611bed57600080fd5b8b35611bf8816117fe565b9a5060208c0135611c08816117fe565b995060408c0135985060608c0135975060808c0135965060a08c0135611c2d816117fe565b9550611c3b60c08d016118a6565b945060e08c0135611c4b816117fe565b93506101008c013592506101208c013567ffffffffffffffff811115611c7057600080fd5b611c7c8e828f01611a1f565b915080935050809150509295989b509295989b9093969950565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b81810381811115610b7757610b77611cc5565b80820180821115610b7757610b77611cc5565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203611d7a57611d7a611cc5565b5060010190565b6001600160a01b03898116825260208201899052604082018890526060820187905260808201869052841660a0820152610100810160038410611ded577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b60c082019390935260e001529695505050505050565b8381526040602082015281604082015260007f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff831115611e4257600080fd5b8260051b808560608501379190910160600194935050505056fea2646970667358221220f1b08fc0bb73927973a4d2415cb768480586640333ba1a353774b179b836c35864736f6c63430008180033
Multichain Portfolio | 36 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
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.