ETH Price: $1,883.80 (+2.39%)

Contract

0x4f09Bc5BdBc516242F3b5614b35ac89AeC749Ea1
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

Advanced mode:
Parent Transaction Hash Method Block
From
To
View All Internal Transactions
Loading...
Loading

Similar Match Source Code
This contract matches the deployed Bytecode of the Source Code for Contract 0x9C9f1598...D5c27C222
The constructor portion of the code might be different and could alter the actual behaviour of the contract

Contract Name:
ProxyAdmin

Compiler Version
v0.8.11+commit.d7f03943

Optimization Enabled:
No with 200 runs

Other Settings:
default evmVersion, MIT license

Contract Source Code (Solidity Multiple files format)

File 1 of 25: ProxyAdmin.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./TransparentUpgradeableProxy.sol";
import "./Ownable.sol";

contract ProxyAdmin is Ownable {

    function getProxyImplementation(TransparentUpgradeableProxy proxy) public view virtual returns (address) {
        // We need to manually run the static call since the getter cannot be flagged as view
        // bytes4(keccak256("implementation()")) == 0x5c60da1b
        (bool success, bytes memory returndata) = address(proxy).staticcall(hex"5c60da1b");
        require(success);
        return abi.decode(returndata, (address));
    }

    function getProxyAdmin(TransparentUpgradeableProxy proxy) public view virtual returns (address) {
        // We need to manually run the static call since the getter cannot be flagged as view
        // bytes4(keccak256("admin()")) == 0xf851a440
        (bool success, bytes memory returndata) = address(proxy).staticcall(hex"f851a440");
        require(success);
        return abi.decode(returndata, (address));
    }

    function changeProxyAdmin(TransparentUpgradeableProxy proxy, address newAdmin) public virtual onlyOwner {
        proxy.changeAdmin(newAdmin);
    }

    function upgrade(TransparentUpgradeableProxy proxy, address implementation) public virtual onlyOwner {
        proxy.upgradeTo(implementation);
    }

    function upgradeAndCall(
        TransparentUpgradeableProxy proxy,
        address implementation,
        bytes memory data
    ) public payable virtual onlyOwner {
        proxy.upgradeToAndCall{value: msg.value}(implementation, data);
    }
}

