ETH Price: $2,606.57 (-0.38%)

Token

 

Overview

Max Total Supply

0

Holders

4

Market

Volume (24H)

N/A

Min Price (24H)

N/A

Max Price (24H)

N/A
0x9e0bf7fd04960e337298175b0ab1b1d5efc69b78
Loading...
Loading
Loading...
Loading
Loading...
Loading

Click here to update the token information / general information
# Exchange Pair Price  24H Volume % Volume

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

Contract Name:
HodlMultiToken

Compiler Version
v0.8.20+commit.a1b79de6

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion
File 1 of 26 : HodlMultiToken.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import "@openzeppelin/contracts/utils/Strings.sol";
import { ERC1155 } from "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import { Ownable } from  "@openzeppelin/contracts/access/Ownable.sol";

import { Vault } from "../Vault.sol";
import { YMultiToken } from "./YMultiToken.sol";

contract HodlMultiToken is ERC1155, Ownable {

    uint256 public nextId = 1;
    mapping(uint256 => uint256) public totalSupply;
    mapping(address => bool) public authorized;

    // Events
    event Authorize(address indexed user);

    event Mint(address indexed user,
               uint256 indexed strike,
               uint256 amount);

    event Burn(address indexed user,
               uint256 indexed strike,
               uint256 amount);

    constructor(string memory uri_) ERC1155(uri_) Ownable(msg.sender) { }

    function name(uint256 strike) public view virtual returns (string memory) {
        if (strike % 1e8 == 0) {
            return string(abi.encodePacked("plETH @ ", Strings.toString(strike / 1e8)));
        } else {
            return string(abi.encodePacked("plETH @ ", Strings.toString(strike)));
        }
    }

    function symbol(uint256 strike) public view virtual returns (string memory) {
        return name(strike);
    }

    // authorize enables another contract to transfer tokens between accounts.
    // This is for use by deployed ERC20 tokens. See src/single/HodlToken.sol.
    function authorize(address operator) public onlyOwner {
        authorized[operator] = true;

        emit Authorize(operator);
    }

    function safeTransferFrom(address from,
                              address to,
                              uint256 strike,
                              uint256 amount,
                              bytes memory) public override {

        require(to != from, "hodl self transfer");
        require(amount > 0, "hodl zero value transfer");

        if (to == address(0)) {
            revert ERC1155InvalidReceiver(address(0));
        }
        if (from == address(0)) {
            revert ERC1155InvalidSender(address(0));
        }

        if (from != msg.sender &&
            !isApprovedForAll(from, msg.sender) &&
            !authorized[msg.sender]) {

            revert ERC1155MissingApprovalForAll(msg.sender, from);
        }

        uint256[] memory strikes = new uint256[](1);
        uint256[] memory amounts = new uint256[](1);
        strikes[0] = strike;
        amounts[0] = amount;

        _update(from, to, strikes, amounts);
    }

    function mint(address user, uint256 strike, uint256 amount) public onlyOwner {
        totalSupply[strike] += amount;
        _mint(user, strike, amount, "");

        emit Mint(user, strike, amount);
    }

    function burn(address user, uint256 strike, uint256 amount) public onlyOwner {
        totalSupply[strike] -= amount;
        _burn(user, strike, amount);

        emit Burn(user, strike, amount);
    }
}

File 2 of 26 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol)

pragma solidity ^0.8.20;

import {Math} from "./math/Math.sol";
import {SignedMath} from "./math/SignedMath.sol";

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

    /**
     * @dev The `value` string doesn't fit in the specified `length`.
     */
    error StringsInsufficientHexLength(uint256 value, uint256 length);

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

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

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

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

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

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

File 3 of 26 : ERC1155.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/ERC1155.sol)

pragma solidity ^0.8.20;

import {IERC1155} from "./IERC1155.sol";
import {IERC1155Receiver} from "./IERC1155Receiver.sol";
import {IERC1155MetadataURI} from "./extensions/IERC1155MetadataURI.sol";
import {Context} from "../../utils/Context.sol";
import {IERC165, ERC165} from "../../utils/introspection/ERC165.sol";
import {Arrays} from "../../utils/Arrays.sol";
import {IERC1155Errors} from "../../interfaces/draft-IERC6093.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
 */
abstract contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI, IERC1155Errors {
    using Arrays for uint256[];
    using Arrays for address[];

    mapping(uint256 id => mapping(address account => uint256)) private _balances;

    mapping(address account => mapping(address operator => 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 ERC].
     *
     * Clients calling this function must replace the `\{id\}` substring with the
     * actual token type ID.
     */
    function uri(uint256 /* id */) public view virtual returns (string memory) {
        return _uri;
    }

    /**
     * @dev See {IERC1155-balanceOf}.
     */
    function balanceOf(address account, uint256 id) public view virtual returns (uint256) {
        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 returns (uint256[] memory) {
        if (accounts.length != ids.length) {
            revert ERC1155InvalidArrayLength(ids.length, accounts.length);
        }

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

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

        return batchBalances;
    }

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

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

    /**
     * @dev See {IERC1155-safeTransferFrom}.
     */
    function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes memory data) public virtual {
        address sender = _msgSender();
        if (from != sender && !isApprovedForAll(from, sender)) {
            revert ERC1155MissingApprovalForAll(sender, from);
        }
        _safeTransferFrom(from, to, id, value, data);
    }

    /**
     * @dev See {IERC1155-safeBatchTransferFrom}.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory values,
        bytes memory data
    ) public virtual {
        address sender = _msgSender();
        if (from != sender && !isApprovedForAll(from, sender)) {
            revert ERC1155MissingApprovalForAll(sender, from);
        }
        _safeBatchTransferFrom(from, to, ids, values, data);
    }

    /**
     * @dev Transfers a `value` amount of tokens of type `id` from `from` to `to`. Will mint (or burn) if `from`
     * (or `to`) is the zero address.
     *
     * Emits a {TransferSingle} event if the arrays contain one element, and {TransferBatch} otherwise.
     *
     * Requirements:
     *
     * - If `to` refers to a smart contract, it must implement either {IERC1155Receiver-onERC1155Received}
     *   or {IERC1155Receiver-onERC1155BatchReceived} and return the acceptance magic value.
     * - `ids` and `values` must have the same length.
     *
     * NOTE: The ERC-1155 acceptance check is not performed in this function. See {_updateWithAcceptanceCheck} instead.
     */
    function _update(address from, address to, uint256[] memory ids, uint256[] memory values) internal virtual {
        if (ids.length != values.length) {
            revert ERC1155InvalidArrayLength(ids.length, values.length);
        }

        address operator = _msgSender();

        for (uint256 i = 0; i < ids.length; ++i) {
            uint256 id = ids.unsafeMemoryAccess(i);
            uint256 value = values.unsafeMemoryAccess(i);

            if (from != address(0)) {
                uint256 fromBalance = _balances[id][from];
                if (fromBalance < value) {
                    revert ERC1155InsufficientBalance(from, fromBalance, value, id);
                }
                unchecked {
                    // Overflow not possible: value <= fromBalance
                    _balances[id][from] = fromBalance - value;
                }
            }

            if (to != address(0)) {
                _balances[id][to] += value;
            }
        }

        if (ids.length == 1) {
            uint256 id = ids.unsafeMemoryAccess(0);
            uint256 value = values.unsafeMemoryAccess(0);
            emit TransferSingle(operator, from, to, id, value);
        } else {
            emit TransferBatch(operator, from, to, ids, values);
        }
    }

    /**
     * @dev Version of {_update} that performs the token acceptance check by calling
     * {IERC1155Receiver-onERC1155Received} or {IERC1155Receiver-onERC1155BatchReceived} on the receiver address if it
     * contains code (eg. is a smart contract at the moment of execution).
     *
     * IMPORTANT: Overriding this function is discouraged because it poses a reentrancy risk from the receiver. So any
     * update to the contract state after this function would break the check-effect-interaction pattern. Consider
     * overriding {_update} instead.
     */
    function _updateWithAcceptanceCheck(
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory values,
        bytes memory data
    ) internal virtual {
        _update(from, to, ids, values);
        if (to != address(0)) {
            address operator = _msgSender();
            if (ids.length == 1) {
                uint256 id = ids.unsafeMemoryAccess(0);
                uint256 value = values.unsafeMemoryAccess(0);
                _doSafeTransferAcceptanceCheck(operator, from, to, id, value, data);
            } else {
                _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, values, data);
            }
        }
    }

    /**
     * @dev Transfers a `value` 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 `value` 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 value, bytes memory data) internal {
        if (to == address(0)) {
            revert ERC1155InvalidReceiver(address(0));
        }
        if (from == address(0)) {
            revert ERC1155InvalidSender(address(0));
        }
        (uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(id, value);
        _updateWithAcceptanceCheck(from, to, ids, values, 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.
     * - `ids` and `values` must have the same length.
     */
    function _safeBatchTransferFrom(
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory values,
        bytes memory data
    ) internal {
        if (to == address(0)) {
            revert ERC1155InvalidReceiver(address(0));
        }
        if (from == address(0)) {
            revert ERC1155InvalidSender(address(0));
        }
        _updateWithAcceptanceCheck(from, to, ids, values, 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 ERC].
     *
     * By this mechanism, any occurrence of the `\{id\}` substring in either the
     * URI or any of the values 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 a `value` amount of tokens of 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 value, bytes memory data) internal {
        if (to == address(0)) {
            revert ERC1155InvalidReceiver(address(0));
        }
        (uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(id, value);
        _updateWithAcceptanceCheck(address(0), to, ids, values, data);
    }

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `values` must have the same length.
     * - `to` cannot be the zero address.
     * - 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 values, bytes memory data) internal {
        if (to == address(0)) {
            revert ERC1155InvalidReceiver(address(0));
        }
        _updateWithAcceptanceCheck(address(0), to, ids, values, data);
    }

    /**
     * @dev Destroys a `value` amount of tokens of type `id` from `from`
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `from` must have at least `value` amount of tokens of type `id`.
     */
    function _burn(address from, uint256 id, uint256 value) internal {
        if (from == address(0)) {
            revert ERC1155InvalidSender(address(0));
        }
        (uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(id, value);
        _updateWithAcceptanceCheck(from, address(0), ids, values, "");
    }

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `from` must have at least `value` amount of tokens of type `id`.
     * - `ids` and `values` must have the same length.
     */
    function _burnBatch(address from, uint256[] memory ids, uint256[] memory values) internal {
        if (from == address(0)) {
            revert ERC1155InvalidSender(address(0));
        }
        _updateWithAcceptanceCheck(from, address(0), ids, values, "");
    }

    /**
     * @dev Approve `operator` to operate on all of `owner` tokens
     *
     * Emits an {ApprovalForAll} event.
     *
     * Requirements:
     *
     * - `operator` cannot be the zero address.
     */
    function _setApprovalForAll(address owner, address operator, bool approved) internal virtual {
        if (operator == address(0)) {
            revert ERC1155InvalidOperator(address(0));
        }
        _operatorApprovals[owner][operator] = approved;
        emit ApprovalForAll(owner, operator, approved);
    }

    /**
     * @dev Performs an acceptance check by calling {IERC1155-onERC1155Received} on the `to` address
     * if it contains code at the moment of execution.
     */
    function _doSafeTransferAcceptanceCheck(
        address operator,
        address from,
        address to,
        uint256 id,
        uint256 value,
        bytes memory data
    ) private {
        if (to.code.length > 0) {
            try IERC1155Receiver(to).onERC1155Received(operator, from, id, value, data) returns (bytes4 response) {
                if (response != IERC1155Receiver.onERC1155Received.selector) {
                    // Tokens rejected
                    revert ERC1155InvalidReceiver(to);
                }
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    // non-IERC1155Receiver implementer
                    revert ERC1155InvalidReceiver(to);
                } else {
                    /// @solidity memory-safe-assembly
                    assembly {
                        revert(add(32, reason), mload(reason))
                    }
                }
            }
        }
    }

    /**
     * @dev Performs a batch acceptance check by calling {IERC1155-onERC1155BatchReceived} on the `to` address
     * if it contains code at the moment of execution.
     */
    function _doSafeBatchTransferAcceptanceCheck(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory values,
        bytes memory data
    ) private {
        if (to.code.length > 0) {
            try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, values, data) returns (
                bytes4 response
            ) {
                if (response != IERC1155Receiver.onERC1155BatchReceived.selector) {
                    // Tokens rejected
                    revert ERC1155InvalidReceiver(to);
                }
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    // non-IERC1155Receiver implementer
                    revert ERC1155InvalidReceiver(to);
                } else {
                    /// @solidity memory-safe-assembly
                    assembly {
                        revert(add(32, reason), mload(reason))
                    }
                }
            }
        }
    }

    /**
     * @dev Creates an array in memory with only one value for each of the elements provided.
     */
    function _asSingletonArrays(
        uint256 element1,
        uint256 element2
    ) private pure returns (uint256[] memory array1, uint256[] memory array2) {
        /// @solidity memory-safe-assembly
        assembly {
            // Load the free memory pointer
            array1 := mload(0x40)
            // Set array length to 1
            mstore(array1, 1)
            // Store the single element at the next word after the length (where content starts)
            mstore(add(array1, 0x20), element1)

            // Repeat for next array locating it right after the first array
            array2 := add(array1, 0x40)
            mstore(array2, 1)
            mstore(add(array2, 0x20), element2)

            // Update the free memory pointer by pointing after the second array
            mstore(0x40, add(array2, 0x40))
        }
    }
}

