Cryo Explorer Ethereum Mainnet

Address Contract Partially Verified

Address 0x910E719C23338f03466a9DD4992a8ce676f17C70
Balance 0 ETH
Nonce 1
Code Size 2331 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

2331 bytes
0x60806040526004361061004a5760003560e01c8063380e6c131461004f5780638da5cb5b1461008c578063a18029c0146100b7578063d46eb119146100e0578063fe5411dc1461010b575b600080fd5b34801561005b57600080fd5b506100766004803603810190610071919061065c565b61013b565b60405161008391906106da565b60405180910390f35b34801561009857600080fd5b506100a16102eb565b6040516100ae9190610704565b60405180910390f35b3480156100c357600080fd5b506100de60048036038101906100d99190610758565b610311565b005b3480156100ec57600080fd5b506100f56103fd565b6040516101029190610704565b60405180910390f35b6101256004803603810190610120919061065c565b610423565b60405161013291906106da565b60405180910390f35b600080849050600084905060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036101bf57600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690505b60005b84518110156102de5760006101f08683815181106101e3576101e2610798565b5b602002602001015161042c565b90506000600260008360ff1660ff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff16636fc904ca86868a878151811061026157610260610798565b5b60200260200101516040518463ffffffff1660e01b8152600401610287939291906107c7565b60408051808303816000875af11580156102a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102c99190610828565b809650819550505082600101925050506101c2565b5081925050509392505050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b3373ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146103a1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610398906108c5565b60405180910390fd5b80600260008460ff1660ff16815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60009392505050565b60007fff00000000000000000000000000000000000000000000000000000000000000821660f81c9050919050565b6000604051905090565b600080fd5b600080fd5b6000819050919050565b6104828161046f565b811461048d57600080fd5b50565b60008135905061049f81610479565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006104d0826104a5565b9050919050565b6104e0816104c5565b81146104eb57600080fd5b50565b6000813590506104fd816104d7565b92915050565b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61055182610508565b810181811067ffffffffffffffff821117156105705761056f610519565b5b80604052505050565b600061058361045b565b905061058f8282610548565b919050565b600067ffffffffffffffff8211156105af576105ae610519565b5b602082029050602081019050919050565b600080fd5b60006105d86105d384610594565b610579565b905080838252602082019050602084028301858111156105fb576105fa6105c0565b5b835b8181101561062457806106108882610490565b8452602084019350506020810190506105fd565b5050509392505050565b600082601f83011261064357610642610503565b5b81356106538482602086016105c5565b91505092915050565b60008060006060848603121561067557610674610465565b5b600061068386828701610490565b9350506020610694868287016104ee565b925050604084013567ffffffffffffffff8111156106b5576106b461046a565b5b6106c18682870161062e565b9150509250925092565b6106d48161046f565b82525050565b60006020820190506106ef60008301846106cb565b92915050565b6106fe816104c5565b82525050565b600060208201905061071960008301846106f5565b92915050565b600060ff82169050919050565b6107358161071f565b811461074057600080fd5b50565b6000813590506107528161072c565b92915050565b6000806040838503121561076f5761076e610465565b5b600061077d85828601610743565b925050602061078e858286016104ee565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60006060820190506107dc60008301866106cb565b6107e960208301856106f5565b6107f660408301846106cb565b949350505050565b60008151905061080d816104d7565b92915050565b60008151905061082281610479565b92915050565b6000806040838503121561083f5761083e610465565b5b600061084d858286016107fe565b925050602061085e85828601610813565b9150509250929050565b600082825260208201905092915050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b60006108af602083610868565b91506108ba82610879565b602082019050919050565b600060208201905081810360008301526108de816108a2565b905091905056fea26469706673582212205398716dd63608a217bd5a1529118743828042244eebabc77d4fcac0dd2c24f364736f6c63430008110033

Verified Source Code Partial Match

Compiler: v0.8.17+commit.8df45f5f EVM: london Optimization: No
QuoteX.sol 761 lines
// SPDX-License-Identifier: UNLICENSED
pragma abicoder v2;