File 2 of 25: Address.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [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://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    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 functionCall(target, data, "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");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(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) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(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) {
        require(isContract(target), "Address: delegate call to non-contract");

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason 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 {
            // 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

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 3 of 25: AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @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
     * ====
     *
     * [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://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    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 functionCall(target, data, "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");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(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) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason 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 {
            // 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

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

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

import "./Initializable.sol";
import "./OwnableUpgradeable.sol";
import "./TransferHelper.sol";
import "./ISwapRouter.sol";
import "./IQuoter.sol";
import "./IMerchant.sol";
import "./Address.sol";
import "./SafeMath.sol";


abstract contract BasePay is Initializable, OwnableUpgradeable{

    uint256 public paymentRate = 50;
    uint256 public withdrawRate = 50;
    IQuoter public immutable iQuoter = IQuoter(0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6);
    uint24 public poolFee = 3000;


    mapping(address => uint256) public tradeFeeOf;
    mapping(address => mapping(address => uint256)) public merchantFunds;
    mapping(address => mapping(string => address)) public merchantOrders;


    event Order(string orderId, uint256 paidAmount,address paidToken,uint256 orderAmount,address settleToken,uint256 totalFee, address merchant, address payer, uint256 rate);
    event Withdraw(address merchant, address settleToken, uint256 settleAmount, address settleAccount, uint256 withdrawFee);
    event WithdrawTradeFee(address token, uint256 amount);


    receive() payable external {}

    function initialize()public initializer{
        __Context_init_unchained();
        __Ownable_init_unchained();
    }


    function getPaymentFee(
        uint256 _merchantRate,
        uint256 _orderAmount,
        uint256 _paidAmount,
        bool isUsdcFee
    ) internal view returns(uint256 totalFee, uint256 platformFee, uint256 proxyFee) {
        if (isUsdcFee) {
            totalFee = SafeMath.div((SafeMath.mul(_orderAmount ,_merchantRate)), 10000);
            platformFee = SafeMath.div((SafeMath.mul(_orderAmount ,paymentRate)), 10000);
            proxyFee = totalFee - platformFee;

            return (totalFee, platformFee, proxyFee);
        } else {
            totalFee = SafeMath.div((SafeMath.mul(_paidAmount ,_merchantRate)), 10000);
            platformFee = SafeMath.div((SafeMath.mul(_paidAmount ,paymentRate)), 10000);
            proxyFee = totalFee - platformFee;

            return (totalFee, platformFee, proxyFee);
        }
    }

    function getWithdrawFee(uint256 _withdrawAmount) internal view returns(uint256 withdrawFee) {
        withdrawFee = SafeMath.div((SafeMath.mul(_withdrawAmount ,withdrawRate)), 10000);
        return withdrawFee;
    }

    function withdrawTradeFee(address _token) external onlyOwner {
        uint256 amount = tradeFeeOf[_token];
        TransferHelper.safeTransfer(_token, msg.sender, amount);
        tradeFeeOf[_token] = 0;
        emit WithdrawTradeFee(_token, amount);
    }

    function getEstimated(address tokenIn, address tokenOut, uint256 amountOut) external payable returns (uint256) {

        return iQuoter.quoteExactOutputSingle(
            tokenIn,
            tokenOut,
            poolFee,
            amountOut,
            0
        );
    }

    function setting(
        uint256 _paymentRate,
        uint256 _withdrawRate,
        uint24 _poolFee
    ) external onlyOwner {
        paymentRate = _paymentRate;
        withdrawRate = _withdrawRate;
        poolFee = _poolFee;
    }

}

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

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}

File 6 of 25: ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;
import "./Initializable.sol";

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract ContextUpgradeable is Initializable {
    function __Context_init() internal onlyInitializing {
    }

    function __Context_init_unchained() internal onlyInitializing {
    }
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

File 7 of 25: draft-IERC1822.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/**
 * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
 * proxy whose upgrades are fully controlled by the current implementation.
 */
interface IERC1822Proxiable {
    /**
     * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
     * address.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy.
     */
    function proxiableUUID() external view returns (bytes32);
}

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

import "./Proxy.sol";
import "./ERC1967Upgrade.sol";

/**
 * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an
 * implementation address that can be changed. This address is stored in storage in the location specified by
 * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the
 * implementation behind the proxy.
 */
contract ERC1967Proxy is Proxy, ERC1967Upgrade {
    /**
     * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.
     *
     * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded
     * function call, and allows initializating the storage of the proxy like a Solidity constructor.
     */
    constructor(address _logic, bytes memory _data) payable {
        assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1));
        _upgradeToAndCall(_logic, _data, false);
    }

    /**
     * @dev Returns the current implementation address.
     */
    function _implementation() internal view virtual override returns (address impl) {
        return ERC1967Upgrade._getImplementation();
    }
}

File 9 of 25: ERC1967Upgrade.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IBeacon.sol";
import "./draft-IERC1822.sol";
import "./Address.sol";
import "./StorageSlot.sol";

/**
 * @dev This abstract contract provides getters and event emitting update functions for
 * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
 *
 * _Available since v4.1._
 *
 * @custom:oz-upgrades-unsafe-allow delegatecall
 */
abstract contract ERC1967Upgrade {
    // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
    bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;

    /**
     * @dev Storage slot with the address of the current implementation.
     * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;

    /**
     * @dev Emitted when the implementation is upgraded.
     */
    event Upgraded(address indexed implementation);

    /**
     * @dev Returns the current implementation address.
     */
    function _getImplementation() internal view returns (address) {
        return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 implementation slot.
     */
    function _setImplementation(address newImplementation) private {
        require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
        StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
    }

    /**
     * @dev Perform implementation upgrade
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeTo(address newImplementation) internal {
        _setImplementation(newImplementation);
        emit Upgraded(newImplementation);
    }

    /**
     * @dev Perform implementation upgrade with additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCall(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        _upgradeTo(newImplementation);
        if (data.length > 0 || forceCall) {
            Address.functionDelegateCall(newImplementation, data);
        }
    }

    /**
     * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCallUUPS(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        // Upgrades from old implementations will perform a rollback test. This test requires the new
        // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
        // this special case will break upgrade paths from old UUPS implementation to new ones.
        if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {
            _setImplementation(newImplementation);
        } else {
            try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
                require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
            } catch {
                revert("ERC1967Upgrade: new implementation is not UUPS");
            }
            _upgradeToAndCall(newImplementation, data, forceCall);
        }
    }

    /**
     * @dev Storage slot with the admin of the contract.
     * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;

    /**
     * @dev Emitted when the admin account has changed.
     */
    event AdminChanged(address previousAdmin, address newAdmin);

    /**
     * @dev Returns the current admin.
     */
    function _getAdmin() internal view returns (address) {
        return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 admin slot.
     */
    function _setAdmin(address newAdmin) private {
        require(newAdmin != address(0), "ERC1967: new admin is the zero address");
        StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
    }

    /**
     * @dev Changes the admin of the proxy.
     *
     * Emits an {AdminChanged} event.
     */
    function _changeAdmin(address newAdmin) internal {
        emit AdminChanged(_getAdmin(), newAdmin);
        _setAdmin(newAdmin);
    }

    /**
     * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
     * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
     */
    bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;

    /**
     * @dev Emitted when the beacon is upgraded.
     */
    event BeaconUpgraded(address indexed beacon);

    /**
     * @dev Returns the current beacon.
     */
    function _getBeacon() internal view returns (address) {
        return StorageSlot.getAddressSlot(_BEACON_SLOT).value;
    }

    /**
     * @dev Stores a new beacon in the EIP1967 beacon slot.
     */
    function _setBeacon(address newBeacon) private {
        require(Address.isContract(newBeacon), "ERC1967: new beacon is not a contract");
        require(
            Address.isContract(IBeacon(newBeacon).implementation()),
            "ERC1967: beacon implementation is not a contract"
        );
        StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;
    }

    /**
     * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
     * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
     *
     * Emits a {BeaconUpgraded} event.
     */
    function _upgradeBeaconToAndCall(
        address newBeacon,
        bytes memory data,
        bool forceCall
    ) internal {
        _setBeacon(newBeacon);
        emit BeaconUpgraded(newBeacon);
        if (data.length > 0 || forceCall) {
            Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
        }
    }
}

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

/**
 * @dev This is the interface that {BeaconProxy} expects of its beacon.
 */
interface IBeacon {
    /**
     * @dev Must return an address that can be used as a delegate call target.
     *
     * {BeaconProxy} will check that this address is a contract.
     */
    function implementation() external view returns (address);
}

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

interface IERC20 {

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

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

    function decimals() external view returns (uint8);

    function totalSupply() external view returns (uint256);

    function balanceOf(address _owner) external view returns(uint256 balance);

    function transfer(address _to, uint256 _value) external returns (bool success);

    function transferFrom(address _from, address _to, uint256 _value) external returns (bool success);

    function approve(address _spender, uint256 _value) external returns (bool success);

    function allowance(address _owner, address _spender) external view returns (uint256 remaining);

    event Transfer(address indexed _from, address indexed _to, uint256 _value);

    event Approval(address indexed _owner, address indexed _spender, uint256 _value);

}

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

interface IMerchant {

    struct MerchantInfo {
        address account;
        address payable settleAccount;
        address settleCurrency;
        bool autoSettle;
        address proxy;
        uint256 rate;
        address [] tokens;
    }

    function addMerchant(
        address payable settleAccount,
        address settleCurrency,
        bool autoSettle,
        address proxy,
        uint256 rate,
        address[] memory tokens
    ) external;

    function setMerchantRate(address _merchant, uint256 _rate) external;

    function getMerchantInfo(address _merchant) external view returns(MerchantInfo memory);

    function isMerchant(address _merchant) external view returns(bool);

    function getMerchantTokens(address _merchant) external view returns(address[] memory);

    function getAutoSettle(address _merchant) external view returns(bool);

    function getSettleCurrency(address _merchant) external view returns(address);

    function getSettleAccount(address _merchant) external view returns(address);

    function getGlobalTokens() external view returns(address[] memory);

    function validatorCurrency(address _merchant, address _currency) external view returns (bool);

    function validatorGlobalToken(address _token) external view returns (bool);

}

File 13 of 25: Initializable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./AddressUpgradeable.sol";

abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        // If the contract is initializing we ignore whether _initialized is set in order to support multiple
        // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the
        // contract may have been reentered.
        require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized");

        bool isTopLevelCall = !_initializing;
        if (isTopLevelCall) {
            _initializing = true;
            _initialized = true;
        }

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} modifier, directly or indirectly.
     */
    modifier onlyInitializing() {
        require(_initializing, "Initializable: contract is not initializing");
        _;
    }

    function _isConstructor() private view returns (bool) {
        return !AddressUpgradeable.isContract(address(this));
    }
}

File 14 of 25: IQuoter.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/// @title Quoter Interface
/// @notice Supports quoting the calculated amounts from exact input or exact output swaps
/// @dev These functions are not marked view because they rely on calling non-view functions and reverting
/// to compute the result. They are also not gas efficient and should not be called on-chain.
interface IQuoter {
    /// @notice Returns the amount out received for a given exact input swap without executing the swap
    /// @param path The path of the swap, i.e. each token pair and the pool fee
    /// @param amountIn The amount of the first token to swap
    /// @return amountOut The amount of the last token that would be received
    function quoteExactInput(bytes memory path, uint256 amountIn) external returns (uint256 amountOut);

    /// @notice Returns the amount out received for a given exact input but for a swap of a single pool
    /// @param tokenIn The token being swapped in
    /// @param tokenOut The token being swapped out
    /// @param fee The fee of the token pool to consider for the pair
    /// @param amountIn The desired input amount
    /// @param sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap
    /// @return amountOut The amount of `tokenOut` that would be received
    function quoteExactInputSingle(
        address tokenIn,
        address tokenOut,
        uint24 fee,
        uint256 amountIn,
        uint160 sqrtPriceLimitX96
    ) external returns (uint256 amountOut);

    /// @notice Returns the amount in required for a given exact output swap without executing the swap
    /// @param path The path of the swap, i.e. each token pair and the pool fee. Path must be provided in reverse order
    /// @param amountOut The amount of the last token to receive
    /// @return amountIn The amount of first token required to be paid
    function quoteExactOutput(bytes memory path, uint256 amountOut) external returns (uint256 amountIn);

    /// @notice Returns the amount in required to receive the given exact output amount but for a swap of a single pool
    /// @param tokenIn The token being swapped in
    /// @param tokenOut The token being swapped out
    /// @param fee The fee of the token pool to consider for the pair
    /// @param amountOut The desired output amount
    /// @param sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap
    /// @return amountIn The amount required as the input for the swap in order to receive `amountOut`
    function quoteExactOutputSingle(
        address tokenIn,
        address tokenOut,
        uint24 fee,
        uint256 amountOut,
        uint160 sqrtPriceLimitX96
    ) external returns (uint256 amountIn);
}

File 15 of 25: ISwapRouter.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./IUniswapV3SwapCallback.sol";

/// @title Router token swapping functionality
/// @notice Functions for swapping tokens via Uniswap V3
interface ISwapRouter is IUniswapV3SwapCallback {
    struct ExactInputSingleParams {
        address tokenIn;
        address tokenOut;
        uint24 fee;
        address recipient;
        uint256 deadline;
        uint256 amountIn;
        uint256 amountOutMinimum;
        uint160 sqrtPriceLimitX96;
    }

    /// @notice Swaps `amountIn` of one token for as much as possible of another token
    /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata
    /// @return amountOut The amount of the received token
    function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);

    struct ExactInputParams {
        bytes path;
        address recipient;
        uint256 deadline;
        uint256 amountIn;
        uint256 amountOutMinimum;
    }

    /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path
    /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata
    /// @return amountOut The amount of the received token
    function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut);

    struct ExactOutputSingleParams {
        address tokenIn;
        address tokenOut;
        uint24  fee;
        address recipient;
        uint256 deadline;
        uint256 amountOut;
        uint256 amountInMaximum;
        uint160 sqrtPriceLimitX96;
    }

    /// @notice Swaps as little as possible of one token for `amountOut` of another token
    /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata
    /// @return amountIn The amount of the input token
    function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn);

    struct ExactOutputParams {
        bytes path;
        address recipient;
        uint256 deadline;
        uint256 amountOut;
        uint256 amountInMaximum;
    }

    /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed)
    /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata
    /// @return amountIn The amount of the input token
    function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn);

    function refundETH() external payable;

}