File 4 of 26 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;

import {Context} from "../utils/Context.sol";

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

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

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

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

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

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

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

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(newOwner);
    }

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

File 5 of 26 : Vault.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

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

import { IOracle } from "./interfaces/IOracle.sol";
import { IYieldSource } from "./interfaces/IYieldSource.sol";

import { HodlMultiToken } from "./multi/HodlMultiToken.sol";
import { YMultiToken } from "./multi/YMultiToken.sol";
import { HodlToken } from  "./single/HodlToken.sol";

// Vault is the core contract for HODL.money. It contains most of the accounting
// logic around token mechanics and yield.
//
// The protocol is based on two complementary tokens, plETH and ybETH, which
// represent long and short positions. The plETH tokens (long position) redeem
// into the underlying token (eg. stETH) after a particular strike price has
// been reached. The ybETH tokens (short position) receive yield from the
// underlying *until* the strike price is reached.
//
// The plETH side makes more profit the faster the strike hits, whereas ybETH
// side wants the strike price to hit as long in the future as possible, ideally
// never.
//
// For more information, visit https://docs.hodl.money/
//
// Technical details:
//
// * Minting
// The plETH and ybETH tokens are minted by the Vault. The user transfers some
// amount of ETH into the contract, and he mints the same amount of plETH and
// ybETH as he transferred, less fees. For example, a deposit of 1 ETH gives
// the user 1 plETH and 1 ybETH at the strike he chose.
//
// * Staking plETH
// Users may stake plETH in anticipation of the strike price hitting. If the
// the user stakes his plETH, he can redeem that stake for underlying stETH once
// the strike hits. The benefit of staking is that he can do the redemption even
// if the price later falls back down below the strike.
//
// * Staking ybETH
// Users need to stake ybETH to receive yield. Staked ybETH receives yield until
// the strike price hits. Staking is used to track how much yield each user is
// entitled to. Unstaked ybETH does not get yield, and overflow yield is evenly
// distributed across the other staked positions.
//
// * Epochs
// Strikes are tracked on a per-epoch basis. This is to account for the
// possibility that the price rises above a strike, then back below, then back
// above again. Multiple crosses across a strike price *may* result in multiple
// epochs.
//
// Each epoch has a start time, and is associated with a strike price. When the
// price rises above the strike, plETH redemption is enabled in that epoch. This
// means all staked plETH within that epoch can be redeemed. In addition, once
// redemption is enabled for particular epoch, ybETH in that epoch stops
// accumulating yield.
//
// * Burning ybETH
// When a strike price hits, all ybETH stakes at that strike stop accumulating
// yield. In addition, all ybETH at that strike is burned, meaning user balances
// go to zero.
//
// * Merging
// Another way to recover the underlying is to merge equal parts plETH and
// ybETH. This is called merging.
//
// * ERC-1155 tokens and ERC-20 wrappers
// The plETH and ybETH tokens are each implemented using the ERC-1155 standard
// for semi-fungible tokens. The tokens are fungible within a strike, eg. all
// plETH at strike of $10,000 are fungible. However, $9,999 is non-fungible with
// $10,000.
//
// For compatibility with broader Defi, an ERC-20 wrapper can be deployed for
// the plETH token at any strike. For example, you can deploy a ERC-20 token
// that represents plETH at strike of $10,000. The token contracts let the
// ERC-20 wrapper make transfers within the ERC-1155 contract.
//
// * Naming
// In code, 'hodl' tokens refer to plETH, and 'y' tokens refer to ybETH.
//
contract Vault is ReentrancyGuard, Ownable, Pausable {
    using SafeERC20 for IERC20;

    uint256 public constant PRECISION_FACTOR = 1 ether;

    uint256 public constant FEE_BASIS = 100_00;
    uint256 public constant MAX_FEE = 10_00;  // 10%

    uint48 public nextId = 1;
    uint256 public fee = 0;

    IYieldSource public immutable source;
    IOracle public immutable oracle;

    HodlMultiToken public immutable hodlMulti;
    YMultiToken public immutable yMulti;

    address public treasury;

    // Keep track of deployed erc20 hodl tokens
    mapping (uint64 strike => IERC20 token) public deployments;

    // Track staked hodl tokens, which are eligible for redemption
    struct HodlStake {
        address user;
        uint48 epochId;
        uint256 amount;
    }
    mapping (uint48 stakedId => HodlStake) public hodlStakes;

    struct YStake {
        address user;
        uint48 epochId;
        uint256 amount;
        uint256 claimed;
        uint256 acc;
    }
    mapping (uint48 stakeId => YStake) public yStakes;

    // Amount of y tokens staked in an epoch
    mapping (uint48 epochId => uint256 amount) public yStaked;

    // Amount of y tokens staked in total
    uint256 public yStakedTotal;

    // For terminated epoch, the final yield per token
    mapping (uint48 epochId => uint256 ypt) public terminalYieldPerToken;

    // Amount of total deposits
    uint256 public deposits;

    // Amount of yield claimed
    uint256 public claimed;

    // Checkpointed yield per token, updated when deposits go up/down
    uint256 public yieldPerTokenAcc;

    // Checkpointed cumulative yield, updated when deposits go up/down
    uint256 public cumulativeYieldAcc;

    // Track yield per token and cumulative yield on a per epoch basis
    struct EpochInfo {
        uint64 strike;
        bool closed;
        uint256 timestamp;
        uint256 yieldPerTokenAcc;
        uint256 cumulativeYieldAcc;
    }
    mapping (uint48 epochId => EpochInfo) public infos;

    // Map strike to active epoch ID
    mapping (uint64 strike => uint48 epochId) public epochs;

    // Events
    event SetTreasury(address treasury);

    event SetFee(uint256 fee);

    event DeployERC20(uint64 indexed strike,
                      address token);

    event Mint(address indexed user,
               uint256 indexed strike,
               uint256 amount);

    event Merge(address indexed user,
                uint64 indexed strike,
                uint256 amount);

    event Redeem(address indexed user,
                 uint64 indexed strike,
                 uint48 indexed stakeId,
                 uint256 amount);

    event RedeemTokens(address indexed user,
                       uint64 indexed strike,
                       uint256 amount);

    event HodlStaked(address indexed user,
                     uint64 indexed strike,
                     uint48 indexed stakeId,
                     uint256 amount);

    event HodlUnstake(address indexed user,
                      uint64 indexed strike,
                      uint48 indexed stakeId,
                      uint256 amount);

    event YStaked(address indexed user,
                  uint64 indexed strike,
                  uint48 indexed stakeId,
                  uint256 amount);

    event YUnstake(address indexed user,
                   uint64 indexed strike,
                   uint48 indexed stakeId,
                   uint256 amount);

    event Claim(address indexed user,
                uint64 indexed strike,
                uint48 indexed stakeId,
                uint256 amount);

    constructor(address source_,
                address oracle_,
                address treasury_)
        ReentrancyGuard()
        Ownable(msg.sender)
        Pausable() {

        require(source_ != address(0));
        require(oracle_ != address(0));
        require(treasury_ != address(0));

        source = IYieldSource(source_);
        oracle = IOracle(oracle_);
        treasury = treasury_;

        hodlMulti = new HodlMultiToken("");
        yMulti = new YMultiToken("", address(this));
    }

    function pause() external onlyOwner {
        _pause();
    }

    function unpause() external onlyOwner {
        _unpause();
    }

    function setTreasury(address treasury_) external nonReentrant onlyOwner {
        require(treasury_ != address(0), "zero address");

        treasury = treasury_;

        emit SetTreasury(treasury);
    }

    function setFee(uint256 fee_) external nonReentrant onlyOwner {
        require(fee_ <= MAX_FEE, "max fee");

        fee = fee_;

        emit SetFee(fee);
    }

    function deployERC20(uint64 strike) external nonReentrant returns (address) {
        require(address(deployments[strike]) == address(0), "already deployed");

        HodlToken hodl = new HodlToken(address(hodlMulti), strike);
        hodlMulti.authorize(address(hodl));

        deployments[strike] = hodl;

        emit DeployERC20(strike, address(hodl));

        return address(hodl);
    }

    function _min(uint256 x, uint256 y) internal pure returns (uint256) {
        return x < y ? x : y;
    }

    function _checkpoint(uint48 epochId) internal {
        uint256 ypt = yieldPerToken();
        uint256 total = totalCumulativeYield();

        infos[epochId].cumulativeYieldAcc = cumulativeYield(epochId);
        infos[epochId].yieldPerTokenAcc = ypt;

        yieldPerTokenAcc = ypt;
        cumulativeYieldAcc = total;
    }

    function previewMint(uint256 value) external view returns (uint256, uint256) {
        if (fee == 0) {
            return (value, 0);
        } else {
            uint256 feeValue = value * fee / FEE_BASIS;
            return (value - feeValue, feeValue);
        }
    }

    function _createEpoch(uint64 strike) internal {
        infos[nextId].strike = strike;
        infos[nextId].timestamp = oracle.timestamp(0);
        epochs[strike] = nextId++;
    }

    function mint(uint64 strike)
        external nonReentrant whenNotPaused payable returns (uint256) {

        require(oracle.price(0) < strike, "strike too low");
        require(msg.value > 0, "zero mint");

        uint256 value = msg.value;
        uint256 feeValue = value * fee / FEE_BASIS;
        if (feeValue > 0) {
            payable(treasury).transfer(feeValue);
            value -= feeValue;
        }

        // Account get the actual amount after deposit into underlying
        uint256 amount = source.deposit{value: value}();
        deposits += amount;

        // Create the epoch if needed
        if (epochs[strike] == 0) {
            _createEpoch(strike);
        }

        // Mint hodl + y
        hodlMulti.mint(msg.sender, strike, amount);
        yMulti.mint(msg.sender, strike, amount);

        emit Mint(msg.sender, strike, amount);

        return amount;
    }

    function canRedeem(uint48 stakeId, uint80 roundId) public view returns (bool) {
        HodlStake storage stk = hodlStakes[stakeId];

        // Check if there is anything to redeem
        if (stk.amount == 0) {
            return false;
        }

        // Check the two conditions that enable redemption:

        // (1) If price is currently above strike
        uint64 strike = infos[stk.epochId].strike;
        if (oracle.price(roundId) >= strike &&
            oracle.timestamp(roundId) >= infos[stk.epochId].timestamp) {

            return true;
        }

        // (2) If this is a passed epoch
        if (infos[stk.epochId].closed) {
            return true;
        }

        // Neither is true, so can't redeem
        return false;
    }

    // _withdraw computes and executes a withdraw. It handles negative rebases,
    // and returns the actual number of tokens sent to the user.
    function _withdraw(uint256 amount, address user) private returns (uint256) {
        uint256 actual = amount;

        // Compute proportional share in case of negative rebase
        if (source.balance() < deposits) {
            actual = amount * source.balance() / deposits;
        }

        actual = _min(actual, source.balance());
        source.withdraw(actual, user);

        return actual;
    }

    // merge combines equal parts y + hodl tokens into the underlying asset.
    function merge(uint64 strike, uint256 amount)
        external nonReentrant returns (uint256) {

        require(hodlMulti.balanceOf(msg.sender, strike) >= amount, "merge hodl balance");
        require(yMulti.balanceOf(msg.sender, strike) >= amount, "merge y balance");

        hodlMulti.burn(msg.sender, strike, amount);
        yMulti.burn(msg.sender, strike, amount);

        uint256 actual = _withdraw(amount, msg.sender);
        deposits -= amount;

        emit Merge(msg.sender, strike, actual);

        return actual;
    }

    // redeem converts a stake into the underlying tokens if the price has
    // touched the strike. The redemption can happen even if the price later
    // dips below.
    function redeem(uint48 stakeId, uint80 roundId, uint256 amount, uint256 minOut)
        external nonReentrant returns (uint256) {

        HodlStake storage stk = hodlStakes[stakeId];
        if (amount == 0) {
            amount = stk.amount;
        }

        require(stk.user == msg.sender, "redeem user");
        require(stk.amount >= amount, "redeem amount");
        require(canRedeem(stakeId, roundId), "cannot redeem");

        // Deduct the specified hodl stake
        stk.amount -= amount;

        // Close out before updating `deposits`
        _closeOutEpoch(stk.epochId);

        uint256 actual = _withdraw(amount, msg.sender);
        require(actual > minOut, "redeem slippage");
        deposits -= amount;

        emit Redeem(msg.sender, infos[stk.epochId].strike, stakeId, actual);

        return actual;
    }

    // redeemTokens redeems unstaked tokens if the price is currently above the
    // strike. Unlike redeemStake, the redemption cannot happen if the price
    // later dips below.
    function redeemTokens(uint64 strike, uint256 amount, uint256 minOut)
        external nonReentrant returns (uint256) {

        require(amount > 0, "zero redeem tokens");
        require(oracle.price(0) >= strike, "below strike");
        require(hodlMulti.balanceOf(msg.sender, strike) >= amount, "redeem tokens balance");

        hodlMulti.burn(msg.sender, strike, amount);

        // Close out before updating `deposits`
        _closeOutEpoch(epochs[strike]);

        uint256 actual = _withdraw(amount, msg.sender);
        require(actual > minOut, "redeem tokens slippage");
        deposits -= amount;

        emit RedeemTokens(msg.sender, strike, actual);

        return actual;
    }

    function _closeOutEpoch(uint48 epochId) private {
        if (infos[epochId].closed) {
            return;
        }

        EpochInfo storage info = infos[epochId];
        require(info.strike != 0, "cannot close epoch 0");

        // Checkpoint this strike, to prevent yield accumulation
        _checkpoint(epochId);

        // Record the ypt at redemption time
        terminalYieldPerToken[epochId] = yieldPerToken();

        // Update accounting for staked y tokens
        yStakedTotal -= yStaked[epochId];
        yStaked[epochId] = 0;

        // Burn all staked y tokens at that strike
        yMulti.burnStrike(info.strike);

        // Don't checkpoint again, trigger new epoch
        _createEpoch(info.strike);

        // Remember that we closed this epoch
        info.closed = true;
    }

    // yStake takes y tokens and stakes them, which makes those tokens receive
    // yield. Only staked y tokens receive yield. This is to enable proper yield
    // accounting in relation to hodl token redemptions.
    function yStake(uint64 strike, uint256 amount, address user)
        external nonReentrant whenNotPaused returns (uint48) {

        require(yMulti.balanceOf(msg.sender, strike) >= amount, "y stake balance");
        uint48 epochId = epochs[strike];

        _checkpoint(epochId);

        yMulti.burn(msg.sender, strike, amount);
        uint48 id = nextId++;

        uint256 ypt = yieldPerToken();
        yStakes[id] = YStake({
            user: user,
            epochId: epochId,
            amount: amount,
            // + 1 to tip rounding error in protocol favor
            claimed: (ypt * amount / PRECISION_FACTOR) + 1,
            acc: 0 });

        yStaked[epochId] += amount;
        yStakedTotal += amount;

        emit YStaked(user, strike, id, amount);

        return id;
    }

    // yUnstake takes a stake and returns all the y tokens to the user. For
    // simplicity, partial unstakes are not possible. The user may unstake
    // entirely, and then re-stake a portion of his tokens.
    function yUnstake(uint48 stakeId, address user) external nonReentrant {
        YStake storage stk = yStakes[stakeId];
        require(stk.user == msg.sender, "y unstake user");
        require(stk.amount > 0, "y unstake zero");
        require(terminalYieldPerToken[stk.epochId] == 0, "y unstake closed epoch");

        uint256 amount = stk.amount;

        _checkpoint(stk.epochId);

        stk.acc = stk.claimed + claimable(stakeId);
        yStaked[stk.epochId] -= amount;
        yStakedTotal -= amount;
        stk.amount = 0;

        uint64 strike = infos[stk.epochId].strike;
        yMulti.mint(user, strike, amount);

        emit YUnstake(user, strike, stakeId, amount);
    }

    // _stakeYpt somputes the yield per token of a particular stake of y tokens.
    function _stakeYpt(uint48 stakeId) internal view returns (uint256) {
        YStake storage stk = yStakes[stakeId];
        if (epochs[infos[stk.epochId].strike] == stk.epochId) {
            // Active epoch
            return yieldPerToken();
        } else {
            // Closed epoch
            return terminalYieldPerToken[stk.epochId];
        }
    }

    // claimable computes the amount of underlying available to claim for a
    // particular stake.
    function claimable(uint48 stakeId) public view returns (uint256) {
        YStake storage stk = yStakes[stakeId];

        uint256 c;
        if (stk.amount == 0) {
            // Unstaked, use saved value
            c = stk.acc;
        } else {
            // Staked, use live value
            assert(stk.acc == 0);  // Only set when unstaking
            uint256 ypt = _stakeYpt(stakeId);
            c = ypt * stk.amount / PRECISION_FACTOR;
        }

        return stk.claimed > c ? 0 : c - stk.claimed;
    }

    // claim transfers to the user his claimable yield.
    function claim(uint48 stakeId) public nonReentrant returns (uint256) {
        YStake storage stk = yStakes[stakeId];
        require(stk.user == msg.sender, "y claim user");

        uint256 c = claimable(stakeId);
        uint256 amount = _withdraw(c, msg.sender);
        stk.claimed += c;
        claimed += c;

        emit Claim(msg.sender, infos[stk.epochId].strike, stakeId, amount);

        return amount;
    }

    // hodlStake takes some hodl tokens, and stakes them. This make them
    // eligible for redemption when the strike price hits.
    function hodlStake(uint64 strike, uint256 amount, address user)
        external nonReentrant whenNotPaused returns (uint48) {

        require(amount > 0, "zero hodl stake");
        require(hodlMulti.balanceOf(msg.sender, strike) >= amount, "hodl stake balance");

        hodlMulti.burn(msg.sender, strike, amount);

        uint48 id = nextId++;
        hodlStakes[id] = HodlStake({
            user: user,
            epochId: epochs[strike],
            amount: amount });

        emit HodlStaked(user, strike, id, amount);

        return id;
    }

    // hodlUnstake can be used to return some portion of staked tokens to the
    // user.
    function hodlUnstake(uint48 stakeId, uint256 amount, address user) external nonReentrant {
        HodlStake storage stk = hodlStakes[stakeId];
        require(amount > 0, "zero hodl unstake");
        require(stk.user == msg.sender, "hodl unstake user");
        require(stk.amount >= amount, "hodl unstake amount");

        uint64 strike = infos[stk.epochId].strike;
        hodlMulti.mint(user, strike, amount);

        stk.amount -= amount;

        emit HodlUnstake(user, strike, stakeId, amount);
    }

    // yieldPerToken computes the global yield per token, meaning how much
    // yield every y token has accumulated thus far.
    function yieldPerToken() public view returns (uint256) {
        uint256 total = totalCumulativeYield();
        if (total < cumulativeYieldAcc) return 0;
        uint256 deltaCumulative = total - cumulativeYieldAcc;
        
        if (yStakedTotal == 0) return yieldPerTokenAcc;
        uint256 incr = deltaCumulative * PRECISION_FACTOR / yStakedTotal;
        return yieldPerTokenAcc + incr;
    }

    // cumulativeYield calculates the total amount of yield a particular epoch
    // is entitled to. This yield is split accordingly among the staked y
    // tokens.
    function cumulativeYield(uint48 epochId) public view returns (uint256) {
        require(epochId < nextId, "invalid epoch");

        uint256 ypt;
        uint256 acc;

        if (infos[epochId].closed) {
            // Passed epoch
            ypt = terminalYieldPerToken[epochId];
            acc = infos[epochId].yieldPerTokenAcc;
        } else {
            // Active epoch
            ypt = yieldPerToken();
            acc = infos[epochId].yieldPerTokenAcc;
        }

        if (ypt < acc) {
            ypt = 0;
        } else {
            ypt -= acc;
        }

        return (infos[epochId].cumulativeYieldAcc +
                yStaked[epochId] * ypt / PRECISION_FACTOR);
    }

    // totalCumulativeYield calculates the total amount of yield for this vault,
    // accross all epochs and strikes.
    function totalCumulativeYield() public view returns (uint256) {
        uint256 balance = source.balance();
        uint256 delta = balance < deposits ? 0 : balance - deposits;
        uint256 result = delta + claimed;
        return result;
    }
}

