Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0x891Ecfcb8C7ac4F2A4Cb09993d829ED8409e1076
Balance 0 ETH
Nonce 1
Code Size 7284 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

7284 bytes
0x6080604052600436106100c65760003560e01c80636db767de1161007f5780639012c4a8116100595780639012c4a81461021a578063955a79c314610243578063ddca3f431461025a578063f2fde38b14610285576100cd565b80636db767de146101bc578063715018a6146101d85780638da5cb5b146101ef576100cd565b80630fc63d10146100d2578063280da6fa146100fd5780632eb4a7ab146101145780634783f0ef1461013f5780635f64b55b1461016857806362b8085714610193576100cd565b366100cd57005b600080fd5b3480156100de57600080fd5b506100e76102ae565b6040516100f4919061111a565b60405180910390f35b34801561010957600080fd5b506101126102d4565b005b34801561012057600080fd5b50610129610642565b604051610136919061114e565b60405180910390f35b34801561014b57600080fd5b50610166600480360381019061016191906111a9565b610648565b005b34801561017457600080fd5b5061017d61065a565b60405161018a919061111a565b60405180910390f35b34801561019f57600080fd5b506101ba60048036038101906101b59190611214565b610680565b005b6101d660048036038101906101d191906113e3565b610825565b005b3480156101e457600080fd5b506101ed610c3f565b005b3480156101fb57600080fd5b50610204610c53565b604051610211919061144e565b60405180910390f35b34801561022657600080fd5b50610241600480360381019061023c9190611469565b610c7c565b005b34801561024f57600080fd5b50610258610cc5565b005b34801561026657600080fd5b5061026f610e13565b60405161027c91906114a5565b60405180910390f35b34801561029157600080fd5b506102ac60048036038101906102a791906114c0565b610e19565b005b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6102dc610e9f565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401610339919061144e565b602060405180830381865afa158015610356573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061037a9190611502565b90506000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016103d9919061144e565b602060405180830381865afa1580156103f6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061041a9190611502565b9050600082111561050557600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33846040518363ffffffff1660e01b815260040161048292919061152f565b6020604051808303816000875af11580156104a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104c59190611590565b610504576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104fb9061161a565b60405180910390fd5b5b60008111156105ee57600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33836040518363ffffffff1660e01b815260040161056b92919061152f565b6020604051808303816000875af115801561058a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105ae9190611590565b6105ed576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105e490611686565b60405180910390fd5b5b3373ffffffffffffffffffffffffffffffffffffffff167f0bdc507a7cea90fbfce2b07a701132eeb606554a51aa6f37fe4b9c3d66d5fc4f83836040516106369291906116a6565b60405180910390a25050565b60035481565b610650610e9f565b8060038190555050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b610688610e9f565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036106f7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106ee9061171b565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610766576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161075d90611787565b60405180910390fd5b81600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507faa48a91a0ecea2b4005db160bd44d0db34e860a7bc8f46ad29dbba52abcb2cc782826040516108199291906117a7565b60405180910390a15050565b60008211610868576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161085f9061181c565b60405180910390fd5b81600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016108c4919061144e565b602060405180830381865afa1580156108e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109059190611502565b1015610946576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161093d906118ae565b60405180910390fd5b60045434101561098b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109829061191a565b60405180910390fd5b60003360405160200161099e919061144e565b604051602081830303815290604052805190602001206040516020016109c4919061195b565b6040516020818303038152906040528051906020012090506109e98260035483610f26565b610a28576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1f906119c2565b60405180910390fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3330866040518463ffffffff1660e01b8152600401610a87939291906119e2565b6020604051808303816000875af1158015610aa6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aca9190611590565b610b09576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b0090611a65565b60405180910390fd5b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33856040518363ffffffff1660e01b8152600401610b6692919061152f565b6020604051808303816000875af1158015610b85573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ba99190611590565b610be8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bdf90611ad1565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff167f3a9a9f34f5831e9c8ecb66ab3aa308b2ff31eaca434615f6c9cadc656a9af71c84600454604051610c329291906116a6565b60405180910390a2505050565b610c47610e9f565b610c516000610f3d565b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b610c84610e9f565b806004819055507f8c4d35e54a3f2ef1134138fd8ea3daee6a3c89e10d2665996babdf70261e2c7681604051610cba91906114a5565b60405180910390a150565b610ccd610e9f565b600047905060008111610d15576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d0c90611b3d565b60405180910390fd5b60003373ffffffffffffffffffffffffffffffffffffffff1682604051610d3b90611b8e565b60006040518083038185875af1925050503d8060008114610d78576040519150601f19603f3d011682016040523d82523d6000602084013e610d7d565b606091505b5050905080610dc1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610db890611bef565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff167fcb34bab4d8a21ce2df6988d496d854246c2a96147dac484b1e1a30be9213befd83604051610e0791906114a5565b60405180910390a25050565b60045481565b610e21610e9f565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610e935760006040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600401610e8a919061144e565b60405180910390fd5b610e9c81610f3d565b50565b610ea7611001565b73ffffffffffffffffffffffffffffffffffffffff16610ec5610c53565b73ffffffffffffffffffffffffffffffffffffffff1614610f2457610ee8611001565b6040517f118cdaa7000000000000000000000000000000000000000000000000000000008152600401610f1b919061144e565b60405180910390fd5b565b600082610f338584611009565b1490509392505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600033905090565b60008082905060005b845181101561104e5761103f8286838151811061103257611031611c0f565b5b6020026020010151611059565b91508080600101915050611012565b508091505092915050565b60008183106110715761106c8284611084565b61107c565b61107b8383611084565b5b905092915050565b600082600052816020526040600020905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006110e06110db6110d68461109b565b6110bb565b61109b565b9050919050565b60006110f2826110c5565b9050919050565b6000611104826110e7565b9050919050565b611114816110f9565b82525050565b600060208201905061112f600083018461110b565b92915050565b6000819050919050565b61114881611135565b82525050565b6000602082019050611163600083018461113f565b92915050565b6000604051905090565b600080fd5b600080fd5b61118681611135565b811461119157600080fd5b50565b6000813590506111a38161117d565b92915050565b6000602082840312156111bf576111be611173565b5b60006111cd84828501611194565b91505092915050565b60006111e18261109b565b9050919050565b6111f1816111d6565b81146111fc57600080fd5b50565b60008135905061120e816111e8565b92915050565b6000806040838503121561122b5761122a611173565b5b6000611239858286016111ff565b925050602061124a858286016111ff565b9150509250929050565b6000819050919050565b61126781611254565b811461127257600080fd5b50565b6000813590506112848161125e565b92915050565b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6112d88261128f565b810181811067ffffffffffffffff821117156112f7576112f66112a0565b5b80604052505050565b600061130a611169565b905061131682826112cf565b919050565b600067ffffffffffffffff821115611336576113356112a0565b5b602082029050602081019050919050565b600080fd5b600061135f61135a8461131b565b611300565b9050808382526020820190506020840283018581111561138257611381611347565b5b835b818110156113ab57806113978882611194565b845260208401935050602081019050611384565b5050509392505050565b600082601f8301126113ca576113c961128a565b5b81356113da84826020860161134c565b91505092915050565b600080604083850312156113fa576113f9611173565b5b600061140885828601611275565b925050602083013567ffffffffffffffff81111561142957611428611178565b5b611435858286016113b5565b9150509250929050565b611448816111d6565b82525050565b6000602082019050611463600083018461143f565b92915050565b60006020828403121561147f5761147e611173565b5b600061148d84828501611275565b91505092915050565b61149f81611254565b82525050565b60006020820190506114ba6000830184611496565b92915050565b6000602082840312156114d6576114d5611173565b5b60006114e4848285016111ff565b91505092915050565b6000815190506114fc8161125e565b92915050565b60006020828403121561151857611517611173565b5b6000611526848285016114ed565b91505092915050565b6000604082019050611544600083018561143f565b6115516020830184611496565b9392505050565b60008115159050919050565b61156d81611558565b811461157857600080fd5b50565b60008151905061158a81611564565b92915050565b6000602082840312156115a6576115a5611173565b5b60006115b48482850161157b565b91505092915050565b600082825260208201905092915050565b7f546f6b656e2041207769746864726177616c206661696c656400000000000000600082015250565b60006116046019836115bd565b915061160f826115ce565b602082019050919050565b60006020820190508181036000830152611633816115f7565b9050919050565b7f546f6b656e2042207769746864726177616c206661696c656400000000000000600082015250565b60006116706019836115bd565b915061167b8261163a565b602082019050919050565b6000602082019050818103600083015261169f81611663565b9050919050565b60006040820190506116bb6000830185611496565b6116c86020830184611496565b9392505050565b7f496e76616c696420746f6b656e41206164647265737300000000000000000000600082015250565b60006117056016836115bd565b9150611710826116cf565b602082019050919050565b60006020820190508181036000830152611734816116f8565b9050919050565b7f496e76616c696420746f6b656e42206164647265737300000000000000000000600082015250565b60006117716016836115bd565b915061177c8261173b565b602082019050919050565b600060208201905081810360008301526117a081611764565b9050919050565b60006040820190506117bc600083018561143f565b6117c9602083018461143f565b9392505050565b7f416d6f756e74206d7573742062652067726561746572207468616e2030000000600082015250565b6000611806601d836115bd565b9150611811826117d0565b602082019050919050565b60006020820190508181036000830152611835816117f9565b9050919050565b7f496e73756666696369656e7420746f6b656e422062616c616e636520696e206360008201527f6f6e747261637400000000000000000000000000000000000000000000000000602082015250565b60006118986027836115bd565b91506118a38261183c565b604082019050919050565b600060208201905081810360008301526118c78161188b565b9050919050565b7f496e73756666696369656e742045544820666f72206665650000000000000000600082015250565b60006119046018836115bd565b915061190f826118ce565b602082019050919050565b60006020820190508181036000830152611933816118f7565b9050919050565b6000819050919050565b61195561195082611135565b61193a565b82525050565b60006119678284611944565b60208201915081905092915050565b7f41646472657373206e6f742077686974656c6973746564000000000000000000600082015250565b60006119ac6017836115bd565b91506119b782611976565b602082019050919050565b600060208201905081810360008301526119db8161199f565b9050919050565b60006060820190506119f7600083018661143f565b611a04602083018561143f565b611a116040830184611496565b949350505050565b7f546f6b656e2041207472616e73666572206661696c6564000000000000000000600082015250565b6000611a4f6017836115bd565b9150611a5a82611a19565b602082019050919050565b60006020820190508181036000830152611a7e81611a42565b9050919050565b7f546f6b656e2042207472616e73666572206661696c6564000000000000000000600082015250565b6000611abb6017836115bd565b9150611ac682611a85565b602082019050919050565b60006020820190508181036000830152611aea81611aae565b9050919050565b7f4e6f206e617469766520746f6b656e7320746f20776974686472617700000000600082015250565b6000611b27601c836115bd565b9150611b3282611af1565b602082019050919050565b60006020820190508181036000830152611b5681611b1a565b9050919050565b600081905092915050565b50565b6000611b78600083611b5d565b9150611b8382611b68565b600082019050919050565b6000611b9982611b6b565b9150819050919050565b7f4e617469766520746f6b656e207769746864726177616c206661696c65640000600082015250565b6000611bd9601e836115bd565b9150611be482611ba3565b602082019050919050565b60006020820190508181036000830152611c0881611bcc565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fdfea264697066735822122022e10958a1b861d2325f224de3e08e27de95be014415a0452661defee642ebab64736f6c634300081c0033