File 16 of 25: IUniswapV3SwapCallback.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/// @title Callback for IUniswapV3PoolActions#swap
/// @notice Any contract that calls IUniswapV3PoolActions#swap must implement this interface
interface IUniswapV3SwapCallback {
    /// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap.
    /// @dev In the implementation you must pay the pool tokens owed for the swap.
    /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.
    /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped.
    /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by
    /// the end of the swap. If positive, the callback must send that amount of token0 to the pool.
    /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by
    /// the end of the swap. If positive, the callback must send that amount of token1 to the pool.
    /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call
    function uniswapV3SwapCallback(
        int256 amount0Delta,
        int256 amount1Delta,
        bytes calldata data
    ) external;
}

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

import "./Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

File 18 of 25: OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./ContextUpgradeable.sol";
import "./Initializable.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    function __Ownable_init() internal onlyInitializing {
        __Ownable_init_unchained();
    }

    function __Ownable_init_unchained() internal onlyInitializing {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

File 19 of 25: Pay.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./BasePay.sol";

contract Pay is BasePay {

    IMerchant public immutable iMerchant;
    ISwapRouter public immutable iSwapRouter;

    address public immutable WETH9;


    constructor(address _iMerchant, address _iSwapRouter, address _WETH9){
        iMerchant = IMerchant(_iMerchant);
        iSwapRouter = ISwapRouter(_iSwapRouter);
        WETH9 = _WETH9;
    }

    function pay(
        string memory _orderId,
        uint256 _paiAmount,
        uint256 _orderAmount,
        address _merchant,
        address _currency
    ) external returns(bool) {

        require(_paiAmount > 0);
        require(_orderAmount > 0);
        require(address(0) == merchantOrders[_merchant][_orderId], "Order existed");
        require(iMerchant.isMerchant(_merchant), "Invalid merchant");
        require(iMerchant.validatorCurrency(_merchant, _currency), "Invalid token");
        require(IERC20(_currency).balanceOf(msg.sender) >= _paiAmount, "Balance insufficient");

        IMerchant.MerchantInfo memory merchantInfo = iMerchant.getMerchantInfo(_merchant);

        address settleToken = merchantInfo.settleCurrency;
        if(_currency == settleToken) {
            require(_paiAmount == _orderAmount);
        }

        TransferHelper.safeTransferFrom(_currency, msg.sender, address(this), _paiAmount);

        uint256 paidAmount = _paiAmount;

        if (address(0) != settleToken) {

            if (_currency != settleToken) {
                paidAmount = swapExactOutputSingle(_currency, _paiAmount, settleToken, _orderAmount);
            }

            (uint256 totalFee, uint256 platformFee, uint256 proxyFee) = getPaymentFee(merchantInfo.rate, _orderAmount, paidAmount, true);

            if (merchantInfo.autoSettle) {
                _autoWithdraw(_merchant, merchantInfo.settleAccount, settleToken, _orderAmount - totalFee);
            } else {
                merchantFunds[_merchant][settleToken] += (_orderAmount - totalFee);
            }

            merchantFunds[merchantInfo.proxy][settleToken] += proxyFee;
            tradeFeeOf[settleToken] += platformFee;

            emit Order(_orderId, paidAmount, _currency, _orderAmount, settleToken, totalFee, merchantInfo.account, msg.sender, merchantInfo.rate);

        } else {

            (uint256 totalFee, uint256 platformFee, uint256 proxyFee) = getPaymentFee(merchantInfo.rate, _orderAmount, _paiAmount, false);

            if (merchantInfo.autoSettle) {
                _autoWithdraw(_merchant, merchantInfo.settleAccount, _currency, _paiAmount - totalFee);
            } else {
                merchantFunds[_merchant][_currency] += (_paiAmount - totalFee);
            }

            merchantFunds[merchantInfo.proxy][_currency] += proxyFee;
            tradeFeeOf[_currency] += platformFee;

            emit Order(_orderId, paidAmount, _currency, _orderAmount, _currency, totalFee, merchantInfo.account, msg.sender, merchantInfo.rate);

        }

        merchantOrders[_merchant][_orderId] = msg.sender;

        return true;

    }

    function payWithETH(
        string memory _orderId,
        address _merchant,
        uint256 _orderAmount
    ) external payable returns(bool) {

        require(msg.value > 0);
        require(address(msg.sender).balance >= msg.value, "Balance insufficient");
        require(address(0) == merchantOrders[_merchant][_orderId], "Order existed");
        require(iMerchant.isMerchant(_merchant), "Invalid merchant");

        IMerchant.MerchantInfo memory merchantInfo = iMerchant.getMerchantInfo(_merchant);

        uint256 _paiAmount = msg.value;
        address settleToken = merchantInfo.settleCurrency;

        if (address(0) != settleToken) {

            _paiAmount = swapExactOutputSingle(WETH9, msg.value, settleToken, _orderAmount);

            (uint256 totalFee, uint256 platformFee, uint256 proxyFee) = getPaymentFee(merchantInfo.rate, _orderAmount, _paiAmount, true);

            if (merchantInfo.autoSettle) {
                _autoWithdraw(_merchant, merchantInfo.settleAccount, settleToken, _orderAmount - totalFee);
            } else {
                merchantFunds[_merchant][settleToken] += (_orderAmount - totalFee);
            }

            merchantFunds[merchantInfo.proxy][settleToken] += proxyFee;
            tradeFeeOf[settleToken] += platformFee;

            emit Order(_orderId, _paiAmount, WETH9, _orderAmount, settleToken, totalFee, merchantInfo.account, msg.sender, merchantInfo.rate);

        } else {

            (uint256 totalFee, uint256 platformFee, uint256 proxyFee) = getPaymentFee(merchantInfo.rate, _orderAmount, _paiAmount, false);

            if (merchantInfo.autoSettle) {
                _autoWithdraw(_merchant, merchantInfo.settleAccount, WETH9, _paiAmount - totalFee);
            } else {
                merchantFunds[_merchant][WETH9] += (_paiAmount - totalFee);
            }

            merchantFunds[merchantInfo.proxy][WETH9] += proxyFee;
            tradeFeeOf[WETH9] += platformFee;

            emit Order(_orderId, _paiAmount, WETH9, _orderAmount, WETH9, totalFee, merchantInfo.account, msg.sender, merchantInfo.rate);

        }

        merchantOrders[_merchant][_orderId] = msg.sender;

        return true;

    }

    function claimToken(
        address _token,
        uint256 _amount,
        address _to
    ) external {

        require(address(0) != _token, "Invalid currency");
        require(iMerchant.isMerchant(msg.sender), "Invalid merchant");

        IMerchant.MerchantInfo memory merchantInfo = iMerchant.getMerchantInfo(msg.sender);

        address settleAccount = _to;

        if(address(0) == _to) {
            settleAccount = merchantInfo.settleAccount;
            if(address(0) == settleAccount) {
                settleAccount = msg.sender;
            }
        }

        _claim(msg.sender, _token, _amount, settleAccount);

    }

    function claimEth(
        uint256 _amount,
        address _to
    ) external {

        require(iMerchant.isMerchant(msg.sender), "Invalid merchant");

        IMerchant.MerchantInfo memory merchantInfo = iMerchant.getMerchantInfo(msg.sender);

        address settleAccount = _to;

        if(address(0) == _to) {
            settleAccount = merchantInfo.settleAccount;
            if(address(0) == settleAccount) {
                settleAccount = msg.sender;
            }
        }

        _claim(msg.sender, WETH9, _amount, settleAccount);

    }

    function swapExactOutputSingle(
        address _tokenIn,
        uint256 _amountInMaximum,
        address _tokenOut,
        uint256 _amountOut
    ) private returns(uint256 _amountIn) {

        if(WETH9 != _tokenIn) {
            TransferHelper.safeApprove(_tokenIn, address(iSwapRouter), _amountInMaximum);
        }

        ISwapRouter.ExactOutputSingleParams memory params =
        ISwapRouter.ExactOutputSingleParams({
            tokenIn: _tokenIn,
            tokenOut: _tokenOut,
            fee: 3000,
            recipient: address(this) ,
            deadline: block.timestamp,
            amountOut: _amountOut,
            amountInMaximum: _amountInMaximum,
            sqrtPriceLimitX96: 0
        });

        _amountIn = iSwapRouter.exactOutputSingle{value:msg.value}(params);

        if (_amountIn < _amountInMaximum) {
            if(WETH9 == _tokenIn) {
                iSwapRouter.refundETH();
                TransferHelper.safeTransferETH(msg.sender, _amountInMaximum - _amountIn);
            } else {
                TransferHelper.safeApprove(_tokenIn, address(iSwapRouter), 0);
                TransferHelper.safeTransfer(_tokenIn, msg.sender, _amountInMaximum - _amountIn);
            }
        }

    }

    function _autoWithdraw(
        address _merchant,
        address _settleAccount,
        address _settleToken,
        uint256 _settleAmount
    ) internal {

        address settleAccount = _settleAccount;

        if(address(0) == settleAccount) {
            settleAccount = _merchant;
        }

        uint256 withdrawFee = getWithdrawFee(_settleAmount);

        if(WETH9 != _settleToken) {
            TransferHelper.safeTransfer(_settleToken, settleAccount, _settleAmount - withdrawFee);
        } else {
            TransferHelper.safeTransferETH(settleAccount, _settleAmount - withdrawFee);
        }

        tradeFeeOf[_settleToken] += withdrawFee;

        emit Withdraw(_merchant, _settleToken, _settleAmount, settleAccount, withdrawFee);

    }

    function _claim(
        address _merchant,
        address _currency,
        uint256 _amount,
        address _settleAccount
    ) internal {

        require(merchantFunds[_merchant][_currency] >= _amount);

        if(WETH9 != _currency) {
            TransferHelper.safeTransfer(_currency, _settleAccount, _amount);
        } else {
            TransferHelper.safeTransferETH(_settleAccount, _amount);
        }

        merchantFunds[_merchant][_currency] -= _amount;

        emit Withdraw(_merchant, _currency, _amount, _settleAccount, 0);

    }

}

File 20 of 25: PayProxy.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./IQuoter.sol";
import "./ERC1967Proxy.sol";


contract PayProxy is ERC1967Proxy {

    IQuoter public immutable iQuoter;

    constructor(
        address _logic,
        address admin_,
        address _iQuoter,
        bytes memory _data
    ) payable ERC1967Proxy(_logic, _data) {
        assert(_ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1));
        iQuoter = IQuoter(_iQuoter);
        _changeAdmin(admin_);
    }


    function getEstimated(address tokenIn, address tokenOut, uint256 amountOut) external payable returns (uint256) {

        return iQuoter.quoteExactOutputSingle(
            tokenIn,
            tokenOut,
            3000,
            amountOut,
            0
        );
    }

    modifier ifAdmin() {
        if (msg.sender == _getAdmin()) {
            _;
        } else {
            _fallback();
        }
    }

    function admin() external ifAdmin returns (address admin_) {
        admin_ = _getAdmin();
    }

    function implementation() external ifAdmin returns (address implementation_) {
        implementation_ = _implementation();
    }

    function changeAdmin(address newAdmin) external virtual ifAdmin {
        _changeAdmin(newAdmin);
    }

    function upgradeTo(address newImplementation) external ifAdmin {
        _upgradeToAndCall(newImplementation, bytes(""), false);
    }

    function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {
        _upgradeToAndCall(newImplementation, data, true);
    }

    function _admin() internal view virtual returns (address) {
        return _getAdmin();
    }

    function _beforeFallback() internal virtual override {
        require(msg.sender != _getAdmin(), "TransparentUpgradeableProxy: admin cannot fallback to proxy target");
        super._beforeFallback();
    }
}

