ETH Price: $2,898.90 (-10.55%)
Gas: 25 Gwei

Contract

0xC6e1074113a954340277aE6F309aF2AF6e259283
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Value
Fill RFQ198158192024-05-07 4:30:2359 days ago1715056223IN
0xC6e10741...F6e259283
0 ETH0.000777844.32061153
Fill RFQ197676042024-04-30 10:43:2365 days ago1714473803IN
0xC6e10741...F6e259283
0 ETH0.001497299.21318942
Fill RFQ197603812024-04-29 10:29:4766 days ago1714386587IN
0xC6e10741...F6e259283
0 ETH0.001414117.51052953
Fill RFQ197090772024-04-22 6:13:5973 days ago1713766439IN
0xC6e10741...F6e259283
0.02 ETH0.000928366.41070224
Fill RFQ197075872024-04-22 1:13:4774 days ago1713748427IN
0xC6e10741...F6e259283
0.03 ETH0.000781676.12044583
Fill RFQ197043732024-04-21 14:27:5974 days ago1713709679IN
0xC6e10741...F6e259283
0 ETH0.0019805810.04697641
Fill RFQ196816072024-04-18 9:59:5977 days ago1713434399IN
0xC6e10741...F6e259283
0.01 ETH0.0014021810.97902556
Fill RFQ196815852024-04-18 9:55:3577 days ago1713434135IN
0xC6e10741...F6e259283
0.05 ETH0.001231619.6434486
Fill RFQ196812012024-04-18 8:38:1177 days ago1713429491IN
0xC6e10741...F6e259283
0.2 ETH0.0018354514.37015594
0x61012060181265772023-09-13 9:44:59295 days ago1694598299IN
 Create: RFQ
0 ETH0.0624739126.48742018

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To Value
199093462024-05-20 6:27:3545 days ago1716186455
0xC6e10741...F6e259283
0.01 ETH
199093462024-05-20 6:27:3545 days ago1716186455
0xC6e10741...F6e259283
0.01 ETH
198747902024-05-15 10:29:3550 days ago1715768975
0xC6e10741...F6e259283
0.03 ETH
198747902024-05-15 10:29:3550 days ago1715768975
0xC6e10741...F6e259283
0.03 ETH
198158192024-05-07 4:30:2359 days ago1715056223
0xC6e10741...F6e259283
0.0234096 ETH
198158192024-05-07 4:30:2359 days ago1715056223
0xC6e10741...F6e259283
0.0005904 ETH
198158192024-05-07 4:30:2359 days ago1715056223
0xC6e10741...F6e259283
0.024 ETH
197676042024-04-30 10:43:2365 days ago1714473803
0xC6e10741...F6e259283
0.04038826 ETH
197676042024-04-30 10:43:2365 days ago1714473803
0xC6e10741...F6e259283
0.00125341 ETH
197676042024-04-30 10:43:2365 days ago1714473803
0xC6e10741...F6e259283
0.04164168 ETH
197603812024-04-29 10:29:4766 days ago1714386587
0xC6e10741...F6e259283
0.0119664 ETH
197603812024-04-29 10:29:4766 days ago1714386587
0xC6e10741...F6e259283
0.0000336 ETH
197603812024-04-29 10:29:4766 days ago1714386587
0xC6e10741...F6e259283
0.012 ETH
197326602024-04-25 13:24:3570 days ago1714051475
0xC6e10741...F6e259283
0.03 ETH
197326602024-04-25 13:24:3570 days ago1714051475
0xC6e10741...F6e259283
0.03 ETH
197315332024-04-25 9:37:4770 days ago1714037867
0xC6e10741...F6e259283
0.04166665 ETH
197315332024-04-25 9:37:4770 days ago1714037867
0xC6e10741...F6e259283
0.04166665 ETH
197284902024-04-24 23:24:5971 days ago1714001099
0xC6e10741...F6e259283
0.01666665 ETH
197284902024-04-24 23:24:5971 days ago1714001099
0xC6e10741...F6e259283
0.01666665 ETH
197233602024-04-24 6:09:3571 days ago1713938975
0xC6e10741...F6e259283
0.00812705 ETH
197233602024-04-24 6:09:3571 days ago1713938975
0xC6e10741...F6e259283
0.00812705 ETH
197160882024-04-23 5:44:2372 days ago1713851063
0xC6e10741...F6e259283
0.02 ETH
197160882024-04-23 5:44:2372 days ago1713851063
0xC6e10741...F6e259283
0.02 ETH
197104542024-04-22 10:51:1173 days ago1713783071
0xC6e10741...F6e259283
0.011 ETH
197104542024-04-22 10:51:1173 days ago1713783071
0xC6e10741...F6e259283
0.011 ETH
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
RFQ

Compiler Version
v0.8.17+commit.8df45f5f

Optimization Enabled:
Yes with 1000 runs

Other Settings:
london EvmVersion
File 1 of 22 : RFQ.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import { Address } from "@openzeppelin/contracts/utils/Address.sol";

import { TokenCollector } from "./abstracts/TokenCollector.sol";
import { Ownable } from "./abstracts/Ownable.sol";
import { EIP712 } from "./abstracts/EIP712.sol";
import { IWETH } from "./interfaces/IWETH.sol";
import { IRFQ } from "./interfaces/IRFQ.sol";
import { Asset } from "./libraries/Asset.sol";
import { RFQOffer, getRFQOfferHash } from "./libraries/RFQOffer.sol";
import { RFQTx, getRFQTxHash } from "./libraries/RFQTx.sol";
import { Constant } from "./libraries/Constant.sol";
import { SignatureValidator } from "./libraries/SignatureValidator.sol";

contract RFQ is IRFQ, Ownable, TokenCollector, EIP712 {
    using Asset for address;

    uint256 private constant FLG_ALLOW_CONTRACT_SENDER = 1 << 255;
    uint256 private constant FLG_ALLOW_PARTIAL_FILL = 1 << 254;

    IWETH public immutable weth;
    address payable public feeCollector;

    mapping(bytes32 => bool) private filledOffer;

    /// @notice Emitted when fee collector address is updated
    /// @param newFeeCollector The address of the new fee collector
    event SetFeeCollector(address newFeeCollector);

    constructor(
        address _owner,
        address _uniswapPermit2,
        address _allowanceTarget,
        IWETH _weth,
        address payable _feeCollector
    ) Ownable(_owner) TokenCollector(_uniswapPermit2, _allowanceTarget) {
        weth = _weth;
        if (_feeCollector == address(0)) revert ZeroAddress();
        feeCollector = _feeCollector;
    }

    receive() external payable {}

    /// @notice Set fee collector
    /// @notice Only owner can call
    /// @param _newFeeCollector The address of the new fee collector
    function setFeeCollector(address payable _newFeeCollector) external onlyOwner {
        if (_newFeeCollector == address(0)) revert ZeroAddress();
        feeCollector = _newFeeCollector;

        emit SetFeeCollector(_newFeeCollector);
    }

    function fillRFQ(
        RFQTx calldata rfqTx,
        bytes calldata makerSignature,
        bytes calldata makerTokenPermit,
        bytes calldata takerTokenPermit
    ) external payable override {
        _fillRFQ(rfqTx, makerSignature, makerTokenPermit, takerTokenPermit, bytes(""));
    }

    function fillRFQ(
        RFQTx calldata rfqTx,
        bytes calldata makerSignature,
        bytes calldata makerTokenPermit,
        bytes calldata takerTokenPermit,
        bytes calldata takerSignature
    ) external override {
        _fillRFQ(rfqTx, makerSignature, makerTokenPermit, takerTokenPermit, takerSignature);
    }

    function cancelRFQOffer(RFQOffer calldata rfqOffer) external override {
        if (msg.sender != rfqOffer.maker) revert NotOfferMaker();
        bytes32 rfqOfferHash = getRFQOfferHash(rfqOffer);
        if (filledOffer[rfqOfferHash]) revert FilledRFQOffer();
        filledOffer[rfqOfferHash] = true;

        emit CancelRFQOffer(rfqOfferHash, rfqOffer.maker);
    }

    function _fillRFQ(
        RFQTx calldata _rfqTx,
        bytes calldata _makerSignature,
        bytes calldata _makerTokenPermit,
        bytes calldata _takerTokenPermit,
        bytes memory _takerSignature
    ) private {
        RFQOffer memory _rfqOffer = _rfqTx.rfqOffer;
        // check the offer deadline and fee factor
        if (_rfqOffer.expiry < block.timestamp) revert ExpiredRFQOffer();
        if (_rfqOffer.flags & FLG_ALLOW_CONTRACT_SENDER == 0) {
            if (msg.sender != tx.origin) revert ForbidContract();
        }
        if (_rfqOffer.flags & FLG_ALLOW_PARTIAL_FILL == 0) {
            if (_rfqTx.takerRequestAmount != _rfqOffer.takerTokenAmount) revert ForbidPartialFill();
        }
        if (_rfqOffer.feeFactor > Constant.BPS_MAX) revert InvalidFeeFactor();
        if (_rfqTx.recipient == address(0)) revert ZeroAddress();
        if (_rfqTx.takerRequestAmount > _rfqOffer.takerTokenAmount || _rfqTx.takerRequestAmount == 0) revert InvalidTakerAmount();

        // check if the offer is available to be filled
        (bytes32 rfqOfferHash, bytes32 rfqTxHash) = getRFQTxHash(_rfqTx);
        if (filledOffer[rfqOfferHash]) revert FilledRFQOffer();
        filledOffer[rfqOfferHash] = true;

        // check maker signature
        if (!SignatureValidator.isValidSignature(_rfqOffer.maker, getEIP712Hash(rfqOfferHash), _makerSignature)) revert InvalidSignature();

        // check taker signature if needed
        if (_rfqOffer.taker != msg.sender) {
            if (!SignatureValidator.isValidSignature(_rfqOffer.taker, getEIP712Hash(rfqTxHash), _takerSignature)) revert InvalidSignature();
        }

        // transfer takerToken to maker
        if (_rfqOffer.takerToken.isETH()) {
            if (msg.value != _rfqTx.takerRequestAmount) revert InvalidMsgValue();
            Address.sendValue(_rfqOffer.maker, _rfqTx.takerRequestAmount);
        } else if (_rfqOffer.takerToken == address(weth)) {
            if (msg.value != 0) revert InvalidMsgValue();
            _collect(_rfqOffer.takerToken, _rfqOffer.taker, address(this), _rfqTx.takerRequestAmount, _takerTokenPermit);
            weth.withdraw(_rfqTx.takerRequestAmount);
            Address.sendValue(_rfqOffer.maker, _rfqTx.takerRequestAmount);
        } else {
            if (msg.value != 0) revert InvalidMsgValue();
            _collect(_rfqOffer.takerToken, _rfqOffer.taker, _rfqOffer.maker, _rfqTx.takerRequestAmount, _takerTokenPermit);
        }

        // collect makerToken from maker to this
        uint256 makerSettleAmount = _rfqOffer.makerTokenAmount;
        if (_rfqTx.takerRequestAmount != _rfqOffer.takerTokenAmount) {
            makerSettleAmount = (_rfqTx.takerRequestAmount * _rfqOffer.makerTokenAmount) / _rfqOffer.takerTokenAmount;
        }
        if (makerSettleAmount == 0) revert InvalidMakerAmount();
        _collect(_rfqOffer.makerToken, _rfqOffer.maker, address(this), makerSettleAmount, _makerTokenPermit);

        // calculate maker token settlement amount (sub fee)
        uint256 fee = (makerSettleAmount * _rfqOffer.feeFactor) / Constant.BPS_MAX;
        uint256 makerTokenToTaker;
        unchecked {
            // feeFactor is ensured <= Constant.BPS_MAX at the beginning so it's safe with unchecked block
            makerTokenToTaker = makerSettleAmount - fee;
        }

        {
            // determine if WETH unwrap is needed, send out ETH if makerToken is WETH
            address makerToken = _rfqOffer.makerToken;
            if (makerToken == address(weth)) {
                weth.withdraw(makerSettleAmount);
                makerToken = Constant.ETH_ADDRESS;
            }

            // collect fee
            makerToken.transferTo(feeCollector, fee);
            // transfer maker token to recipient
            makerToken.transferTo(_rfqTx.recipient, makerTokenToTaker);
        }

        _emitFilledRFQEvent(rfqOfferHash, _rfqTx, makerTokenToTaker, fee);
    }

    function _emitFilledRFQEvent(
        bytes32 _rfqOfferHash,
        RFQTx calldata _rfqTx,
        uint256 _makerTokenToTaker,
        uint256 fee
    ) internal {
        emit FilledRFQ(
            _rfqOfferHash,
            _rfqTx.rfqOffer.taker,
            _rfqTx.rfqOffer.maker,
            _rfqTx.rfqOffer.takerToken,
            _rfqTx.takerRequestAmount,
            _rfqTx.rfqOffer.makerToken,
            _makerTokenToTaker,
            _rfqTx.recipient,
            fee
        );
    }
}