File 6 of 26 : YMultiToken.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import "@openzeppelin/contracts/utils/Strings.sol";
import { ERC1155 } from "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import { Ownable } from  "@openzeppelin/contracts/access/Ownable.sol";

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

contract YMultiToken is ERC1155, Ownable {

    Vault public immutable vault;

    uint256 public nextId = 1;

    // seq -> address -> balance
    mapping (uint256 strikeSeq => mapping(address user => uint256 balance)) public balances;

    // strike -> active seq
    mapping (uint256 strike => uint256 strikeSeq) public strikeSeqs;

    mapping (uint256 => uint256) public totalSupply;

    // Events
    event Mint(address indexed user,
               uint256 indexed strike,
               uint256 amount);

    event Burn(address indexed user,
               uint256 indexed strike,
               uint256 amount);

    event BurnStrike(uint256 indexed strike,
                     uint256 seq);

    constructor(string memory uri_, address vault_) Ownable(msg.sender) ERC1155(uri_) {
        require(vault_ != address(0));

        vault = Vault(vault_);
    }

    function name(uint256 strike) public view virtual returns (string memory) {
        if (strike % 1e8 == 0) {
            return string(abi.encodePacked("ybETH @ ", Strings.toString(strike / 1e8)));
        } else {
            return string(abi.encodePacked("ybETH @ ", Strings.toString(strike)));
        }
    }

    function symbol(uint256 strike) public view virtual returns (string memory) {
        return name(strike);
    }

    function mint(address user, uint256 strike, uint256 amount) public onlyOwner {
        uint256[] memory strikes = new uint256[](1);
        uint256[] memory amounts = new uint256[](1);
        strikes[0] = strike;
        amounts[0] = amount;
        _update(address(0), user, strikes, amounts);
        totalSupply[strike] += amount;

        emit Mint(user, strike, amount);
    }

    function burn(address user, uint256 strike, uint256 amount) public onlyOwner {
        uint256[] memory strikes = new uint256[](1);
        uint256[] memory amounts = new uint256[](1);
        strikes[0] = strike;
        amounts[0] = amount;
        _update(user, address(0), strikes, amounts);
        totalSupply[strike] -= amount;

        emit Burn(user, strike, amount);
    }

    function balanceOf(address user, uint256 strike) public override view returns (uint256) {
        uint256 seq = strikeSeqs[strike];
        return balances[seq][user];
    }

    function burnStrike(uint256 strike) public {
        require(msg.sender == address(vault), "only vault");

        strikeSeqs[strike] = nextId++;

        emit BurnStrike(strike, strikeSeqs[strike] - 1);
    }

    // This function is lifted from OZ's ERC1155.sol contract, modified
    // to access balances based on seq number.
    function _update(address from,
                     address to,
                     uint256[] memory strikes,
                     uint256[] memory values) internal override {

        require(strikes.length == values.length, "mismatched update length");
        require(to != from, "y self transfer");

        for (uint256 i = 0; i < strikes.length; ++i) {
            uint256 value = values[i];

            // Prevent 0 value transfers from initializing strikes with seq numbers
            require(value > 0, "y zero value transfer");

            uint256 strike = strikes[i];
            if (strikeSeqs[strike] == 0) {
                strikeSeqs[strike] = nextId++;
            }

            uint256 seq = strikeSeqs[strike];

            if (from != address(0)) {
                uint256 fromBalance = balances[seq][from];
                require(fromBalance >= value, "insufficient balance");
                unchecked {
                    balances[seq][from] = fromBalance - value;
                }
            }

            if (to != address(0)) {
                balances[seq][to] += value;
            }
        }

        if (strikes.length == 1) {
            uint256 strike = strikes[0];
            uint256 value = values[0];
            emit TransferSingle(msg.sender, from, to, strike, value);
        } else {
            emit TransferBatch(msg.sender, from, to, strikes, values);
        }
    }
}

