ETH Price: $2,385.14 (+2.57%)

Contract

0x30F5907E7F943e8eBE5db444Ab7e3C8251346344
 
Transaction Hash
Method
Block
From
To
Withdraw178254422023-08-02 6:11:59413 days ago1690956719IN
0x30F5907E...251346344
0 ETH0.0018159415.72481965
Withdraw164893682023-01-26 7:02:35601 days ago1674716555IN
0x30F5907E...251346344
0 ETH0.0016955414.68216114
Withdraw164893482023-01-26 6:58:35601 days ago1674716315IN
0x30F5907E...251346344
0 ETH0.001668514.44803395
Withdraw163479812023-01-06 13:15:59621 days ago1673010959IN
0x30F5907E...251346344
0 ETH0.0016407714.20794534
Withdraw162751132022-12-27 9:13:23631 days ago1672132403IN
0x30F5907E...251346344
0 ETH0.0012605512.81276603
Withdraw162751042022-12-27 9:11:35631 days ago1672132295IN
0x30F5907E...251346344
0 ETH0.0016887914.62375218
Withdraw162750942022-12-27 9:09:35631 days ago1672132175IN
0x30F5907E...251346344
0 ETH0.0012662512.87067147
Withdraw162750882022-12-27 9:08:23631 days ago1672132103IN
0x30F5907E...251346344
0 ETH0.0014667212.70081636
Withdraw162750612022-12-27 9:02:59631 days ago1672131779IN
0x30F5907E...251346344
0 ETH0.0011583711.77410258
Withdraw162750442022-12-27 8:59:35631 days ago1672131575IN
0x30F5907E...251346344
0 ETH0.0014255212.34398803
Withdraw162335632022-12-21 14:06:35637 days ago1671631595IN
0x30F5907E...251346344
0 ETH0.0017386615.05560491
Withdraw162303562022-12-21 3:21:59637 days ago1671592919IN
0x30F5907E...251346344
0 ETH0.001707814.78840166
Withdraw162267892022-12-20 15:25:11638 days ago1671549911IN
0x30F5907E...251346344
0 ETH0.0025598522.16646721
Withdraw162196652022-12-19 15:33:35639 days ago1671464015IN
0x30F5907E...251346344
0 ETH0.0018357418.65916875
Withdraw162177962022-12-19 9:18:23639 days ago1671441503IN
0x30F5907E...251346344
0 ETH0.0011397111.58449052
Withdraw162113882022-12-18 11:50:35640 days ago1671364235IN
0x30F5907E...251346344
0 ETH0.001858516.09334644
Withdraw162105062022-12-18 8:53:47640 days ago1671353627IN
0x30F5907E...251346344
0 ETH0.0016565814.34485171
Withdraw162102612022-12-18 8:04:47640 days ago1671350687IN
0x30F5907E...251346344
0 ETH0.0019472416.86176655
Transfer Ownersh...160818262022-11-30 9:11:35658 days ago1669799495IN
0x30F5907E...251346344
0 ETH0.0003060310.53668135
Borrow152754322022-08-04 10:51:41776 days ago1659610301IN
0x30F5907E...251346344
0 ETH0.000595249.80870046
Deposit152754072022-08-04 10:46:44776 days ago1659610004IN
0x30F5907E...251346344
8.5655007 ETH0.001796838.3203617
Deposit152753812022-08-04 10:40:45776 days ago1659609645IN
0x30F5907E...251346344
0 ETH0.0011076410.34400168
Deposit152753752022-08-04 10:39:07776 days ago1659609547IN
0x30F5907E...251346344
0 ETH0.0013638810.98304339
Deposit152753652022-08-04 10:36:46776 days ago1659609406IN
0x30F5907E...251346344
0 ETH0.000835688.17142937
Deposit152753542022-08-04 10:33:30776 days ago1659609210IN
0x30F5907E...251346344
0 ETH0.0012103210.13935156
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To
152754072022-08-04 10:46:44776 days ago1659610004
0x30F5907E...251346344
0.37065565 ETH
152754072022-08-04 10:46:44776 days ago1659610004
0x30F5907E...251346344
0.37065565 ETH
152754072022-08-04 10:46:44776 days ago1659610004
0x30F5907E...251346344
8.5655007 ETH
152676372022-08-03 5:34:03777 days ago1659504843
0x30F5907E...251346344
0.0039943 ETH
152676372022-08-03 5:34:03777 days ago1659504843
0x30F5907E...251346344
0.0039943 ETH
152676372022-08-03 5:34:03777 days ago1659504843
0x30F5907E...251346344
0.07776577 ETH
152552982022-08-01 7:35:30779 days ago1659339330
0x30F5907E...251346344
0.00565866 ETH
152552982022-08-01 7:35:30779 days ago1659339330
0x30F5907E...251346344
0.00565866 ETH
152552982022-08-01 7:35:30779 days ago1659339330
0x30F5907E...251346344
0.12489592 ETH
152552712022-08-01 7:27:12779 days ago1659338832
0x30F5907E...251346344
0.00557726 ETH
152552712022-08-01 7:27:12779 days ago1659338832
0x30F5907E...251346344
0.00557726 ETH
152552712022-08-01 7:27:12779 days ago1659338832
0x30F5907E...251346344
0.12487735 ETH
152304972022-07-28 10:29:38783 days ago1659004178
0x30F5907E...251346344
0.00124525 ETH
152304972022-07-28 10:29:38783 days ago1659004178
0x30F5907E...251346344
0.00124525 ETH
152304972022-07-28 10:29:38783 days ago1659004178
0x30F5907E...251346344
0.02588438 ETH
152300062022-07-28 8:41:06783 days ago1658997666
0x30F5907E...251346344
0.00588054 ETH
152300062022-07-28 8:41:06783 days ago1658997666
0x30F5907E...251346344
0.00588054 ETH
152300062022-07-28 8:41:06783 days ago1658997666
0x30F5907E...251346344
0.12294248 ETH
152300022022-07-28 8:40:17783 days ago1658997617
0x30F5907E...251346344
0.00600688 ETH
152300022022-07-28 8:40:17783 days ago1658997617
0x30F5907E...251346344
0.00600688 ETH
152300022022-07-28 8:40:17783 days ago1658997617
0x30F5907E...251346344
0.12294248 ETH
152230242022-07-27 7:07:08784 days ago1658905628
0x30F5907E...251346344
0.00074644 ETH
152230242022-07-27 7:07:08784 days ago1658905628
0x30F5907E...251346344
0.00074644 ETH
152230242022-07-27 7:07:08784 days ago1658905628
0x30F5907E...251346344
0.014381 ETH
152227932022-07-27 6:15:32784 days ago1658902532
0x30F5907E...251346344
0.0224235 ETH
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
Controller

Compiler Version
v0.8.11+commit.d7f03943

Optimization Enabled:
No with 200 runs

Other Settings:
default evmVersion, MIT license
File 1 of 20 : Controller.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;

import "@openzeppelin/contracts/access/Ownable.sol";
import "./NftBond.sol";
import "./SwapHelper.sol";

error InitProject_InvalidTimestampInput();
error InitProject_InvalidTotalAmountInput();
error Deposit_NotStarted();
error Deposit_Ended();
error Deposit_ExceededTotalAmount();
error Deposit_NotDivisibleByDecimals();
error Withdraw_NotRepayedProject();
error Repay_NotEnoughAmountInput();
error Repay_AlreadyDepositted();
error NotExistingProject();
error Borrow_DepositNotEnded();
error Repay_DepositNotEnded();
error AlreadyBorrowed();

interface IController {
    event Deposited(
        address _depositor,
        uint256 indexed _projectId,
        uint256 _amount
    );
    event Borrowed(
        address _borrower,
        uint256 indexed _projectId,
        uint256 _amount
    );
    event Repaid(address _repayer, uint256 indexed _projectId, uint256 _amount);
    event Withdrawed(
        address _withdrawer,
        uint256 indexed _projectId,
        uint256 _amount
    );

    /**
     * @notice A user deposits ETH or USDC and buys a NFT.
     * @param projectId id of the project the user wants to invest.
     * @param depositAmount the amount of USDC user wants to deposit.
     */
    function deposit(uint256 projectId, uint256 depositAmount) external payable;

    /**
     * @notice A user burns his/her NFT and receives USDC with accrued interests.
     * @param tokenId id of the NFT the user wants to burn.
     */
    function withdraw(uint256 tokenId) external;

    /**
     * @notice The owner withdraws all deposited USDC.
     * @param projectId id of the project
     * @dev totalAmount is updated equal to the currentAmount to handle when
     *      the total deposited amount is below the target amount.
     */
    function borrow(uint256 projectId) external;

    /**
     * @notice The owner transfers USDC for depositors to withdraw.
     * @param projectId id of the project
     * @param amount the amount of USDC the owner wants to transfer to this contract.
     */
    function repay(uint256 projectId, uint256 amount) external;
}