File 2 of 22 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     *
     * Furthermore, `isContract` will also return true if the target contract within
     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
     * which only has an effect at the end of a transaction.
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

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

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}

File 3 of 22 : TokenCollector.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import { IERC20Permit } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

import { IUniswapPermit2 } from "../interfaces/IUniswapPermit2.sol";
import { IAllowanceTarget } from "../interfaces/IAllowanceTarget.sol";

abstract contract TokenCollector {
    using SafeERC20 for IERC20;

    error Permit2DataEmpty();

    enum Source {
        TokenlonAllowanceTarget,
        Token,
        TokenPermit,
        Permit2AllowanceTransfer,
        Permit2SignatureTransfer
    }

    address public immutable permit2;
    address public immutable allowanceTarget;

    constructor(address _permit2, address _allowanceTarget) {
        permit2 = _permit2;
        allowanceTarget = _allowanceTarget;
    }

    function _collect(
        address token,
        address from,
        address to,
        uint256 amount,
        bytes calldata data
    ) internal {
        Source src = Source(uint8(data[0]));

        if (src == Source.TokenlonAllowanceTarget) {
            return IAllowanceTarget(allowanceTarget).spendFromUserTo(from, token, to, amount);
        } else if (src == Source.Token) {
            return IERC20(token).safeTransferFrom(from, to, amount);
        } else if (src == Source.TokenPermit) {
            (bool success, bytes memory result) = token.call(abi.encodePacked(IERC20Permit.permit.selector, data[1:]));
            if (!success) {
                assembly {
                    revert(add(result, 32), returndatasize())
                }
            }
            return IERC20(token).safeTransferFrom(from, to, amount);
        } else if (src == Source.Permit2AllowanceTransfer) {
            bytes memory permit2Data = data[1:];
            if (permit2Data.length > 0) {
                (bool success, bytes memory result) = permit2.call(abi.encodePacked(IUniswapPermit2.permit.selector, permit2Data));
                if (!success) {
                    assembly {
                        revert(add(result, 32), returndatasize())
                    }
                }
            }
            return IUniswapPermit2(permit2).transferFrom(from, to, uint160(amount), token);
        } else if (src == Source.Permit2SignatureTransfer) {
            bytes memory permit2Data = data[1:];
            if (permit2Data.length == 0) revert Permit2DataEmpty();
            (uint256 nonce, uint256 deadline, bytes memory permitSig) = abi.decode(permit2Data, (uint256, uint256, bytes));
            IUniswapPermit2.PermitTransferFrom memory permit = IUniswapPermit2.PermitTransferFrom({
                permitted: IUniswapPermit2.TokenPermissions({ token: token, amount: amount }),
                nonce: nonce,
                deadline: deadline
            });
            IUniswapPermit2.SignatureTransferDetails memory detail = IUniswapPermit2.SignatureTransferDetails({ to: to, requestedAmount: amount });
            return IUniswapPermit2(permit2).permitTransferFrom(permit, detail, from, permitSig);
        }

        // won't be reached
        revert();
    }
}

File 4 of 22 : Ownable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/// @title Ownable Contract
/// @author imToken Labs
abstract contract Ownable {
    address public owner;
    address public nominatedOwner;

    error NotOwner();
    error NotNominated();
    error ZeroOwner();
    error NominationExists();

    event OwnerNominated(address indexed newOwner);
    event OwnerChanged(address indexed oldOwner, address indexed newOwner);

    constructor(address _owner) {
        if (_owner == address(0)) revert ZeroOwner();
        owner = _owner;
    }

    modifier onlyOwner() {
        if (msg.sender != owner) revert NotOwner();
        _;
    }

    /// @notice Activate new ownership
    /// @notice Only nominated owner can call
    function acceptOwnership() external {
        if (msg.sender != nominatedOwner) revert NotNominated();
        emit OwnerChanged(owner, nominatedOwner);

        owner = nominatedOwner;
        nominatedOwner = address(0);
    }

    /// @notice Give up the ownership
    /// @notice Only owner can call
    /// @notice Ownership cannot be recovered
    function renounceOwnership() external onlyOwner {
        if (nominatedOwner != address(0)) revert NominationExists();
        emit OwnerChanged(owner, address(0));
        owner = address(0);
    }

    /// @notice Nominate new owner
    /// @notice Only owner can call
    /// @param newOwner The address of the new owner
    function nominateNewOwner(address newOwner) external onlyOwner {
        nominatedOwner = newOwner;
        emit OwnerNominated(newOwner);
    }
}

File 5 of 22 : EIP712.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

abstract contract EIP712 {
    // EIP-191 Header
    string public constant EIP191_HEADER = "\x19\x01";

    // EIP-712 Domain
    string public constant EIP712_NAME = "Tokenlon";
    string public constant EIP712_VERSION = "v6";
    bytes32 public constant EIP712_TYPE_HASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
    bytes32 private constant EIP712_HASHED_NAME = keccak256(bytes(EIP712_NAME));
    bytes32 private constant EIP712_HASHED_VERSION = keccak256(bytes(EIP712_VERSION));

    uint256 public immutable originalChainId;
    bytes32 public immutable originalEIP712DomainSeparator;

    constructor() {
        originalChainId = block.chainid;
        originalEIP712DomainSeparator = _buildDomainSeparator();
    }

    function _buildDomainSeparator() private view returns (bytes32) {
        return keccak256(abi.encode(EIP712_TYPE_HASH, EIP712_HASHED_NAME, EIP712_HASHED_VERSION, block.chainid, address(this)));
    }

    function _getDomainSeparator() private view returns (bytes32) {
        if (block.chainid == originalChainId) {
            return originalEIP712DomainSeparator;
        } else {
            return _buildDomainSeparator();
        }
    }

    function getEIP712Hash(bytes32 structHash) internal view returns (bytes32) {
        return keccak256(abi.encodePacked(EIP191_HEADER, _getDomainSeparator(), structHash));
    }

    function EIP712_DOMAIN_SEPARATOR() external view returns (bytes32) {
        return _getDomainSeparator();
    }
}

File 6 of 22 : IWETH.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;

interface IWETH {
    function balanceOf(address account) external view returns (uint256);

    function deposit() external payable;

    function withdraw(uint256 amount) external;

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

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

File 7 of 22 : IRFQ.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;

import { RFQOffer } from "../libraries/RFQOffer.sol";
import { RFQTx } from "../libraries/RFQTx.sol";

/// @title IRFQ Interface
/// @author imToken Labs
interface IRFQ {
    error ExpiredRFQOffer();
    error FilledRFQOffer();
    error ZeroAddress();
    error InvalidFeeFactor();
    error InvalidMsgValue();
    error InvalidSignature();
    error InvalidTakerAmount();
    error InvalidMakerAmount();
    error ForbidContract();
    error ForbidPartialFill();
    error NotOfferMaker();

    event FilledRFQ(
        bytes32 indexed rfqOfferHash,
        address indexed user,
        address indexed maker,
        address takerToken,
        uint256 takerTokenUserAmount,
        address makerToken,
        uint256 makerTokenUserAmount,
        address recipient,
        uint256 fee
    );

    event CancelRFQOffer(bytes32 indexed rfqOfferHash, address indexed maker);