File 7 of 26 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)

pragma solidity ^0.8.20;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    /**
     * @dev Muldiv operation overflow.
     */
    error MathOverflowedMulDiv();

    enum Rounding {
        Floor, // Toward negative infinity
        Ceil, // Toward positive infinity
        Trunc, // Toward zero
        Expand // Away from zero
    }

    /**
     * @dev Returns the addition of two unsigned integers, with an success flag (no overflow).
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, with an success flag (no overflow).
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

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

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

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

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

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

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

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds towards infinity instead
     * of rounding towards zero.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        if (b == 0) {
            // Guarantee the same behavior as in a regular Solidity division.
            return a / b;
        }

        // The following calculation ensures accurate ceiling division without overflow.
        // Since a is non-zero, (a - 1) / b will not overflow.
        // The largest possible result occurs when (a - 1) / b is type(uint256).max,
        // but the largest value we can obtain is type(uint256).max - 1, which happens
        // when a = type(uint256).max and b = 1.
        unchecked {
            return a == 0 ? 0 : (a - 1) / b + 1;
        }
    }

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

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

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            if (denominator <= prod1) {
                revert MathOverflowedMulDiv();
            }

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

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

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

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

            uint256 twos = denominator & (0 - denominator);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    /**
     * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
     */
    function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
        return uint8(rounding) % 2 == 1;
    }
}

File 8 of 26 : SignedMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol)

pragma solidity ^0.8.20;

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

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

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

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

File 9 of 26 : IERC1155.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (token/ERC1155/IERC1155.sol)

pragma solidity ^0.8.20;

import {IERC165} from "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC-1155 compliant contract, as defined in the
 * https://eips.ethereum.org/EIPS/eip-1155[ERC].
 */