File 21 of 25: Proxy.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
 * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
 * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
 * be specified by overriding the virtual {_implementation} function.
 *
 * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
 * different contract through the {_delegate} function.
 *
 * The success and return data of the delegated call will be returned back to the caller of the proxy.
 */
abstract contract Proxy {
    /**
     * @dev Delegates the current call to `implementation`.
     *
     * This function does not return to its internal call site, it will return directly to the external caller.
     */
    function _delegate(address implementation) internal virtual {
        assembly {
        // Copy msg.data. We take full control of memory in this inline assembly
        // block because it will not return to Solidity code. We overwrite the
        // Solidity scratch pad at memory position 0.
            calldatacopy(0, 0, calldatasize())

        // Call the implementation.
        // out and outsize are 0 because we don't know the size yet.
            let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)

        // Copy the returned data.
            returndatacopy(0, 0, returndatasize())

            switch result
            // delegatecall returns 0 on error.
            case 0 {
                revert(0, returndatasize())
            }
            default {
                return(0, returndatasize())
            }
        }
    }

    /**
     * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function
     * and {_fallback} should delegate.
     */
    function _implementation() internal view virtual returns (address);

    /**
     * @dev Delegates the current call to the address returned by `_implementation()`.
     *
     * This function does not return to its internall call site, it will return directly to the external caller.
     */
    function _fallback() internal virtual {
        _beforeFallback();
        _delegate(_implementation());
    }

    /**
     * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
     * function in the contract matches the call data.
     */
    fallback() external payable virtual {
        _fallback();
    }

    /**
     * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data
     * is empty.
     */
    receive() external payable virtual {
        _fallback();
    }

    /**
     * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`
     * call, or as part of the Solidity `fallback` or `receive` functions.
     *
     * If overriden should call `super._beforeFallback()`.
     */
    function _beforeFallback() internal virtual {}
}

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

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        uint256 c = a + b;
        if (c < a) return (false, 0);
        return (true, c);
    }

    /**
     * @dev Returns the substraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b > a) return (false, 0);
        return (true, a - b);
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) return (true, 0);
        uint256 c = a * b;
        if (c / a != b) return (false, 0);
        return (true, c);
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b == 0) return (false, 0);
        return (true, a / b);
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b == 0) return (false, 0);
        return (true, a % b);
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b <= a, "SafeMath: subtraction overflow");
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        if (a == 0) return 0;
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b > 0, "SafeMath: division by zero");
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b > 0, "SafeMath: modulo by zero");
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        return a - b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryDiv}.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        return a % b;
    }
}

File 23 of 25: StorageSlot.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/**
 * @dev Library for reading and writing primitive types to specific storage slots.
 *
 * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
 * This library helps with reading and writing to such slots without the need for inline assembly.
 *
 * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
 *
 * Example usage to set ERC1967 implementation slot:
 * ```
 * contract ERC1967 {
 *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
 *
 *     function _getImplementation() internal view returns (address) {
 *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
 *     }
 *
 *     function _setImplementation(address newImplementation) internal {
 *         require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 *
 * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
 */