contract Controller is Ownable, SwapHelper, IController {
    /**
     * totalAmount: target amount (Before Borrow) & total deposited (After Project Ended). Changes with borrow.
     * currentAmount: balance of this project. Changes with deposit, withdraw, borrow, and repay.
     * finalAmount: repaid amount after interest. Changes with repay.
     */
    struct Project {
        uint256 totalAmount;
        uint256 currentAmount;
        uint256 depositStartTs;
        uint256 depositEndTs;
        uint256 finalAmount;
    }
    NftBond public nft;
    mapping(uint256 => Project) public projects;

    /**
     * Events.
     */
    event Controller_NewProject(
        uint256 _totalAmount,
        uint256 _depositStartTs,
        uint256 _depositEndTs,
        uint256 _unit,
        string _uri
    );

    /**
     * Constructor.
     */
    constructor(
        NftBond nft_,
        address router_,
        address usdc_,
        address weth_
    ) SwapHelper(router_, usdc_, weth_) {
        nft = nft_;
    }

    /**
     * @notice projectId starts from 0.
     */
    function initProject(
        uint256 totalAmount,
        uint256 depositStartTs,
        uint256 depositEndTs,
        uint256 unit,
        string memory uri
    ) external onlyOwner {
        if (depositEndTs <= block.timestamp || depositEndTs <= depositStartTs)
            revert InitProject_InvalidTimestampInput();
        if (totalAmount == 0) revert InitProject_InvalidTotalAmountInput();

        Project memory newProject = Project({
            totalAmount: totalAmount,
            currentAmount: 0,
            depositStartTs: depositStartTs,
            depositEndTs: depositEndTs,
            finalAmount: 0
        });

        uint256 projectId = nft.tokenIdCounter();
        projects[projectId] = newProject;

        nft.initProject(uri, unit);
        emit Controller_NewProject(
            totalAmount,
            depositStartTs,
            depositEndTs,
            unit,
            uri
        );
    }

    function deposit(uint256 projectId, uint256 amount)
        external
        payable
        override
    {
        // check
        Project storage project = projects[projectId];
        if (project.depositStartTs == 0) revert NotExistingProject();
        if (block.timestamp < project.depositStartTs)
            revert Deposit_NotStarted();
        if (project.depositEndTs <= block.timestamp) revert Deposit_Ended();
        if (project.currentAmount + amount > project.totalAmount)
            revert Deposit_ExceededTotalAmount();
        if (amount % (10**decimal) != 0)
            revert Deposit_NotDivisibleByDecimals();

        // effect
        projects[projectId].currentAmount += amount;

        // interaction
        if (msg.value != 0) {
            swapExactOutputSingle(amount);
        } else {
            TransferHelper.safeTransferFrom(
                usdc,
                msg.sender,
                address(this),
                amount
            );
        }

        uint256 principal = _calculatePrincipal(amount);
        nft.createLoan(projectId, principal, msg.sender);

        emit Deposited(msg.sender, projectId, amount);
    }

    function borrow(uint256 projectId) external onlyOwner {
        // check
        Project storage project = projects[projectId];
        if (project.depositStartTs == 0) revert NotExistingProject();
        if (
            block.timestamp < project.depositEndTs &&
            project.currentAmount != project.totalAmount
        ) revert Borrow_DepositNotEnded();
        if (project.currentAmount == 0) revert AlreadyBorrowed();

        // effect
        project.totalAmount = project.currentAmount;
        uint256 amount = project.currentAmount;
        project.currentAmount = 0;

        // interaction
        IERC20(usdc).transfer(msg.sender, amount);

        emit Borrowed(msg.sender, projectId, amount);
    }

    function repay(uint256 projectId, uint256 amount)
        external
        override
        onlyOwner
    {
        Project storage project = projects[projectId];
        // check
        if (project.finalAmount != 0) revert Repay_AlreadyDepositted();
        if (project.depositStartTs == 0) revert NotExistingProject();
        if (amount < project.totalAmount) revert Repay_NotEnoughAmountInput();
        if (project.depositEndTs > block.timestamp)
            revert Repay_DepositNotEnded();

        // effect
        project.finalAmount = project.currentAmount = amount;

        // interaction
        IERC20(usdc).transferFrom(msg.sender, address(this), amount);

        emit Repaid(msg.sender, projectId, amount);
    }

    function withdraw(uint256 projectId) external override {
        Project storage project = projects[projectId];
        if (project.depositStartTs == 0) revert NotExistingProject();
        if (project.finalAmount == 0) revert Withdraw_NotRepayedProject();

        uint256 userTokenBalance = nft.balanceOf(msg.sender, projectId);
        uint256 userDollarBalance = _calculateDollarBalance(
            projectId,
            userTokenBalance
        );

        // effect
        // Multiply first to prevent decimal from going down to 0.
        uint256 userBalancePlusInterest = (project.finalAmount *
            userDollarBalance) / project.totalAmount;
        project.currentAmount -= userBalancePlusInterest;

        // interaction
        TransferHelper.safeTransfer(usdc, msg.sender, userBalancePlusInterest);

        nft.redeem(projectId, msg.sender, userTokenBalance);

        emit Withdrawed(msg.sender, projectId, userBalancePlusInterest);
    }

    function _calculatePrincipal(uint256 amount)
        internal
        view
        returns (uint256)
    {
        return amount / (10**decimal);
    }

    function _calculateDollarBalance(uint256 projectId, uint256 balance)
        internal
        view
        returns (uint256)
    {
        uint256 unit = nft.unit(projectId);

        return balance * unit * (10**decimal);
    }
}

File 2 of 20 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * 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 Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

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

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        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 3 of 20 : ERC1155.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/ERC1155.sol)

pragma solidity ^0.8.0;

import "./IERC1155.sol";
import "./IERC1155Receiver.sol";
import "./extensions/IERC1155MetadataURI.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/introspection/ERC165.sol";

/**
 * @dev Implementation of the basic standard multi-token.
 * See https://eips.ethereum.org/EIPS/eip-1155
 * Originally based on code by Enjin: https://github.com/enjin/erc-1155
 *
 * _Available since v3.1._
 */
contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI {
    using Address for address;

    // Mapping from token ID to account balances
    mapping(uint256 => mapping(address => uint256)) private _balances;

    // Mapping from account to operator approvals
    mapping(address => mapping(address => bool)) private _operatorApprovals;

    // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json
    string private _uri;

    /**
     * @dev See {_setURI}.
     */
    constructor(string memory uri_) {
        _setURI(uri_);
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
        return
            interfaceId == type(IERC1155).interfaceId ||
            interfaceId == type(IERC1155MetadataURI).interfaceId ||
            super.supportsInterface(interfaceId);
    }

    /**
     * @dev See {IERC1155MetadataURI-uri}.
     *
     * This implementation returns the same URI for *all* token types. It relies
     * on the token type ID substitution mechanism
     * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
     *
     * Clients calling this function must replace the `\{id\}` substring with the
     * actual token type ID.
     */
    function uri(uint256) public view virtual override returns (string memory) {
        return _uri;
    }

    /**
     * @dev See {IERC1155-balanceOf}.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) public view virtual override returns (uint256) {
        require(account != address(0), "ERC1155: address zero is not a valid owner");
        return _balances[id][account];
    }

    /**
     * @dev See {IERC1155-balanceOfBatch}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(address[] memory accounts, uint256[] memory ids)
        public
        view
        virtual
        override
        returns (uint256[] memory)
    {
        require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch");

        uint256[] memory batchBalances = new uint256[](accounts.length);

        for (uint256 i = 0; i < accounts.length; ++i) {
            batchBalances[i] = balanceOf(accounts[i], ids[i]);
        }

        return batchBalances;
    }

    /**
     * @dev See {IERC1155-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved) public virtual override {
        _setApprovalForAll(_msgSender(), operator, approved);
    }

    /**
     * @dev See {IERC1155-isApprovedForAll}.
     */
    function isApprovedForAll(address account, address operator) public view virtual override returns (bool) {
        return _operatorApprovals[account][operator];
    }

    /**
     * @dev See {IERC1155-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) public virtual override {
        require(
            from == _msgSender() || isApprovedForAll(from, _msgSender()),
            "ERC1155: caller is not token owner nor approved"
        );
        _safeTransferFrom(from, to, id, amount, data);
    }

    /**
     * @dev See {IERC1155-safeBatchTransferFrom}.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) public virtual override {
        require(
            from == _msgSender() || isApprovedForAll(from, _msgSender()),
            "ERC1155: caller is not token owner nor approved"
        );
        _safeBatchTransferFrom(from, to, ids, amounts, data);
    }

    /**
     * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `from` must have a balance of tokens of type `id` of at least `amount`.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function _safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) internal virtual {
        require(to != address(0), "ERC1155: transfer to the zero address");

        address operator = _msgSender();
        uint256[] memory ids = _asSingletonArray(id);
        uint256[] memory amounts = _asSingletonArray(amount);

        _beforeTokenTransfer(operator, from, to, ids, amounts, data);

        uint256 fromBalance = _balances[id][from];
        require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
        unchecked {
            _balances[id][from] = fromBalance - amount;
        }
        _balances[id][to] += amount;

        emit TransferSingle(operator, from, to, id, amount);

        _afterTokenTransfer(operator, from, to, ids, amounts, data);

        _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data);
    }

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function _safeBatchTransferFrom(
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {
        require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
        require(to != address(0), "ERC1155: transfer to the zero address");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, from, to, ids, amounts, data);

        for (uint256 i = 0; i < ids.length; ++i) {
            uint256 id = ids[i];
            uint256 amount = amounts[i];

            uint256 fromBalance = _balances[id][from];
            require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
            unchecked {
                _balances[id][from] = fromBalance - amount;
            }
            _balances[id][to] += amount;
        }

        emit TransferBatch(operator, from, to, ids, amounts);

        _afterTokenTransfer(operator, from, to, ids, amounts, data);

        _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data);
    }

    /**
     * @dev Sets a new URI for all token types, by relying on the token type ID
     * substitution mechanism
     * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
     *
     * By this mechanism, any occurrence of the `\{id\}` substring in either the
     * URI or any of the amounts in the JSON file at said URI will be replaced by
     * clients with the token type ID.
     *
     * For example, the `https://token-cdn-domain/\{id\}.json` URI would be
     * interpreted by clients as
     * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json`
     * for token type ID 0x4cce0.
     *
     * See {uri}.
     *
     * Because these URIs cannot be meaningfully represented by the {URI} event,
     * this function emits no events.
     */
    function _setURI(string memory newuri) internal virtual {
        _uri = newuri;
    }

    /**
     * @dev Creates `amount` tokens of token type `id`, and assigns them to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function _mint(
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) internal virtual {
        require(to != address(0), "ERC1155: mint to the zero address");

        address operator = _msgSender();
        uint256[] memory ids = _asSingletonArray(id);
        uint256[] memory amounts = _asSingletonArray(amount);

        _beforeTokenTransfer(operator, address(0), to, ids, amounts, data);

        _balances[id][to] += amount;
        emit TransferSingle(operator, address(0), to, id, amount);

        _afterTokenTransfer(operator, address(0), to, ids, amounts, data);

        _doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data);
    }

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function _mintBatch(
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {
        require(to != address(0), "ERC1155: mint to the zero address");
        require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, address(0), to, ids, amounts, data);

        for (uint256 i = 0; i < ids.length; i++) {
            _balances[ids[i]][to] += amounts[i];
        }

        emit TransferBatch(operator, address(0), to, ids, amounts);

        _afterTokenTransfer(operator, address(0), to, ids, amounts, data);

        _doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data);
    }

    /**
     * @dev Destroys `amount` tokens of token type `id` from `from`
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `from` must have at least `amount` tokens of token type `id`.
     */
    function _burn(
        address from,
        uint256 id,
        uint256 amount
    ) internal virtual {
        require(from != address(0), "ERC1155: burn from the zero address");

        address operator = _msgSender();
        uint256[] memory ids = _asSingletonArray(id);
        uint256[] memory amounts = _asSingletonArray(amount);

        _beforeTokenTransfer(operator, from, address(0), ids, amounts, "");

        uint256 fromBalance = _balances[id][from];
        require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
        unchecked {
            _balances[id][from] = fromBalance - amount;
        }

        emit TransferSingle(operator, from, address(0), id, amount);

        _afterTokenTransfer(operator, from, address(0), ids, amounts, "");
    }

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     */
    function _burnBatch(
        address from,
        uint256[] memory ids,
        uint256[] memory amounts
    ) internal virtual {
        require(from != address(0), "ERC1155: burn from the zero address");
        require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, from, address(0), ids, amounts, "");

        for (uint256 i = 0; i < ids.length; i++) {
            uint256 id = ids[i];
            uint256 amount = amounts[i];

            uint256 fromBalance = _balances[id][from];
            require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
            unchecked {
                _balances[id][from] = fromBalance - amount;
            }
        }

        emit TransferBatch(operator, from, address(0), ids, amounts);

        _afterTokenTransfer(operator, from, address(0), ids, amounts, "");
    }

    /**
     * @dev Approve `operator` to operate on all of `owner` tokens
     *
     * Emits an {ApprovalForAll} event.
     */
    function _setApprovalForAll(
        address owner,
        address operator,
        bool approved
    ) internal virtual {
        require(owner != operator, "ERC1155: setting approval status for self");
        _operatorApprovals[owner][operator] = approved;
        emit ApprovalForAll(owner, operator, approved);
    }

    /**
     * @dev Hook that is called before any token transfer. This includes minting
     * and burning, as well as batched variants.
     *
     * The same hook is called on both single and batched variants. For single
     * transfers, the length of the `ids` and `amounts` arrays will be 1.
     *
     * Calling conditions (for each `id` and `amount` pair):
     *
     * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * of token type `id` will be  transferred to `to`.
     * - When `from` is zero, `amount` tokens of token type `id` will be minted
     * for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
     * will be burned.
     * - `from` and `to` are never both zero.
     * - `ids` and `amounts` have the same, non-zero length.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {}

    /**
     * @dev Hook that is called after any token transfer. This includes minting
     * and burning, as well as batched variants.
     *
     * The same hook is called on both single and batched variants. For single
     * transfers, the length of the `id` and `amount` arrays will be 1.
     *
     * Calling conditions (for each `id` and `amount` pair):
     *
     * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * of token type `id` will be  transferred to `to`.
     * - When `from` is zero, `amount` tokens of token type `id` will be minted
     * for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
     * will be burned.
     * - `from` and `to` are never both zero.
     * - `ids` and `amounts` have the same, non-zero length.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {}

    function _doSafeTransferAcceptanceCheck(
        address operator,
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) private {
        if (to.isContract()) {
            try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {
                if (response != IERC1155Receiver.onERC1155Received.selector) {
                    revert("ERC1155: ERC1155Receiver rejected tokens");
                }
            } catch Error(string memory reason) {
                revert(reason);
            } catch {
                revert("ERC1155: transfer to non ERC1155Receiver implementer");
            }
        }
    }

    function _doSafeBatchTransferAcceptanceCheck(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) private {
        if (to.isContract()) {
            try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (
                bytes4 response
            ) {
                if (response != IERC1155Receiver.onERC1155BatchReceived.selector) {
                    revert("ERC1155: ERC1155Receiver rejected tokens");
                }
            } catch Error(string memory reason) {
                revert(reason);
            } catch {
                revert("ERC1155: transfer to non ERC1155Receiver implementer");
            }
        }
    }

    function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) {
        uint256[] memory array = new uint256[](1);
        array[0] = element;

        return array;
    }
}

File 4 of 20 : IERC1155.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC1155 compliant contract, as defined in the
 * https://eips.ethereum.org/EIPS/eip-1155[EIP].
 *
 * _Available since v3.1._
 */
interface IERC1155 is IERC165 {
    /**
     * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
     */
    event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);

    /**
     * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
     * transfers.
     */
    event TransferBatch(
        address indexed operator,
        address indexed from,
        address indexed to,
        uint256[] ids,
        uint256[] values
    );

    /**
     * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
     * `approved`.
     */
    event ApprovalForAll(address indexed account, address indexed operator, bool approved);

    /**
     * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
     *
     * If an {URI} event was emitted for `id`, the standard
     * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
     * returned by {IERC1155MetadataURI-uri}.
     */
    event URI(string value, uint256 indexed id);

    /**
     * @dev Returns the amount of tokens of token type `id` owned by `account`.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) external view returns (uint256);

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
        external
        view
        returns (uint256[] memory);

    /**
     * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
     *
     * Emits an {ApprovalForAll} event.
     *
     * Requirements:
     *
     * - `operator` cannot be the caller.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
     *
     * See {setApprovalForAll}.
     */
    function isApprovedForAll(address account, address operator) external view returns (bool);

    /**
     * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
     * - `from` must have a balance of tokens of type `id` of at least `amount`.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes calldata data
    ) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] calldata ids,
        uint256[] calldata amounts,
        bytes calldata data
    ) external;
}

File 5 of 20 : IERC1155Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev _Available since v3.1._
 */
interface IERC1155Receiver is IERC165 {
    /**
     * @dev Handles the receipt of a single ERC1155 token type. This function is
     * called at the end of a `safeTransferFrom` after the balance has been updated.
     *
     * NOTE: To accept the transfer, this must return
     * `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
     * (i.e. 0xf23a6e61, or its own function selector).
     *
     * @param operator The address which initiated the transfer (i.e. msg.sender)
     * @param from The address which previously owned the token
     * @param id The ID of the token being transferred
     * @param value The amount of tokens being transferred
     * @param data Additional data with no specified format
     * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
     */
    function onERC1155Received(
        address operator,
        address from,
        uint256 id,
        uint256 value,
        bytes calldata data
    ) external returns (bytes4);

    /**
     * @dev Handles the receipt of a multiple ERC1155 token types. This function
     * is called at the end of a `safeBatchTransferFrom` after the balances have
     * been updated.
     *
     * NOTE: To accept the transfer(s), this must return
     * `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
     * (i.e. 0xbc197c81, or its own function selector).
     *
     * @param operator The address which initiated the batch transfer (i.e. msg.sender)
     * @param from The address which previously owned the token
     * @param ids An array containing ids of each token being transferred (order and length must match values array)
     * @param values An array containing amounts of each token being transferred (order and length must match ids array)
     * @param data Additional data with no specified format
     * @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
     */
    function onERC1155BatchReceived(
        address operator,
        address from,
        uint256[] calldata ids,
        uint256[] calldata values,
        bytes calldata data
    ) external returns (bytes4);
}