interface IERC1155 is IERC165 {
    /**
     * @dev Emitted when `value` amount of tokens of 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 value 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 a `value` amount of tokens of type `id` from `from` to `to`.
     *
     * WARNING: This function can potentially allow a reentrancy attack when transferring tokens
     * to an untrusted contract, when invoking {onERC1155Received} on the receiver.
     * Ensure to follow the checks-effects-interactions pattern and consider employing
     * reentrancy guards when interacting with untrusted contracts.
     *
     * 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 `value` 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 value, bytes calldata data) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * WARNING: This function can potentially allow a reentrancy attack when transferring tokens
     * to an untrusted contract, when invoking {onERC1155BatchReceived} on the receiver.
     * Ensure to follow the checks-effects-interactions pattern and consider employing
     * reentrancy guards when interacting with untrusted contracts.
     *
     * Emits either a {TransferSingle} or a {TransferBatch} event, depending on the length of the array arguments.
     *
     * Requirements:
     *
     * - `ids` and `values` 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 values,
        bytes calldata data
    ) external;
}

File 10 of 26 : IERC1155Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/IERC1155Receiver.sol)

pragma solidity ^0.8.20;

import {IERC165} from "../../utils/introspection/IERC165.sol";

/**
 * @dev Interface that must be implemented by smart contracts in order to receive
 * ERC-1155 token transfers.
 */
interface IERC1155Receiver is IERC165 {
    /**
     * @dev Handles the receipt of a single ERC-1155 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 ERC-1155 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 11 of 26 : IERC1155MetadataURI.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/extensions/IERC1155MetadataURI.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Interface of the optional ERC1155MetadataExtension interface, as defined
 * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[ERC].
 */
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 12 of 26 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

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

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

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}

File 13 of 26 : ERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC-165 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);
 * }
 * ```
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

File 14 of 26 : Arrays.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Arrays.sol)

pragma solidity ^0.8.20;

import {StorageSlot} from "./StorageSlot.sol";
import {Math} from "./math/Math.sol";

/**
 * @dev Collection of functions related to array types.
 */
library Arrays {
    using StorageSlot for bytes32;

    /**
     * @dev Searches a sorted `array` and returns the first index that contains
     * a value greater or equal to `element`. If no such index exists (i.e. all
     * values in the array are strictly less than `element`), the array length is
     * returned. Time complexity O(log n).
     *
     * `array` is expected to be sorted in ascending order, and to contain no
     * repeated elements.
     */
    function findUpperBound(uint256[] storage array, uint256 element) internal view returns (uint256) {
        uint256 low = 0;
        uint256 high = array.length;

        if (high == 0) {
            return 0;
        }

        while (low < high) {
            uint256 mid = Math.average(low, high);

            // Note that mid will always be strictly less than high (i.e. it will be a valid array index)
            // because Math.average rounds towards zero (it does integer division with truncation).
            if (unsafeAccess(array, mid).value > element) {
                high = mid;
            } else {
                low = mid + 1;
            }
        }

        // At this point `low` is the exclusive upper bound. We will return the inclusive upper bound.
        if (low > 0 && unsafeAccess(array, low - 1).value == element) {
            return low - 1;
        } else {
            return low;
        }
    }

    /**
     * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
     *
     * WARNING: Only use if you are certain `pos` is lower than the array length.
     */
    function unsafeAccess(address[] storage arr, uint256 pos) internal pure returns (StorageSlot.AddressSlot storage) {
        bytes32 slot;
        // We use assembly to calculate the storage slot of the element at index `pos` of the dynamic array `arr`
        // following https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays.

        /// @solidity memory-safe-assembly
        assembly {
            mstore(0, arr.slot)
            slot := add(keccak256(0, 0x20), pos)
        }
        return slot.getAddressSlot();
    }

    /**
     * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
     *
     * WARNING: Only use if you are certain `pos` is lower than the array length.
     */
    function unsafeAccess(bytes32[] storage arr, uint256 pos) internal pure returns (StorageSlot.Bytes32Slot storage) {
        bytes32 slot;
        // We use assembly to calculate the storage slot of the element at index `pos` of the dynamic array `arr`
        // following https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays.

        /// @solidity memory-safe-assembly
        assembly {
            mstore(0, arr.slot)
            slot := add(keccak256(0, 0x20), pos)
        }
        return slot.getBytes32Slot();
    }

    /**
     * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
     *
     * WARNING: Only use if you are certain `pos` is lower than the array length.
     */
    function unsafeAccess(uint256[] storage arr, uint256 pos) internal pure returns (StorageSlot.Uint256Slot storage) {
        bytes32 slot;
        // We use assembly to calculate the storage slot of the element at index `pos` of the dynamic array `arr`
        // following https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays.

        /// @solidity memory-safe-assembly
        assembly {
            mstore(0, arr.slot)
            slot := add(keccak256(0, 0x20), pos)
        }
        return slot.getUint256Slot();
    }

    /**
     * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
     *
     * WARNING: Only use if you are certain `pos` is lower than the array length.
     */
    function unsafeMemoryAccess(uint256[] memory arr, uint256 pos) internal pure returns (uint256 res) {
        assembly {
            res := mload(add(add(arr, 0x20), mul(pos, 0x20)))
        }
    }

    /**
     * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
     *
     * WARNING: Only use if you are certain `pos` is lower than the array length.
     */
    function unsafeMemoryAccess(address[] memory arr, uint256 pos) internal pure returns (address res) {
        assembly {
            res := mload(add(add(arr, 0x20), mul(pos, 0x20)))
        }
    }
}

File 15 of 26 : draft-IERC6093.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)
pragma solidity ^0.8.20;

/**
 * @dev Standard ERC-20 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens.
 */
interface IERC20Errors {
    /**
     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param balance Current balance for the interacting account.
     * @param needed Minimum amount required to perform a transfer.
     */
    error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC20InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC20InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
     * @param spender Address that may be allowed to operate on tokens without being their owner.
     * @param allowance Amount of tokens a `spender` is allowed to operate with.
     * @param needed Minimum amount required to perform a transfer.
     */
    error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC20InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `spender` to be approved. Used in approvals.
     * @param spender Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC20InvalidSpender(address spender);
}

/**
 * @dev Standard ERC-721 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens.
 */
interface IERC721Errors {
    /**
     * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-20.
     * Used in balance queries.
     * @param owner Address of the current owner of a token.
     */
    error ERC721InvalidOwner(address owner);

    /**
     * @dev Indicates a `tokenId` whose `owner` is the zero address.
     * @param tokenId Identifier number of a token.
     */
    error ERC721NonexistentToken(uint256 tokenId);

    /**
     * @dev Indicates an error related to the ownership over a particular token. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param tokenId Identifier number of a token.
     * @param owner Address of the current owner of a token.
     */
    error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC721InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC721InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `operator`’s approval. Used in transfers.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     * @param tokenId Identifier number of a token.
     */
    error ERC721InsufficientApproval(address operator, uint256 tokenId);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC721InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `operator` to be approved. Used in approvals.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC721InvalidOperator(address operator);
}

/**
 * @dev Standard ERC-1155 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 tokens.
 */
interface IERC1155Errors {
    /**
     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param balance Current balance for the interacting account.
     * @param needed Minimum amount required to perform a transfer.
     * @param tokenId Identifier number of a token.
     */
    error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC1155InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC1155InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `operator`’s approval. Used in transfers.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     * @param owner Address of the current owner of a token.
     */
    error ERC1155MissingApprovalForAll(address operator, address owner);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC1155InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `operator` to be approved. Used in approvals.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC1155InvalidOperator(address operator);

    /**
     * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
     * Used in batch transfers.
     * @param idsLength Length of the array of token identifiers
     * @param valuesLength Length of the array of token amounts
     */
    error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}

File 16 of 26 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../utils/Address.sol";

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

    /**
     * @dev An operation with an ERC-20 token failed.
     */
    error SafeERC20FailedOperation(address token);

    /**
     * @dev Indicates a failed `decreaseAllowance` request.
     */
    error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);

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

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

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

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
     * value, non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
        unchecked {
            uint256 currentAllowance = token.allowance(address(this), spender);
            if (currentAllowance < requestedDecrease) {
                revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
            }
            forceApprove(token, spender, currentAllowance - requestedDecrease);
        }
    }

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

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

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

        bytes memory returndata = address(token).functionCall(data);
        if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

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

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

File 17 of 26 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

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

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

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

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

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

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

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

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

File 18 of 26 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)

pragma solidity ^0.8.20;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant NOT_ENTERED = 1;
    uint256 private constant ENTERED = 2;

    uint256 private _status;

    /**
     * @dev Unauthorized reentrant call.
     */
    error ReentrancyGuardReentrantCall();

    constructor() {
        _status = NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be NOT_ENTERED
        if (_status == ENTERED) {
            revert ReentrancyGuardReentrantCall();
        }

        // Any calls to nonReentrant after this point will fail
        _status = ENTERED;
    }

    function _nonReentrantAfter() private {
        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = NOT_ENTERED;
    }

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _status == ENTERED;
    }
}

File 19 of 26 : Pausable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol)

pragma solidity ^0.8.20;

import {Context} from "../utils/Context.sol";

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract Pausable is Context {
    bool private _paused;

    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    /**
     * @dev The operation failed because the contract is paused.
     */
    error EnforcedPause();

    /**
     * @dev The operation failed because the contract is not paused.
     */
    error ExpectedPause();

    /**
     * @dev Initializes the contract in unpaused state.
     */
    constructor() {
        _paused = false;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        _requireNotPaused();
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        _requirePaused();
        _;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        if (paused()) {
            revert EnforcedPause();
        }
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        if (!paused()) {
            revert ExpectedPause();
        }
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
}

File 20 of 26 : IOracle.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.13;

interface IOracle {
    function price(uint80 roundId) external view returns (uint256);
    function timestamp(uint80 roundId) external view returns (uint256);
    function roundId() external view returns (uint80);
}

File 21 of 26 : IYieldSource.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

interface IYieldSource {

    function asset() external view returns (address);
    function balance() external view returns (uint256);
    function deposit() external payable returns (uint256);
    function withdraw(uint256 amount, address receiver) external;

}

File 22 of 26 : HodlToken.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

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

import { HodlMultiToken } from "../multi/HodlMultiToken.sol";

// HodlToken is an ERC20 wrapper on top of the ERC1155 HodlMultiToken. It
// represents a token at a particular strike, and can be composed inside defi
// applications that expect ERC20 tokens. For example, it can be used to create
// a swap liquidity pool in protocols that operate on ERC20 tokens.
contract HodlToken is IERC20 {

    mapping(address => mapping(address => uint256)) private _allowances;

    HodlMultiToken public immutable hodlMulti;
    uint256 public immutable strike;

    string private _name;
    string private _symbol;

    constructor(address hodlMulti_, uint64 strike_) {
        require(hodlMulti_ != address(0));

        hodlMulti = HodlMultiToken(hodlMulti_);
        strike = strike_;

        _name = hodlMulti.name(strike);
        _symbol = hodlMulti.symbol(strike);
    }

    function name() public view virtual returns (string memory) {
        return _name;
    }

    function symbol() public view virtual returns (string memory) {
        return _symbol;
    }

    function decimals() public view virtual returns (uint8) {
        return 18;
    }

    function totalSupply() public view returns (uint256) {
        return hodlMulti.totalSupply(strike);
    }

    function balanceOf(address user) public view returns (uint256) {
        return hodlMulti.balanceOf(user, strike);
    }

    function transfer(address to, uint256 amount) public returns (bool) {
        hodlMulti.safeTransferFrom(msg.sender, to, strike, amount, "");

        emit Transfer(msg.sender, to, amount);

        return true;
    }

    function allowance(address owner, address spender) public view returns (uint256) {
        return _allowances[owner][spender];
    }

    function approve(address spender, uint256 amount) public returns (bool) {
        require(spender != address(0), "approve zero address");
        _allowances[msg.sender][spender] = amount;

        emit Approval(msg.sender, spender, amount);

        return true;
    }

    function transferFrom(address from, address to, uint256 amount) public returns (bool) {
        require(from == msg.sender || _allowances[from][msg.sender] >= amount, "not authorized");

        // Decrement the allowance if needed
        if (from != msg.sender &&
            _allowances[from][msg.sender] != type(uint256).max) {

            _allowances[from][msg.sender] -= amount;
        }

        hodlMulti.safeTransferFrom(from, to, strike, amount, "");

        emit Transfer(from, to, amount);

        return true;
    }
}

File 23 of 26 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC-165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[ERC].
 *
 * 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[ERC 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 24 of 26 : StorageSlot.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.

pragma solidity ^0.8.20;

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

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    struct StringSlot {
        string value;
    }

    struct BytesSlot {
        bytes value;
    }

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

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

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

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

    /**
     * @dev Returns an `StringSlot` with member `value` located at `slot`.
     */
    function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `StringSlot` representation of the string storage pointer `store`.
     */
    function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := store.slot
        }
    }

    /**
     * @dev Returns an `BytesSlot` with member `value` located at `slot`.
     */
    function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
     */
    function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := store.slot
        }
    }
}

File 25 of 26 : IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC-20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[ERC-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC-20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 *
 * ==== Security Considerations
 *
 * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
 * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
 * considered as an intention to spend the allowance in any specific way. The second is that because permits have
 * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
 * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
 * generally recommended is:
 *
 * ```solidity
 * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
 *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
 *     doThing(..., value);
 * }
 *
 * function doThing(..., uint256 value) public {
 *     token.safeTransferFrom(msg.sender, address(this), value);
 *     ...
 * }
 * ```
 *
 * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
 * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
 * {SafeERC20-safeTransferFrom}).
 *
 * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
 * contracts should have entry points that don't rely on permit.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     *
     * CAUTION: See Security Considerations above.
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

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

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

File 26 of 26 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)

pragma solidity ^0.8.20;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev The ETH balance of the account is not enough to perform the operation.
     */
    error AddressInsufficientBalance(address account);

    /**
     * @dev There's no code at `target` (it is not a contract).
     */
    error AddressEmptyCode(address target);

    /**
     * @dev A call to an address target failed. The target may have reverted.
     */
    error FailedInnerCall();

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

        (bool success, ) = recipient.call{value: amount}("");
        if (!success) {
            revert FailedInnerCall();
        }
    }

    /**
     * @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 or custom error, it is bubbled
     * up by this function (like regular Solidity function calls). However, if
     * the call reverted with no returned reason, this function reverts with a
     * {FailedInnerCall} error.
     *
     * 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.
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0);
    }

    /**
     * @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`.
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        if (address(this).balance < value) {
            revert AddressInsufficientBalance(address(this));
        }
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

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

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

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
     * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
     * unsuccessful call.
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata
    ) internal view returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            // only check if target is a contract if the call was successful and the return data is empty
            // otherwise we already know that it was a contract
            if (returndata.length == 0 && target.code.length == 0) {
                revert AddressEmptyCode(target);
            }
            return returndata;
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
     * revert reason or with a default {FailedInnerCall} error.
     */
    function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            return returndata;
        }
    }

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

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"string","name":"uri_","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ERC1155InsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC1155InvalidApprover","type":"error"},{"inputs":[{"internalType":"uint256","name":"idsLength","type":"uint256"},{"internalType":"uint256","name":"valuesLength","type":"uint256"}],"name":"ERC1155InvalidArrayLength","type":"error"},{"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"ERC1155InvalidOperator","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC1155InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC1155InvalidSender","type":"error"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"address","name":"owner","type":"address"}],"name":"ERC1155MissingApprovalForAll","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"Authorize","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"strike","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Burn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"strike","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Mint","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":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"TransferBatch","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"TransferSingle","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"value","type":"string"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"URI","type":"event"},{"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"authorize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"authorized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"balanceOfBatch","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"strike","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"strike","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"strike","type":"uint256"}],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nextId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeBatchTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"strike","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"strike","type":"uint256"}],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"uri","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"}]