library StorageSlot {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    /**
     * @dev Returns an `AddressSlot` with member `value` located at `slot`.
     */
    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BooleanSlot` with member `value` located at `slot`.
     */
    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
     */
    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Uint256Slot` with member `value` located at `slot`.
     */
    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
        assembly {
            r.slot := slot
        }
    }
}

File 24 of 25: TransferHelper.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;

import "./IERC20.sol";

library TransferHelper {
    /// @notice Transfers tokens from the targeted address to the given destination
    /// @notice Errors with 'STF' if transfer fails
    /// @param token The contract address of the token to be transferred
    /// @param from The originating address from which the tokens will be transferred
    /// @param to The destination address of the transfer
    /// @param value The amount to be transferred
    function safeTransferFrom(
        address token,
        address from,
        address to,
        uint256 value
    ) internal {
        (bool success, bytes memory data) =
        token.call(abi.encodeWithSelector(IERC20.transferFrom.selector, from, to, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))), 'STF');
    }

    /// @notice Transfers tokens from msg.sender to a recipient
    /// @dev Errors with ST if transfer fails
    /// @param token The contract address of the token which will be transferred
    /// @param to The recipient of the transfer
    /// @param value The value of the transfer
    function safeTransfer(
        address token,
        address to,
        uint256 value
    ) internal {
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transfer.selector, to, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))), 'ST');
    }

    /// @notice Approves the stipulated contract to spend the given allowance in the given token
    /// @dev Errors with 'SA' if transfer fails
    /// @param token The contract address of the token to be approved
    /// @param to The target of the approval
    /// @param value The amount of the given token the target will be allowed to spend
    function safeApprove(
        address token,
        address to,
        uint256 value
    ) internal {
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.approve.selector, to, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))), 'SA');
    }

    /// @notice Transfers ETH to the recipient address
    /// @dev Fails with `STE`
    /// @param to The destination of the transfer
    /// @param value The value to be transferred
    function safeTransferETH(address to, uint256 value) internal {
        (bool success, ) = to.call{value: value}(new bytes(0));
        require(success, 'STE');
    }
}

File 25 of 25: TransparentUpgradeableProxy.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./ERC1967Proxy.sol";

/**
 * @dev This contract implements a proxy that is upgradeable by an admin.
 *
 * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector
 * clashing], which can potentially be used in an attack, this contract uses the
 * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two
 * things that go hand in hand:
 *
 * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if
 * that call matches one of the admin functions exposed by the proxy itself.
 * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the
 * implementation. If the admin tries to call a function on the implementation it will fail with an error that says
 * "admin cannot fallback to proxy target".
 *
 * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing
 * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due
 * to sudden errors when trying to call a function from the proxy implementation.
 *
 * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,
 * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.
 */
contract TransparentUpgradeableProxy is ERC1967Proxy {
    /**
     * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and
     * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.
     */
    constructor(
        address _logic,
        address admin_,
        bytes memory _data
    ) payable ERC1967Proxy(_logic, _data) {
        assert(_ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1));
        _changeAdmin(admin_);
    }

    /**
     * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.
     */
    modifier ifAdmin() {
        if (msg.sender == _getAdmin()) {
            _;
        } else {
            _fallback();
        }
    }

    /**
     * @dev Returns the current admin.
     *
     * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.
     *
     * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
     * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
     * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
     */
    function admin() external ifAdmin returns (address admin_) {
        admin_ = _getAdmin();
    }

    /**
     * @dev Returns the current implementation.
     *
     * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.
     *
     * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
     * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
     * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`
     */
    function implementation() external ifAdmin returns (address implementation_) {
        implementation_ = _implementation();
    }

    /**
     * @dev Changes the admin of the proxy.
     *
     * Emits an {AdminChanged} event.
     *
     * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.
     */
    function changeAdmin(address newAdmin) external virtual ifAdmin {
        _changeAdmin(newAdmin);
    }

    /**
     * @dev Upgrade the implementation of the proxy.
     *
     * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.
     */
    function upgradeTo(address newImplementation) external ifAdmin {
        _upgradeToAndCall(newImplementation, bytes(""), false);
    }

    /**
     * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified
     * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the
     * proxied contract.
     *
     * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.
     */
    function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {
        _upgradeToAndCall(newImplementation, data, true);
    }

    /**
     * @dev Returns the current admin.
     */
    function _admin() internal view virtual returns (address) {
        return _getAdmin();
    }

    /**
     * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.
     */
    function _beforeFallback() internal virtual override {
        require(msg.sender != _getAdmin(), "TransparentUpgradeableProxy: admin cannot fallback to proxy target");
        super._beforeFallback();
    }
}