// File contracts/interfaces/IQuoter.sol

pragma solidity ^0.8.0;
// Original pragma directive: pragma abicoder v2

interface IQuoter {

    function quote(uint256 amount, address token, uint256 pool)
    external
    returns (address, uint256);
}


// File contracts/interfaces/IWETH.sol
pragma solidity ^0.8.0;
// Original pragma directive: pragma abicoder v2

interface IWETH {
    function totalSupply() external view returns (uint256);

    function balanceOf(address account) external view returns (uint256);

    function transfer(address recipient, uint256 amount)
        external
        returns (bool);

    function allowance(address owner, address spender)
        external
        view
        returns (uint256);

    function approve(address spender, uint256 amount) external returns (bool);

    function transferFrom(
        address src,
        address dst,
        uint256 wad
    ) external returns (bool);

    function deposit() external payable;

    function withdraw(uint256 wad) external;
}


// File contracts/interfaces/IERC20.sol
pragma solidity ^0.8.0;

interface IERC20 {
    event Approval(
        address indexed owner,
        address indexed spender,
        uint256 value
    );
    event Transfer(address indexed from, address indexed to, uint256 value);

    function name() external view returns (string memory);

    function symbol() external view returns (string memory);

    function decimals() external view returns (uint8);

    function totalSupply() external view returns (uint256);

    function balanceOf(address owner) external view returns (uint256);

    function allowance(address owner, address spender)
        external
        view
        returns (uint256);

    function approve(address spender, uint256 value) external returns (bool);

    function transfer(address to, uint256 value) external returns (bool);

    function transferFrom(
        address from,
        address to,
        uint256 value
    ) external returns (bool);
}


// File contracts/interfaces/IDaiLikePermit.sol

pragma solidity ^0.8.0;

/// @title Interface for DAI-style permits
interface IDaiLikePermit {
    function permit(
        address holder,
        address spender,
        uint256 nonce,
        uint256 expiry,
        bool allowed,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;
}


// File contracts/interfaces/IERC20Permit.sol

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over `owner`'s tokens,
     * given `owner`'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for `permit`, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}


// File contracts/libraries/Address.sol

pragma solidity ^0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // According to EIP-1052, 0x0 is the value returned for not-yet created accounts
        // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
        // for accounts without code, i.e. `keccak256('')`
        bytes32 codehash;
        bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
        // solhint-disable-next-line no-inline-assembly
        assembly {
            codehash := extcodehash(account)
        }
        return (codehash != accountHash && codehash != 0x0);
    }

    /**
     * @dev Converts an `address` into `address payable`. Note that this is
     * simply a type cast: the actual underlying value is not changed.
     *
     * _Available since v2.4.0._
     */
    function toPayable(address account)
        internal
        pure
        returns (address payable)
    {
        return payable(account);
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     *
     * _Available since v2.4.0._
     */
    function sendValue(address recipient, uint256 amount) internal {
        require(
            address(this).balance >= amount,
            "Address: insufficient balance"
        );

        // solhint-disable-next-line avoid-call-value
        (bool success, ) = recipient.call{value: amount}("");
        require(
            success,
            "Address: unable to send value, recipient may have reverted"
        );
    }
}


// File contracts/libraries/RevertReasonForwarder.sol


pragma solidity ^0.8.0;

library RevertReasonForwarder {
    function reRevert() internal pure {
        // bubble up revert reason from latest external call
        /// @solidity memory-safe-assembly
        assembly { // solhint-disable-line no-inline-assembly
            let ptr := mload(0x40)
            returndatacopy(ptr, 0, returndatasize())
            revert(ptr, returndatasize())
        }
    }
}


// File contracts/libraries/SafeMath.sol

pragma solidity ^0.8.0;