608060405260016004553480156200001657600080fd5b5060405162001c3038038062001c30833981016040819052620000399162000103565b3381620000468162000089565b506001600160a01b0381166200007657604051631e4fbdf760e01b81526000600482015260240160405180910390fd5b62000081816200009b565b505062000333565b600262000097828262000267565b5050565b600380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b634e487b7160e01b600052604160045260246000fd5b600060208083850312156200011757600080fd5b82516001600160401b03808211156200012f57600080fd5b818501915085601f8301126200014457600080fd5b815181811115620001595762000159620000ed565b604051601f8201601f19908116603f01168101908382118183101715620001845762000184620000ed565b8160405282815288868487010111156200019d57600080fd5b600093505b82841015620001c15784840186015181850187015292850192620001a2565b600086848301015280965050505050505092915050565b600181811c90821680620001ed57607f821691505b6020821081036200020e57634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200026257600081815260208120601f850160051c810160208610156200023d5750805b601f850160051c820191505b818110156200025e5782815560010162000249565b5050505b505050565b81516001600160401b03811115620002835762000283620000ed565b6200029b81620002948454620001d8565b8462000214565b602080601f831160018114620002d35760008415620002ba5750858301515b600019600386901b1c1916600185901b1785556200025e565b600085815260208120601f198616915b828110156200030457888601518255948401946001909101908401620002e3565b5085821015620003235787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b6118ed80620003436000396000f3fe608060405234801561001057600080fd5b506004361061011f5760003560e01c8063715018a6116100ad578063bd85b03911610071578063bd85b03914610274578063e985e9c514610294578063f242432a146102a7578063f2fde38b146102ba578063f5298aca146102cd57600080fd5b8063715018a6146102085780638da5cb5b14610210578063a22cb4651461022b578063b6a5d7de1461023e578063b91816111461025157600080fd5b8063156e29f6116100f4578063156e29f6146101a45780632eb2c2d6146101b95780634e1273f4146101cc5780634e41a1fb146101ec57806361b8ce8c146101ff57600080fd5b8062ad800c14610124578062fdd58e1461014d57806301ffc9a71461016e5780630e89341c14610191575b600080fd5b61013761013236600461119f565b6102e0565b6040516101449190611208565b60405180910390f35b61016061015b366004611239565b610341565b604051908152602001610144565b61018161017c366004611279565b610369565b6040519015158152602001610144565b61013761019f36600461119f565b6103b9565b6101b76101b2366004611296565b61044d565b005b6101b76101c736600461140f565b6104de565b6101df6101da3660046114b9565b61054a565b60405161014491906115b4565b6101376101fa36600461119f565b61061f565b61016060045481565b6101b761062a565b6003546040516001600160a01b039091168152602001610144565b6101b76102393660046115c7565b61063e565b6101b761024c366004611603565b61064d565b61018161025f366004611603565b60066020526000908152604090205460ff1681565b61016061028236600461119f565b60056020526000908152604090205481565b6101816102a236600461161e565b6106a1565b6101b76102b5366004611651565b6106cf565b6101b76102c8366004611603565b6108cd565b6101b76102db366004611296565b61090b565b60606102f06305f5e100836116cc565b6000036103335761030d6103086305f5e100846116f6565b61097e565b60405160200161031d919061170a565b6040516020818303038152906040529050919050565b61030d8261097e565b919050565b6000818152602081815260408083206001600160a01b03861684529091529020545b92915050565b60006001600160e01b03198216636cdb3d1360e11b148061039a57506001600160e01b031982166303a24d0760e21b145b8061036357506301ffc9a760e01b6001600160e01b0319831614610363565b6060600280546103c89061173a565b80601f01602080910402602001604051908101604052809291908181526020018280546103f49061173a565b80156104415780601f1061041657610100808354040283529160200191610441565b820191906000526020600020905b81548152906001019060200180831161042457829003601f168201915b50505050509050919050565b610455610a11565b60008281526005602052604081208054839290610473908490611774565b9250508190555061049583838360405180602001604052806000815250610a3e565b81836001600160a01b03167f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f836040516104d191815260200190565b60405180910390a3505050565b336001600160a01b03861681148015906104ff57506104fd86826106a1565b155b156105355760405163711bec9160e11b81526001600160a01b038083166004830152871660248201526044015b60405180910390fd5b6105428686868686610a9b565b505050505050565b6060815183511461057b5781518351604051635b05999160e01b81526004810192909252602482015260440161052c565b6000835167ffffffffffffffff811115610597576105976112c9565b6040519080825280602002602001820160405280156105c0578160200160208202803683370190505b50905060005b8451811015610617576020808202860101516105ea90602080840287010151610341565b8282815181106105fc576105fc611787565b60209081029190910101526106108161179d565b90506105c6565b509392505050565b6060610363826102e0565b610632610a11565b61063c6000610b02565b565b610649338383610b54565b5050565b610655610a11565b6001600160a01b038116600081815260066020526040808220805460ff19166001179055517f6d81a01b39982517ba331aeb4f387b0f9cc32334b65bb9a343a077973cf7adf59190a250565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205460ff1690565b846001600160a01b0316846001600160a01b0316036107255760405162461bcd60e51b81526020600482015260126024820152713437b2361039b2b633103a3930b739b332b960711b604482015260640161052c565b600082116107755760405162461bcd60e51b815260206004820152601860248201527f686f646c207a65726f2076616c7565207472616e736665720000000000000000604482015260640161052c565b6001600160a01b03841661079f57604051632bfa23e760e11b81526000600482015260240161052c565b6001600160a01b0385166107c857604051626a0d4560e21b81526000600482015260240161052c565b6001600160a01b03851633148015906107e857506107e685336106a1565b155b801561080457503360009081526006602052604090205460ff16155b156108335760405163711bec9160e11b81523360048201526001600160a01b038616602482015260440161052c565b604080516001808252818301909252600091602080830190803683375050604080516001808252818301909252929350600092915060208083019080368337019050509050848260008151811061088c5761088c611787565b60200260200101818152505083816000815181106108ac576108ac611787565b6020026020010181815250506108c487878484610be2565b50505050505050565b6108d5610a11565b6001600160a01b0381166108ff57604051631e4fbdf760e01b81526000600482015260240161052c565b61090881610b02565b50565b610913610a11565b600082815260056020526040812080548392906109319084906117b6565b909155506109429050838383610dff565b81836001600160a01b03167f49995e5dd6158cf69ad3e9777c46755a1a826a446c6416992167462dad033b2a836040516104d191815260200190565b6060600061098b83610e67565b600101905060008167ffffffffffffffff8111156109ab576109ab6112c9565b6040519080825280601f01601f1916602001820160405280156109d5576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a85049450846109df57509392505050565b6003546001600160a01b0316331461063c5760405163118cdaa760e01b815233600482015260240161052c565b6001600160a01b038416610a6857604051632bfa23e760e11b81526000600482015260240161052c565b60408051600180825260208201869052818301908152606082018590526080820190925290610542600087848487610f3f565b6001600160a01b038416610ac557604051632bfa23e760e11b81526000600482015260240161052c565b6001600160a01b038516610aee57604051626a0d4560e21b81526000600482015260240161052c565b610afb8585858585610f3f565b5050505050565b600380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b038216610b7d5760405162ced3e160e81b81526000600482015260240161052c565b6001600160a01b03838116600081815260016020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3191016104d1565b8051825114610c115781518151604051635b05999160e01b81526004810192909252602482015260440161052c565b3360005b8351811015610d20576020818102858101820151908501909101516001600160a01b03881615610cc8576000828152602081815260408083206001600160a01b038c16845290915290205481811015610ca1576040516303dee4c560e01b81526001600160a01b038a16600482015260248101829052604481018390526064810184905260840161052c565b6000838152602081815260408083206001600160a01b038d16845290915290209082900390555b6001600160a01b03871615610d0d576000828152602081815260408083206001600160a01b038b16845290915281208054839290610d07908490611774565b90915550505b505080610d199061179d565b9050610c15565b508251600103610da15760208301516000906020840151909150856001600160a01b0316876001600160a01b0316846001600160a01b03167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f628585604051610d92929190918252602082015260400190565b60405180910390a45050610afb565b836001600160a01b0316856001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8686604051610df09291906117c9565b60405180910390a45050505050565b6001600160a01b038316610e2857604051626a0d4560e21b81526000600482015260240161052c565b604080516001808252602082018590528183019081526060820184905260a08201909252600060808201818152919291610afb91879185908590610f3f565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b8310610ea65772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef81000000008310610ed2576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc100008310610ef057662386f26fc10000830492506010015b6305f5e1008310610f08576305f5e100830492506008015b6127108310610f1c57612710830492506004015b60648310610f2e576064830492506002015b600a83106103635760010192915050565b610f4b85858585610be2565b6001600160a01b03841615610afb5782513390600103610f845760208481015190840151610f7d838989858589610f92565b5050610542565b6105428187878787876110b6565b6001600160a01b0384163b156105425760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e6190610fd690899089908890889088906004016117f7565b6020604051808303816000875af1925050508015611011575060408051601f3d908101601f1916820190925261100e9181019061183c565b60015b61107a573d80801561103f576040519150601f19603f3d011682016040523d82523d6000602084013e611044565b606091505b50805160000361107257604051632bfa23e760e11b81526001600160a01b038616600482015260240161052c565b805181602001fd5b6001600160e01b0319811663f23a6e6160e01b146108c457604051632bfa23e760e11b81526001600160a01b038616600482015260240161052c565b6001600160a01b0384163b156105425760405163bc197c8160e01b81526001600160a01b0385169063bc197c81906110fa9089908990889088908890600401611859565b6020604051808303816000875af1925050508015611135575060408051601f3d908101601f191682019092526111329181019061183c565b60015b611163573d80801561103f576040519150601f19603f3d011682016040523d82523d6000602084013e611044565b6001600160e01b0319811663bc197c8160e01b146108c457604051632bfa23e760e11b81526001600160a01b038616600482015260240161052c565b6000602082840312156111b157600080fd5b5035919050565b60005b838110156111d35781810151838201526020016111bb565b50506000910152565b600081518084526111f48160208601602086016111b8565b601f01601f19169290920160200192915050565b60208152600061121b60208301846111dc565b9392505050565b80356001600160a01b038116811461033c57600080fd5b6000806040838503121561124c57600080fd5b61125583611222565b946020939093013593505050565b6001600160e01b03198116811461090857600080fd5b60006020828403121561128b57600080fd5b813561121b81611263565b6000806000606084860312156112ab57600080fd5b6112b484611222565b95602085013595506040909401359392505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715611308576113086112c9565b604052919050565b600067ffffffffffffffff82111561132a5761132a6112c9565b5060051b60200190565b600082601f83011261134557600080fd5b8135602061135a61135583611310565b6112df565b82815260059290921b8401810191818101908684111561137957600080fd5b8286015b84811015611394578035835291830191830161137d565b509695505050505050565b600082601f8301126113b057600080fd5b813567ffffffffffffffff8111156113ca576113ca6112c9565b6113dd601f8201601f19166020016112df565b8181528460208386010111156113f257600080fd5b816020850160208301376000918101602001919091529392505050565b600080600080600060a0868803121561142757600080fd5b61143086611222565b945061143e60208701611222565b9350604086013567ffffffffffffffff8082111561145b57600080fd5b61146789838a01611334565b9450606088013591508082111561147d57600080fd5b61148989838a01611334565b9350608088013591508082111561149f57600080fd5b506114ac8882890161139f565b9150509295509295909350565b600080604083850312156114cc57600080fd5b823567ffffffffffffffff808211156114e457600080fd5b818501915085601f8301126114f857600080fd5b8135602061150861135583611310565b82815260059290921b8401810191818101908984111561152757600080fd5b948201945b8386101561154c5761153d86611222565b8252948201949082019061152c565b9650508601359250508082111561156257600080fd5b5061156f85828601611334565b9150509250929050565b600081518084526020808501945080840160005b838110156115a95781518752958201959082019060010161158d565b509495945050505050565b60208152600061121b6020830184611579565b600080604083850312156115da57600080fd5b6115e383611222565b9150602083013580151581146115f857600080fd5b809150509250929050565b60006020828403121561161557600080fd5b61121b82611222565b6000806040838503121561163157600080fd5b61163a83611222565b915061164860208401611222565b90509250929050565b600080600080600060a0868803121561166957600080fd5b61167286611222565b945061168060208701611222565b93506040860135925060608601359150608086013567ffffffffffffffff8111156116aa57600080fd5b6114ac8882890161139f565b634e487b7160e01b600052601260045260246000fd5b6000826116db576116db6116b6565b500690565b634e487b7160e01b600052601160045260246000fd5b600082611705576117056116b6565b500490565b670383622aa241020160c51b81526000825161172d8160088501602087016111b8565b9190910160080192915050565b600181811c9082168061174e57607f821691505b60208210810361176e57634e487b7160e01b600052602260045260246000fd5b50919050565b80820180821115610363576103636116e0565b634e487b7160e01b600052603260045260246000fd5b6000600182016117af576117af6116e0565b5060010190565b81810381811115610363576103636116e0565b6040815260006117dc6040830185611579565b82810360208401526117ee8185611579565b95945050505050565b6001600160a01b03868116825285166020820152604081018490526060810183905260a060808201819052600090611831908301846111dc565b979650505050505050565b60006020828403121561184e57600080fd5b815161121b81611263565b6001600160a01b0386811682528516602082015260a06040820181905260009061188590830186611579565b82810360608401526118978186611579565b905082810360808401526118ab81856111dc565b9897505050505050505056fea26469706673582212201d706eff9acc6c9daf336aec621b6a97acd83ef406670eb9cb19f82e22ea1cb064736f6c6343000814003300000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061011f5760003560e01c8063715018a6116100ad578063bd85b03911610071578063bd85b03914610274578063e985e9c514610294578063f242432a146102a7578063f2fde38b146102ba578063f5298aca146102cd57600080fd5b8063715018a6146102085780638da5cb5b14610210578063a22cb4651461022b578063b6a5d7de1461023e578063b91816111461025157600080fd5b8063156e29f6116100f4578063156e29f6146101a45780632eb2c2d6146101b95780634e1273f4146101cc5780634e41a1fb146101ec57806361b8ce8c146101ff57600080fd5b8062ad800c14610124578062fdd58e1461014d57806301ffc9a71461016e5780630e89341c14610191575b600080fd5b61013761013236600461119f565b6102e0565b6040516101449190611208565b60405180910390f35b61016061015b366004611239565b610341565b604051908152602001610144565b61018161017c366004611279565b610369565b6040519015158152602001610144565b61013761019f36600461119f565b6103b9565b6101b76101b2366004611296565b61044d565b005b6101b76101c736600461140f565b6104de565b6101df6101da3660046114b9565b61054a565b60405161014491906115b4565b6101376101fa36600461119f565b61061f565b61016060045481565b6101b761062a565b6003546040516001600160a01b039091168152602001610144565b6101b76102393660046115c7565b61063e565b6101b761024c366004611603565b61064d565b61018161025f366004611603565b60066020526000908152604090205460ff1681565b61016061028236600461119f565b60056020526000908152604090205481565b6101816102a236600461161e565b6106a1565b6101b76102b5366004611651565b6106cf565b6101b76102c8366004611603565b6108cd565b6101b76102db366004611296565b61090b565b60606102f06305f5e100836116cc565b6000036103335761030d6103086305f5e100846116f6565b61097e565b60405160200161031d919061170a565b6040516020818303038152906040529050919050565b61030d8261097e565b919050565b6000818152602081815260408083206001600160a01b03861684529091529020545b92915050565b60006001600160e01b03198216636cdb3d1360e11b148061039a57506001600160e01b031982166303a24d0760e21b145b8061036357506301ffc9a760e01b6001600160e01b0319831614610363565b6060600280546103c89061173a565b80601f01602080910402602001604051908101604052809291908181526020018280546103f49061173a565b80156104415780601f1061041657610100808354040283529160200191610441565b820191906000526020600020905b81548152906001019060200180831161042457829003601f168201915b50505050509050919050565b610455610a11565b60008281526005602052604081208054839290610473908490611774565b9250508190555061049583838360405180602001604052806000815250610a3e565b81836001600160a01b03167f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f836040516104d191815260200190565b60405180910390a3505050565b336001600160a01b03861681148015906104ff57506104fd86826106a1565b155b156105355760405163711bec9160e11b81526001600160a01b038083166004830152871660248201526044015b60405180910390fd5b6105428686868686610a9b565b505050505050565b6060815183511461057b5781518351604051635b05999160e01b81526004810192909252602482015260440161052c565b6000835167ffffffffffffffff811115610597576105976112c9565b6040519080825280602002602001820160405280156105c0578160200160208202803683370190505b50905060005b8451811015610617576020808202860101516105ea90602080840287010151610341565b8282815181106105fc576105fc611787565b60209081029190910101526106108161179d565b90506105c6565b509392505050565b6060610363826102e0565b610632610a11565b61063c6000610b02565b565b610649338383610b54565b5050565b610655610a11565b6001600160a01b038116600081815260066020526040808220805460ff19166001179055517f6d81a01b39982517ba331aeb4f387b0f9cc32334b65bb9a343a077973cf7adf59190a250565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205460ff1690565b846001600160a01b0316846001600160a01b0316036107255760405162461bcd60e51b81526020600482015260126024820152713437b2361039b2b633103a3930b739b332b960711b604482015260640161052c565b600082116107755760405162461bcd60e51b815260206004820152601860248201527f686f646c207a65726f2076616c7565207472616e736665720000000000000000604482015260640161052c565b6001600160a01b03841661079f57604051632bfa23e760e11b81526000600482015260240161052c565b6001600160a01b0385166107c857604051626a0d4560e21b81526000600482015260240161052c565b6001600160a01b03851633148015906107e857506107e685336106a1565b155b801561080457503360009081526006602052604090205460ff16155b156108335760405163711bec9160e11b81523360048201526001600160a01b038616602482015260440161052c565b604080516001808252818301909252600091602080830190803683375050604080516001808252818301909252929350600092915060208083019080368337019050509050848260008151811061088c5761088c611787565b60200260200101818152505083816000815181106108ac576108ac611787565b6020026020010181815250506108c487878484610be2565b50505050505050565b6108d5610a11565b6001600160a01b0381166108ff57604051631e4fbdf760e01b81526000600482015260240161052c565b61090881610b02565b50565b610913610a11565b600082815260056020526040812080548392906109319084906117b6565b909155506109429050838383610dff565b81836001600160a01b03167f49995e5dd6158cf69ad3e9777c46755a1a826a446c6416992167462dad033b2a836040516104d191815260200190565b6060600061098b83610e67565b600101905060008167ffffffffffffffff8111156109ab576109ab6112c9565b6040519080825280601f01601f1916602001820160405280156109d5576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a85049450846109df57509392505050565b6003546001600160a01b0316331461063c5760405163118cdaa760e01b815233600482015260240161052c565b6001600160a01b038416610a6857604051632bfa23e760e11b81526000600482015260240161052c565b60408051600180825260208201869052818301908152606082018590526080820190925290610542600087848487610f3f565b6001600160a01b038416610ac557604051632bfa23e760e11b81526000600482015260240161052c565b6001600160a01b038516610aee57604051626a0d4560e21b81526000600482015260240161052c565b610afb8585858585610f3f565b5050505050565b600380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b038216610b7d5760405162ced3e160e81b81526000600482015260240161052c565b6001600160a01b03838116600081815260016020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3191016104d1565b8051825114610c115781518151604051635b05999160e01b81526004810192909252602482015260440161052c565b3360005b8351811015610d20576020818102858101820151908501909101516001600160a01b03881615610cc8576000828152602081815260408083206001600160a01b038c16845290915290205481811015610ca1576040516303dee4c560e01b81526001600160a01b038a16600482015260248101829052604481018390526064810184905260840161052c565b6000838152602081815260408083206001600160a01b038d16845290915290209082900390555b6001600160a01b03871615610d0d576000828152602081815260408083206001600160a01b038b16845290915281208054839290610d07908490611774565b90915550505b505080610d199061179d565b9050610c15565b508251600103610da15760208301516000906020840151909150856001600160a01b0316876001600160a01b0316846001600160a01b03167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f628585604051610d92929190918252602082015260400190565b60405180910390a45050610afb565b836001600160a01b0316856001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8686604051610df09291906117c9565b60405180910390a45050505050565b6001600160a01b038316610e2857604051626a0d4560e21b81526000600482015260240161052c565b604080516001808252602082018590528183019081526060820184905260a08201909252600060808201818152919291610afb91879185908590610f3f565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b8310610ea65772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef81000000008310610ed2576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc100008310610ef057662386f26fc10000830492506010015b6305f5e1008310610f08576305f5e100830492506008015b6127108310610f1c57612710830492506004015b60648310610f2e576064830492506002015b600a83106103635760010192915050565b610f4b85858585610be2565b6001600160a01b03841615610afb5782513390600103610f845760208481015190840151610f7d838989858589610f92565b5050610542565b6105428187878787876110b6565b6001600160a01b0384163b156105425760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e6190610fd690899089908890889088906004016117f7565b6020604051808303816000875af1925050508015611011575060408051601f3d908101601f1916820190925261100e9181019061183c565b60015b61107a573d80801561103f576040519150601f19603f3d011682016040523d82523d6000602084013e611044565b606091505b50805160000361107257604051632bfa23e760e11b81526001600160a01b038616600482015260240161052c565b805181602001fd5b6001600160e01b0319811663f23a6e6160e01b146108c457604051632bfa23e760e11b81526001600160a01b038616600482015260240161052c565b6001600160a01b0384163b156105425760405163bc197c8160e01b81526001600160a01b0385169063bc197c81906110fa9089908990889088908890600401611859565b6020604051808303816000875af1925050508015611135575060408051601f3d908101601f191682019092526111329181019061183c565b60015b611163573d80801561103f576040519150601f19603f3d011682016040523d82523d6000602084013e611044565b6001600160e01b0319811663bc197c8160e01b146108c457604051632bfa23e760e11b81526001600160a01b038616600482015260240161052c565b6000602082840312156111b157600080fd5b5035919050565b60005b838110156111d35781810151838201526020016111bb565b50506000910152565b600081518084526111f48160208601602086016111b8565b601f01601f19169290920160200192915050565b60208152600061121b60208301846111dc565b9392505050565b80356001600160a01b038116811461033c57600080fd5b6000806040838503121561124c57600080fd5b61125583611222565b946020939093013593505050565b6001600160e01b03198116811461090857600080fd5b60006020828403121561128b57600080fd5b813561121b81611263565b6000806000606084860312156112ab57600080fd5b6112b484611222565b95602085013595506040909401359392505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715611308576113086112c9565b604052919050565b600067ffffffffffffffff82111561132a5761132a6112c9565b5060051b60200190565b600082601f83011261134557600080fd5b8135602061135a61135583611310565b6112df565b82815260059290921b8401810191818101908684111561137957600080fd5b8286015b84811015611394578035835291830191830161137d565b509695505050505050565b600082601f8301126113b057600080fd5b813567ffffffffffffffff8111156113ca576113ca6112c9565b6113dd601f8201601f19166020016112df565b8181528460208386010111156113f257600080fd5b816020850160208301376000918101602001919091529392505050565b600080600080600060a0868803121561142757600080fd5b61143086611222565b945061143e60208701611222565b9350604086013567ffffffffffffffff8082111561145b57600080fd5b61146789838a01611334565b9450606088013591508082111561147d57600080fd5b61148989838a01611334565b9350608088013591508082111561149f57600080fd5b506114ac8882890161139f565b9150509295509295909350565b600080604083850312156114cc57600080fd5b823567ffffffffffffffff808211156114e457600080fd5b818501915085601f8301126114f857600080fd5b8135602061150861135583611310565b82815260059290921b8401810191818101908984111561152757600080fd5b948201945b8386101561154c5761153d86611222565b8252948201949082019061152c565b9650508601359250508082111561156257600080fd5b5061156f85828601611334565b9150509250929050565b600081518084526020808501945080840160005b838110156115a95781518752958201959082019060010161158d565b509495945050505050565b60208152600061121b6020830184611579565b600080604083850312156115da57600080fd5b6115e383611222565b9150602083013580151581146115f857600080fd5b809150509250929050565b60006020828403121561161557600080fd5b61121b82611222565b6000806040838503121561163157600080fd5b61163a83611222565b915061164860208401611222565b90509250929050565b600080600080600060a0868803121561166957600080fd5b61167286611222565b945061168060208701611222565b93506040860135925060608601359150608086013567ffffffffffffffff8111156116aa57600080fd5b6114ac8882890161139f565b634e487b7160e01b600052601260045260246000fd5b6000826116db576116db6116b6565b500690565b634e487b7160e01b600052601160045260246000fd5b600082611705576117056116b6565b500490565b670383622aa241020160c51b81526000825161172d8160088501602087016111b8565b9190910160080192915050565b600181811c9082168061174e57607f821691505b60208210810361176e57634e487b7160e01b600052602260045260246000fd5b50919050565b80820180821115610363576103636116e0565b634e487b7160e01b600052603260045260246000fd5b6000600182016117af576117af6116e0565b5060010190565b81810381811115610363576103636116e0565b6040815260006117dc6040830185611579565b82810360208401526117ee8185611579565b95945050505050565b6001600160a01b03868116825285166020820152604081018490526060810183905260a060808201819052600090611831908301846111dc565b979650505050505050565b60006020828403121561184e57600080fd5b815161121b81611263565b6001600160a01b0386811682528516602082015260a06040820181905260009061188590830186611579565b82810360608401526118978186611579565b905082810360808401526118ab81856111dc565b9897505050505050505056fea26469706673582212201d706eff9acc6c9daf336aec621b6a97acd83ef406670eb9cb19f82e22ea1cb064736f6c63430008140033

Loading...
Loading
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.