Contract Security Audit

Contract ABI

API
[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[{"internalType":"contract TransparentUpgradeableProxy","name":"proxy","type":"address"},{"internalType":"address","name":"newAdmin","type":"address"}],"name":"changeProxyAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract TransparentUpgradeableProxy","name":"proxy","type":"address"}],"name":"getProxyAdmin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract TransparentUpgradeableProxy","name":"proxy","type":"address"}],"name":"getProxyImplementation","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract TransparentUpgradeableProxy","name":"proxy","type":"address"},{"internalType":"address","name":"implementation","type":"address"}],"name":"upgrade","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract TransparentUpgradeableProxy","name":"proxy","type":"address"},{"internalType":"address","name":"implementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeAndCall","outputs":[],"stateMutability":"payable","type":"function"}]

Deployed Bytecode

0x60806040526004361061007b5760003560e01c80639623609d1161004e5780639623609d1461012857806399a88ec414610144578063f2fde38b1461016d578063f3b7dead146101965761007b565b8063204e1c7a14610080578063715018a6146100bd5780637eff275e146100d45780638da5cb5b146100fd575b600080fd5b34801561008c57600080fd5b506100a760048036038101906100a291906108b9565b6101d3565b6040516100b49190610907565b60405180910390f35b3480156100c957600080fd5b506100d2610267565b005b3480156100e057600080fd5b506100fb60048036038101906100f6919061094e565b6102ef565b005b34801561010957600080fd5b506101126103da565b60405161011f9190610907565b60405180910390f35b610142600480360381019061013d9190610ad4565b610403565b005b34801561015057600080fd5b5061016b6004803603810190610166919061094e565b6104f2565b005b34801561017957600080fd5b50610194600480360381019061018f9190610b43565b6105dd565b005b3480156101a257600080fd5b506101bd60048036038101906101b891906108b9565b6106d5565b6040516101ca9190610907565b60405180910390f35b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101fb90610bc7565b600060405180830381855afa9150503d8060008114610236576040519150601f19603f3d011682016040523d82523d6000602084013e61023b565b606091505b50915091508161024a57600080fd5b8080602001905181019061025e9190610c08565b92505050919050565b61026f610769565b73ffffffffffffffffffffffffffffffffffffffff1661028d6103da565b73ffffffffffffffffffffffffffffffffffffffff16146102e3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102da90610c92565b60405180910390fd5b6102ed6000610771565b565b6102f7610769565b73ffffffffffffffffffffffffffffffffffffffff166103156103da565b73ffffffffffffffffffffffffffffffffffffffff161461036b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161036290610c92565b60405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff16638f283970826040518263ffffffff1660e01b81526004016103a49190610907565b600060405180830381600087803b1580156103be57600080fd5b505af11580156103d2573d6000803e3d6000fd5b505050505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b61040b610769565b73ffffffffffffffffffffffffffffffffffffffff166104296103da565b73ffffffffffffffffffffffffffffffffffffffff161461047f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161047690610c92565b60405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff16634f1ef2863484846040518463ffffffff1660e01b81526004016104bb929190610d3a565b6000604051808303818588803b1580156104d457600080fd5b505af11580156104e8573d6000803e3d6000fd5b5050505050505050565b6104fa610769565b73ffffffffffffffffffffffffffffffffffffffff166105186103da565b73ffffffffffffffffffffffffffffffffffffffff161461056e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161056590610c92565b60405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff16633659cfe6826040518263ffffffff1660e01b81526004016105a79190610907565b600060405180830381600087803b1580156105c157600080fd5b505af11580156105d5573d6000803e3d6000fd5b505050505050565b6105e5610769565b73ffffffffffffffffffffffffffffffffffffffff166106036103da565b73ffffffffffffffffffffffffffffffffffffffff1614610659576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161065090610c92565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156106c9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106c090610ddc565b60405180910390fd5b6106d281610771565b50565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516106fd90610e48565b600060405180830381855afa9150503d8060008114610738576040519150601f19603f3d011682016040523d82523d6000602084013e61073d565b606091505b50915091508161074c57600080fd5b808060200190518101906107609190610c08565b92505050919050565b600033905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061087482610849565b9050919050565b600061088682610869565b9050919050565b6108968161087b565b81146108a157600080fd5b50565b6000813590506108b38161088d565b92915050565b6000602082840312156108cf576108ce61083f565b5b60006108dd848285016108a4565b91505092915050565b60006108f182610849565b9050919050565b610901816108e6565b82525050565b600060208201905061091c60008301846108f8565b92915050565b61092b816108e6565b811461093657600080fd5b50565b60008135905061094881610922565b92915050565b600080604083850312156109655761096461083f565b5b6000610973858286016108a4565b925050602061098485828601610939565b9150509250929050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6109e182610998565b810181811067ffffffffffffffff82111715610a00576109ff6109a9565b5b80604052505050565b6000610a13610835565b9050610a1f82826109d8565b919050565b600067ffffffffffffffff821115610a3f57610a3e6109a9565b5b610a4882610998565b9050602081019050919050565b82818337600083830152505050565b6000610a77610a7284610a24565b610a09565b905082815260208101848484011115610a9357610a92610993565b5b610a9e848285610a55565b509392505050565b600082601f830112610abb57610aba61098e565b5b8135610acb848260208601610a64565b91505092915050565b600080600060608486031215610aed57610aec61083f565b5b6000610afb868287016108a4565b9350506020610b0c86828701610939565b925050604084013567ffffffffffffffff811115610b2d57610b2c610844565b5b610b3986828701610aa6565b9150509250925092565b600060208284031215610b5957610b5861083f565b5b6000610b6784828501610939565b91505092915050565b600081905092915050565b7f5c60da1b00000000000000000000000000000000000000000000000000000000600082015250565b6000610bb1600483610b70565b9150610bbc82610b7b565b600482019050919050565b6000610bd282610ba4565b9150819050919050565b610be581610869565b8114610bf057600080fd5b50565b600081519050610c0281610bdc565b92915050565b600060208284031215610c1e57610c1d61083f565b5b6000610c2c84828501610bf3565b91505092915050565b600082825260208201905092915050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000610c7c602083610c35565b9150610c8782610c46565b602082019050919050565b60006020820190508181036000830152610cab81610c6f565b9050919050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610cec578082015181840152602081019050610cd1565b83811115610cfb576000848401525b50505050565b6000610d0c82610cb2565b610d168185610cbd565b9350610d26818560208601610cce565b610d2f81610998565b840191505092915050565b6000604082019050610d4f60008301856108f8565b8181036020830152610d618184610d01565b90509392505050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000610dc6602683610c35565b9150610dd182610d6a565b604082019050919050565b60006020820190508181036000830152610df581610db9565b9050919050565b7ff851a44000000000000000000000000000000000000000000000000000000000600082015250565b6000610e32600483610b70565b9150610e3d82610dfc565b600482019050919050565b6000610e5382610e25565b915081905091905056fea26469706673582212203e18e07d0abfb19c4b6373dc668760f9d778c1d46543d4a38b0bba59ea3d989664736f6c634300080b0033