library SafeMath {
    uint256 constant WAD = 10**18;
    uint256 constant RAY = 10**27;

    function wad() public pure returns (uint256) {
        return WAD;
    }

    function ray() public pure returns (uint256) {
        return RAY;
    }

    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");

        return c;
    }

    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }

    function sub(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;

        return c;
    }

    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }

    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }

    function div(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        // Solidity only automatically asserts when dividing by 0
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }

    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }

    function mod(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }

    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a <= b ? a : b;
    }

    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a >= b ? a : b;
    }

    function sqrt(uint256 a) internal pure returns (uint256 b) {
        if (a > 3) {
            b = a;
            uint256 x = a / 2 + 1;
            while (x < b) {
                b = x;
                x = (a / x + x) / 2;
            }
        } else if (a != 0) {
            b = 1;
        }
    }

    function wmul(uint256 a, uint256 b) internal pure returns (uint256) {
        return mul(a, b) / WAD;
    }

    function wmulRound(uint256 a, uint256 b) internal pure returns (uint256) {
        return add(mul(a, b), WAD / 2) / WAD;
    }

    function rmul(uint256 a, uint256 b) internal pure returns (uint256) {
        return mul(a, b) / RAY;
    }

    function rmulRound(uint256 a, uint256 b) internal pure returns (uint256) {
        return add(mul(a, b), RAY / 2) / RAY;
    }

    function wdiv(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(mul(a, WAD), b);
    }

    function wdivRound(uint256 a, uint256 b) internal pure returns (uint256) {
        return add(mul(a, WAD), b / 2) / b;
    }

    function rdiv(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(mul(a, RAY), b);
    }

    function rdivRound(uint256 a, uint256 b) internal pure returns (uint256) {
        return add(mul(a, RAY), b / 2) / b;
    }

    function wpow(uint256 x, uint256 n) internal pure returns (uint256) {
        uint256 result = WAD;
        while (n > 0) {
            if (n % 2 != 0) {
                result = wmul(result, x);
            }
            x = wmul(x, x);
            n /= 2;
        }
        return result;
    }

    function rpow(uint256 x, uint256 n) internal pure returns (uint256) {
        uint256 result = RAY;
        while (n > 0) {
            if (n % 2 != 0) {
                result = rmul(result, x);
            }
            x = rmul(x, x);
            n /= 2;
        }
        return result;
    }

    function divCeil(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 quotient = div(a, b);
        uint256 remainder = a - quotient * b;
        if (remainder > 0) {
            return quotient + 1;
        } else {
            return quotient;
        }
    }
}


// File contracts/libraries/SafeERC20.sol

pragma solidity ^0.8.0;






// File @1inch/solidity-utils/contracts/libraries/[email protected]