Verified Source Code Full Match

Compiler: v0.8.28+commit.7893614a EVM: paris Optimization: No
Ownable.sol 100 lines
// 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);
    }
}
IERC20.sol 79 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

/**
 * @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);
}
Context.sol 28 lines
// 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;
    }
}
Hashes.sol 31 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.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) private pure returns (bytes32 value) {
        assembly ("memory-safe") {
            mstore(0x00, a)
            mstore(0x20, b)
            value := keccak256(0x00, 0x40)
        }
    }
}
MerkleProof.sol 514 lines
// 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];
        }
    }
}
Swap.sol 117 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";

contract Swap is Ownable {
    IERC20 public tokenA;
    IERC20 public tokenB;
    bytes32 public merkleRoot;
    uint256 public fee; // Fixed fee in ETH for each swap

    // Events
    event Swapped(address indexed user, uint256 amount, uint256 fee);
    event TokensWithdrawn(address indexed owner, address token, uint256 amount);
    event AllTokensWithdrawn(address indexed owner, uint256 tokenAAmount, uint256 tokenBAmount);
    event NativeTokenWithdrawn(address indexed owner, uint256 amount);
    event FeeUpdated(uint256 newFee);
    event TokenAddressesUpdated(address newTokenA, address newTokenB);

    // Constructor
    constructor(address _tokenA, address _tokenB, bytes32 _merkleRoot, uint256 _fee) Ownable(msg.sender) {
        tokenA = IERC20(_tokenA);
        tokenB = IERC20(_tokenB);
        merkleRoot = _merkleRoot;
        fee = _fee;
    }

    /**
     * @notice Swap tokenA for tokenB.
     * @param amount Amount of tokens to swap.
     * @param merkleProof The Merkle proof for verifying the user's address.
     */
    function swap(uint256 amount, bytes32[] memory merkleProof) external payable {
        require(amount > 0, "Amount must be greater than 0");
        require(tokenB.balanceOf(address(this)) >= amount, "Insufficient tokenB balance in contract");
        require(msg.value >= fee, "Insufficient ETH for fee");

        // Verify the user's address is in the whitelist
        bytes32 leaf = keccak256(bytes.concat(keccak256(abi.encode(msg.sender))));
        require(MerkleProof.verify(merkleProof, merkleRoot, leaf), "Address not whitelisted");

        // Transfer tokenA from user to contract
        require(tokenA.transferFrom(msg.sender, address(this), amount), "Token A transfer failed");

        // Transfer tokenB from contract to user
        require(tokenB.transfer(msg.sender, amount), "Token B transfer failed");

        // Emit the swap event
        emit Swapped(msg.sender, amount, fee);
    }

    /**
     * @notice Update the Merkle root for the whitelist.
     * @param _newMerkleRoot The new Merkle root.
     */
    function updateMerkleRoot(bytes32 _newMerkleRoot) external onlyOwner {
        merkleRoot = _newMerkleRoot;
    }

    /**
     * @notice Update the ETH fee.
     * @param _newFee The new fee amount in ETH.
     */
    function updateFee(uint256 _newFee) external onlyOwner {
        fee = _newFee;
        emit FeeUpdated(_newFee);
    }

    /**
     * @notice Update the addresses of tokenA and tokenB.
     * @param _newTokenA The new address for tokenA.
     * @param _newTokenB The new address for tokenB.
     */
    function updateTokenAddresses(address _newTokenA, address _newTokenB) external onlyOwner {
        require(_newTokenA != address(0), "Invalid tokenA address");
        require(_newTokenB != address(0), "Invalid tokenB address");
        tokenA = IERC20(_newTokenA);
        tokenB = IERC20(_newTokenB);
        emit TokenAddressesUpdated(_newTokenA, _newTokenB);
    }

    /**
     * @notice Withdraw all tokenA and tokenB from the contract.
     */
    function withdrawAllTokens() external onlyOwner {
        uint256 tokenABalance = tokenA.balanceOf(address(this));
        uint256 tokenBBalance = tokenB.balanceOf(address(this));

        if (tokenABalance > 0) {
            require(tokenA.transfer(msg.sender, tokenABalance), "Token A withdrawal failed");
        }

        if (tokenBBalance > 0) {
            require(tokenB.transfer(msg.sender, tokenBBalance), "Token B withdrawal failed");
        }

        emit AllTokensWithdrawn(msg.sender, tokenABalance, tokenBBalance);
    }

    /**
     * @notice Withdraw all native tokens (ETH) from the contract.
     */
    function withdrawNativeTokens() external onlyOwner {
        uint256 balance = address(this).balance;
        require(balance > 0, "No native tokens to withdraw");

        (bool success, ) = msg.sender.call{value: balance}("");
        require(success, "Native token withdrawal failed");

        emit NativeTokenWithdrawn(msg.sender, balance);
    }

    // Fallback function to accept native tokens (ETH)
    receive() external payable {}
}

Read Contract

fee 0xddca3f43 → uint256
merkleRoot 0x2eb4a7ab → bytes32
owner 0x8da5cb5b → address
tokenA 0x0fc63d10 → address
tokenB 0x5f64b55b → address

Write Contract 8 functions

These functions modify contract state and require a wallet transaction to execute.

renounceOwnership 0x715018a6
No parameters
swap 0x6db767de
uint256 amount
bytes32[] merkleProof
transferOwnership 0xf2fde38b
address newOwner
updateFee 0x9012c4a8
uint256 _newFee
updateMerkleRoot 0x4783f0ef
bytes32 _newMerkleRoot
updateTokenAddresses 0x62b80857
address _newTokenA
address _newTokenB
withdrawAllTokens 0x280da6fa
No parameters
withdrawNativeTokens 0x955a79c3
No parameters

Recent Transactions

No transactions found for this address