File 6 of 20 : ERC1155Supply.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC1155/extensions/ERC1155Supply.sol)

pragma solidity ^0.8.0;

import "../ERC1155.sol";

/**
 * @dev Extension of ERC1155 that adds tracking of total supply per id.
 *
 * Useful for scenarios where Fungible and Non-fungible tokens have to be
 * clearly identified. Note: While a totalSupply of 1 might mean the
 * corresponding is an NFT, there is no guarantees that no other token with the
 * same id are not going to be minted.
 */
abstract contract ERC1155Supply is ERC1155 {
    mapping(uint256 => uint256) private _totalSupply;

    /**
     * @dev Total amount of tokens in with a given id.
     */
    function totalSupply(uint256 id) public view virtual returns (uint256) {
        return _totalSupply[id];
    }

    /**
     * @dev Indicates whether any token exist with a given id, or not.
     */
    function exists(uint256 id) public view virtual returns (bool) {
        return ERC1155Supply.totalSupply(id) > 0;
    }

    /**
     * @dev See {ERC1155-_beforeTokenTransfer}.
     */
    function _beforeTokenTransfer(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual override {
        super._beforeTokenTransfer(operator, from, to, ids, amounts, data);

        if (from == address(0)) {
            for (uint256 i = 0; i < ids.length; ++i) {
                _totalSupply[ids[i]] += amounts[i];
            }
        }

        if (to == address(0)) {
            for (uint256 i = 0; i < ids.length; ++i) {
                uint256 id = ids[i];
                uint256 amount = amounts[i];
                uint256 supply = _totalSupply[id];
                require(supply >= amount, "ERC1155: burn amount exceeds totalSupply");
                unchecked {
                    _totalSupply[id] = supply - amount;
                }
            }
        }
    }
}

File 7 of 20 : IERC1155MetadataURI.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol)

pragma solidity ^0.8.0;

import "../IERC1155.sol";

/**
 * @dev Interface of the optional ERC1155MetadataExtension interface, as defined
 * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP].
 *
 * _Available since v3.1._
 */
interface IERC1155MetadataURI is IERC1155 {
    /**
     * @dev Returns the URI for token type `id`.
     *
     * If the `\{id\}` substring is present in the URI, it must be replaced by
     * clients with the actual token type ID.
     */
    function uri(uint256 id) external view returns (string memory);
}

File 8 of 20 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

File 9 of 20 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

File 10 of 20 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [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
                /// @solidity memory-safe-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 11 of 20 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

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 12 of 20 : Counters.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)

pragma solidity ^0.8.0;

/**
 * @title Counters
 * @author Matt Condon (@shrugs)
 * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number
 * of elements in a mapping, issuing ERC721 ids, or counting request ids.
 *
 * Include with `using Counters for Counters.Counter;`
 */
library Counters {
    struct Counter {
        // This variable should never be directly accessed by users of the library: interactions must be restricted to
        // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
        // this feature: see https://github.com/ethereum/solidity/issues/4637
        uint256 _value; // default: 0
    }

    function current(Counter storage counter) internal view returns (uint256) {
        return counter._value;
    }

    function increment(Counter storage counter) internal {
        unchecked {
            counter._value += 1;
        }
    }

    function decrement(Counter storage counter) internal {
        uint256 value = counter._value;
        require(value > 0, "Counter: decrement overflow");
        unchecked {
            counter._value = value - 1;
        }
    }

    function reset(Counter storage counter) internal {
        counter._value = 0;
    }
}

File 13 of 20 : ERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

File 14 of 20 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

File 15 of 20 : IUniswapV3SwapCallback.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.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 16 of 20 : IPeripheryPayments.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;

/// @title Periphery Payments
/// @notice Functions to ease deposits and withdrawals of ETH
interface IPeripheryPayments {
    /// @notice Unwraps the contract's WETH9 balance and sends it to recipient as ETH.
    /// @dev The amountMinimum parameter prevents malicious contracts from stealing WETH9 from users.
    /// @param amountMinimum The minimum amount of WETH9 to unwrap
    /// @param recipient The address receiving ETH
    function unwrapWETH9(uint256 amountMinimum, address recipient) external payable;

    /// @notice Refunds any ETH balance held by this contract to the `msg.sender`
    /// @dev Useful for bundling with mint or increase liquidity that uses ether, or exact output swaps
    /// that use ether for the input amount
    function refundETH() external payable;

    /// @notice Transfers the full amount of a token held by this contract to recipient
    /// @dev The amountMinimum parameter prevents malicious contracts from stealing the token from users
    /// @param token The contract address of the token which will be transferred to `recipient`
    /// @param amountMinimum The minimum amount of token required for a transfer
    /// @param recipient The destination address of the token
    function sweepToken(
        address token,
        uint256 amountMinimum,
        address recipient
    ) external payable;
}

File 17 of 20 : ISwapRouter.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;

import '@uniswap/v3-core/contracts/interfaces/callback/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);
}

File 18 of 20 : TransferHelper.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.6.0;

import '@openzeppelin/contracts/token/ERC20/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 19 of 20 : NftBond.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;

import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Supply.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";

error AlreadyInitialized();
error OnlyController();
error NotExistingToken();
error NotDivisibleByUnit();
error ZeroBalance();

/**
 * tokenId is projectId
 */
contract NftBond is ERC1155Supply, Ownable {
    /**
     * stores how much one unit worths. We use USDC, so if a unit is $10, it is 10.
     */
    mapping(uint256 => uint256) private _unit;
    mapping(uint256 => string) private _uri;

    address public controller;
    uint256 public tokenIdCounter;

    /**
     * Events.
     */
    event InitProject(string _uri_, uint256 _unit_);
    event CreateLoan(uint256 _tokenId, uint256 _principal, address _account);
    event Redeem(uint256 _tokenId, address _account, uint256 _tokenBalance);

    /**
     * Constructor.
     */

    constructor() ERC1155("") {}

    function unit(uint256 tokenId) public view returns (uint256) {
        return _unit[tokenId];
    }

    function init(address controller_) external onlyOwner {
        if (controller != address(0)) revert AlreadyInitialized();

        controller = controller_;
    }

    function updateController(address controller_) external onlyOwner {
        controller = controller_;
    }

    function initProject(string memory uri_, uint256 unit_)
        external
        onlyController
    {
        uint256 tokenId = tokenIdCounter;
        _setURI(tokenId, uri_);
        _setUnit(tokenId, unit_);
        _tokenIdIncrement();

        emit InitProject(uri_, unit_);
    }

    function uri(uint256 tokenId) public view override returns (string memory) {
        return _uri[tokenId];
    }

    /**
     * @notice Mint tokens corresponding amount to unit value
     * @param tokenId id of the project
     * @param principal the total value of tokens user want to mint
     */
    function createLoan(
        uint256 tokenId,
        uint256 principal,
        address account
    ) external onlyController {
        uint256 unit_ = _unit[tokenId];
        if (principal % unit_ != 0) revert NotDivisibleByUnit();

        _mint(account, tokenId, principal / unit_, "");

        emit CreateLoan(tokenId, principal, account);
    }

    // amount is necessary for fractional redemption.
    function redeem(
        uint256 tokenId,
        address account,
        uint256 tokenBalance
    ) external onlyController {
        if (balanceOf(account, tokenId) == 0) revert ZeroBalance();

        _burn(account, tokenId, tokenBalance);

        emit Redeem(tokenId, account, tokenBalance);
    }

    function setURI(uint256 tokenId, string memory uri_) external onlyOwner {
        _setURI(tokenId, uri_);
    }

    function _tokenIdIncrement() internal {
        tokenIdCounter++;
    }

    function _setURI(uint256 tokenId, string memory uri_) private {
        _uri[tokenId] = uri_;
    }

    function _setUnit(uint256 tokenId, uint256 unit_) private {
        _unit[tokenId] = unit_;
    }

    modifier onlyController() {
        if (msg.sender != controller) revert OnlyController();
        _;
    }
}

File 20 of 20 : SwapHelper.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.11;
import "@uniswap/v3-periphery/contracts/libraries/TransferHelper.sol";
import "@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol";
import "@uniswap/v3-periphery/contracts/interfaces/IPeripheryPayments.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";

interface ISwapHelper {
    function swapExactOutputSingle(uint256 amountOut) external payable;
}

contract SwapHelper is ISwapHelper {
    address public router;
    address public usdc;
    address public weth;
    uint256 public decimal;

    constructor(
        address router_,
        address usdc_,
        address weth_
    ) {
        router = router_;
        usdc = usdc_;
        weth = weth_;

        decimal = IERC20Metadata(usdc_).decimals();
    }

    /*
    address public constant WETH9 = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
    address public constant USDC = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
    // NOTE: Does not work with SwapRouter02
    address public constant swapRouter =
        0xE592427A0AEce92De3Edee1F18E0157C05861564;
    */

    /// @notice swaps a minimum possible amount of WETH for a fixed amount of USDC.
    ///         This contract receives the output USDC to use later operations.
    function swapExactOutputSingle(uint256 amountOut) public payable {
        require(amountOut > 0, "Must pass non 0 DAI amount");
        require(msg.value > 0, "Must pass non 0 ETH amount");
        uint256 amountInMaximum = msg.value;

        ISwapRouter.ExactOutputSingleParams memory params = ISwapRouter
            .ExactOutputSingleParams({
                tokenIn: weth,
                tokenOut: usdc,
                fee: 500, // pool fee to 0.05%.
                recipient: address(this),
                deadline: block.timestamp,
                amountOut: amountOut,
                amountInMaximum: amountInMaximum,
                sqrtPriceLimitX96: 0
            });

        ISwapRouter(router).exactOutputSingle{value: msg.value}(params);
        IPeripheryPayments(router).refundETH();

        // refund leftover ETH to user
        (bool success, ) = msg.sender.call{value: address(this).balance}("");
        require(success, "refund failed");
    }

    receive() external payable {}
}