library SafeERC20 {
    error SafeTransferFailed();
    error SafeTransferFromFailed();
    error ForceApproveFailed();
    error SafeIncreaseAllowanceFailed();
    error SafeDecreaseAllowanceFailed();
    error SafePermitBadLength();

    // Ensures method do not revert or return boolean `true`, admits call to non-smart-contract
    function safeTransferFrom(IERC20 token, address from, address to, uint256 amount) internal {
        bytes4 selector = token.transferFrom.selector;
        bool success;
        /// @solidity memory-safe-assembly
        assembly { // solhint-disable-line no-inline-assembly
            let data := mload(0x40)

            mstore(data, selector)
            mstore(add(data, 0x04), from)
            mstore(add(data, 0x24), to)
            mstore(add(data, 0x44), amount)
            success := call(gas(), token, 0, data, 100, 0x0, 0x20)
            if success {
                switch returndatasize()
                case 0 { success := gt(extcodesize(token), 0) }
                default { success := and(gt(returndatasize(), 31), eq(mload(0), 1)) }
            }
        }
        if (!success) revert SafeTransferFromFailed();
    }

    // Ensures method do not revert or return boolean `true`, admits call to non-smart-contract
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        if (!_makeCall(token, token.transfer.selector, to, value)) {
            revert SafeTransferFailed();
        }
    }

    function safeApprove(IERC20 token, address spender, uint256 value) internal {
        forceApprove(token, spender, value);
    }

    // If `approve(from, to, amount)` fails, try to `approve(from, to, 0)` before retry
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        if (!_makeCall(token, token.approve.selector, spender, value)) {
            if (!_makeCall(token, token.approve.selector, spender, 0) ||
                !_makeCall(token, token.approve.selector, spender, value))
            {
                revert ForceApproveFailed();
            }
        }
    }

    

    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 allowance = token.allowance(address(this), spender);
        if (value > type(uint256).max - allowance) revert SafeIncreaseAllowanceFailed();
        forceApprove(token, spender, allowance + value);
    }

    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 allowance = token.allowance(address(this), spender);
        if (value > allowance) revert SafeDecreaseAllowanceFailed();
        forceApprove(token, spender, allowance - value);
    }

    function safePermit(IERC20 token, bytes calldata permit) internal {
        bool success;
        if (permit.length == 32 * 7) {
            success = _makeCalldataCall(token, IERC20Permit.permit.selector, permit);
        } else if (permit.length == 32 * 8) {
            success = _makeCalldataCall(token, IDaiLikePermit.permit.selector, permit);
        } else {
            revert SafePermitBadLength();
        }
        if (!success) RevertReasonForwarder.reRevert();
    }

    function _makeCall(IERC20 token, bytes4 selector, address to, uint256 amount) private returns(bool success) {
        /// @solidity memory-safe-assembly
        assembly { // solhint-disable-line no-inline-assembly
            let data := mload(0x40)

            mstore(data, selector)
            mstore(add(data, 0x04), to)
            mstore(add(data, 0x24), amount)
            success := call(gas(), token, 0, data, 0x44, 0x0, 0x20)
            if success {
                switch returndatasize()
                case 0 { success := gt(extcodesize(token), 0) }
                default { success := and(gt(returndatasize(), 31), eq(mload(0), 1)) }
            }
        }
    }

    function _makeCalldataCall(IERC20 token, bytes4 selector, bytes calldata args) private returns(bool success) {
        /// @solidity memory-safe-assembly
        assembly { // solhint-disable-line no-inline-assembly
            let len := add(4, args.length)
            let data := mload(0x40)

            mstore(data, selector)
            calldatacopy(add(data, 0x04), args.offset, args.length)
            success := call(gas(), token, 0, data, len, 0x0, 0x20)
            if success {
                switch returndatasize()
                case 0 { success := gt(extcodesize(token), 0) }
                default { success := and(gt(returndatasize(), 31), eq(mload(0), 1)) }
            }
        }
    }
}


// File contracts/libraries/UniversalERC20.sol

pragma solidity ^0.8.0;



library UniversalERC20 {
    using SafeMath for uint256;
    using SafeERC20 for IERC20;

    IERC20 private constant ETH_ADDRESS =
        IERC20(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE);

    function universalTransfer(
        IERC20 token,
        address payable to,
        uint256 amount
    ) internal {
        if (amount > 0) {
            if (isETH(token)) {
                to.transfer(amount);
            } else {
                token.safeTransfer(to, amount);
            }
        }
    }

    function universalTransferFrom(
        IERC20 token,
        address from,
        address payable to,
        uint256 amount
    ) internal {
        if (amount > 0) {
            token.safeTransferFrom(from, to, amount);
        }
    }

    function universalApproveMax(
        IERC20 token,
        address to,
        uint256 amount
    ) internal {
        uint256 allowance = token.allowance(address(this), to);
        if (allowance < amount) {
            token.forceApprove(to, type(uint256).max);
        }
    }

    function universalBalanceOf(IERC20 token, address who)
        internal
        view
        returns (uint256)
    {
        if (isETH(token)) {
            return who.balance;
        } else {
            return token.balanceOf(who);
        }
    }

    function tokenBalanceOf(IERC20 token, address who)
        internal
        view
        returns (uint256)
    {
        return token.balanceOf(who);
    }

    function isETH(IERC20 token) internal pure returns (bool) {
        return token == ETH_ADDRESS;
    }
}


// File contracts/dexCheck/MixQuote.sol

pragma solidity ^0.8.17;