    function fillRFQ(
        RFQTx calldata rfqTx,
        bytes calldata makerSignature,
        bytes calldata makerTokenPermit,
        bytes calldata takerTokenPermit
    ) external payable;

    function fillRFQ(
        RFQTx calldata rfqTx,
        bytes calldata makerSignature,
        bytes calldata makerTokenPermit,
        bytes calldata takerTokenPermit,
        bytes calldata takerSignature
    ) external;

    function cancelRFQOffer(RFQOffer calldata rfqOffer) external;
}

File 8 of 22 : Asset.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

import { Constant } from "./Constant.sol";

library Asset {
    using SafeERC20 for IERC20;

    error InsufficientBalance();

    function isETH(address addr) internal pure returns (bool) {
        return (addr == Constant.ETH_ADDRESS || addr == Constant.ZERO_ADDRESS);
    }

    function getBalance(address asset, address owner) internal view returns (uint256) {
        if (isETH(asset)) {
            return owner.balance;
        } else {
            return IERC20(asset).balanceOf(owner);
        }
    }

    function transferTo(
        address asset,
        address payable to,
        uint256 amount
    ) internal {
        if (to == address(this) || amount == 0) {
            return;
        }
        if (isETH(asset)) {
            // @dev forward all available gas and may cause reentrancy
            if (address(this).balance < amount) revert InsufficientBalance();
            (bool success, bytes memory result) = to.call{ value: amount }("");
            if (!success) {
                assembly {
                    revert(add(result, 32), mload(result))
                }
            }
        } else {
            IERC20(asset).safeTransfer(to, amount);
        }
    }
}

File 9 of 22 : RFQOffer.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

string constant RFQ_OFFER_TYPESTRING = "RFQOffer(address taker,address maker,address takerToken,uint256 takerTokenAmount,address makerToken,uint256 makerTokenAmount,uint256 feeFactor,uint256 flags,uint256 expiry,uint256 salt)";

bytes32 constant RFQ_OFFER_DATA_TYPEHASH = 0x4b43f8e0f7a19a08c96469eb0679ca2da9fab62fb18a10e34e5e0c4ae0248a1c;
// keccak256(RFQ_OFFER_TYPESTRING);

struct RFQOffer {
    address taker;
    address payable maker;
    address takerToken;
    uint256 takerTokenAmount;
    address makerToken;
    uint256 makerTokenAmount;
    uint256 feeFactor;
    uint256 flags;
    uint256 expiry;
    uint256 salt;
}

// solhint-disable-next-line func-visibility
function getRFQOfferHash(RFQOffer memory rfqOffer) pure returns (bytes32) {
    return
        keccak256(
            abi.encode(
                RFQ_OFFER_DATA_TYPEHASH,
                rfqOffer.taker,
                rfqOffer.maker,
                rfqOffer.takerToken,
                rfqOffer.takerTokenAmount,
                rfqOffer.makerToken,
                rfqOffer.makerTokenAmount,
                rfqOffer.feeFactor,
                rfqOffer.flags,
                rfqOffer.expiry,
                rfqOffer.salt
            )
        );
}

File 10 of 22 : RFQTx.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { RFQOffer, getRFQOfferHash, RFQ_OFFER_TYPESTRING } from "./RFQOffer.sol";

string constant RFQ_TX_TYPESTRING = string(abi.encodePacked("RFQTx(RFQOffer rfqOffer,address recipient,uint256 takerRequestAmount)", RFQ_OFFER_TYPESTRING));

bytes32 constant RFQ_TX_TYPEHASH = 0x97972dc666c2aa8c659018f15b9a82f6ef40f271eebb1ab163a310eca758f29f;
// keccak256(RFQ_TX_TYPESTRING);

struct RFQTx {
    RFQOffer rfqOffer;
    address payable recipient;
    uint256 takerRequestAmount;
}

// solhint-disable-next-line func-visibility
function getRFQTxHash(RFQTx memory rfqTx) pure returns (bytes32 rfqOfferHash, bytes32 rfqTxHash) {
    rfqOfferHash = getRFQOfferHash(rfqTx.rfqOffer);
    rfqTxHash = keccak256(abi.encode(RFQ_TX_TYPEHASH, rfqOfferHash, rfqTx.recipient, rfqTx.takerRequestAmount));
}

File 11 of 22 : Constant.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

library Constant {
    uint16 internal constant BPS_MAX = 10000;
    address internal constant ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
    address internal constant ZERO_ADDRESS = address(0);
}

File 12 of 22 : SignatureValidator.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import { Address } from "@openzeppelin/contracts/utils/Address.sol";

import { IERC1271Wallet } from "../interfaces/IERC1271Wallet.sol";

library SignatureValidator {
    using Address for address;

    // bytes4(keccak256("isValidSignature(bytes32,bytes)"))
    bytes4 internal constant ERC1271_MAGICVALUE = 0x1626ba7e;

    /**
     * @dev Verifies that a hash has been signed by the given signer.
     * @param _signerAddress  Address that should have signed the given hash.
     * @param _hash           Hash of the EIP-712 encoded data
     * @param _signature      Proof that the hash has been signed by signer.
     * @return True if the address recovered from the provided signature matches the input signer address.
     */
    function isValidSignature(
        address _signerAddress,
        bytes32 _hash,
        bytes memory _signature
    ) internal view returns (bool) {
        if (_signerAddress.isContract()) {
            return ERC1271_MAGICVALUE == IERC1271Wallet(_signerAddress).isValidSignature(_hash, _signature);
        } else {
            return _signerAddress == ECDSA.recover(_hash, _signature);
        }
    }
}

File 13 of 22 : IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 */
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 14 of 22 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 amount) external returns (bool);
}

File 15 of 22 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(IERC20 token, address spender, uint256 value) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Compatible with tokens that require the approval to be set to
     * 0 before setting it to a non-zero value.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
     * Revert on invalid signature.
     */
    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return
            success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
    }
}

File 16 of 22 : IUniswapPermit2.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;

interface IUniswapPermit2 {
    /// @notice Thrown when an allowance on a token has expired.
    /// @param deadline The timestamp at which the allowed amount is no longer valid
    error AllowanceExpired(uint256 deadline);

    /// @notice Thrown when an allowance on a token has been depleted.
    /// @param amount The maximum amount allowed
    error InsufficientAllowance(uint256 amount);

    /// @notice Thrown when the requested amount for a transfer is larger than the permissioned amount
    /// @param maxAmount The maximum amount a spender can request to transfer
    error InvalidAmount(uint256 maxAmount);

    /// @notice Thrown when validating that the inputted nonce has not been used
    error InvalidNonce();

    /// @notice Thrown when the recovered signer does not equal the claimedSigner
    error InvalidSigner();

    /// @notice Thrown when validating an inputted signature that is stale
    /// @param signatureDeadline The timestamp at which a signature is no longer valid
    error SignatureExpired(uint256 signatureDeadline);

    /*
     * Allowance Transfer
     */

    /// @notice The permit data for a token
    struct PermitDetails {
        // ERC20 token address
        address token;
        // the maximum amount allowed to spend
        uint160 amount;
        // timestamp at which a spender's token allowances become invalid
        uint48 expiration;
        // an incrementing value indexed per owner,token,and spender for each signature
        uint48 nonce;
    }

    /// @notice The permit message signed for a single token allownce
    struct PermitSingle {
        // the permit data for a single token alownce
        PermitDetails details;
        // address permissioned on the allowed tokens
        address spender;
        // deadline on the permit signature
        uint256 sigDeadline;
    }

    /// @notice Returns the domain separator for the current chain.
    /// @dev Uses cached version if chainid and address are unchanged from construction.
    function DOMAIN_SEPARATOR() external view returns (bytes32);

    /// @notice A mapping from owner address to token address to spender address to PackedAllowance struct, which contains details and conditions of the approval.
    /// @notice The mapping is indexed in the above order see: allowance[ownerAddress][tokenAddress][spenderAddress]
    /// @dev The packed slot holds the allowed amount, expiration at which the allowed amount is no longer valid, and current nonce thats updated on any signature based approvals.
    function allowance(
        address user,
        address token,
        address spender
    )
        external
        view
        returns (
            uint160 amount,
            uint48 expiration,
            uint48 nonce
        );

    /// @notice Permit a spender to a given amount of the owners token via the owner's EIP-712 signature
    /// @dev May fail if the owner's nonce was invalidated in-flight by invalidateNonce
    /// @param owner The owner of the tokens being approved
    /// @param permitSingle Data signed over by the owner specifying the terms of approval
    /// @param signature The owner's signature over the permit data
    function permit(
        address owner,
        PermitSingle memory permitSingle,
        bytes calldata signature
    ) external;

    /// @notice Transfer approved tokens from one address to another
    /// @param from The address to transfer from
    /// @param to The address of the recipient
    /// @param amount The amount of the token to transfer
    /// @param token The token address to transfer
    /// @dev Requires the from address to have approved at least the desired amount
    /// of tokens to msg.sender.
    function transferFrom(
        address from,
        address to,
        uint160 amount,
        address token
    ) external;

    /// @notice Approves the spender to use up to amount of the specified token up until the expiration
    /// @param token The token to approve
    /// @param spender The spender address to approve
    /// @param amount The approved amount of the token
    /// @param expiration The timestamp at which the approval is no longer valid
    /// @dev The packed allowance also holds a nonce, which will stay unchanged in approve
    /// @dev Setting amount to type(uint160).max sets an unlimited approval
    function approve(
        address token,
        address spender,
        uint160 amount,
        uint48 expiration
    ) external;

    /*
     * Signature Transfer
     */

    /// @notice The token and amount details for a transfer signed in the permit transfer signature
    struct TokenPermissions {
        // ERC20 token address
        address token;
        // the maximum amount that can be spent
        uint256 amount;
    }

    /// @notice The signed permit message for a single token transfer
    struct PermitTransferFrom {
        TokenPermissions permitted;
        // a unique value for every token owner's signature to prevent signature replays
        uint256 nonce;
        // deadline on the permit signature
        uint256 deadline;
    }