Settings
{
  "evmVersion": "london",
  "libraries": {},
  "metadata": {
    "bytecodeHash": "ipfs",
    "useLiteralContent": true
  },
  "optimizer": {
    "enabled": false,
    "runs": 200
  },
  "remappings": [],
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  }
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"contract NftBond","name":"nft_","type":"address"},{"internalType":"address","name":"router_","type":"address"},{"internalType":"address","name":"usdc_","type":"address"},{"internalType":"address","name":"weth_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AlreadyBorrowed","type":"error"},{"inputs":[],"name":"Borrow_DepositNotEnded","type":"error"},{"inputs":[],"name":"Deposit_Ended","type":"error"},{"inputs":[],"name":"Deposit_ExceededTotalAmount","type":"error"},{"inputs":[],"name":"Deposit_NotDivisibleByDecimals","type":"error"},{"inputs":[],"name":"Deposit_NotStarted","type":"error"},{"inputs":[],"name":"InitProject_InvalidTimestampInput","type":"error"},{"inputs":[],"name":"InitProject_InvalidTotalAmountInput","type":"error"},{"inputs":[],"name":"NotExistingProject","type":"error"},{"inputs":[],"name":"Repay_AlreadyDepositted","type":"error"},{"inputs":[],"name":"Repay_DepositNotEnded","type":"error"},{"inputs":[],"name":"Repay_NotEnoughAmountInput","type":"error"},{"inputs":[],"name":"Withdraw_NotRepayedProject","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_borrower","type":"address"},{"indexed":true,"internalType":"uint256","name":"_projectId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"Borrowed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_totalAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_depositStartTs","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_depositEndTs","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_unit","type":"uint256"},{"indexed":false,"internalType":"string","name":"_uri","type":"string"}],"name":"Controller_NewProject","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_depositor","type":"address"},{"indexed":true,"internalType":"uint256","name":"_projectId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"Deposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_repayer","type":"address"},{"indexed":true,"internalType":"uint256","name":"_projectId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"Repaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_withdrawer","type":"address"},{"indexed":true,"internalType":"uint256","name":"_projectId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"Withdrawed","type":"event"},{"inputs":[{"internalType":"uint256","name":"projectId","type":"uint256"}],"name":"borrow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimal","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"projectId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"totalAmount","type":"uint256"},{"internalType":"uint256","name":"depositStartTs","type":"uint256"},{"internalType":"uint256","name":"depositEndTs","type":"uint256"},{"internalType":"uint256","name":"unit","type":"uint256"},{"internalType":"string","name":"uri","type":"string"}],"name":"initProject","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"nft","outputs":[{"internalType":"contract NftBond","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"projects","outputs":[{"internalType":"uint256","name":"totalAmount","type":"uint256"},{"internalType":"uint256","name":"currentAmount","type":"uint256"},{"internalType":"uint256","name":"depositStartTs","type":"uint256"},{"internalType":"uint256","name":"depositEndTs","type":"uint256"},{"internalType":"uint256","name":"finalAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"projectId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"repay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"router","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"}],"name":"swapExactOutputSingle","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"usdc","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"weth","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"projectId","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

60806040523480156200001157600080fd5b5060405162002bea38038062002bea833981810160405281019062000037919062000361565b8282826200005a6200004e620001e660201b60201c565b620001ee60201b60201c565b82600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000169573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200018f919062000411565b60ff1660048190555050505083600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050505062000443565b600033905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620002e482620002b7565b9050919050565b6000620002f882620002d7565b9050919050565b6200030a81620002eb565b81146200031657600080fd5b50565b6000815190506200032a81620002ff565b92915050565b6200033b81620002d7565b81146200034757600080fd5b50565b6000815190506200035b8162000330565b92915050565b600080600080608085870312156200037e576200037d620002b2565b5b60006200038e8782880162000319565b9450506020620003a1878288016200034a565b9350506040620003b4878288016200034a565b9250506060620003c7878288016200034a565b91505092959194509250565b600060ff82169050919050565b620003eb81620003d3565b8114620003f757600080fd5b50565b6000815190506200040b81620003e0565b92915050565b6000602082840312156200042a5762000429620002b2565b5b60006200043a84828501620003fa565b91505092915050565b61279780620004536000396000f3fe6080604052600436106100ec5760003560e01c806376809ce31161008a578063d8aed14511610059578063d8aed145146102be578063e2bbb158146102e7578063f2fde38b14610303578063f887ea401461032c576100f3565b806376809ce314610223578063889ad54c1461024e5780638da5cb5b1461026a578063c5ebeaec14610295576100f3565b80633fc8cef3116100c65780633fc8cef31461018d578063452f8f04146101b857806347ccca02146101e1578063715018a61461020c576100f3565b8063107046bd146100f85780632e1a7d4d146101395780633e413bee14610162576100f3565b366100f357005b600080fd5b34801561010457600080fd5b5061011f600480360381019061011a9190611906565b610357565b604051610130959493929190611942565b60405180910390f35b34801561014557600080fd5b50610160600480360381019061015b9190611906565b61038d565b005b34801561016e57600080fd5b5061017761060e565b60405161018491906119d6565b60405180910390f35b34801561019957600080fd5b506101a2610634565b6040516101af91906119d6565b60405180910390f35b3480156101c457600080fd5b506101df60048036038101906101da9190611b37565b61065a565b005b3480156101ed57600080fd5b506101f66108c5565b6040516102039190611c2d565b60405180910390f35b34801561021857600080fd5b506102216108eb565b005b34801561022f57600080fd5b506102386108ff565b6040516102459190611c48565b60405180910390f35b61026860048036038101906102639190611906565b610905565b005b34801561027657600080fd5b5061027f610c46565b60405161028c91906119d6565b60405180910390f35b3480156102a157600080fd5b506102bc60048036038101906102b79190611906565b610c6f565b005b3480156102ca57600080fd5b506102e560048036038101906102e09190611c63565b610e5e565b005b61030160048036038101906102fc9190611c63565b611068565b005b34801561030f57600080fd5b5061032a60048036038101906103259190611ccf565b611329565b005b34801561033857600080fd5b506103416113ad565b60405161034e91906119d6565b60405180910390f35b60066020528060005260406000206000915090508060000154908060010154908060020154908060030154908060040154905085565b60006006600083815260200190815260200160002090506000816002015414156103e3576040517f8652b88000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600081600401541415610422576040517fd7c09c7c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1662fdd58e33856040518363ffffffff1660e01b8152600401610480929190611cfc565b602060405180830381865afa15801561049d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104c19190611d3a565b905060006104cf84836113d3565b9050600083600001548285600401546104e89190611d96565b6104f29190611e1f565b9050808460010160008282546105089190611e50565b9250508190555061053c600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1633836114a2565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663d87801618633866040518463ffffffff1660e01b815260040161059b93929190611e84565b600060405180830381600087803b1580156105b557600080fd5b505af11580156105c9573d6000803e3d6000fd5b50505050847f4cdcd27ae88503b2d4d3034a348b78aec00eca6369f48e5002ca3df8686b9b3e33836040516105ff929190611cfc565b60405180910390a25050505050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6106626115f7565b42831115806106715750838311155b156106a8576040517f177392d000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008514156106e3576040517f9077f15900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006040518060a0016040528087815260200160008152602001868152602001858152602001600081525090506000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166398bdf6f56040518163ffffffff1660e01b8152600401602060405180830381865afa15801561077f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107a39190611d3a565b905081600660008381526020019081526020016000206000820151816000015560208201518160010155604082015181600201556060820151816003015560808201518160040155905050600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f6c5feb984866040518363ffffffff1660e01b815260040161084b929190611f43565b600060405180830381600087803b15801561086557600080fd5b505af1158015610879573d6000803e3d6000fd5b505050507f1811d209632cdd903e0705320ebbc0e3540f728b32f874b8338e47e3a148e3d587878787876040516108b4959493929190611f73565b60405180910390a150505050505050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6108f36115f7565b6108fd6000611675565b565b60045481565b60008111610948576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161093f90612019565b60405180910390fd5b6000341161098b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161098290612085565b60405180910390fd5b60003490506000604051806101000160405280600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016101f462ffffff1681526020013073ffffffffffffffffffffffffffffffffffffffff168152602001428152602001848152602001838152602001600073ffffffffffffffffffffffffffffffffffffffff168152509050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663db3e219834836040518363ffffffff1660e01b8152600401610ace9190612192565b60206040518083038185885af1158015610aec573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610b119190611d3a565b50600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166312210e8a6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610b7c57600080fd5b505af1158015610b90573d6000803e3d6000fd5b5050505060003373ffffffffffffffffffffffffffffffffffffffff1647604051610bba906121df565b60006040518083038185875af1925050503d8060008114610bf7576040519150601f19603f3d011682016040523d82523d6000602084013e610bfc565b606091505b5050905080610c40576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c3790612240565b60405180910390fd5b50505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b610c776115f7565b6000600660008381526020019081526020016000209050600081600201541415610ccd576040517f8652b88000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806003015442108015610ce857508060000154816001015414155b15610d1f576040517fd12b230800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600081600101541415610d5e576040517f467f208e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060010154816000018190555060008160010154905060008260010181905550600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33836040518363ffffffff1660e01b8152600401610ddb929190611cfc565b6020604051808303816000875af1158015610dfa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e1e9190612298565b50827feae9cfbc77fdd40ca899f36b608256063b2bc9d8178b0220f7ad513e178d67303383604051610e51929190611cfc565b60405180910390a2505050565b610e666115f7565b60006006600084815260200190815260200160002090506000816004015414610ebb576040517fefe994fa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600081600201541415610efa576040517f8652b88000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060000154821015610f38576040517f821ca7c200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b4281600301541115610f76576040517f29d003f300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b81816001018190558160040181905550600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3330856040518463ffffffff1660e01b8152600401610fe5939291906122c5565b6020604051808303816000875af1158015611004573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110289190612298565b50827f1b8cd61ed43bec7c6bdad3a18ffee613f99c853d16c50678d248d879e1b43438338460405161105b929190611cfc565b60405180910390a2505050565b60006006600084815260200190815260200160002090506000816002015414156110be576040517f8652b88000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80600201544210156110fc576040517fb13fef1900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b42816003015411611139576040517feaf1d1c500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806000015482826001015461114e91906122fc565b1115611186576040517fe680a04700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000600454600a6111979190612485565b836111a291906124d0565b146111d9576040517f72f51f5100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b816006600085815260200190815260200160002060010160008282546111ff91906122fc565b925050819055506000341461121c5761121782610905565b61124b565b61124a600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16333085611739565b5b600061125683611891565b9050600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dc4cab0c8583336040518463ffffffff1660e01b81526004016112b793929190612501565b600060405180830381600087803b1580156112d157600080fd5b505af11580156112e5573d6000803e3d6000fd5b50505050837f73a19dd210f1a7f902193214c0ee91dd35ee5b4d920cba8d519eca65a7b488ca338560405161131b929190611cfc565b60405180910390a250505050565b6113316115f7565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156113a1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611398906125aa565b60405180910390fd5b6113aa81611675565b50565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663e00508ba856040518263ffffffff1660e01b81526004016114319190611c48565b602060405180830381865afa15801561144e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114729190611d3a565b9050600454600a6114839190612485565b818461148f9190611d96565b6114999190611d96565b91505092915050565b6000808473ffffffffffffffffffffffffffffffffffffffff1663a9059cbb60e01b85856040516024016114d7929190611cfc565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516115419190612606565b6000604051808303816000865af19150503d806000811461157e576040519150601f19603f3d011682016040523d82523d6000602084013e611583565b606091505b50915091508180156115b157506000815114806115b05750808060200190518101906115af9190612298565b5b5b6115f0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115e790612669565b60405180910390fd5b5050505050565b6115ff6118b4565b73ffffffffffffffffffffffffffffffffffffffff1661161d610c46565b73ffffffffffffffffffffffffffffffffffffffff1614611673576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161166a906126d5565b60405180910390fd5b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6000808573ffffffffffffffffffffffffffffffffffffffff166323b872dd60e01b868686604051602401611770939291906122c5565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516117da9190612606565b6000604051808303816000865af19150503d8060008114611817576040519150601f19603f3d011682016040523d82523d6000602084013e61181c565b606091505b509150915081801561184a57506000815114806118495750808060200190518101906118489190612298565b5b5b611889576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161188090612741565b60405180910390fd5b505050505050565b6000600454600a6118a29190612485565b826118ad9190611e1f565b9050919050565b600033905090565b6000604051905090565b600080fd5b600080fd5b6000819050919050565b6118e3816118d0565b81146118ee57600080fd5b50565b600081359050611900816118da565b92915050565b60006020828403121561191c5761191b6118c6565b5b600061192a848285016118f1565b91505092915050565b61193c816118d0565b82525050565b600060a0820190506119576000830188611933565b6119646020830187611933565b6119716040830186611933565b61197e6060830185611933565b61198b6080830184611933565b9695505050505050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006119c082611995565b9050919050565b6119d0816119b5565b82525050565b60006020820190506119eb60008301846119c7565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b611a44826119fb565b810181811067ffffffffffffffff82111715611a6357611a62611a0c565b5b80604052505050565b6000611a766118bc565b9050611a828282611a3b565b919050565b600067ffffffffffffffff821115611aa257611aa1611a0c565b5b611aab826119fb565b9050602081019050919050565b82818337600083830152505050565b6000611ada611ad584611a87565b611a6c565b905082815260208101848484011115611af657611af56119f6565b5b611b01848285611ab8565b509392505050565b600082601f830112611b1e57611b1d6119f1565b5b8135611b2e848260208601611ac7565b91505092915050565b600080600080600060a08688031215611b5357611b526118c6565b5b6000611b61888289016118f1565b9550506020611b72888289016118f1565b9450506040611b83888289016118f1565b9350506060611b94888289016118f1565b925050608086013567ffffffffffffffff811115611bb557611bb46118cb565b5b611bc188828901611b09565b9150509295509295909350565b6000819050919050565b6000611bf3611bee611be984611995565b611bce565b611995565b9050919050565b6000611c0582611bd8565b9050919050565b6000611c1782611bfa565b9050919050565b611c2781611c0c565b82525050565b6000602082019050611c426000830184611c1e565b92915050565b6000602082019050611c5d6000830184611933565b92915050565b60008060408385031215611c7a57611c796118c6565b5b6000611c88858286016118f1565b9250506020611c99858286016118f1565b9150509250929050565b611cac816119b5565b8114611cb757600080fd5b50565b600081359050611cc981611ca3565b92915050565b600060208284031215611ce557611ce46118c6565b5b6000611cf384828501611cba565b91505092915050565b6000604082019050611d1160008301856119c7565b611d1e6020830184611933565b9392505050565b600081519050611d34816118da565b92915050565b600060208284031215611d5057611d4f6118c6565b5b6000611d5e84828501611d25565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000611da1826118d0565b9150611dac836118d0565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615611de557611de4611d67565b5b828202905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000611e2a826118d0565b9150611e35836118d0565b925082611e4557611e44611df0565b5b828204905092915050565b6000611e5b826118d0565b9150611e66836118d0565b925082821015611e7957611e78611d67565b5b828203905092915050565b6000606082019050611e996000830186611933565b611ea660208301856119c7565b611eb36040830184611933565b949350505050565b600081519050919050565b600082825260208201905092915050565b60005b83811015611ef5578082015181840152602081019050611eda565b83811115611f04576000848401525b50505050565b6000611f1582611ebb565b611f1f8185611ec6565b9350611f2f818560208601611ed7565b611f38816119fb565b840191505092915050565b60006040820190508181036000830152611f5d8185611f0a565b9050611f6c6020830184611933565b9392505050565b600060a082019050611f886000830188611933565b611f956020830187611933565b611fa26040830186611933565b611faf6060830185611933565b8181036080830152611fc18184611f0a565b90509695505050505050565b7f4d7573742070617373206e6f6e20302044414920616d6f756e74000000000000600082015250565b6000612003601a83611ec6565b915061200e82611fcd565b602082019050919050565b6000602082019050818103600083015261203281611ff6565b9050919050565b7f4d7573742070617373206e6f6e20302045544820616d6f756e74000000000000600082015250565b600061206f601a83611ec6565b915061207a82612039565b602082019050919050565b6000602082019050818103600083015261209e81612062565b9050919050565b6120ae816119b5565b82525050565b600062ffffff82169050919050565b6120cc816120b4565b82525050565b6120db816118d0565b82525050565b6120ea81611995565b82525050565b6101008201600082015161210760008501826120a5565b50602082015161211a60208501826120a5565b50604082015161212d60408501826120c3565b50606082015161214060608501826120a5565b50608082015161215360808501826120d2565b5060a082015161216660a08501826120d2565b5060c082015161217960c08501826120d2565b5060e082015161218c60e08501826120e1565b50505050565b6000610100820190506121a860008301846120f0565b92915050565b600081905092915050565b50565b60006121c96000836121ae565b91506121d4826121b9565b600082019050919050565b60006121ea826121bc565b9150819050919050565b7f726566756e64206661696c656400000000000000000000000000000000000000600082015250565b600061222a600d83611ec6565b9150612235826121f4565b602082019050919050565b600060208201905081810360008301526122598161221d565b9050919050565b60008115159050919050565b61227581612260565b811461228057600080fd5b50565b6000815190506122928161226c565b92915050565b6000602082840312156122ae576122ad6118c6565b5b60006122bc84828501612283565b91505092915050565b60006060820190506122da60008301866119c7565b6122e760208301856119c7565b6122f46040830184611933565b949350505050565b6000612307826118d0565b9150612312836118d0565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561234757612346611d67565b5b828201905092915050565b60008160011c9050919050565b6000808291508390505b60018511156123a95780860481111561238557612384611d67565b5b60018516156123945780820291505b80810290506123a285612352565b9450612369565b94509492505050565b6000826123c2576001905061247e565b816123d0576000905061247e565b81600181146123e657600281146123f05761241f565b600191505061247e565b60ff84111561240257612401611d67565b5b8360020a91508482111561241957612418611d67565b5b5061247e565b5060208310610133831016604e8410600b84101617156124545782820a90508381111561244f5761244e611d67565b5b61247e565b612461848484600161235f565b9250905081840481111561247857612477611d67565b5b81810290505b9392505050565b6000612490826118d0565b915061249b836118d0565b92506124c87fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff84846123b2565b905092915050565b60006124db826118d0565b91506124e6836118d0565b9250826124f6576124f5611df0565b5b828206905092915050565b60006060820190506125166000830186611933565b6125236020830185611933565b61253060408301846119c7565b949350505050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000612594602683611ec6565b915061259f82612538565b604082019050919050565b600060208201905081810360008301526125c381612587565b9050919050565b600081519050919050565b60006125e0826125ca565b6125ea81856121ae565b93506125fa818560208601611ed7565b80840191505092915050565b600061261282846125d5565b915081905092915050565b7f5354000000000000000000000000000000000000000000000000000000000000600082015250565b6000612653600283611ec6565b915061265e8261261d565b602082019050919050565b6000602082019050818103600083015261268281612646565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b60006126bf602083611ec6565b91506126ca82612689565b602082019050919050565b600060208201905081810360008301526126ee816126b2565b9050919050565b7f5354460000000000000000000000000000000000000000000000000000000000600082015250565b600061272b600383611ec6565b9150612736826126f5565b602082019050919050565b6000602082019050818103600083015261275a8161271e565b905091905056fea2646970667358221220e192b57602bb0f1f8659c87666b62deb5d6af784949054878b93e459fd5e05e064736f6c634300080b0033000000000000000000000000a12243a014ab9d1bc016ba2c1b76ac6a86ae4510000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2

Deployed Bytecode

0x6080604052600436106100ec5760003560e01c806376809ce31161008a578063d8aed14511610059578063d8aed145146102be578063e2bbb158146102e7578063f2fde38b14610303578063f887ea401461032c576100f3565b806376809ce314610223578063889ad54c1461024e5780638da5cb5b1461026a578063c5ebeaec14610295576100f3565b80633fc8cef3116100c65780633fc8cef31461018d578063452f8f04146101b857806347ccca02146101e1578063715018a61461020c576100f3565b8063107046bd146100f85780632e1a7d4d146101395780633e413bee14610162576100f3565b366100f357005b600080fd5b34801561010457600080fd5b5061011f600480360381019061011a9190611906565b610357565b604051610130959493929190611942565b60405180910390f35b34801561014557600080fd5b50610160600480360381019061015b9190611906565b61038d565b005b34801561016e57600080fd5b5061017761060e565b60405161018491906119d6565b60405180910390f35b34801561019957600080fd5b506101a2610634565b6040516101af91906119d6565b60405180910390f35b3480156101c457600080fd5b506101df60048036038101906101da9190611b37565b61065a565b005b3480156101ed57600080fd5b506101f66108c5565b6040516102039190611c2d565b60405180910390f35b34801561021857600080fd5b506102216108eb565b005b34801561022f57600080fd5b506102386108ff565b6040516102459190611c48565b60405180910390f35b61026860048036038101906102639190611906565b610905565b005b34801561027657600080fd5b5061027f610c46565b60405161028c91906119d6565b60405180910390f35b3480156102a157600080fd5b506102bc60048036038101906102b79190611906565b610c6f565b005b3480156102ca57600080fd5b506102e560048036038101906102e09190611c63565b610e5e565b005b61030160048036038101906102fc9190611c63565b611068565b005b34801561030f57600080fd5b5061032a60048036038101906103259190611ccf565b611329565b005b34801561033857600080fd5b506103416113ad565b60405161034e91906119d6565b60405180910390f35b60066020528060005260406000206000915090508060000154908060010154908060020154908060030154908060040154905085565b60006006600083815260200190815260200160002090506000816002015414156103e3576040517f8652b88000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600081600401541415610422576040517fd7c09c7c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1662fdd58e33856040518363ffffffff1660e01b8152600401610480929190611cfc565b602060405180830381865afa15801561049d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104c19190611d3a565b905060006104cf84836113d3565b9050600083600001548285600401546104e89190611d96565b6104f29190611e1f565b9050808460010160008282546105089190611e50565b9250508190555061053c600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1633836114a2565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663d87801618633866040518463ffffffff1660e01b815260040161059b93929190611e84565b600060405180830381600087803b1580156105b557600080fd5b505af11580156105c9573d6000803e3d6000fd5b50505050847f4cdcd27ae88503b2d4d3034a348b78aec00eca6369f48e5002ca3df8686b9b3e33836040516105ff929190611cfc565b60405180910390a25050505050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6106626115f7565b42831115806106715750838311155b156106a8576040517f177392d000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008514156106e3576040517f9077f15900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006040518060a0016040528087815260200160008152602001868152602001858152602001600081525090506000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166398bdf6f56040518163ffffffff1660e01b8152600401602060405180830381865afa15801561077f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107a39190611d3a565b905081600660008381526020019081526020016000206000820151816000015560208201518160010155604082015181600201556060820151816003015560808201518160040155905050600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f6c5feb984866040518363ffffffff1660e01b815260040161084b929190611f43565b600060405180830381600087803b15801561086557600080fd5b505af1158015610879573d6000803e3d6000fd5b505050507f1811d209632cdd903e0705320ebbc0e3540f728b32f874b8338e47e3a148e3d587878787876040516108b4959493929190611f73565b60405180910390a150505050505050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6108f36115f7565b6108fd6000611675565b565b60045481565b60008111610948576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161093f90612019565b60405180910390fd5b6000341161098b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161098290612085565b60405180910390fd5b60003490506000604051806101000160405280600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016101f462ffffff1681526020013073ffffffffffffffffffffffffffffffffffffffff168152602001428152602001848152602001838152602001600073ffffffffffffffffffffffffffffffffffffffff168152509050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663db3e219834836040518363ffffffff1660e01b8152600401610ace9190612192565b60206040518083038185885af1158015610aec573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610b119190611d3a565b50600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166312210e8a6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610b7c57600080fd5b505af1158015610b90573d6000803e3d6000fd5b5050505060003373ffffffffffffffffffffffffffffffffffffffff1647604051610bba906121df565b60006040518083038185875af1925050503d8060008114610bf7576040519150601f19603f3d011682016040523d82523d6000602084013e610bfc565b606091505b5050905080610c40576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c3790612240565b60405180910390fd5b50505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b610c776115f7565b6000600660008381526020019081526020016000209050600081600201541415610ccd576040517f8652b88000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806003015442108015610ce857508060000154816001015414155b15610d1f576040517fd12b230800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600081600101541415610d5e576040517f467f208e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060010154816000018190555060008160010154905060008260010181905550600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33836040518363ffffffff1660e01b8152600401610ddb929190611cfc565b6020604051808303816000875af1158015610dfa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e1e9190612298565b50827feae9cfbc77fdd40ca899f36b608256063b2bc9d8178b0220f7ad513e178d67303383604051610e51929190611cfc565b60405180910390a2505050565b610e666115f7565b60006006600084815260200190815260200160002090506000816004015414610ebb576040517fefe994fa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600081600201541415610efa576040517f8652b88000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060000154821015610f38576040517f821ca7c200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b4281600301541115610f76576040517f29d003f300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b81816001018190558160040181905550600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3330856040518463ffffffff1660e01b8152600401610fe5939291906122c5565b6020604051808303816000875af1158015611004573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110289190612298565b50827f1b8cd61ed43bec7c6bdad3a18ffee613f99c853d16c50678d248d879e1b43438338460405161105b929190611cfc565b60405180910390a2505050565b60006006600084815260200190815260200160002090506000816002015414156110be576040517f8652b88000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80600201544210156110fc576040517fb13fef1900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b42816003015411611139576040517feaf1d1c500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806000015482826001015461114e91906122fc565b1115611186576040517fe680a04700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000600454600a6111979190612485565b836111a291906124d0565b146111d9576040517f72f51f5100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b816006600085815260200190815260200160002060010160008282546111ff91906122fc565b925050819055506000341461121c5761121782610905565b61124b565b61124a600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16333085611739565b5b600061125683611891565b9050600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dc4cab0c8583336040518463ffffffff1660e01b81526004016112b793929190612501565b600060405180830381600087803b1580156112d157600080fd5b505af11580156112e5573d6000803e3d6000fd5b50505050837f73a19dd210f1a7f902193214c0ee91dd35ee5b4d920cba8d519eca65a7b488ca338560405161131b929190611cfc565b60405180910390a250505050565b6113316115f7565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156113a1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611398906125aa565b60405180910390fd5b6113aa81611675565b50565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663e00508ba856040518263ffffffff1660e01b81526004016114319190611c48565b602060405180830381865afa15801561144e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114729190611d3a565b9050600454600a6114839190612485565b818461148f9190611d96565b6114999190611d96565b91505092915050565b6000808473ffffffffffffffffffffffffffffffffffffffff1663a9059cbb60e01b85856040516024016114d7929190611cfc565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516115419190612606565b6000604051808303816000865af19150503d806000811461157e576040519150601f19603f3d011682016040523d82523d6000602084013e611583565b606091505b50915091508180156115b157506000815114806115b05750808060200190518101906115af9190612298565b5b5b6115f0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115e790612669565b60405180910390fd5b5050505050565b6115ff6118b4565b73ffffffffffffffffffffffffffffffffffffffff1661161d610c46565b73ffffffffffffffffffffffffffffffffffffffff1614611673576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161166a906126d5565b60405180910390fd5b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6000808573ffffffffffffffffffffffffffffffffffffffff166323b872dd60e01b868686604051602401611770939291906122c5565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516117da9190612606565b6000604051808303816000865af19150503d8060008114611817576040519150601f19603f3d011682016040523d82523d6000602084013e61181c565b606091505b509150915081801561184a57506000815114806118495750808060200190518101906118489190612298565b5b5b611889576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161188090612741565b60405180910390fd5b505050505050565b6000600454600a6118a29190612485565b826118ad9190611e1f565b9050919050565b600033905090565b6000604051905090565b600080fd5b600080fd5b6000819050919050565b6118e3816118d0565b81146118ee57600080fd5b50565b600081359050611900816118da565b92915050565b60006020828403121561191c5761191b6118c6565b5b600061192a848285016118f1565b91505092915050565b61193c816118d0565b82525050565b600060a0820190506119576000830188611933565b6119646020830187611933565b6119716040830186611933565b61197e6060830185611933565b61198b6080830184611933565b9695505050505050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006119c082611995565b9050919050565b6119d0816119b5565b82525050565b60006020820190506119eb60008301846119c7565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b611a44826119fb565b810181811067ffffffffffffffff82111715611a6357611a62611a0c565b5b80604052505050565b6000611a766118bc565b9050611a828282611a3b565b919050565b600067ffffffffffffffff821115611aa257611aa1611a0c565b5b611aab826119fb565b9050602081019050919050565b82818337600083830152505050565b6000611ada611ad584611a87565b611a6c565b905082815260208101848484011115611af657611af56119f6565b5b611b01848285611ab8565b509392505050565b600082601f830112611b1e57611b1d6119f1565b5b8135611b2e848260208601611ac7565b91505092915050565b600080600080600060a08688031215611b5357611b526118c6565b5b6000611b61888289016118f1565b9550506020611b72888289016118f1565b9450506040611b83888289016118f1565b9350506060611b94888289016118f1565b925050608086013567ffffffffffffffff811115611bb557611bb46118cb565b5b611bc188828901611b09565b9150509295509295909350565b6000819050919050565b6000611bf3611bee611be984611995565b611bce565b611995565b9050919050565b6000611c0582611bd8565b9050919050565b6000611c1782611bfa565b9050919050565b611c2781611c0c565b82525050565b6000602082019050611c426000830184611c1e565b92915050565b6000602082019050611c5d6000830184611933565b92915050565b60008060408385031215611c7a57611c796118c6565b5b6000611c88858286016118f1565b9250506020611c99858286016118f1565b9150509250929050565b611cac816119b5565b8114611cb757600080fd5b50565b600081359050611cc981611ca3565b92915050565b600060208284031215611ce557611ce46118c6565b5b6000611cf384828501611cba565b91505092915050565b6000604082019050611d1160008301856119c7565b611d1e6020830184611933565b9392505050565b600081519050611d34816118da565b92915050565b600060208284031215611d5057611d4f6118c6565b5b6000611d5e84828501611d25565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000611da1826118d0565b9150611dac836118d0565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615611de557611de4611d67565b5b828202905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000611e2a826118d0565b9150611e35836118d0565b925082611e4557611e44611df0565b5b828204905092915050565b6000611e5b826118d0565b9150611e66836118d0565b925082821015611e7957611e78611d67565b5b828203905092915050565b6000606082019050611e996000830186611933565b611ea660208301856119c7565b611eb36040830184611933565b949350505050565b600081519050919050565b600082825260208201905092915050565b60005b83811015611ef5578082015181840152602081019050611eda565b83811115611f04576000848401525b50505050565b6000611f1582611ebb565b611f1f8185611ec6565b9350611f2f818560208601611ed7565b611f38816119fb565b840191505092915050565b60006040820190508181036000830152611f5d8185611f0a565b9050611f6c6020830184611933565b9392505050565b600060a082019050611f886000830188611933565b611f956020830187611933565b611fa26040830186611933565b611faf6060830185611933565b8181036080830152611fc18184611f0a565b90509695505050505050565b7f4d7573742070617373206e6f6e20302044414920616d6f756e74000000000000600082015250565b6000612003601a83611ec6565b915061200e82611fcd565b602082019050919050565b6000602082019050818103600083015261203281611ff6565b9050919050565b7f4d7573742070617373206e6f6e20302045544820616d6f756e74000000000000600082015250565b600061206f601a83611ec6565b915061207a82612039565b602082019050919050565b6000602082019050818103600083015261209e81612062565b9050919050565b6120ae816119b5565b82525050565b600062ffffff82169050919050565b6120cc816120b4565b82525050565b6120db816118d0565b82525050565b6120ea81611995565b82525050565b6101008201600082015161210760008501826120a5565b50602082015161211a60208501826120a5565b50604082015161212d60408501826120c3565b50606082015161214060608501826120a5565b50608082015161215360808501826120d2565b5060a082015161216660a08501826120d2565b5060c082015161217960c08501826120d2565b5060e082015161218c60e08501826120e1565b50505050565b6000610100820190506121a860008301846120f0565b92915050565b600081905092915050565b50565b60006121c96000836121ae565b91506121d4826121b9565b600082019050919050565b60006121ea826121bc565b9150819050919050565b7f726566756e64206661696c656400000000000000000000000000000000000000600082015250565b600061222a600d83611ec6565b9150612235826121f4565b602082019050919050565b600060208201905081810360008301526122598161221d565b9050919050565b60008115159050919050565b61227581612260565b811461228057600080fd5b50565b6000815190506122928161226c565b92915050565b6000602082840312156122ae576122ad6118c6565b5b60006122bc84828501612283565b91505092915050565b60006060820190506122da60008301866119c7565b6122e760208301856119c7565b6122f46040830184611933565b949350505050565b6000612307826118d0565b9150612312836118d0565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561234757612346611d67565b5b828201905092915050565b60008160011c9050919050565b6000808291508390505b60018511156123a95780860481111561238557612384611d67565b5b60018516156123945780820291505b80810290506123a285612352565b9450612369565b94509492505050565b6000826123c2576001905061247e565b816123d0576000905061247e565b81600181146123e657600281146123f05761241f565b600191505061247e565b60ff84111561240257612401611d67565b5b8360020a91508482111561241957612418611d67565b5b5061247e565b5060208310610133831016604e8410600b84101617156124545782820a90508381111561244f5761244e611d67565b5b61247e565b612461848484600161235f565b9250905081840481111561247857612477611d67565b5b81810290505b9392505050565b6000612490826118d0565b915061249b836118d0565b92506124c87fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff84846123b2565b905092915050565b60006124db826118d0565b91506124e6836118d0565b9250826124f6576124f5611df0565b5b828206905092915050565b60006060820190506125166000830186611933565b6125236020830185611933565b61253060408301846119c7565b949350505050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000612594602683611ec6565b915061259f82612538565b604082019050919050565b600060208201905081810360008301526125c381612587565b9050919050565b600081519050919050565b60006125e0826125ca565b6125ea81856121ae565b93506125fa818560208601611ed7565b80840191505092915050565b600061261282846125d5565b915081905092915050565b7f5354000000000000000000000000000000000000000000000000000000000000600082015250565b6000612653600283611ec6565b915061265e8261261d565b602082019050919050565b6000602082019050818103600083015261268281612646565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b60006126bf602083611ec6565b91506126ca82612689565b602082019050919050565b600060208201905081810360008301526126ee816126b2565b9050919050565b7f5354460000000000000000000000000000000000000000000000000000000000600082015250565b600061272b600383611ec6565b9150612736826126f5565b602082019050919050565b6000602082019050818103600083015261275a8161271e565b905091905056fea2646970667358221220e192b57602bb0f1f8659c87666b62deb5d6af784949054878b93e459fd5e05e064736f6c634300080b0033

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

000000000000000000000000a12243a014ab9d1bc016ba2c1b76ac6a86ae4510000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2

-----Decoded View---------------
Arg [0] : nft_ (address): 0xA12243a014Ab9d1bC016BA2c1b76AC6a86aE4510
Arg [1] : router_ (address): 0xE592427A0AEce92De3Edee1F18E0157C05861564
Arg [2] : usdc_ (address): 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
Arg [3] : weth_ (address): 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2

-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 000000000000000000000000a12243a014ab9d1bc016ba2c1b76ac6a86ae4510
Arg [1] : 000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564
Arg [2] : 000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48
Arg [3] : 000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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