contract QuoteX {
    using UniversalERC20 for IERC20;

    bytes32 private constant _DEX_MASK = 0xff00000000000000000000000000000000000000000000000000000000000000;
    uint256 private constant _FEE_MASK = 0x00000000000000000000ffff0000000000000000000000000000000000000000;
    bytes32 private constant _ADDRESS_MASK = 0x000000000000000000000000ffffffffffffffffffffffffffffffffffffffff;
    address NULL_ADDRESS = 0x0000000000000000000000000000000000000000;

    mapping(uint8 => address) private adapters;
    mapping(uint8 => address) private quoters;
    address public owner;
    address public wrap;

    constructor(address _wrap) {
        owner = msg.sender;
        wrap = _wrap;
    }

    function mixQuote(uint amount, address token, uint256[] memory pools) public returns (uint256) {
        uint256 nextAmount = amount;
        address nextToken = token;
        if (nextToken == NULL_ADDRESS) {
            nextToken = wrap;
        }
        for (uint256 i = 0; i < pools.length;) {
            uint8 dex = getDexType(pools[i]);
            address quoter = quoters[dex];
            (nextToken, nextAmount) = IQuoter(quoter).quote(nextAmount, nextToken, pools[i]);
        unchecked {
            ++i;
        }
        }
        return nextAmount;
    }

    function mixQuoteBySwap(uint amount, address token, uint256[] memory pools) public payable returns (uint256) {
        //1.判断token是否是wrap
        //2.wrap直接走对应dex兑换,普通token先找v2池子
        //3.swap换出对应amount数量的token
        //4.decode poolInfo走对应dex兑换,目前先支持v3
//        if (token == wrap) {
//            IWETH(wrap).deposit(){value : amount}();
//        } else {
//            IWETH(wrap).deposit(){value : msg.value}();
//            address poolV2 = IFactoryV2.getPair(wrap, token);
//        }

        return 0;
    }

    function setDexQuoter(uint8 dex, address quoter) public {
        require(owner == msg.sender, "Ownable: caller is not the owner");
        quoters[dex] = quoter;
    }

    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        if (!_makeCall(token, token.transfer.selector, to, value)) {
            revert SafeTransferFailed();
        }
    }

    function safeApprove(IERC20 token, address spender, uint256 value) internal {
        forceApprove(token, spender, value);
    }

    function _makeCall(IERC20 token, bytes4 selector, address to, uint256 amount) private returns (bool success) {
        /// @solidity memory-safe-assembly
        assembly {// solhint-disable-line no-inline-assembly
            let data := mload(0x40)

            mstore(data, selector)
            mstore(add(data, 0x04), to)
            mstore(add(data, 0x24), amount)
            success := call(gas(), token, 0, data, 0x44, 0x0, 0x20)
            if success {
                switch returndatasize()
                case 0 {success := gt(extcodesize(token), 0)}
                default {success := and(gt(returndatasize(), 31), eq(mload(0), 1))}
            }
        }
    }

    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        if (!_makeCall(token, token.approve.selector, spender, value)) {
            if (!_makeCall(token, token.approve.selector, spender, 0) ||
            !_makeCall(token, token.approve.selector, spender, value))
            {
                revert ForceApproveFailed();
            }
        }
    }

    function bytes32ToAddress(uint256 param) internal pure returns (address result) {
        assembly {
            result := and(param, _ADDRESS_MASK)
        }
    }

    function getDexType(uint256 param) internal pure returns (uint8 result) {
        assembly {
            result := shr(248, and(param, _DEX_MASK))
        }
    }

    function getFee(uint256 param) internal pure returns (uint256 result) {
        assembly {
            result := shr(160, and(param, _FEE_MASK))
        }
    }

    error SafeTransferFailed();
    error ForceApproveFailed();

}

Read Contract

owner 0x8da5cb5b → address
wrap 0xd46eb119 → address

Write Contract 3 functions

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

mixQuote 0x380e6c13
uint256 amount
address token
uint256[] pools
returns: uint256
mixQuoteBySwap 0xfe5411dc
uint256 amount
address token
uint256[] pools
returns: uint256
setDexQuoter 0xa18029c0
uint8 dex
address quoter

Recent Transactions

No transactions found for this address