Deployed Bytecode Sourcemap

132:1494:19:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;172:443;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;1657:103:14;;;;;;;;;;;;;:::i;:::-;;1056:150:19;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;:::i;:::-;;1006:87:14;;;;;;;;;;;;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;1373:250:19;;;;;;;;;;;;;:::i;:::-;;:::i;:::-;;1214:151;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;:::i;:::-;;1915:201:14;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;:::i;:::-;;623:425:19;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;172:443;268:7;448:12;462:23;497:5;489:25;;:40;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;447:82;;;;548:7;540:16;;;;;;585:10;574:33;;;;;;;;;;;;:::i;:::-;567:40;;;;172:443;;;:::o;1657:103:14:-;1237:12;:10;:12::i;:::-;1226:23;;:7;:5;:7::i;:::-;:23;;;1218:68;;;;;;;;;;;;:::i;:::-;;;;;;;;;1722:30:::1;1749:1;1722:18;:30::i;:::-;1657:103::o:0;1056:150:19:-;1237:12:14;:10;:12::i;:::-;1226:23;;:7;:5;:7::i;:::-;:23;;;1218:68;;;;;;;;;;;;:::i;:::-;;;;;;;;;1171:5:19::1;:17;;;1189:8;1171:27;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;1056:150:::0;;:::o;1006:87:14:-;1052:7;1079:6;;;;;;;;;;;1072:13;;1006:87;:::o;1373:250:19:-;1237:12:14;:10;:12::i;:::-;1226:23;;:7;:5;:7::i;:::-;:23;;;1218:68;;;;;;;;;;;;:::i;:::-;;;;;;;;;1553:5:19::1;:22;;;1583:9;1594:14;1610:4;1553:62;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;;1373:250:::0;;;:::o;1214:151::-;1237:12:14;:10;:12::i;:::-;1226:23;;:7;:5;:7::i;:::-;:23;;;1218:68;;;;;;;;;;;;:::i;:::-;;;;;;;;;1326:5:19::1;:15;;;1342:14;1326:31;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;1214:151:::0;;:::o;1915:201:14:-;1237:12;:10;:12::i;:::-;1226:23;;:7;:5;:7::i;:::-;:23;;;1218:68;;;;;;;;;;;;:::i;:::-;;;;;;;;;2024:1:::1;2004:22;;:8;:22;;;;1996:73;;;;;;;;;;;;:::i;:::-;;;;;;;;;2080:28;2099:8;2080:18;:28::i;:::-;1915:201:::0;:::o;623:425:19:-;710:7;881:12;895:23;930:5;922:25;;:40;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;880:82;;;;981:7;973:16;;;;;;1018:10;1007:33;;;;;;;;;;;;:::i;:::-;1000:40;;;;623:425;;;:::o;600:98:3:-;653:7;680:10;673:17;;600:98;:::o;2276:191:14:-;2350:16;2369:6;;;;;;;;;;;2350:25;;2395:8;2386:6;;:17;;;;;;;;;;;;;;;;;;2450:8;2419:40;;2440:8;2419:40;;;;;;;;;;;;2339:128;2276:191;:::o;7:75:25:-;40:6;73:2;67:9;57:19;;7:75;:::o;88:117::-;197:1;194;187:12;211:117;320:1;317;310:12;334:126;371:7;411:42;404:5;400:54;389:65;;334:126;;;:::o;466:104::-;511:7;540:24;558:5;540:24;:::i;:::-;529:35;;466:104;;;:::o;576:140::-;649:7;678:32;704:5;678:32;:::i;:::-;667:43;;576:140;;;:::o;722:194::-;831:60;885:5;831:60;:::i;:::-;824:5;821:71;811:99;;906:1;903;896:12;811:99;722:194;:::o;922:211::-;1004:5;1042:6;1029:20;1020:29;;1058:69;1121:5;1058:69;:::i;:::-;922:211;;;;:::o;1139:401::-;1234:6;1283:2;1271:9;1262:7;1258:23;1254:32;1251:119;;;1289:79;;:::i;:::-;1251:119;1409:1;1434:89;1515:7;1506:6;1495:9;1491:22;1434:89;:::i;:::-;1424:99;;1380:153;1139:401;;;;:::o;1546:96::-;1583:7;1612:24;1630:5;1612:24;:::i;:::-;1601:35;;1546:96;;;:::o;1648:118::-;1735:24;1753:5;1735:24;:::i;:::-;1730:3;1723:37;1648:118;;:::o;1772:222::-;1865:4;1903:2;1892:9;1888:18;1880:26;;1916:71;1984:1;1973:9;1969:17;1960:6;1916:71;:::i;:::-;1772:222;;;;:::o;2000:122::-;2073:24;2091:5;2073:24;:::i;:::-;2066:5;2063:35;2053:63;;2112:1;2109;2102:12;2053:63;2000:122;:::o;2128:139::-;2174:5;2212:6;2199:20;2190:29;;2228:33;2255:5;2228:33;:::i;:::-;2128:139;;;;:::o;2273:546::-;2377:6;2385;2434:2;2422:9;2413:7;2409:23;2405:32;2402:119;;;2440:79;;:::i;:::-;2402:119;2560:1;2585:89;2666:7;2657:6;2646:9;2642:22;2585:89;:::i;:::-;2575:99;;2531:153;2723:2;2749:53;2794:7;2785:6;2774:9;2770:22;2749:53;:::i;:::-;2739:63;;2694:118;2273:546;;;;;:::o;2825:117::-;2934:1;2931;2924:12;2948:117;3057:1;3054;3047:12;3071:102;3112:6;3163:2;3159:7;3154:2;3147:5;3143:14;3139:28;3129:38;;3071:102;;;:::o;3179:180::-;3227:77;3224:1;3217:88;3324:4;3321:1;3314:15;3348:4;3345:1;3338:15;3365:281;3448:27;3470:4;3448:27;:::i;:::-;3440:6;3436:40;3578:6;3566:10;3563:22;3542:18;3530:10;3527:34;3524:62;3521:88;;;3589:18;;:::i;:::-;3521:88;3629:10;3625:2;3618:22;3408:238;3365:281;;:::o;3652:129::-;3686:6;3713:20;;:::i;:::-;3703:30;;3742:33;3770:4;3762:6;3742:33;:::i;:::-;3652:129;;;:::o;3787:307::-;3848:4;3938:18;3930:6;3927:30;3924:56;;;3960:18;;:::i;:::-;3924:56;3998:29;4020:6;3998:29;:::i;:::-;3990:37;;4082:4;4076;4072:15;4064:23;;3787:307;;;:::o;4100:154::-;4184:6;4179:3;4174;4161:30;4246:1;4237:6;4232:3;4228:16;4221:27;4100:154;;;:::o;4260:410::-;4337:5;4362:65;4378:48;4419:6;4378:48;:::i;:::-;4362:65;:::i;:::-;4353:74;;4450:6;4443:5;4436:21;4488:4;4481:5;4477:16;4526:3;4517:6;4512:3;4508:16;4505:25;4502:112;;;4533:79;;:::i;:::-;4502:112;4623:41;4657:6;4652:3;4647;4623:41;:::i;:::-;4343:327;4260:410;;;;;:::o;4689:338::-;4744:5;4793:3;4786:4;4778:6;4774:17;4770:27;4760:122;;4801:79;;:::i;:::-;4760:122;4918:6;4905:20;4943:78;5017:3;5009:6;5002:4;4994:6;4990:17;4943:78;:::i;:::-;4934:87;;4750:277;4689:338;;;;:::o;5033:869::-;5155:6;5163;5171;5220:2;5208:9;5199:7;5195:23;5191:32;5188:119;;;5226:79;;:::i;:::-;5188:119;5346:1;5371:89;5452:7;5443:6;5432:9;5428:22;5371:89;:::i;:::-;5361:99;;5317:153;5509:2;5535:53;5580:7;5571:6;5560:9;5556:22;5535:53;:::i;:::-;5525:63;;5480:118;5665:2;5654:9;5650:18;5637:32;5696:18;5688:6;5685:30;5682:117;;;5718:79;;:::i;:::-;5682:117;5823:62;5877:7;5868:6;5857:9;5853:22;5823:62;:::i;:::-;5813:72;;5608:287;5033:869;;;;;:::o;5908:329::-;5967:6;6016:2;6004:9;5995:7;5991:23;5987:32;5984:119;;;6022:79;;:::i;:::-;5984:119;6142:1;6167:53;6212:7;6203:6;6192:9;6188:22;6167:53;:::i;:::-;6157:63;;6113:117;5908:329;;;;:::o;6243:147::-;6344:11;6381:3;6366:18;;6243:147;;;;:::o;6396:214::-;6536:66;6532:1;6524:6;6520:14;6513:90;6396:214;:::o;6616:398::-;6775:3;6796:83;6877:1;6872:3;6796:83;:::i;:::-;6789:90;;6888:93;6977:3;6888:93;:::i;:::-;7006:1;7001:3;6997:11;6990:18;;6616:398;;;:::o;7020:379::-;7204:3;7226:147;7369:3;7226:147;:::i;:::-;7219:154;;7390:3;7383:10;;7020:379;;;:::o;7405:138::-;7486:32;7512:5;7486:32;:::i;:::-;7479:5;7476:43;7466:71;;7533:1;7530;7523:12;7466:71;7405:138;:::o;7549:159::-;7614:5;7645:6;7639:13;7630:22;;7661:41;7696:5;7661:41;:::i;:::-;7549:159;;;;:::o;7714:367::-;7792:6;7841:2;7829:9;7820:7;7816:23;7812:32;7809:119;;;7847:79;;:::i;:::-;7809:119;7967:1;7992:72;8056:7;8047:6;8036:9;8032:22;7992:72;:::i;:::-;7982:82;;7938:136;7714:367;;;;:::o;8087:169::-;8171:11;8205:6;8200:3;8193:19;8245:4;8240:3;8236:14;8221:29;;8087:169;;;;:::o;8262:182::-;8402:34;8398:1;8390:6;8386:14;8379:58;8262:182;:::o;8450:366::-;8592:3;8613:67;8677:2;8672:3;8613:67;:::i;:::-;8606:74;;8689:93;8778:3;8689:93;:::i;:::-;8807:2;8802:3;8798:12;8791:19;;8450:366;;;:::o;8822:419::-;8988:4;9026:2;9015:9;9011:18;9003:26;;9075:9;9069:4;9065:20;9061:1;9050:9;9046:17;9039:47;9103:131;9229:4;9103:131;:::i;:::-;9095:139;;8822:419;;;:::o;9247:98::-;9298:6;9332:5;9326:12;9316:22;;9247:98;;;:::o;9351:168::-;9434:11;9468:6;9463:3;9456:19;9508:4;9503:3;9499:14;9484:29;;9351:168;;;;:::o;9525:307::-;9593:1;9603:113;9617:6;9614:1;9611:13;9603:113;;;9702:1;9697:3;9693:11;9687:18;9683:1;9678:3;9674:11;9667:39;9639:2;9636:1;9632:10;9627:15;;9603:113;;;9734:6;9731:1;9728:13;9725:101;;;9814:1;9805:6;9800:3;9796:16;9789:27;9725:101;9574:258;9525:307;;;:::o;9838:360::-;9924:3;9952:38;9984:5;9952:38;:::i;:::-;10006:70;10069:6;10064:3;10006:70;:::i;:::-;9999:77;;10085:52;10130:6;10125:3;10118:4;10111:5;10107:16;10085:52;:::i;:::-;10162:29;10184:6;10162:29;:::i;:::-;10157:3;10153:39;10146:46;;9928:270;9838:360;;;;:::o;10204:419::-;10343:4;10381:2;10370:9;10366:18;10358:26;;10394:71;10462:1;10451:9;10447:17;10438:6;10394:71;:::i;:::-;10512:9;10506:4;10502:20;10497:2;10486:9;10482:18;10475:48;10540:76;10611:4;10602:6;10540:76;:::i;:::-;10532:84;;10204:419;;;;;:::o;10629:225::-;10769:34;10765:1;10757:6;10753:14;10746:58;10838:8;10833:2;10825:6;10821:15;10814:33;10629:225;:::o;10860:366::-;11002:3;11023:67;11087:2;11082:3;11023:67;:::i;:::-;11016:74;;11099:93;11188:3;11099:93;:::i;:::-;11217:2;11212:3;11208:12;11201:19;;10860:366;;;:::o;11232:419::-;11398:4;11436:2;11425:9;11421:18;11413:26;;11485:9;11479:4;11475:20;11471:1;11460:9;11456:17;11449:47;11513:131;11639:4;11513:131;:::i;:::-;11505:139;;11232:419;;;:::o;11657:214::-;11797:66;11793:1;11785:6;11781:14;11774:90;11657:214;:::o;11877:398::-;12036:3;12057:83;12138:1;12133:3;12057:83;:::i;:::-;12050:90;;12149:93;12238:3;12149:93;:::i;:::-;12267:1;12262:3;12258:11;12251:18;;11877:398;;;:::o;12281:379::-;12465:3;12487:147;12630:3;12487:147;:::i;:::-;12480:154;;12651:3;12644:10;;12281:379;;;:::o

Swarm Source

ipfs://3e18e07d0abfb19c4b6373dc668760f9d778c1d46543d4a38b0bba59ea3d9896

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

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.