    /// @notice Specifies the recipient address and amount for batched transfers.
    /// @dev Recipients and amounts correspond to the index of the signed token permissions array.
    /// @dev Reverts if the requested amount is greater than the permitted signed amount.
    struct SignatureTransferDetails {
        // recipient address
        address to;
        // spender requested amount
        uint256 requestedAmount;
    }

    /// @notice Transfers a token using a signed permit message
    /// @dev Reverts if the requested amount is greater than the permitted signed amount
    /// @param permit The permit data signed over by the owner
    /// @param owner The owner of the tokens to transfer
    /// @param transferDetails The spender's requested transfer details for the permitted token
    /// @param signature The signature to verify
    function permitTransferFrom(
        PermitTransferFrom memory permit,
        SignatureTransferDetails calldata transferDetails,
        address owner,
        bytes calldata signature
    ) external;
}

File 17 of 22 : IAllowanceTarget.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;

/// @title IAllowanceTarget Interface
/// @author imToken Labs
interface IAllowanceTarget {
    error NotAuthorized();

    /// @dev Spend tokens on user's behalf. Only an authority can call this.
    /// @param  from The user to spend token from.
    /// @param  token The address of the token.
    /// @param  to The recipient of the trasnfer.
    /// @param  amount Amount to spend.
    function spendFromUserTo(
        address from,
        address token,
        address to,
        uint256 amount
    ) external;
}

File 18 of 22 : ECDSA.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.0;

import "../Strings.sol";

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSA {
    enum RecoverError {
        NoError,
        InvalidSignature,
        InvalidSignatureLength,
        InvalidSignatureS,
        InvalidSignatureV // Deprecated in v4.8
    }

    function _throwError(RecoverError error) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert("ECDSA: invalid signature");
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert("ECDSA: invalid signature length");
        } else if (error == RecoverError.InvalidSignatureS) {
            revert("ECDSA: invalid signature 's' value");
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature` or error string. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            /// @solidity memory-safe-assembly
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength);
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, signature);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError) {
        bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
        uint8 v = uint8((uint256(vs) >> 255) + 27);
        return tryRecover(hash, v, r, s);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
     *
     * _Available since v4.2._
     */
    function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, r, vs);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) {
        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
        // signatures from current libraries generate a unique signature with an s-value in the lower half order.
        //
        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
        // these malleable signatures as well.
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            return (address(0), RecoverError.InvalidSignatureS);
        }

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        if (signer == address(0)) {
            return (address(0), RecoverError.InvalidSignature);
        }

        return (signer, RecoverError.NoError);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, v, r, s);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from a `hash`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 message) {
        // 32 is the length in bytes of hash,
        // enforced by the type signature above
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x00, "\x19Ethereum Signed Message:\n32")
            mstore(0x1c, hash)
            message := keccak256(0x00, 0x3c)
        }
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from `s`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
    }

    /**
     * @dev Returns an Ethereum Signed Typed Data, created from a
     * `domainSeparator` and a `structHash`. This produces hash corresponding
     * to the one signed with the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
     * JSON-RPC method as part of EIP-712.
     *
     * See {recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 data) {
        /// @solidity memory-safe-assembly
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, "\x19\x01")
            mstore(add(ptr, 0x02), domainSeparator)
            mstore(add(ptr, 0x22), structHash)
            data := keccak256(ptr, 0x42)
        }
    }

    /**
     * @dev Returns an Ethereum Signed Data with intended validator, created from a
     * `validator` and `data` according to the version 0 of EIP-191.
     *
     * See {recover}.
     */
    function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19\x00", validator, data));
    }
}

File 19 of 22 : IERC1271Wallet.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;

interface IERC1271Wallet {
    function isValidSignature(bytes32 _hash, bytes calldata _signature) external view returns (bytes4 magicValue);
}

File 20 of 22 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/Math.sol";
import "./math/SignedMath.sol";

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        unchecked {
            uint256 length = Math.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            /// @solidity memory-safe-assembly
            assembly {
                ptr := add(buffer, add(32, length))
            }
            while (true) {
                ptr--;
                /// @solidity memory-safe-assembly
                assembly {
                    mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `int256` to its ASCII `string` decimal representation.
     */
    function toString(int256 value) internal pure returns (string memory) {
        return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value))));
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, Math.log256(value) + 1);
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }

    /**
     * @dev Returns true if the two strings are equal.
     */
    function equal(string memory a, string memory b) internal pure returns (bool) {
        return keccak256(bytes(a)) == keccak256(bytes(b));
    }
}

File 21 of 22 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
     * with further edits by Uniswap Labs also under MIT license.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod0 := mul(x, y)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                // Solidity will revert if denominator == 0, unlike the div opcode on its own.
                // The surrounding unchecked block does not change this fact.
                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1, "Math: mulDiv overflow");

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
            // See https://cs.stackexchange.com/q/138556/92363.

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
            // in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10 ** 64) {
                value /= 10 ** 64;
                result += 64;
            }
            if (value >= 10 ** 32) {
                value /= 10 ** 32;
                result += 32;
            }
            if (value >= 10 ** 16) {
                value /= 10 ** 16;
                result += 16;
            }
            if (value >= 10 ** 8) {
                value /= 10 ** 8;
                result += 8;
            }
            if (value >= 10 ** 4) {
                value /= 10 ** 4;
                result += 4;
            }
            if (value >= 10 ** 2) {
                value /= 10 ** 2;
                result += 2;
            }
            if (value >= 10 ** 1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256, rounded down, of a positive value.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 256, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);
        }
    }
}

File 22 of 22 : SignedMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard signed math utilities missing in the Solidity language.
 */
library SignedMath {
    /**
     * @dev Returns the largest of two signed numbers.
     */
    function max(int256 a, int256 b) internal pure returns (int256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two signed numbers.
     */
    function min(int256 a, int256 b) internal pure returns (int256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two signed numbers without overflow.
     * The result is rounded towards zero.
     */
    function average(int256 a, int256 b) internal pure returns (int256) {
        // Formula from the book "Hacker's Delight"
        int256 x = (a & b) + ((a ^ b) >> 1);
        return x + (int256(uint256(x) >> 255) & (a ^ b));
    }

    /**
     * @dev Returns the absolute unsigned value of a signed value.
     */
    function abs(int256 n) internal pure returns (uint256) {
        unchecked {
            // must be unchecked in order to support `n = type(int256).min`
            return uint256(n >= 0 ? n : -n);
        }
    }
}

Settings
{
  "remappings": [
    "@openzeppelin/=lib/openzeppelin-contracts/",
    "forge-std/=lib/forge-std/src/",
    "ds-test/=lib/forge-std/lib/ds-test/src/",
    "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "openzeppelin/=lib/openzeppelin-contracts/contracts/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 1000
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "ipfs"
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "london",
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_uniswapPermit2","type":"address"},{"internalType":"address","name":"_allowanceTarget","type":"address"},{"internalType":"contract IWETH","name":"_weth","type":"address"},{"internalType":"address payable","name":"_feeCollector","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ExpiredRFQOffer","type":"error"},{"inputs":[],"name":"FilledRFQOffer","type":"error"},{"inputs":[],"name":"ForbidContract","type":"error"},{"inputs":[],"name":"ForbidPartialFill","type":"error"},{"inputs":[],"name":"InsufficientBalance","type":"error"},{"inputs":[],"name":"InvalidFeeFactor","type":"error"},{"inputs":[],"name":"InvalidMakerAmount","type":"error"},{"inputs":[],"name":"InvalidMsgValue","type":"error"},{"inputs":[],"name":"InvalidSignature","type":"error"},{"inputs":[],"name":"InvalidTakerAmount","type":"error"},{"inputs":[],"name":"NominationExists","type":"error"},{"inputs":[],"name":"NotNominated","type":"error"},{"inputs":[],"name":"NotOfferMaker","type":"error"},{"inputs":[],"name":"NotOwner","type":"error"},{"inputs":[],"name":"Permit2DataEmpty","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"inputs":[],"name":"ZeroOwner","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"rfqOfferHash","type":"bytes32"},{"indexed":true,"internalType":"address","name":"maker","type":"address"}],"name":"CancelRFQOffer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"rfqOfferHash","type":"bytes32"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"maker","type":"address"},{"indexed":false,"internalType":"address","name":"takerToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"takerTokenUserAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"makerToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"makerTokenUserAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"FilledRFQ","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerNominated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newFeeCollector","type":"address"}],"name":"SetFeeCollector","type":"event"},{"inputs":[],"name":"EIP191_HEADER","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"EIP712_DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"EIP712_NAME","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"EIP712_TYPE_HASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"EIP712_VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"allowanceTarget","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"taker","type":"address"},{"internalType":"address payable","name":"maker","type":"address"},{"internalType":"address","name":"takerToken","type":"address"},{"internalType":"uint256","name":"takerTokenAmount","type":"uint256"},{"internalType":"address","name":"makerToken","type":"address"},{"internalType":"uint256","name":"makerTokenAmount","type":"uint256"},{"internalType":"uint256","name":"feeFactor","type":"uint256"},{"internalType":"uint256","name":"flags","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"salt","type":"uint256"}],"internalType":"struct RFQOffer","name":"rfqOffer","type":"tuple"}],"name":"cancelRFQOffer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"feeCollector","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"components":[{"internalType":"address","name":"taker","type":"address"},{"internalType":"address payable","name":"maker","type":"address"},{"internalType":"address","name":"takerToken","type":"address"},{"internalType":"uint256","name":"takerTokenAmount","type":"uint256"},{"internalType":"address","name":"makerToken","type":"address"},{"internalType":"uint256","name":"makerTokenAmount","type":"uint256"},{"internalType":"uint256","name":"feeFactor","type":"uint256"},{"internalType":"uint256","name":"flags","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"salt","type":"uint256"}],"internalType":"struct RFQOffer","name":"rfqOffer","type":"tuple"},{"internalType":"address payable","name":"recipient","type":"address"},{"internalType":"uint256","name":"takerRequestAmount","type":"uint256"}],"internalType":"struct RFQTx","name":"rfqTx","type":"tuple"},{"internalType":"bytes","name":"makerSignature","type":"bytes"},{"internalType":"bytes","name":"makerTokenPermit","type":"bytes"},{"internalType":"bytes","name":"takerTokenPermit","type":"bytes"}],"name":"fillRFQ","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"components":[{"internalType":"address","name":"taker","type":"address"},{"internalType":"address payable","name":"maker","type":"address"},{"internalType":"address","name":"takerToken","type":"address"},{"internalType":"uint256","name":"takerTokenAmount","type":"uint256"},{"internalType":"address","name":"makerToken","type":"address"},{"internalType":"uint256","name":"makerTokenAmount","type":"uint256"},{"internalType":"uint256","name":"feeFactor","type":"uint256"},{"internalType":"uint256","name":"flags","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"salt","type":"uint256"}],"internalType":"struct RFQOffer","name":"rfqOffer","type":"tuple"},{"internalType":"address payable","name":"recipient","type":"address"},{"internalType":"uint256","name":"takerRequestAmount","type":"uint256"}],"internalType":"struct RFQTx","name":"rfqTx","type":"tuple"},{"internalType":"bytes","name":"makerSignature","type":"bytes"},{"internalType":"bytes","name":"makerTokenPermit","type":"bytes"},{"internalType":"bytes","name":"takerTokenPermit","type":"bytes"},{"internalType":"bytes","name":"takerSignature","type":"bytes"}],"name":"fillRFQ","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"nominateNewOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"nominatedOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"originalChainId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"originalEIP712DomainSeparator","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"permit2","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"_newFeeCollector","type":"address"}],"name":"setFeeCollector","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"weth","outputs":[{"internalType":"contract IWETH","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]

6101206040523480156200001257600080fd5b5060405162002bbd38038062002bbd8339810160408190526200003591620001d4565b8383866001600160a01b0381166200006057604051639905827b60e01b815260040160405180910390fd5b600080546001600160a01b0319166001600160a01b039283161790559182166080521660a0524660c0526200015e60408051808201825260088152672a37b5b2b73637b760c11b6020918201528151808301835260028152613b1b60f11b9082015281517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f818301527f4428669f887e7f6a6e361e218ee42308201bdbacbf601211fc38b8b2ec696181818401527fe38c993d0cb6abdb6be519a6875b139ddd45568fc076f7b5fa6362a5581f4a1460608201524660808201523060a0808301919091528351808303909101815260c0909101909252815191012090565b60e0526001600160a01b03808316610100528116620001905760405163d92e233d60e01b815260040160405180910390fd5b600280546001600160a01b0319166001600160a01b0392909216919091179055506200025492505050565b6001600160a01b0381168114620001d157600080fd5b50565b600080600080600060a08688031215620001ed57600080fd5b8551620001fa81620001bb565b60208701519095506200020d81620001bb565b60408701519094506200022081620001bb565b60608701519093506200023381620001bb565b60808701519092506200024681620001bb565b809150509295509295909350565b60805160a05160c05160e051610100516128de620002df600039600081816102ab01528181610c4b01528181610cda01528181610e500152610e8f0152600081816102360152611080015260008181610181015261105801526000818161039001526114e90152600081816101c8015281816116dc015281816117de015261195c01526128de6000f3fe6080604052600436106101635760003560e01c806379ba5097116100c0578063cfb012bf11610074578063de1b84d611610059578063de1b84d614610427578063e0c05c2414610447578063eccec5a81461047557600080fd5b8063cfb012bf146103f2578063dab400f31461041257600080fd5b8063910cab11116100a5578063910cab111461037e578063a42dce80146103b2578063c415b95c146103d257600080fd5b806379ba5097146103495780638da5cb5b1461035e57600080fd5b80633fc8cef3116101175780636344a774116100fc5780636344a774146102ed578063715018a61461030057806374a640ff1461031557600080fd5b80633fc8cef31461029957806353a47bb7146102cd57600080fd5b80631627540c116101485780631627540c1461020257806337be5439146102245780633b2fb7a81461025857600080fd5b80630d788c361461016f57806312261ee7146101b657600080fd5b3661016a57005b600080fd5b34801561017b57600080fd5b506101a37f000000000000000000000000000000000000000000000000000000000000000081565b6040519081526020015b60405180910390f35b3480156101c257600080fd5b506101ea7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016101ad565b34801561020e57600080fd5b5061022261021d3660046121d8565b6104a3565b005b34801561023057600080fd5b506101a37f000000000000000000000000000000000000000000000000000000000000000081565b34801561026457600080fd5b5061028c604051806040016040528060088152602001672a37b5b2b73637b760c11b81525081565b6040516101ad9190612245565b3480156102a557600080fd5b506101ea7f000000000000000000000000000000000000000000000000000000000000000081565b3480156102d957600080fd5b506001546101ea906001600160a01b031681565b6102226102fb3660046122b3565b610525565b34801561030c57600080fd5b5061022261054d565b34801561032157600080fd5b506101a37f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81565b34801561035557600080fd5b50610222610612565b34801561036a57600080fd5b506000546101ea906001600160a01b031681565b34801561038a57600080fd5b506101ea7f000000000000000000000000000000000000000000000000000000000000000081565b3480156103be57600080fd5b506102226103cd3660046121d8565b6106c7565b3480156103de57600080fd5b506002546101ea906001600160a01b031681565b3480156103fe57600080fd5b5061022261040d366004612363565b61077a565b34801561041e57600080fd5b506101a3610885565b34801561043357600080fd5b50610222610442366004612376565b610894565b34801561045357600080fd5b5061028c60405180604001604052806002815260200161190160f01b81525081565b34801561048157600080fd5b5061028c604051806040016040528060028152602001613b1b60f11b81525081565b6000546001600160a01b031633146104ce576040516330cd747160e01b815260040160405180910390fd5b6001805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0383169081179091556040517f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce2290600090a250565b61054487878787878787604051806020016040528060008152506108e5565b50505050505050565b6000546001600160a01b03163314610578576040516330cd747160e01b815260040160405180910390fd5b6001546001600160a01b0316156105bb576040517fcea9483800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080546040516001600160a01b03909116907fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c908390a36000805473ffffffffffffffffffffffffffffffffffffffff19169055565b6001546001600160a01b03163314610656576040517f9ceae3db00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600154600080546040516001600160a01b0393841693909116917fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91a3600180546000805473ffffffffffffffffffffffffffffffffffffffff199081166001600160a01b03841617909155169055565b6000546001600160a01b031633146106f2576040516330cd747160e01b815260040160405180910390fd5b6001600160a01b0381166107195760405163d92e233d60e01b815260040160405180910390fd5b6002805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0383169081179091556040519081527fd649da8f6092116f86ea4e5139de0b75ad371d823918d16368ba3ff09a5cbc9f9060200160405180910390a150565b61078a60408201602083016121d8565b6001600160a01b0316336001600160a01b0316146107d4576040517f53e486f900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006107ed6107e836849003840184612565565b610f6a565b60008181526003602052604090205490915060ff16156108205760405163fb66510760e01b815260040160405180910390fd5b600081815260036020908152604091829020805460ff1916600117905561084b9184019084016121d8565b6001600160a01b0316817fdb33e3ea1dfd277096cecc697c8875ebe4de17d3e9ef1b85484cb43e5b05ba5360405160405180910390a35050565b600061088f611054565b905090565b6108da8989898989898989898080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506108e592505050565b505050505050505050565b60006108f6368a90038a018a612565565b9050428161010001511015610937576040517f72e64f9800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f80000000000000000000000000000000000000000000000000000000000000008160e001511660000361099e5733321461099e576040517f7d3c611900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f40000000000000000000000000000000000000000000000000000000000000008160e0015116600003610a0e57806060015189610160013514610a0e576040517f18ac5e3800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60c08101516127101015610a4e576040517f45ec4b8500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610a626101608b016101408c016121d8565b6001600160a01b031603610a895760405163d92e233d60e01b815260040160405180910390fd5b80606001518961016001351180610aa35750610160890135155b15610ada576040517f65b9dd2f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080610af4610aef368d90038d018d612582565b611173565b600082815260036020526040902054919350915060ff1615610b295760405163fb66510760e01b815260040160405180910390fd5b6000828152600360209081526040909120805460ff19166001179055830151610b9190610b55846111f7565b8c8c8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061122f92505050565b610bae57604051638baa579f60e01b815260040160405180910390fd5b82516001600160a01b03163314610bf1578251610bd490610bce836111f7565b8661122f565b610bf157604051638baa579f60e01b815260040160405180910390fd5b610c0783604001516001600160a01b03166112f2565b15610c49578a61016001353414610c3157604051631841b4e160e01b815260040160405180910390fd5b610c4483602001518c610160013561132c565b610d8f565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031683604001516001600160a01b031603610d51573415610ca557604051631841b4e160e01b815260040160405180910390fd5b610cc083604001518460000151308e61016001358a8a61144f565b604051632e1a7d4d60e01b81526101608c013560048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690632e1a7d4d90602401600060405180830381600087803b158015610d2657600080fd5b505af1158015610d3a573d6000803e3d6000fd5b50505050610c4483602001518c610160013561132c565b3415610d7057604051631841b4e160e01b815260040160405180910390fd5b610d8f8360400151846000015185602001518e61016001358a8a61144f565b60a083015160608401516101608d013514610dca57606084015160a0850151610dbd906101608f01356125ee565b610dc79190612613565b90505b80600003610e04576040517ff20a287600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610e1a8460800151856020015130848d8d61144f565b60c084015160009061271090610e3090846125ee565b610e3a9190612613565b6080860151909150818303906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811690821603610f0b57604051632e1a7d4d60e01b8152600481018590527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690632e1a7d4d90602401600060405180830381600087803b158015610edb57600080fd5b505af1158015610eef573d6000803e3d6000fd5b5050505073eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee90505b600254610f25906001600160a01b038381169116856119ee565b610f4d8f610140016020810190610f3c91906121d8565b6001600160a01b03831690846119ee565b50610f5a858f8385611ad5565b5050505050505050505050505050565b80516020808301516040808501516060860151608087015160a088015160c089015160e08a01516101008b01516101208c0151975160009b6110379b7f4b43f8e0f7a19a08c96469eb0679ca2da9fab62fb18a10e34e5e0c4ae0248a1c9b919a919998979695949392019a8b526001600160a01b03998a1660208c015297891660408b015295881660608a015260808901949094529190951660a087015260c086019490945260e08501939093526101008401929092526101208301919091526101408201526101600190565b604051602081830303815290604052805190602001209050919050565b60007f000000000000000000000000000000000000000000000000000000000000000046036110a257507f000000000000000000000000000000000000000000000000000000000000000090565b5060408051808201825260088152672a37b5b2b73637b760c11b6020918201528151808301835260028152613b1b60f11b9082015281517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f818301527f4428669f887e7f6a6e361e218ee42308201bdbacbf601211fc38b8b2ec696181818401527fe38c993d0cb6abdb6be519a6875b139ddd45568fc076f7b5fa6362a5581f4a1460608201524660808201523060a0808301919091528351808303909101815260c0909101909252815191012090565b6000806111838360000151610f6a565b60208085015160408087015181517f97972dc666c2aa8c659018f15b9a82f6ef40f271eebb1ab163a310eca758f29f948101949094529083018490526001600160a01b039091166060830152608082015290925060a001604051602081830303815290604052805190602001209050915091565b600060405180604001604052806002815260200161190160f01b81525061121c611054565b8360405160200161103793929190612635565b60006001600160a01b0384163b156112ca57604051630b135d3f60e11b81526001600160a01b03851690631626ba7e9061126f908690869060040161265c565b602060405180830381865afa15801561128c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112b09190612675565b6001600160e01b031916630b135d3f60e11b1490506112eb565b6112d48383611ba7565b6001600160a01b0316846001600160a01b03161490505b9392505050565b60006001600160a01b03821673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee148061132657506001600160a01b038216155b92915050565b804710156113815760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e636500000060448201526064015b60405180910390fd5b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146113ce576040519150601f19603f3d011682016040523d82523d6000602084013e6113d3565b606091505b505090508061144a5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401611378565b505050565b6000828260008181106114645761146461269f565b919091013560f81c9050600481111561147f5761147f6126b5565b90506000816004811115611495576114956126b5565b0361154b576040517f1567599f0000000000000000000000000000000000000000000000000000000081526001600160a01b03878116600483015288811660248301528681166044830152606482018690527f00000000000000000000000000000000000000000000000000000000000000001690631567599f90608401600060405180830381600087803b15801561152d57600080fd5b505af1158015611541573d6000803e3d6000fd5b50505050506119e6565b600181600481111561155f5761155f6126b5565b0361157f576115796001600160a01b038816878787611bcb565b506119e6565b6002816004811115611593576115936126b5565b0361166f576000806001600160a01b0389167fd505accf000000000000000000000000000000000000000000000000000000006115d3866001818a6126cb565b6040516020016115e5939291906126f5565b60408051601f19818403018152908290526115ff91612719565b6000604051808303816000865af19150503d806000811461163c576040519150601f19603f3d011682016040523d82523d6000602084013e611641565b606091505b509150915081611652573d60208201fd5b6116676001600160a01b038a16898989611bcb565b5050506119e6565b6003816004811115611683576116836126b5565b0361184157600061169783600181876126cb565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250508251929350509015905061178e576000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316632b67b57060e01b8460405160200161171e929190612735565b60408051601f198184030181529082905261173891612719565b6000604051808303816000865af19150503d8060008114611775576040519150601f19603f3d011682016040523d82523d6000602084013e61177a565b606091505b50915091508161178b573d60208201fd5b50505b6040517f36c785160000000000000000000000000000000000000000000000000000000081526001600160a01b0388811660048301528781166024830152868116604483015289811660648301527f000000000000000000000000000000000000000000000000000000000000000016906336c7851690608401600060405180830381600087803b15801561182257600080fd5b505af1158015611836573d6000803e3d6000fd5b5050505050506119e6565b6004816004811115611855576118556126b5565b0361016a57600061186983600181876126cb565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092018290525084519495509390930392506118dd915050576040517fb826d62c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000806000838060200190518101906118f69190612765565b9250925092506000604051806060016040528060405180604001604052808f6001600160a01b031681526020018c8152508152602001858152602001848152509050600060405180604001604052808c6001600160a01b031681526020018b81525090507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166330f28b7a83838f876040518563ffffffff1660e01b81526004016119ac949392919061280e565b600060405180830381600087803b1580156119c657600080fd5b505af11580156119da573d6000803e3d6000fd5b50505050505050505050505b505050505050565b6001600160a01b038216301480611a03575080155b15611a0d57505050565b611a16836112f2565b15611ac15780471015611a55576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080836001600160a01b03168360405160006040518083038185875af1925050503d8060008114611aa3576040519150601f19603f3d011682016040523d82523d6000602084013e611aa8565b606091505b509150915081611aba57805160208201fd5b5050505050565b61144a6001600160a01b0384168383611c6a565b611ae560408401602085016121d8565b6001600160a01b0316611afb60208501856121d8565b6001600160a01b0316857f2681973c78aaff737a243109f6ba7666a9658dcc4a58c408aed42ca8987ff7e9611b3660608801604089016121d8565b610160880135611b4c60a08a0160808b016121d8565b88611b5f6101608c016101408d016121d8565b604080516001600160a01b0396871681526020810195909552928516928401929092526060830152909116608082015260a0810186905260c00160405180910390a450505050565b6000806000611bb68585611cb3565b91509150611bc381611cf8565b509392505050565b6040516001600160a01b0380851660248301528316604482015260648101829052611c649085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166001600160e01b031990931692909217909152611e60565b50505050565b6040516001600160a01b03831660248201526044810182905261144a9084907fa9059cbb0000000000000000000000000000000000000000000000000000000090606401611c18565b6000808251604103611ce95760208301516040840151606085015160001a611cdd87828585611f48565b94509450505050611cf1565b506000905060025b9250929050565b6000816004811115611d0c57611d0c6126b5565b03611d145750565b6001816004811115611d2857611d286126b5565b03611d755760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401611378565b6002816004811115611d8957611d896126b5565b03611dd65760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401611378565b6003816004811115611dea57611dea6126b5565b03611e5d5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c60448201527f75650000000000000000000000000000000000000000000000000000000000006064820152608401611378565b50565b6000611eb5826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661200c9092919063ffffffff16565b9050805160001480611ed6575080806020019051810190611ed69190612886565b61144a5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401611378565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115611f7f5750600090506003612003565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015611fd3573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116611ffc57600060019250925050612003565b9150600090505b94509492505050565b606061201b8484600085612023565b949350505050565b60608247101561209b5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401611378565b600080866001600160a01b031685876040516120b79190612719565b60006040518083038185875af1925050503d80600081146120f4576040519150601f19603f3d011682016040523d82523d6000602084013e6120f9565b606091505b509150915061210a87838387612115565b979650505050505050565b6060831561218457825160000361217d576001600160a01b0385163b61217d5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401611378565b508161201b565b61201b83838151156121995781518083602001fd5b8060405162461bcd60e51b81526004016113789190612245565b6001600160a01b0381168114611e5d57600080fd5b80356121d3816121b3565b919050565b6000602082840312156121ea57600080fd5b81356112eb816121b3565b60005b838110156122105781810151838201526020016121f8565b50506000910152565b600081518084526122318160208601602086016121f5565b601f01601f19169290920160200192915050565b6020815260006112eb6020830184612219565b6000610180828403121561226b57600080fd5b50919050565b60008083601f84011261228357600080fd5b50813567ffffffffffffffff81111561229b57600080fd5b602083019150836020828501011115611cf157600080fd5b60008060008060008060006101e0888a0312156122cf57600080fd5b6122d98989612258565b965061018088013567ffffffffffffffff808211156122f757600080fd5b6123038b838c01612271565b90985096506101a08a013591508082111561231d57600080fd5b6123298b838c01612271565b90965094506101c08a013591508082111561234357600080fd5b506123508a828b01612271565b989b979a50959850939692959293505050565b6000610140828403121561226b57600080fd5b60008060008060008060008060006102008a8c03121561239557600080fd5b61239f8b8b612258565b98506101808a013567ffffffffffffffff808211156123bd57600080fd5b6123c98d838e01612271565b909a5098506101a08c01359150808211156123e357600080fd5b6123ef8d838e01612271565b90985096506101c08c013591508082111561240957600080fd5b6124158d838e01612271565b90965094506101e08c013591508082111561242f57600080fd5b5061243c8c828d01612271565b915080935050809150509295985092959850929598565b634e487b7160e01b600052604160045260246000fd5b604051610140810167ffffffffffffffff8111828210171561248d5761248d612453565b60405290565b604051601f8201601f1916810167ffffffffffffffff811182821017156124bc576124bc612453565b604052919050565b600061014082840312156124d757600080fd5b6124df612469565b90506124ea826121c8565b81526124f8602083016121c8565b6020820152612509604083016121c8565b604082015260608201356060820152612524608083016121c8565b608082015260a082013560a082015260c082013560c082015260e082013560e082015261010080830135818301525061012080830135818301525092915050565b6000610140828403121561257857600080fd5b6112eb83836124c4565b6000610180828403121561259557600080fd5b6040516060810181811067ffffffffffffffff821117156125b8576125b8612453565b6040526125c584846124c4565b81526101408301356125d6816121b3565b60208201526101609290920135604083015250919050565b808202811582820484141761132657634e487b7160e01b600052601160045260246000fd5b60008261263057634e487b7160e01b600052601260045260246000fd5b500490565b600084516126478184602089016121f5565b91909101928352506020820152604001919050565b82815260406020820152600061201b6040830184612219565b60006020828403121561268757600080fd5b81516001600160e01b0319811681146112eb57600080fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b600080858511156126db57600080fd5b838611156126e857600080fd5b5050820193919092039150565b6001600160e01b031984168152818360048301376000910160040190815292915050565b6000825161272b8184602087016121f5565b9190910192915050565b6001600160e01b031983168152600082516127578160048501602087016121f5565b919091016004019392505050565b60008060006060848603121561277a57600080fd5b8351925060208401519150604084015167ffffffffffffffff808211156127a057600080fd5b818601915086601f8301126127b457600080fd5b8151818111156127c6576127c6612453565b6127d9601f8201601f1916602001612493565b91508082528760208285010111156127f057600080fd5b6128018160208401602086016121f5565b5080925050509250925092565b600061010061283183885180516001600160a01b03168252602090810151910152565b6020870151604084015260408701516060840152612865608084018780516001600160a01b03168252602090810151910152565b6001600160a01b03851660c08401528060e084015261210a81840185612219565b60006020828403121561289857600080fd5b815180151581146112eb57600080fdfea26469706673582212204a9c0c31299c599ae01b076eca3c673a6809b18eb61ddb7e40ca1e8df24c087264736f6c6343000811003300000000000000000000000063ef071b8a69c52a88dca4a844286aeff195129f000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba300000000000000000000000015974e3165cfe1fb21324c5bd1d3b63d34212ec6000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000063ef071b8a69c52a88dca4a844286aeff195129f

Deployed Bytecode

0x6080604052600436106101635760003560e01c806379ba5097116100c0578063cfb012bf11610074578063de1b84d611610059578063de1b84d614610427578063e0c05c2414610447578063eccec5a81461047557600080fd5b8063cfb012bf146103f2578063dab400f31461041257600080fd5b8063910cab11116100a5578063910cab111461037e578063a42dce80146103b2578063c415b95c146103d257600080fd5b806379ba5097146103495780638da5cb5b1461035e57600080fd5b80633fc8cef3116101175780636344a774116100fc5780636344a774146102ed578063715018a61461030057806374a640ff1461031557600080fd5b80633fc8cef31461029957806353a47bb7146102cd57600080fd5b80631627540c116101485780631627540c1461020257806337be5439146102245780633b2fb7a81461025857600080fd5b80630d788c361461016f57806312261ee7146101b657600080fd5b3661016a57005b600080fd5b34801561017b57600080fd5b506101a37f000000000000000000000000000000000000000000000000000000000000000181565b6040519081526020015b60405180910390f35b3480156101c257600080fd5b506101ea7f000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba381565b6040516001600160a01b0390911681526020016101ad565b34801561020e57600080fd5b5061022261021d3660046121d8565b6104a3565b005b34801561023057600080fd5b506101a37fc4ae072cb605b527ba5e4a5447fcfa521fd471caee1ec1729d0740cbaa047daa81565b34801561026457600080fd5b5061028c604051806040016040528060088152602001672a37b5b2b73637b760c11b81525081565b6040516101ad9190612245565b3480156102a557600080fd5b506101ea7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b3480156102d957600080fd5b506001546101ea906001600160a01b031681565b6102226102fb3660046122b3565b610525565b34801561030c57600080fd5b5061022261054d565b34801561032157600080fd5b506101a37f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81565b34801561035557600080fd5b50610222610612565b34801561036a57600080fd5b506000546101ea906001600160a01b031681565b34801561038a57600080fd5b506101ea7f00000000000000000000000015974e3165cfe1fb21324c5bd1d3b63d34212ec681565b3480156103be57600080fd5b506102226103cd3660046121d8565b6106c7565b3480156103de57600080fd5b506002546101ea906001600160a01b031681565b3480156103fe57600080fd5b5061022261040d366004612363565b61077a565b34801561041e57600080fd5b506101a3610885565b34801561043357600080fd5b50610222610442366004612376565b610894565b34801561045357600080fd5b5061028c60405180604001604052806002815260200161190160f01b81525081565b34801561048157600080fd5b5061028c604051806040016040528060028152602001613b1b60f11b81525081565b6000546001600160a01b031633146104ce576040516330cd747160e01b815260040160405180910390fd5b6001805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0383169081179091556040517f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce2290600090a250565b61054487878787878787604051806020016040528060008152506108e5565b50505050505050565b6000546001600160a01b03163314610578576040516330cd747160e01b815260040160405180910390fd5b6001546001600160a01b0316156105bb576040517fcea9483800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080546040516001600160a01b03909116907fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c908390a36000805473ffffffffffffffffffffffffffffffffffffffff19169055565b6001546001600160a01b03163314610656576040517f9ceae3db00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600154600080546040516001600160a01b0393841693909116917fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91a3600180546000805473ffffffffffffffffffffffffffffffffffffffff199081166001600160a01b03841617909155169055565b6000546001600160a01b031633146106f2576040516330cd747160e01b815260040160405180910390fd5b6001600160a01b0381166107195760405163d92e233d60e01b815260040160405180910390fd5b6002805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0383169081179091556040519081527fd649da8f6092116f86ea4e5139de0b75ad371d823918d16368ba3ff09a5cbc9f9060200160405180910390a150565b61078a60408201602083016121d8565b6001600160a01b0316336001600160a01b0316146107d4576040517f53e486f900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006107ed6107e836849003840184612565565b610f6a565b60008181526003602052604090205490915060ff16156108205760405163fb66510760e01b815260040160405180910390fd5b600081815260036020908152604091829020805460ff1916600117905561084b9184019084016121d8565b6001600160a01b0316817fdb33e3ea1dfd277096cecc697c8875ebe4de17d3e9ef1b85484cb43e5b05ba5360405160405180910390a35050565b600061088f611054565b905090565b6108da8989898989898989898080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506108e592505050565b505050505050505050565b60006108f6368a90038a018a612565565b9050428161010001511015610937576040517f72e64f9800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f80000000000000000000000000000000000000000000000000000000000000008160e001511660000361099e5733321461099e576040517f7d3c611900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f40000000000000000000000000000000000000000000000000000000000000008160e0015116600003610a0e57806060015189610160013514610a0e576040517f18ac5e3800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60c08101516127101015610a4e576040517f45ec4b8500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610a626101608b016101408c016121d8565b6001600160a01b031603610a895760405163d92e233d60e01b815260040160405180910390fd5b80606001518961016001351180610aa35750610160890135155b15610ada576040517f65b9dd2f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080610af4610aef368d90038d018d612582565b611173565b600082815260036020526040902054919350915060ff1615610b295760405163fb66510760e01b815260040160405180910390fd5b6000828152600360209081526040909120805460ff19166001179055830151610b9190610b55846111f7565b8c8c8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061122f92505050565b610bae57604051638baa579f60e01b815260040160405180910390fd5b82516001600160a01b03163314610bf1578251610bd490610bce836111f7565b8661122f565b610bf157604051638baa579f60e01b815260040160405180910390fd5b610c0783604001516001600160a01b03166112f2565b15610c49578a61016001353414610c3157604051631841b4e160e01b815260040160405180910390fd5b610c4483602001518c610160013561132c565b610d8f565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031683604001516001600160a01b031603610d51573415610ca557604051631841b4e160e01b815260040160405180910390fd5b610cc083604001518460000151308e61016001358a8a61144f565b604051632e1a7d4d60e01b81526101608c013560048201527f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031690632e1a7d4d90602401600060405180830381600087803b158015610d2657600080fd5b505af1158015610d3a573d6000803e3d6000fd5b50505050610c4483602001518c610160013561132c565b3415610d7057604051631841b4e160e01b815260040160405180910390fd5b610d8f8360400151846000015185602001518e61016001358a8a61144f565b60a083015160608401516101608d013514610dca57606084015160a0850151610dbd906101608f01356125ee565b610dc79190612613565b90505b80600003610e04576040517ff20a287600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610e1a8460800151856020015130848d8d61144f565b60c084015160009061271090610e3090846125ee565b610e3a9190612613565b6080860151909150818303906001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2811690821603610f0b57604051632e1a7d4d60e01b8152600481018590527f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031690632e1a7d4d90602401600060405180830381600087803b158015610edb57600080fd5b505af1158015610eef573d6000803e3d6000fd5b5050505073eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee90505b600254610f25906001600160a01b038381169116856119ee565b610f4d8f610140016020810190610f3c91906121d8565b6001600160a01b03831690846119ee565b50610f5a858f8385611ad5565b5050505050505050505050505050565b80516020808301516040808501516060860151608087015160a088015160c089015160e08a01516101008b01516101208c0151975160009b6110379b7f4b43f8e0f7a19a08c96469eb0679ca2da9fab62fb18a10e34e5e0c4ae0248a1c9b919a919998979695949392019a8b526001600160a01b03998a1660208c015297891660408b015295881660608a015260808901949094529190951660a087015260c086019490945260e08501939093526101008401929092526101208301919091526101408201526101600190565b604051602081830303815290604052805190602001209050919050565b60007f000000000000000000000000000000000000000000000000000000000000000146036110a257507fc4ae072cb605b527ba5e4a5447fcfa521fd471caee1ec1729d0740cbaa047daa90565b5060408051808201825260088152672a37b5b2b73637b760c11b6020918201528151808301835260028152613b1b60f11b9082015281517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f818301527f4428669f887e7f6a6e361e218ee42308201bdbacbf601211fc38b8b2ec696181818401527fe38c993d0cb6abdb6be519a6875b139ddd45568fc076f7b5fa6362a5581f4a1460608201524660808201523060a0808301919091528351808303909101815260c0909101909252815191012090565b6000806111838360000151610f6a565b60208085015160408087015181517f97972dc666c2aa8c659018f15b9a82f6ef40f271eebb1ab163a310eca758f29f948101949094529083018490526001600160a01b039091166060830152608082015290925060a001604051602081830303815290604052805190602001209050915091565b600060405180604001604052806002815260200161190160f01b81525061121c611054565b8360405160200161103793929190612635565b60006001600160a01b0384163b156112ca57604051630b135d3f60e11b81526001600160a01b03851690631626ba7e9061126f908690869060040161265c565b602060405180830381865afa15801561128c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112b09190612675565b6001600160e01b031916630b135d3f60e11b1490506112eb565b6112d48383611ba7565b6001600160a01b0316846001600160a01b03161490505b9392505050565b60006001600160a01b03821673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee148061132657506001600160a01b038216155b92915050565b804710156113815760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e636500000060448201526064015b60405180910390fd5b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146113ce576040519150601f19603f3d011682016040523d82523d6000602084013e6113d3565b606091505b505090508061144a5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401611378565b505050565b6000828260008181106114645761146461269f565b919091013560f81c9050600481111561147f5761147f6126b5565b90506000816004811115611495576114956126b5565b0361154b576040517f1567599f0000000000000000000000000000000000000000000000000000000081526001600160a01b03878116600483015288811660248301528681166044830152606482018690527f00000000000000000000000015974e3165cfe1fb21324c5bd1d3b63d34212ec61690631567599f90608401600060405180830381600087803b15801561152d57600080fd5b505af1158015611541573d6000803e3d6000fd5b50505050506119e6565b600181600481111561155f5761155f6126b5565b0361157f576115796001600160a01b038816878787611bcb565b506119e6565b6002816004811115611593576115936126b5565b0361166f576000806001600160a01b0389167fd505accf000000000000000000000000000000000000000000000000000000006115d3866001818a6126cb565b6040516020016115e5939291906126f5565b60408051601f19818403018152908290526115ff91612719565b6000604051808303816000865af19150503d806000811461163c576040519150601f19603f3d011682016040523d82523d6000602084013e611641565b606091505b509150915081611652573d60208201fd5b6116676001600160a01b038a16898989611bcb565b5050506119e6565b6003816004811115611683576116836126b5565b0361184157600061169783600181876126cb565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250508251929350509015905061178e576000807f000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba36001600160a01b0316632b67b57060e01b8460405160200161171e929190612735565b60408051601f198184030181529082905261173891612719565b6000604051808303816000865af19150503d8060008114611775576040519150601f19603f3d011682016040523d82523d6000602084013e61177a565b606091505b50915091508161178b573d60208201fd5b50505b6040517f36c785160000000000000000000000000000000000000000000000000000000081526001600160a01b0388811660048301528781166024830152868116604483015289811660648301527f000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba316906336c7851690608401600060405180830381600087803b15801561182257600080fd5b505af1158015611836573d6000803e3d6000fd5b5050505050506119e6565b6004816004811115611855576118556126b5565b0361016a57600061186983600181876126cb565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092018290525084519495509390930392506118dd915050576040517fb826d62c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000806000838060200190518101906118f69190612765565b9250925092506000604051806060016040528060405180604001604052808f6001600160a01b031681526020018c8152508152602001858152602001848152509050600060405180604001604052808c6001600160a01b031681526020018b81525090507f000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba36001600160a01b03166330f28b7a83838f876040518563ffffffff1660e01b81526004016119ac949392919061280e565b600060405180830381600087803b1580156119c657600080fd5b505af11580156119da573d6000803e3d6000fd5b50505050505050505050505b505050505050565b6001600160a01b038216301480611a03575080155b15611a0d57505050565b611a16836112f2565b15611ac15780471015611a55576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080836001600160a01b03168360405160006040518083038185875af1925050503d8060008114611aa3576040519150601f19603f3d011682016040523d82523d6000602084013e611aa8565b606091505b509150915081611aba57805160208201fd5b5050505050565b61144a6001600160a01b0384168383611c6a565b611ae560408401602085016121d8565b6001600160a01b0316611afb60208501856121d8565b6001600160a01b0316857f2681973c78aaff737a243109f6ba7666a9658dcc4a58c408aed42ca8987ff7e9611b3660608801604089016121d8565b610160880135611b4c60a08a0160808b016121d8565b88611b5f6101608c016101408d016121d8565b604080516001600160a01b0396871681526020810195909552928516928401929092526060830152909116608082015260a0810186905260c00160405180910390a450505050565b6000806000611bb68585611cb3565b91509150611bc381611cf8565b509392505050565b6040516001600160a01b0380851660248301528316604482015260648101829052611c649085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166001600160e01b031990931692909217909152611e60565b50505050565b6040516001600160a01b03831660248201526044810182905261144a9084907fa9059cbb0000000000000000000000000000000000000000000000000000000090606401611c18565b6000808251604103611ce95760208301516040840151606085015160001a611cdd87828585611f48565b94509450505050611cf1565b506000905060025b9250929050565b6000816004811115611d0c57611d0c6126b5565b03611d145750565b6001816004811115611d2857611d286126b5565b03611d755760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401611378565b6002816004811115611d8957611d896126b5565b03611dd65760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401611378565b6003816004811115611dea57611dea6126b5565b03611e5d5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c60448201527f75650000000000000000000000000000000000000000000000000000000000006064820152608401611378565b50565b6000611eb5826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661200c9092919063ffffffff16565b9050805160001480611ed6575080806020019051810190611ed69190612886565b61144a5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401611378565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115611f7f5750600090506003612003565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015611fd3573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116611ffc57600060019250925050612003565b9150600090505b94509492505050565b606061201b8484600085612023565b949350505050565b60608247101561209b5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401611378565b600080866001600160a01b031685876040516120b79190612719565b60006040518083038185875af1925050503d80600081146120f4576040519150601f19603f3d011682016040523d82523d6000602084013e6120f9565b606091505b509150915061210a87838387612115565b979650505050505050565b6060831561218457825160000361217d576001600160a01b0385163b61217d5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401611378565b508161201b565b61201b83838151156121995781518083602001fd5b8060405162461bcd60e51b81526004016113789190612245565b6001600160a01b0381168114611e5d57600080fd5b80356121d3816121b3565b919050565b6000602082840312156121ea57600080fd5b81356112eb816121b3565b60005b838110156122105781810151838201526020016121f8565b50506000910152565b600081518084526122318160208601602086016121f5565b601f01601f19169290920160200192915050565b6020815260006112eb6020830184612219565b6000610180828403121561226b57600080fd5b50919050565b60008083601f84011261228357600080fd5b50813567ffffffffffffffff81111561229b57600080fd5b602083019150836020828501011115611cf157600080fd5b60008060008060008060006101e0888a0312156122cf57600080fd5b6122d98989612258565b965061018088013567ffffffffffffffff808211156122f757600080fd5b6123038b838c01612271565b90985096506101a08a013591508082111561231d57600080fd5b6123298b838c01612271565b90965094506101c08a013591508082111561234357600080fd5b506123508a828b01612271565b989b979a50959850939692959293505050565b6000610140828403121561226b57600080fd5b60008060008060008060008060006102008a8c03121561239557600080fd5b61239f8b8b612258565b98506101808a013567ffffffffffffffff808211156123bd57600080fd5b6123c98d838e01612271565b909a5098506101a08c01359150808211156123e357600080fd5b6123ef8d838e01612271565b90985096506101c08c013591508082111561240957600080fd5b6124158d838e01612271565b90965094506101e08c013591508082111561242f57600080fd5b5061243c8c828d01612271565b915080935050809150509295985092959850929598565b634e487b7160e01b600052604160045260246000fd5b604051610140810167ffffffffffffffff8111828210171561248d5761248d612453565b60405290565b604051601f8201601f1916810167ffffffffffffffff811182821017156124bc576124bc612453565b604052919050565b600061014082840312156124d757600080fd5b6124df612469565b90506124ea826121c8565b81526124f8602083016121c8565b6020820152612509604083016121c8565b604082015260608201356060820152612524608083016121c8565b608082015260a082013560a082015260c082013560c082015260e082013560e082015261010080830135818301525061012080830135818301525092915050565b6000610140828403121561257857600080fd5b6112eb83836124c4565b6000610180828403121561259557600080fd5b6040516060810181811067ffffffffffffffff821117156125b8576125b8612453565b6040526125c584846124c4565b81526101408301356125d6816121b3565b60208201526101609290920135604083015250919050565b808202811582820484141761132657634e487b7160e01b600052601160045260246000fd5b60008261263057634e487b7160e01b600052601260045260246000fd5b500490565b600084516126478184602089016121f5565b91909101928352506020820152604001919050565b82815260406020820152600061201b6040830184612219565b60006020828403121561268757600080fd5b81516001600160e01b0319811681146112eb57600080fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b600080858511156126db57600080fd5b838611156126e857600080fd5b5050820193919092039150565b6001600160e01b031984168152818360048301376000910160040190815292915050565b6000825161272b8184602087016121f5565b9190910192915050565b6001600160e01b031983168152600082516127578160048501602087016121f5565b919091016004019392505050565b60008060006060848603121561277a57600080fd5b8351925060208401519150604084015167ffffffffffffffff808211156127a057600080fd5b818601915086601f8301126127b457600080fd5b8151818111156127c6576127c6612453565b6127d9601f8201601f1916602001612493565b91508082528760208285010111156127f057600080fd5b6128018160208401602086016121f5565b5080925050509250925092565b600061010061283183885180516001600160a01b03168252602090810151910152565b6020870151604084015260408701516060840152612865608084018780516001600160a01b03168252602090810151910152565b6001600160a01b03851660c08401528060e084015261210a81840185612219565b60006020828403121561289857600080fd5b815180151581146112eb57600080fdfea26469706673582212204a9c0c31299c599ae01b076eca3c673a6809b18eb61ddb7e40ca1e8df24c087264736f6c63430008110033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

00000000000000000000000063ef071b8a69c52a88dca4a844286aeff195129f000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba300000000000000000000000015974e3165cfe1fb21324c5bd1d3b63d34212ec6000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000063ef071b8a69c52a88dca4a844286aeff195129f

-----Decoded View---------------
Arg [0] : _owner (address): 0x63Ef071b8A69C52a88dCA4A844286Aeff195129F
Arg [1] : _uniswapPermit2 (address): 0x000000000022D473030F116dDEE9F6B43aC78BA3
Arg [2] : _allowanceTarget (address): 0x15974e3165CFE1fb21324C5bD1D3b63D34212EC6
Arg [3] : _weth (address): 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
Arg [4] : _feeCollector (address): 0x63Ef071b8A69C52a88dCA4A844286Aeff195129F

-----Encoded View---------------
5 Constructor Arguments found :
Arg [0] : 00000000000000000000000063ef071b8a69c52a88dca4a844286aeff195129f
Arg [1] : 000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba3
Arg [2] : 00000000000000000000000015974e3165cfe1fb21324c5bd1d3b63d34212ec6
Arg [3] : 000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
Arg [4] : 00000000000000000000000063ef071b8a69c52a88dca4a844286aeff195129f


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.