ETH Price: $2,521.75 (+1.12%)

Contract

0xD4C5871592A42109518d208337f655e872180D9A
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Create ERC404202223652024-07-03 0:20:3561 days ago1719966035IN
0xD4C58715...872180D9A
2.1 ETH0.016631342.9473519
0x61010060202085182024-07-01 1:54:5963 days ago1719798899IN
 Create: ERC404TokenFactory
0 ETH0.01550683.59232874

Latest 2 internal transactions

Advanced mode:
Parent Transaction Hash Block From To
202223652024-07-03 0:20:3561 days ago1719966035
0xD4C58715...872180D9A
2.1 ETH
202223652024-07-03 0:20:3561 days ago1719966035
0xD4C58715...872180D9A
 Contract Creation0 ETH
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ERC404TokenFactory

Compiler Version
v0.8.23+commit.f704f362

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion
File 1 of 19 : ERC404TokenFactory.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;

import {BaseFactory, IERC20, IUniswapV2Factory, IUniswapV2Router02} from "../BaseFactory.sol";

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

/// @title ERC404TokenFactory
/// @notice A factory contract to create new non-ruggable ERC404 tokens
contract ERC404TokenFactory is BaseFactory {
    // ============================================================================================
    // Constructor
    // ============================================================================================

    constructor(
        IERC20 _wnt,
        IUniswapV2Router02 _univ2router,
        IUniswapV2Factory _univ2factory,
        address _treasury
    ) BaseFactory(_wnt, _univ2router, _univ2factory, _treasury) {}

    // ============================================================================================
    // External Functions
    // ============================================================================================

    /// @notice Create a new ERC404 token, add liquidity and burn the LP tokens
    /// @param _name The token name
    /// @param _symbol The token symbol
    /// @param _baseURI The base URI
    /// @param _totalSupply The total supply
    /// @param _tokenLiquidityThreshold_ The token liquidity threshold

    /// @return The pair address and the token address
    function createERC404(
        string memory _name,
        string memory _symbol,
        string memory _baseURI,
        uint96 _totalSupply,
        uint256 _tokenLiquidityThreshold
    ) external payable nonReentrant returns (address, address) {
        require(_tokenLiquidityThreshold >= _totalSupply * 2/ 10000 && _tokenLiquidityThreshold <= _totalSupply / 100, "tokenLiquidityThreshold must 0.02-1% of supply");
        BaseERC404 _token = new BaseERC404(
            wnt,
            univ2router,
            treasury,
            _name,
            _symbol,
            _baseURI,
            _totalSupply,
            _tokenLiquidityThreshold,
            univ2factory
        );
        address _pair = _addLiquidityAndBurn(address(_token));
        emit TokenCreated(address(_token), _name, _symbol, _totalSupply);

        return (_pair, address(_token));
    }
}

File 2 of 19 : BaseFactory.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
import {ReentrancyGuard} from "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import {Address} from "@openzeppelin/contracts/utils/Address.sol";

import {IUniswapV2Router02} from "@uniswap-periphery/interfaces/IUniswapV2Router02.sol";
import {IUniswapV2Factory} from "@uniswap-core/interfaces/IUniswapV2Factory.sol";

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

/// @title BaseFactory
/// @notice A base factory contract to create new non-ruggable ERC20/ERC404 tokens
abstract contract BaseFactory is ReentrancyGuard {
    using SafeERC20 for IERC20;
    using Address for address payable;

    address public immutable treasury;

    IERC20 public immutable wnt;
    IUniswapV2Router02 public immutable univ2router;
    IUniswapV2Factory public immutable univ2factory;

    uint256 public constant SWAP_TAX = 125; // 0.25%
    uint256 public constant PRECISION = 10000;

    // ============================================================================================
    // Constructor
    // ============================================================================================

    constructor(
        IERC20 _wnt,
        IUniswapV2Router02 _univ2router,
        IUniswapV2Factory _univ2factory,
        address _treasury
    ) {
        if (_treasury == address(0)) revert InvalidAddress();

        wnt = _wnt;
        univ2router = _univ2router;
        univ2factory = _univ2factory;

        treasury = _treasury;

        if (block.chainid == 252) {
            // https://docs.frax.com/fraxtal/fraxtal-incentives/fraxtal-incentives-delegation#setting-delegations-for-smart-contracts
            address _delegationRegistry = 0x4392dC16867D53DBFE227076606455634d4c2795;
            _delegationRegistry.call(
                abi.encodeWithSignature(
                    "setDelegationForSelf(address)",
                    _treasury
                )
            );
            _delegationRegistry.call(
                abi.encodeWithSignature("disableSelfManagingDelegations()")
            );
        }
    }

    // ============================================================================================
    // Internal Functions
    // ============================================================================================

    function _addLiquidityAndBurn(
        address _token
    ) internal returns (address _pair) {
        if (msg.value == 0) revert InvalidAmount();

        payable(address(wnt)).functionCallWithValue(
            abi.encodeWithSignature("deposit()"),
            msg.value
        );

        uint256 _amountToken = IERC20(_token).balanceOf(address(this));
        uint256 _amountWNT = wnt.balanceOf(address(this));
        // slither-disable-next-line incorrect-equality
        if (_amountToken == 0 || _amountWNT == 0) revert InvalidAmount();

        _pair = univ2factory.getPair(_token, address(wnt));
        (_token, address(wnt));

        IERC20(_token).forceApprove(address(univ2router), _amountToken);
        wnt.forceApprove(address(univ2router), _amountWNT);

        uint256 _liquidity = 0;
        (_amountToken, _amountWNT, _liquidity) = univ2router.addLiquidity(
            _token, // tokenA
            address(wnt), // tokenB
            _amountToken, // amountADesired
            _amountWNT, // amountBDesired
            _amountToken, // amountAMin
            _amountWNT, // amountBMin
            address(0), // to
            block.timestamp // deadline
        );

        emit AddLiquidityAndBurn(
            _amountToken,
            _amountWNT,
            0,
            _liquidity,
            _pair
        );
    }

    // ============================================================================================
    // Events
    // ============================================================================================

    event AddLiquidityAndBurn(
        uint256 amountToken,
        uint256 amountWNT,
        uint256 amountTax,
        uint256 liquidity,
        address pair
    );
    event TokenCreated(
        address token,
        string name,
        string symbol,
        uint256 totalSupply
    );

    // ============================================================================================
    // Errors
    // ============================================================================================

    error InvalidAmount();
    error InvalidAddress();
}

File 3 of 19 : BaseERC404.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;

import {DN404} from "@vectorized/DN404.sol";
import {DN404Mirror} from "@vectorized/DN404Mirror.sol";

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

import {BaseToken, IUniswapV2Router02, IERC20} from "../BaseToken.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import {IUniswapV2Factory} from "@uniswap-core/interfaces/IUniswapV2Factory.sol";

/// @title BaseERC404
/// @notice A standard ERC404 token
contract BaseERC404 is DN404, BaseToken {
    string private _name;
    string private _symbol;
    string private _baseURI;

    IUniswapV2Router02 public router;

    address public pair;
    address tokenFactory;

    uint256 private tokenLiquidityThreshold;
    bool public isSwapping;

    constructor(
        IERC20 _wnt,
        IUniswapV2Router02 _univ2router,
        address _treasury,
        string memory name_,
        string memory symbol_,
        string memory baseURI_,
        uint96 _totalSupply,
        uint256 _tokenLiquidityThreshold,
        IUniswapV2Factory univ2factory
    ) BaseToken(_wnt, _univ2router, _treasury) {
        _name = name_;
        _symbol = symbol_;
        _baseURI = baseURI_;
        _initializeDN404(
            _totalSupply, // initialTokenSupply
            msg.sender, // initialSupplyOwner, TokenFactory
            address(new DN404Mirror(address(0))) // Mirror
        );
        tokenFactory = msg.sender;
        pair = univ2factory.createPair(address(this), address(_wnt));
        router = _univ2router;
        tokenLiquidityThreshold = _tokenLiquidityThreshold;
        _approve(address(this), address(router), type(uint256).max);
        isSwapping = false;
    }

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

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

    function tokenURI(
        uint256 _tokenId
    ) public view override returns (string memory _result) {
        if (bytes(_baseURI).length != 0)
            _result = string(
                abi.encodePacked(_baseURI, Strings.toString(_tokenId))
            );
    }

    function _transfer(
        address from,
        address to,
        uint256 value
    ) internal override {
        require(value > 0, "Transfer amount must be greater than zero");

        uint256 fee = 0;
        if (to == pair || from == pair) {
            if (!(to == address(this) || from == address(this))) {
                if (from != tokenFactory) {
                    fee = ((value * SWAP_TAX) / PRECISION);
                    if (from != pair) {
                        handle_fees();
                    }
                }
            }
        }
        super._transfer(from, to, value - fee);
        if (fee > 0) {
            super._transfer(from, address(this), fee);
        }
    }

    function handle_fees() private {
        uint256 contractBalance = balanceOf(address(this));
        if (contractBalance >= tokenLiquidityThreshold) {
            swapTokensForETH(contractBalance);
        }
    }

    function swapTokensForETH(uint256 tokenAmount) private {
        if (isSwapping) return;
        isSwapping = true;
        address[] memory path = new address[](2);
        path[0] = address(this);
        path[1] = router.WETH();

        router.swapExactTokensForETHSupportingFeeOnTransferTokens(
            tokenAmount,
            0,
            path,
            treasury,
            block.timestamp
        );
        isSwapping = false;
    }
}

File 4 of 19 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

/**
 * @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;

    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
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // 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 5 of 19 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

File 6 of 19 : IUniswapV2Router02.sol
pragma solidity >=0.6.2;

import './IUniswapV2Router01.sol';

interface IUniswapV2Router02 is IUniswapV2Router01 {
    function removeLiquidityETHSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountETH);
    function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountETH);

    function swapExactTokensForTokensSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
    function swapExactETHForTokensSupportingFeeOnTransferTokens(
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external payable;
    function swapExactTokensForETHSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
}

File 7 of 19 : IUniswapV2Factory.sol
pragma solidity >=0.5.0;

interface IUniswapV2Factory {
    event PairCreated(address indexed token0, address indexed token1, address pair, uint);

    function feeTo() external view returns (address);
    function feeToSetter() external view returns (address);

    function getPair(address tokenA, address tokenB) external view returns (address pair);
    function allPairs(uint) external view returns (address pair);
    function allPairsLength() external view returns (uint);

    function createPair(address tokenA, address tokenB) external returns (address pair);

    function setFeeTo(address) external;
    function setFeeToSetter(address) external;
}

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

File 10 of 19 : DN404.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

/// @title DN404
/// @notice DN404 is a hybrid ERC20 and ERC721 implementation that mints
/// and burns NFTs based on an account's ERC20 token balance.
///
/// @author vectorized.eth (@optimizoor)
/// @author Quit (@0xQuit)
/// @author Michael Amadi (@AmadiMichaels)
/// @author cygaar (@0xCygaar)
/// @author Thomas (@0xjustadev)
/// @author Harrison (@PopPunkOnChain)
///
/// @dev Note:
/// - The ERC721 data is stored in this base DN404 contract, however a
///   DN404Mirror contract ***MUST*** be deployed and linked during
///   initialization.
abstract contract DN404 {
    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                           EVENTS                           */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Emitted when `amount` tokens is transferred from `from` to `to`.
    event Transfer(address indexed from, address indexed to, uint256 amount);

    /// @dev Emitted when `amount` tokens is approved by `owner` to be used by `spender`.
    event Approval(address indexed owner, address indexed spender, uint256 amount);

    /// @dev Emitted when `target` sets their skipNFT flag to `status`.
    event SkipNFTSet(address indexed target, bool status);

    /// @dev `keccak256(bytes("Transfer(address,address,uint256)"))`.
    uint256 private constant _TRANSFER_EVENT_SIGNATURE =
        0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef;

    /// @dev `keccak256(bytes("Approval(address,address,uint256)"))`.
    uint256 private constant _APPROVAL_EVENT_SIGNATURE =
        0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925;

    /// @dev `keccak256(bytes("SkipNFTSet(address,bool)"))`.
    uint256 private constant _SKIP_NFT_SET_EVENT_SIGNATURE =
        0xb5a1de456fff688115a4f75380060c23c8532d14ff85f687cc871456d6420393;

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                        CUSTOM ERRORS                       */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Thrown when attempting to double-initialize the contract.
    error DNAlreadyInitialized();

    /// @dev Thrown when attempting to transfer or burn more tokens than sender's balance.
    error InsufficientBalance();

    /// @dev Thrown when a spender attempts to transfer tokens with an insufficient allowance.
    error InsufficientAllowance();

    /// @dev Thrown when minting an amount of tokens that would overflow the max tokens.
    error TotalSupplyOverflow();

    /// @dev The unit cannot be zero.
    error UnitIsZero();

    /// @dev Thrown when the caller for a fallback NFT function is not the mirror contract.
    error SenderNotMirror();

    /// @dev Thrown when attempting to transfer tokens to the zero address.
    error TransferToZeroAddress();

    /// @dev Thrown when the mirror address provided for initialization is the zero address.
    error MirrorAddressIsZero();

    /// @dev Thrown when the link call to the mirror contract reverts.
    error LinkMirrorContractFailed();

    /// @dev Thrown when setting an NFT token approval
    /// and the caller is not the owner or an approved operator.
    error ApprovalCallerNotOwnerNorApproved();

    /// @dev Thrown when transferring an NFT
    /// and the caller is not the owner or an approved operator.
    error TransferCallerNotOwnerNorApproved();

    /// @dev Thrown when transferring an NFT and the from address is not the current owner.
    error TransferFromIncorrectOwner();

    /// @dev Thrown when checking the owner or approved address for a non-existent NFT.
    error TokenDoesNotExist();

    /// @dev The function selector is not recognized.
    error FnSelectorNotRecognized();

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                         CONSTANTS                          */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev The flag to denote that the address data is initialized.
    uint8 internal constant _ADDRESS_DATA_INITIALIZED_FLAG = 1 << 0;

    /// @dev The flag to denote that the address should skip NFTs.
    uint8 internal constant _ADDRESS_DATA_SKIP_NFT_FLAG = 1 << 1;

    /// @dev The flag to denote that the address has overridden the default Permit2 allowance.
    uint8 internal constant _ADDRESS_DATA_OVERRIDE_PERMIT2_FLAG = 1 << 2;

    /// @dev The canonical Permit2 address.
    /// For signature-based allowance granting for single transaction ERC20 `transferFrom`.
    /// To enable, override `_givePermit2DefaultInfiniteAllowance()`.
    /// [Github](https://github.com/Uniswap/permit2)
    /// [Etherscan](https://etherscan.io/address/0x000000000022D473030F116dDEE9F6B43aC78BA3)
    address internal constant _PERMIT2 = 0x000000000022D473030F116dDEE9F6B43aC78BA3;

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                          STORAGE                           */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Struct containing an address's token data and settings.
    struct AddressData {
        // Auxiliary data.
        uint88 aux;
        // Flags for `initialized` and `skipNFT`.
        uint8 flags;
        // The alias for the address. Zero means absence of an alias.
        uint32 addressAlias;
        // The number of NFT tokens.
        uint32 ownedLength;
        // The token balance in wei.
        uint96 balance;
    }

    /// @dev A uint32 map in storage.
    struct Uint32Map {
        uint256 spacer;
    }

    /// @dev A bitmap in storage.
    struct Bitmap {
        uint256 spacer;
    }

    /// @dev A struct to wrap a uint256 in storage.
    struct Uint256Ref {
        uint256 value;
    }

    /// @dev A mapping of an address pair to a Uint256Ref.
    struct AddressPairToUint256RefMap {
        uint256 spacer;
    }

    /// @dev Struct containing the base token contract storage.
    struct DN404Storage {
        // Current number of address aliases assigned.
        uint32 numAliases;
        // Next NFT ID to assign for a mint.
        uint32 nextTokenId;
        // The head of the burned pool.
        uint32 burnedPoolHead;
        // The tail of the burned pool.
        uint32 burnedPoolTail;
        // Total number of NFTs in existence.
        uint32 totalNFTSupply;
        // Total supply of tokens.
        uint96 totalSupply;
        // Address of the NFT mirror contract.
        address mirrorERC721;
        // Mapping of a user alias number to their address.
        mapping(uint32 => address) aliasToAddress;
        // Mapping of user operator approvals for NFTs.
        AddressPairToUint256RefMap operatorApprovals;
        // Mapping of NFT approvals to approved operators.
        mapping(uint256 => address) nftApprovals;
        // Bitmap of whether an non-zero NFT approval may exist.
        Bitmap mayHaveNFTApproval;
        // Bitmap of whether a NFT ID exists. Ignored if `_useExistsLookup()` returns false.
        Bitmap exists;
        // Mapping of user allowances for ERC20 spenders.
        AddressPairToUint256RefMap allowance;
        // Mapping of NFT IDs owned by an address.
        mapping(address => Uint32Map) owned;
        // The pool of burned NFT IDs.
        Uint32Map burnedPool;
        // Even indices: owner aliases. Odd indices: owned indices.
        Uint32Map oo;
        // Mapping of user account AddressData.
        mapping(address => AddressData) addressData;
    }

    /// @dev Returns a storage pointer for DN404Storage.
    function _getDN404Storage() internal pure virtual returns (DN404Storage storage $) {
        /// @solidity memory-safe-assembly
        assembly {
            // `uint72(bytes9(keccak256("DN404_STORAGE")))`.
            $.slot := 0xa20d6e21d0e5255308 // Truncate to 9 bytes to reduce bytecode size.
        }
    }

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                         INITIALIZER                        */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Initializes the DN404 contract with an
    /// `initialTokenSupply`, `initialTokenOwner` and `mirror` NFT contract address.
    function _initializeDN404(
        uint256 initialTokenSupply,
        address initialSupplyOwner,
        address mirror
    ) internal virtual {
        DN404Storage storage $ = _getDN404Storage();

        if (_unit() == 0) revert UnitIsZero();
        if ($.mirrorERC721 != address(0)) revert DNAlreadyInitialized();
        if (mirror == address(0)) revert MirrorAddressIsZero();

        /// @solidity memory-safe-assembly
        assembly {
            // Make the call to link the mirror contract.
            mstore(0x00, 0x0f4599e5) // `linkMirrorContract(address)`.
            mstore(0x20, caller())
            if iszero(and(eq(mload(0x00), 1), call(gas(), mirror, 0, 0x1c, 0x24, 0x00, 0x20))) {
                mstore(0x00, 0xd125259c) // `LinkMirrorContractFailed()`.
                revert(0x1c, 0x04)
            }
        }

        $.nextTokenId = 1;
        $.mirrorERC721 = mirror;

        if (initialTokenSupply != 0) {
            if (initialSupplyOwner == address(0)) revert TransferToZeroAddress();
            if (_totalSupplyOverflows(initialTokenSupply)) revert TotalSupplyOverflow();

            $.totalSupply = uint96(initialTokenSupply);
            AddressData storage initialOwnerAddressData = _addressData(initialSupplyOwner);
            initialOwnerAddressData.balance = uint96(initialTokenSupply);

            /// @solidity memory-safe-assembly
            assembly {
                // Emit the {Transfer} event.
                mstore(0x00, initialTokenSupply)
                log3(0x00, 0x20, _TRANSFER_EVENT_SIGNATURE, 0, shr(96, shl(96, initialSupplyOwner)))
            }

            _setSkipNFT(initialSupplyOwner, true);
        }
    }

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*               BASE UNIT FUNCTION TO OVERRIDE               */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Amount of token balance that is equal to one NFT.
    function _unit() internal view virtual returns (uint256) {
        return 10 ** 18;
    }

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*               METADATA FUNCTIONS TO OVERRIDE               */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Returns the name of the token.
    function name() public view virtual returns (string memory);

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

    /// @dev Returns the Uniform Resource Identifier (URI) for token `id`.
    function tokenURI(uint256 id) public view virtual returns (string memory);

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                       CONFIGURABLES                        */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Returns if direct NFT transfers should be used during ERC20 transfers
    /// whenever possible, instead of burning and re-minting.
    function _useDirectTransfersIfPossible() internal view virtual returns (bool) {
        return true;
    }

    /// @dev Returns if burns should be added to the burn pool.
    /// This returns false by default, which means the NFT IDs are re-minted in a cycle.
    function _addToBurnedPool(uint256 totalNFTSupplyAfterBurn, uint256 totalSupplyAfterBurn)
        internal
        view
        virtual
        returns (bool)
    {
        // Silence unused variable compiler warning.
        totalSupplyAfterBurn = totalNFTSupplyAfterBurn;
        return false;
    }

    /// @dev Returns whether to use the exists bitmap for more efficient
    /// scanning of an empty token ID slot.
    /// Recommended for collections that do not use the burn pool,
    /// and are expected to have nearly all possible NFTs materialized.
    ///
    /// Note: The returned value must be constant after initialization.
    function _useExistsLookup() internal view virtual returns (bool) {
        return true;
    }

    /// @dev Hook that is called after any NFT token transfers, including minting and burning.
    function _afterNFTTransfer(address from, address to, uint256 id) internal virtual {}

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                      ERC20 OPERATIONS                      */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Returns the decimals places of the token. Always 18.
    function decimals() public pure returns (uint8) {
        return 18;
    }

    /// @dev Returns the amount of tokens in existence.
    function totalSupply() public view virtual returns (uint256) {
        return uint256(_getDN404Storage().totalSupply);
    }

    /// @dev Returns the amount of tokens owned by `owner`.
    function balanceOf(address owner) public view virtual returns (uint256) {
        return _getDN404Storage().addressData[owner].balance;
    }

    /// @dev Returns the amount of tokens that `spender` can spend on behalf of `owner`.
    function allowance(address owner, address spender) public view returns (uint256) {
        if (_givePermit2DefaultInfiniteAllowance() && spender == _PERMIT2) {
            uint8 flags = _getDN404Storage().addressData[owner].flags;
            if (flags & _ADDRESS_DATA_OVERRIDE_PERMIT2_FLAG == 0) return type(uint256).max;
        }
        return _ref(_getDN404Storage().allowance, owner, spender).value;
    }

    /// @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
    ///
    /// Emits a {Approval} event.
    function approve(address spender, uint256 amount) public virtual returns (bool) {
        _approve(msg.sender, spender, amount);
        return true;
    }

    /// @dev Transfer `amount` tokens from the caller to `to`.
    ///
    /// Will burn sender NFTs if balance after transfer is less than
    /// the amount required to support the current NFT balance.
    ///
    /// Will mint NFTs to `to` if the recipient's new balance supports
    /// additional NFTs ***AND*** the `to` address's skipNFT flag is
    /// set to false.
    ///
    /// Requirements:
    /// - `from` must at least have `amount`.
    ///
    /// Emits a {Transfer} event.
    function transfer(address to, uint256 amount) public virtual returns (bool) {
        _transfer(msg.sender, to, amount);
        return true;
    }

    /// @dev Transfers `amount` tokens from `from` to `to`.
    ///
    /// Note: Does not update the allowance if it is the maximum uint256 value.
    ///
    /// Will burn sender NFTs if balance after transfer is less than
    /// the amount required to support the current NFT balance.
    ///
    /// Will mint NFTs to `to` if the recipient's new balance supports
    /// additional NFTs ***AND*** the `to` address's skipNFT flag is
    /// set to false.
    ///
    /// Requirements:
    /// - `from` must at least have `amount`.
    /// - The caller must have at least `amount` of allowance to transfer the tokens of `from`.
    ///
    /// Emits a {Transfer} event.
    function transferFrom(address from, address to, uint256 amount) public virtual returns (bool) {
        Uint256Ref storage a = _ref(_getDN404Storage().allowance, from, msg.sender);

        uint256 allowed = _givePermit2DefaultInfiniteAllowance() && msg.sender == _PERMIT2
            && (_getDN404Storage().addressData[from].flags & _ADDRESS_DATA_OVERRIDE_PERMIT2_FLAG) == 0
            ? type(uint256).max
            : a.value;

        if (allowed != type(uint256).max) {
            if (amount > allowed) revert InsufficientAllowance();
            unchecked {
                a.value = allowed - amount;
            }
        }
        _transfer(from, to, amount);
        return true;
    }

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                          PERMIT2                           */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Whether Permit2 has infinite allowances by default for all owners.
    /// For signature-based allowance granting for single transaction ERC20 `transferFrom`.
    /// To enable, override this function to return true.
    function _givePermit2DefaultInfiniteAllowance() internal view virtual returns (bool) {
        return false;
    }

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                  INTERNAL MINT FUNCTIONS                   */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Mints `amount` tokens to `to`, increasing the total supply.
    ///
    /// Will mint NFTs to `to` if the recipient's new balance supports
    /// additional NFTs ***AND*** the `to` address's skipNFT flag is set to false.
    ///
    /// Emits a {Transfer} event.
    function _mint(address to, uint256 amount) internal virtual {
        if (to == address(0)) revert TransferToZeroAddress();

        AddressData storage toAddressData = _addressData(to);
        DN404Storage storage $ = _getDN404Storage();
        if ($.mirrorERC721 == address(0)) revert();

        _DNMintTemps memory t;
        unchecked {
            uint256 toBalance = uint256(toAddressData.balance) + amount;
            toAddressData.balance = uint96(toBalance);
            t.toEnd = toBalance / _unit();
        }
        uint256 maxId;
        unchecked {
            uint256 totalSupply_ = uint256($.totalSupply) + amount;
            $.totalSupply = uint96(totalSupply_);
            uint256 overflows = _toUint(_totalSupplyOverflows(totalSupply_));
            if (overflows | _toUint(totalSupply_ < amount) != 0) revert TotalSupplyOverflow();
            maxId = totalSupply_ / _unit();
        }
        unchecked {
            if (toAddressData.flags & _ADDRESS_DATA_SKIP_NFT_FLAG == 0) {
                Uint32Map storage toOwned = $.owned[to];
                Uint32Map storage oo = $.oo;
                uint256 toIndex = toAddressData.ownedLength;
                _DNPackedLogs memory packedLogs = _packedLogsMalloc(_zeroFloorSub(t.toEnd, toIndex));

                if (packedLogs.logs.length != 0) {
                    _packedLogsSet(packedLogs, to, 0);
                    $.totalNFTSupply += uint32(packedLogs.logs.length);
                    toAddressData.ownedLength = uint32(t.toEnd);
                    t.toAlias = _registerAndResolveAlias(toAddressData, to);
                    uint32 burnedPoolHead = $.burnedPoolHead;
                    t.burnedPoolTail = $.burnedPoolTail;
                    t.nextTokenId = _wrapNFTId($.nextTokenId, maxId);
                    // Mint loop.
                    do {
                        uint256 id;
                        if (burnedPoolHead != t.burnedPoolTail) {
                            id = _get($.burnedPool, burnedPoolHead++);
                        } else {
                            id = t.nextTokenId;
                            while (_get(oo, _ownershipIndex(id)) != 0) {
                                id = _useExistsLookup()
                                    ? _wrapNFTId(_findFirstUnset($.exists, id + 1, maxId + 1), maxId)
                                    : _wrapNFTId(id + 1, maxId);
                            }
                            t.nextTokenId = _wrapNFTId(id + 1, maxId);
                        }
                        if (_useExistsLookup()) _set($.exists, id, true);
                        _set(toOwned, toIndex, uint32(id));
                        _setOwnerAliasAndOwnedIndex(oo, id, t.toAlias, uint32(toIndex++));
                        _packedLogsAppend(packedLogs, id);
                        _afterNFTTransfer(address(0), to, id);
                    } while (toIndex != t.toEnd);

                    $.nextTokenId = uint32(t.nextTokenId);
                    $.burnedPoolHead = burnedPoolHead;
                    _packedLogsSend(packedLogs, $.mirrorERC721);
                }
            }
        }
        /// @solidity memory-safe-assembly
        assembly {
            // Emit the {Transfer} event.
            mstore(0x00, amount)
            log3(0x00, 0x20, _TRANSFER_EVENT_SIGNATURE, 0, shr(96, shl(96, to)))
        }
    }

    /// @dev Mints `amount` tokens to `to`, increasing the total supply.
    /// This variant mints NFT tokens starting from ID `preTotalSupply / _unit() + 1`.
    /// This variant will not touch the `burnedPool` and `nextTokenId`.
    ///
    /// Will mint NFTs to `to` if the recipient's new balance supports
    /// additional NFTs ***AND*** the `to` address's skipNFT flag is set to false.
    ///
    /// Emits a {Transfer} event.
    function _mintNext(address to, uint256 amount) internal virtual {
        if (to == address(0)) revert TransferToZeroAddress();

        AddressData storage toAddressData = _addressData(to);
        DN404Storage storage $ = _getDN404Storage();
        if ($.mirrorERC721 == address(0)) revert();

        _DNMintTemps memory t;
        unchecked {
            uint256 toBalance = uint256(toAddressData.balance) + amount;
            toAddressData.balance = uint96(toBalance);
            t.toEnd = toBalance / _unit();
        }
        uint256 startId;
        uint256 maxId;
        unchecked {
            uint256 preTotalSupply = uint256($.totalSupply);
            startId = preTotalSupply / _unit() + 1;
            uint256 totalSupply_ = uint256(preTotalSupply) + amount;
            $.totalSupply = uint96(totalSupply_);
            uint256 overflows = _toUint(_totalSupplyOverflows(totalSupply_));
            if (overflows | _toUint(totalSupply_ < amount) != 0) revert TotalSupplyOverflow();
            maxId = totalSupply_ / _unit();
        }
        unchecked {
            if (toAddressData.flags & _ADDRESS_DATA_SKIP_NFT_FLAG == 0) {
                Uint32Map storage toOwned = $.owned[to];
                Uint32Map storage oo = $.oo;
                uint256 toIndex = toAddressData.ownedLength;
                _DNPackedLogs memory packedLogs = _packedLogsMalloc(_zeroFloorSub(t.toEnd, toIndex));

                if (packedLogs.logs.length != 0) {
                    _packedLogsSet(packedLogs, to, 0);
                    $.totalNFTSupply += uint32(packedLogs.logs.length);
                    toAddressData.ownedLength = uint32(t.toEnd);
                    t.toAlias = _registerAndResolveAlias(toAddressData, to);
                    // Mint loop.
                    do {
                        uint256 id = startId;
                        while (_get(oo, _ownershipIndex(id)) != 0) {
                            id = _useExistsLookup()
                                ? _wrapNFTId(_findFirstUnset($.exists, id + 1, maxId + 1), maxId)
                                : _wrapNFTId(id + 1, maxId);
                        }
                        startId = _wrapNFTId(id + 1, maxId);
                        if (_useExistsLookup()) _set($.exists, id, true);
                        _set(toOwned, toIndex, uint32(id));
                        _setOwnerAliasAndOwnedIndex(oo, id, t.toAlias, uint32(toIndex++));
                        _packedLogsAppend(packedLogs, id);
                        _afterNFTTransfer(address(0), to, id);
                    } while (toIndex != t.toEnd);

                    _packedLogsSend(packedLogs, $.mirrorERC721);
                }
            }
        }
        /// @solidity memory-safe-assembly
        assembly {
            // Emit the {Transfer} event.
            mstore(0x00, amount)
            log3(0x00, 0x20, _TRANSFER_EVENT_SIGNATURE, 0, shr(96, shl(96, to)))
        }
    }

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                  INTERNAL BURN FUNCTIONS                   */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Burns `amount` tokens from `from`, reducing the total supply.
    ///
    /// Will burn sender NFTs if balance after transfer is less than
    /// the amount required to support the current NFT balance.
    ///
    /// Emits a {Transfer} event.
    function _burn(address from, uint256 amount) internal virtual {
        AddressData storage fromAddressData = _addressData(from);
        DN404Storage storage $ = _getDN404Storage();
        if ($.mirrorERC721 == address(0)) revert();

        uint256 fromBalance = fromAddressData.balance;
        if (amount > fromBalance) revert InsufficientBalance();

        unchecked {
            fromAddressData.balance = uint96(fromBalance -= amount);
            uint256 totalSupply_ = uint256($.totalSupply) - amount;
            $.totalSupply = uint96(totalSupply_);

            Uint32Map storage fromOwned = $.owned[from];
            uint256 fromIndex = fromAddressData.ownedLength;
            uint256 numNFTBurns = _zeroFloorSub(fromIndex, fromBalance / _unit());

            if (numNFTBurns != 0) {
                _DNPackedLogs memory packedLogs = _packedLogsMalloc(numNFTBurns);
                _packedLogsSet(packedLogs, from, 1);
                bool addToBurnedPool;
                {
                    uint256 totalNFTSupply = uint256($.totalNFTSupply) - numNFTBurns;
                    $.totalNFTSupply = uint32(totalNFTSupply);
                    addToBurnedPool = _addToBurnedPool(totalNFTSupply, totalSupply_);
                }

                Uint32Map storage oo = $.oo;
                uint256 fromEnd = fromIndex - numNFTBurns;
                fromAddressData.ownedLength = uint32(fromEnd);
                uint32 burnedPoolTail = $.burnedPoolTail;
                // Burn loop.
                do {
                    uint256 id = _get(fromOwned, --fromIndex);
                    _setOwnerAliasAndOwnedIndex(oo, id, 0, 0);
                    _packedLogsAppend(packedLogs, id);
                    if (_useExistsLookup()) _set($.exists, id, false);
                    if (addToBurnedPool) _set($.burnedPool, burnedPoolTail++, uint32(id));
                    if (_get($.mayHaveNFTApproval, id)) {
                        _set($.mayHaveNFTApproval, id, false);
                        delete $.nftApprovals[id];
                    }
                    _afterNFTTransfer(from, address(0), id);
                } while (fromIndex != fromEnd);

                if (addToBurnedPool) $.burnedPoolTail = burnedPoolTail;
                _packedLogsSend(packedLogs, $.mirrorERC721);
            }
        }
        /// @solidity memory-safe-assembly
        assembly {
            // Emit the {Transfer} event.
            mstore(0x00, amount)
            log3(0x00, 0x20, _TRANSFER_EVENT_SIGNATURE, shr(96, shl(96, from)), 0)
        }
    }

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                INTERNAL TRANSFER FUNCTIONS                 */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Moves `amount` of tokens from `from` to `to`.
    ///
    /// Will burn sender NFTs if balance after transfer is less than
    /// the amount required to support the current NFT balance.
    ///
    /// Will mint NFTs to `to` if the recipient's new balance supports
    /// additional NFTs ***AND*** the `to` address's skipNFT flag is
    /// set to false.
    ///
    /// Emits a {Transfer} event.
    function _transfer(address from, address to, uint256 amount) internal virtual {
        if (to == address(0)) revert TransferToZeroAddress();

        AddressData storage fromAddressData = _addressData(from);
        AddressData storage toAddressData = _addressData(to);
        DN404Storage storage $ = _getDN404Storage();
        if ($.mirrorERC721 == address(0)) revert();

        _DNTransferTemps memory t;
        t.fromOwnedLength = fromAddressData.ownedLength;
        t.toOwnedLength = toAddressData.ownedLength;
        t.totalSupply = $.totalSupply;

        if (amount > (t.fromBalance = fromAddressData.balance)) revert InsufficientBalance();

        unchecked {
            fromAddressData.balance = uint96(t.fromBalance -= amount);
            toAddressData.balance = uint96(t.toBalance = uint256(toAddressData.balance) + amount);

            t.numNFTBurns = _zeroFloorSub(t.fromOwnedLength, t.fromBalance / _unit());

            if (toAddressData.flags & _ADDRESS_DATA_SKIP_NFT_FLAG == 0) {
                if (from == to) t.toOwnedLength = t.fromOwnedLength - t.numNFTBurns;
                t.numNFTMints = _zeroFloorSub(t.toBalance / _unit(), t.toOwnedLength);
            }

            while (_useDirectTransfersIfPossible()) {
                uint256 n = _min(t.fromOwnedLength, _min(t.numNFTBurns, t.numNFTMints));
                if (n == 0) break;
                t.numNFTBurns -= n;
                t.numNFTMints -= n;
                if (from == to) {
                    t.toOwnedLength += n;
                    break;
                }
                _DNDirectLogs memory directLogs = _directLogsMalloc(n, from, to);
                Uint32Map storage fromOwned = $.owned[from];
                Uint32Map storage toOwned = $.owned[to];
                t.toAlias = _registerAndResolveAlias(toAddressData, to);
                uint256 toIndex = t.toOwnedLength;
                // Direct transfer loop.
                do {
                    uint256 id = _get(fromOwned, --t.fromOwnedLength);
                    _set(toOwned, toIndex, uint32(id));
                    _setOwnerAliasAndOwnedIndex($.oo, id, t.toAlias, uint32(toIndex++));
                    _directLogsAppend(directLogs, id);
                    if (_get($.mayHaveNFTApproval, id)) {
                        _set($.mayHaveNFTApproval, id, false);
                        delete $.nftApprovals[id];
                    }
                    _afterNFTTransfer(from, to, id);
                } while (--n != 0);

                toAddressData.ownedLength = uint32(t.toOwnedLength = toIndex);
                fromAddressData.ownedLength = uint32(t.fromOwnedLength);
                _directLogsSend(directLogs, $.mirrorERC721);
                break;
            }

            t.totalNFTSupply = uint256($.totalNFTSupply) + t.numNFTMints - t.numNFTBurns;
            $.totalNFTSupply = uint32(t.totalNFTSupply);

            Uint32Map storage oo = $.oo;
            _DNPackedLogs memory packedLogs = _packedLogsMalloc(t.numNFTBurns + t.numNFTMints);

            t.burnedPoolTail = $.burnedPoolTail;
            if (t.numNFTBurns != 0) {
                _packedLogsSet(packedLogs, from, 1);
                bool addToBurnedPool = _addToBurnedPool(t.totalNFTSupply, t.totalSupply);
                Uint32Map storage fromOwned = $.owned[from];
                uint256 fromIndex = t.fromOwnedLength;
                fromAddressData.ownedLength = uint32(t.fromEnd = fromIndex - t.numNFTBurns);
                uint32 burnedPoolTail = t.burnedPoolTail;
                // Burn loop.
                do {
                    uint256 id = _get(fromOwned, --fromIndex);
                    _setOwnerAliasAndOwnedIndex(oo, id, 0, 0);
                    _packedLogsAppend(packedLogs, id);
                    if (_useExistsLookup()) _set($.exists, id, false);
                    if (addToBurnedPool) _set($.burnedPool, burnedPoolTail++, uint32(id));
                    if (_get($.mayHaveNFTApproval, id)) {
                        _set($.mayHaveNFTApproval, id, false);
                        delete $.nftApprovals[id];
                    }
                    _afterNFTTransfer(from, address(0), id);
                } while (fromIndex != t.fromEnd);

                if (addToBurnedPool) $.burnedPoolTail = (t.burnedPoolTail = burnedPoolTail);
            }

            if (t.numNFTMints != 0) {
                _packedLogsSet(packedLogs, to, 0);
                Uint32Map storage toOwned = $.owned[to];
                t.toAlias = _registerAndResolveAlias(toAddressData, to);
                uint256 maxId = t.totalSupply / _unit();
                t.nextTokenId = _wrapNFTId($.nextTokenId, maxId);
                uint256 toIndex = t.toOwnedLength;
                toAddressData.ownedLength = uint32(t.toEnd = toIndex + t.numNFTMints);
                uint32 burnedPoolHead = $.burnedPoolHead;
                // Mint loop.
                do {
                    uint256 id;
                    if (burnedPoolHead != t.burnedPoolTail) {
                        id = _get($.burnedPool, burnedPoolHead++);
                    } else {
                        id = t.nextTokenId;
                        while (_get(oo, _ownershipIndex(id)) != 0) {
                            id = _useExistsLookup()
                                ? _wrapNFTId(_findFirstUnset($.exists, id + 1, maxId + 1), maxId)
                                : _wrapNFTId(id + 1, maxId);
                        }
                        t.nextTokenId = _wrapNFTId(id + 1, maxId);
                    }
                    if (_useExistsLookup()) _set($.exists, id, true);
                    _set(toOwned, toIndex, uint32(id));
                    _setOwnerAliasAndOwnedIndex(oo, id, t.toAlias, uint32(toIndex++));
                    _packedLogsAppend(packedLogs, id);
                    _afterNFTTransfer(address(0), to, id);
                } while (toIndex != t.toEnd);

                $.burnedPoolHead = burnedPoolHead;
                $.nextTokenId = uint32(t.nextTokenId);
            }

            if (packedLogs.logs.length != 0) _packedLogsSend(packedLogs, $.mirrorERC721);
        }
        /// @solidity memory-safe-assembly
        assembly {
            // Emit the {Transfer} event.
            mstore(0x00, amount)
            // forgefmt: disable-next-item
            log3(0x00, 0x20, _TRANSFER_EVENT_SIGNATURE, shr(96, shl(96, from)), shr(96, shl(96, to)))
        }
    }

    /// @dev Transfers token `id` from `from` to `to`.
    ///
    /// Requirements:
    ///
    /// - Call must originate from the mirror contract.
    /// - Token `id` must exist.
    /// - `from` must be the owner of the token.
    /// - `to` cannot be the zero address.
    ///   `msgSender` must be the owner of the token, or be approved to manage the token.
    ///
    /// Emits a {Transfer} event.
    function _transferFromNFT(address from, address to, uint256 id, address msgSender)
        internal
        virtual
    {
        if (to == address(0)) revert TransferToZeroAddress();

        DN404Storage storage $ = _getDN404Storage();
        if ($.mirrorERC721 == address(0)) revert();

        Uint32Map storage oo = $.oo;

        if (from != $.aliasToAddress[_get(oo, _ownershipIndex(_restrictNFTId(id)))]) {
            revert TransferFromIncorrectOwner();
        }

        if (msgSender != from) {
            if (_ref($.operatorApprovals, from, msgSender).value == 0) {
                if (msgSender != $.nftApprovals[id]) {
                    revert TransferCallerNotOwnerNorApproved();
                }
            }
        }

        AddressData storage fromAddressData = _addressData(from);
        AddressData storage toAddressData = _addressData(to);

        uint256 unit = _unit();
        mapping(address => Uint32Map) storage owned = $.owned;
        Uint32Map storage fromOwned = owned[from];

        unchecked {
            uint256 fromBalance = fromAddressData.balance;
            if (unit > fromBalance) revert InsufficientBalance();
            fromAddressData.balance = uint96(fromBalance - unit);
            toAddressData.balance += uint96(unit);
        }
        if (_get($.mayHaveNFTApproval, id)) {
            _set($.mayHaveNFTApproval, id, false);
            delete $.nftApprovals[id];
        }
        unchecked {
            uint32 updatedId = _get(fromOwned, --fromAddressData.ownedLength);
            uint32 i = _get(oo, _ownedIndex(id));
            _set(fromOwned, i, updatedId);
            _set(oo, _ownedIndex(updatedId), i);
        }
        unchecked {
            uint32 n = toAddressData.ownedLength++;
            _set(owned[to], n, uint32(id));
            _setOwnerAliasAndOwnedIndex(oo, id, _registerAndResolveAlias(toAddressData, to), n);
        }
        _afterNFTTransfer(from, to, id);
        /// @solidity memory-safe-assembly
        assembly {
            // Emit the {Transfer} event.
            mstore(0x00, unit)
            // forgefmt: disable-next-item
            log3(0x00, 0x20, _TRANSFER_EVENT_SIGNATURE, shr(96, shl(96, from)), shr(96, shl(96, to)))
        }
    }

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                 INTERNAL APPROVE FUNCTIONS                 */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Sets `amount` as the allowance of `spender` over the tokens of `owner`.
    ///
    /// Emits a {Approval} event.
    function _approve(address owner, address spender, uint256 amount) internal virtual {
        if (_givePermit2DefaultInfiniteAllowance() && spender == _PERMIT2) {
            _getDN404Storage().addressData[owner].flags |= _ADDRESS_DATA_OVERRIDE_PERMIT2_FLAG;
        }
        _ref(_getDN404Storage().allowance, owner, spender).value = amount;
        /// @solidity memory-safe-assembly
        assembly {
            // Emit the {Approval} event.
            mstore(0x00, amount)
            // forgefmt: disable-next-item
            log3(0x00, 0x20, _APPROVAL_EVENT_SIGNATURE, shr(96, shl(96, owner)), shr(96, shl(96, spender)))
        }
    }

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                 DATA HITCHHIKING FUNCTIONS                 */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Returns the auxiliary data for `owner`.
    /// Minting, transferring, burning the tokens of `owner` will not change the auxiliary data.
    /// Auxiliary data can be set for any address, even if it does not have any tokens.
    function _getAux(address owner) internal view virtual returns (uint88) {
        return _getDN404Storage().addressData[owner].aux;
    }

    /// @dev Set the auxiliary data for `owner` to `value`.
    /// Minting, transferring, burning the tokens of `owner` will not change the auxiliary data.
    /// Auxiliary data can be set for any address, even if it does not have any tokens.
    function _setAux(address owner, uint88 value) internal virtual {
        _getDN404Storage().addressData[owner].aux = value;
    }

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                     SKIP NFT FUNCTIONS                     */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Returns true if minting and transferring ERC20s to `owner` will skip minting NFTs.
    /// Returns false otherwise.
    function getSkipNFT(address owner) public view virtual returns (bool) {
        AddressData storage d = _getDN404Storage().addressData[owner];
        if (d.flags & _ADDRESS_DATA_INITIALIZED_FLAG == 0) return _hasCode(owner);
        return d.flags & _ADDRESS_DATA_SKIP_NFT_FLAG != 0;
    }

    /// @dev Sets the caller's skipNFT flag to `skipNFT`. Returns true.
    ///
    /// Emits a {SkipNFTSet} event.
    function setSkipNFT(bool skipNFT) public virtual returns (bool) {
        _setSkipNFT(msg.sender, skipNFT);
        return true;
    }

    /// @dev Internal function to set account `owner` skipNFT flag to `state`
    ///
    /// Initializes account `owner` AddressData if it is not currently initialized.
    ///
    /// Emits a {SkipNFTSet} event.
    function _setSkipNFT(address owner, bool state) internal virtual {
        AddressData storage d = _addressData(owner);
        if ((d.flags & _ADDRESS_DATA_SKIP_NFT_FLAG != 0) != state) {
            d.flags ^= _ADDRESS_DATA_SKIP_NFT_FLAG;
        }
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x00, iszero(iszero(state)))
            log2(0x00, 0x20, _SKIP_NFT_SET_EVENT_SIGNATURE, shr(96, shl(96, owner)))
        }
    }

    /// @dev Returns a storage data pointer for account `owner` AddressData
    ///
    /// Initializes account `owner` AddressData if it is not currently initialized.
    function _addressData(address owner) internal virtual returns (AddressData storage d) {
        d = _getDN404Storage().addressData[owner];
        unchecked {
            if (d.flags & _ADDRESS_DATA_INITIALIZED_FLAG == 0) {
                uint256 skipNFT = _toUint(_hasCode(owner)) * _ADDRESS_DATA_SKIP_NFT_FLAG;
                d.flags = uint8(skipNFT | _ADDRESS_DATA_INITIALIZED_FLAG);
            }
        }
    }

    /// @dev Returns the `addressAlias` of account `to`.
    ///
    /// Assigns and registers the next alias if `to` alias was not previously registered.
    function _registerAndResolveAlias(AddressData storage toAddressData, address to)
        internal
        virtual
        returns (uint32 addressAlias)
    {
        DN404Storage storage $ = _getDN404Storage();
        addressAlias = toAddressData.addressAlias;
        if (addressAlias == 0) {
            unchecked {
                addressAlias = ++$.numAliases;
            }
            toAddressData.addressAlias = addressAlias;
            $.aliasToAddress[addressAlias] = to;
            if (addressAlias == 0) revert(); // Overflow.
        }
    }

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                     MIRROR OPERATIONS                      */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Returns the address of the mirror NFT contract.
    function mirrorERC721() public view virtual returns (address) {
        return _getDN404Storage().mirrorERC721;
    }

    /// @dev Returns the total NFT supply.
    function _totalNFTSupply() internal view virtual returns (uint256) {
        return _getDN404Storage().totalNFTSupply;
    }

    /// @dev Returns `owner` NFT balance.
    function _balanceOfNFT(address owner) internal view virtual returns (uint256) {
        return _getDN404Storage().addressData[owner].ownedLength;
    }

    /// @dev Returns the owner of token `id`.
    /// Returns the zero address instead of reverting if the token does not exist.
    function _ownerAt(uint256 id) internal view virtual returns (address) {
        DN404Storage storage $ = _getDN404Storage();
        return $.aliasToAddress[_get($.oo, _ownershipIndex(_restrictNFTId(id)))];
    }

    /// @dev Returns the owner of token `id`.
    ///
    /// Requirements:
    /// - Token `id` must exist.
    function _ownerOf(uint256 id) internal view virtual returns (address) {
        if (!_exists(id)) revert TokenDoesNotExist();
        return _ownerAt(id);
    }

    /// @dev Returns if token `id` exists.
    function _exists(uint256 id) internal view virtual returns (bool) {
        return _ownerAt(id) != address(0);
    }

    /// @dev Returns the account approved to manage token `id`.
    ///
    /// Requirements:
    /// - Token `id` must exist.
    function _getApproved(uint256 id) internal view virtual returns (address) {
        if (!_exists(id)) revert TokenDoesNotExist();
        return _getDN404Storage().nftApprovals[id];
    }

    /// @dev Sets `spender` as the approved account to manage token `id`, using `msgSender`.
    ///
    /// Requirements:
    /// - `msgSender` must be the owner or an approved operator for the token owner.
    function _approveNFT(address spender, uint256 id, address msgSender)
        internal
        virtual
        returns (address owner)
    {
        DN404Storage storage $ = _getDN404Storage();

        owner = $.aliasToAddress[_get($.oo, _ownershipIndex(_restrictNFTId(id)))];

        if (msgSender != owner) {
            if (_ref($.operatorApprovals, owner, msgSender).value == 0) {
                revert ApprovalCallerNotOwnerNorApproved();
            }
        }

        $.nftApprovals[id] = spender;
        _set($.mayHaveNFTApproval, id, spender != address(0));
    }

    /// @dev Approve or remove the `operator` as an operator for `msgSender`,
    /// without authorization checks.
    function _setApprovalForAll(address operator, bool approved, address msgSender)
        internal
        virtual
    {
        _ref(_getDN404Storage().operatorApprovals, msgSender, operator).value = _toUint(approved);
    }

    /// @dev Returns the NFT IDs of `owner` in range `[begin, end)`.
    /// Optimized for smaller bytecode size, as this function is intended for off-chain calling.
    function _ownedIds(address owner, uint256 begin, uint256 end)
        internal
        view
        virtual
        returns (uint256[] memory ids)
    {
        DN404Storage storage $ = _getDN404Storage();
        Uint32Map storage owned = $.owned[owner];
        uint256 n = _min($.addressData[owner].ownedLength, end);
        /// @solidity memory-safe-assembly
        assembly {
            ids := mload(0x40)
            let i := begin
            for {} lt(i, n) { i := add(i, 1) } {
                let s := add(shl(96, owned.slot), shr(3, i)) // Storage slot.
                let id := and(0xffffffff, shr(shl(5, and(i, 7)), sload(s)))
                mstore(add(add(ids, 0x20), shl(5, sub(i, begin))), id) // Append to.
            }
            mstore(ids, sub(i, begin)) // Store the length.
            mstore(0x40, add(add(ids, 0x20), shl(5, sub(i, begin)))) // Allocate memory.
        }
    }

    /// @dev Fallback modifier to dispatch calls from the mirror NFT contract
    /// to internal functions in this contract.
    modifier dn404Fallback() virtual {
        DN404Storage storage $ = _getDN404Storage();

        uint256 fnSelector = _calldataload(0x00) >> 224;
        address mirror = $.mirrorERC721;

        // `transferFromNFT(address,address,uint256,address)`.
        if (fnSelector == 0xe5eb36c8) {
            if (msg.sender != mirror) revert SenderNotMirror();
            _transferFromNFT(
                address(uint160(_calldataload(0x04))), // `from`.
                address(uint160(_calldataload(0x24))), // `to`.
                _calldataload(0x44), // `id`.
                address(uint160(_calldataload(0x64))) // `msgSender`.
            );
            _return(1);
        }
        // `setApprovalForAll(address,bool,address)`.
        if (fnSelector == 0x813500fc) {
            if (msg.sender != mirror) revert SenderNotMirror();
            _setApprovalForAll(
                address(uint160(_calldataload(0x04))), // `spender`.
                _calldataload(0x24) != 0, // `status`.
                address(uint160(_calldataload(0x44))) // `msgSender`.
            );
            _return(1);
        }
        // `isApprovedForAll(address,address)`.
        if (fnSelector == 0xe985e9c5) {
            if (msg.sender != mirror) revert SenderNotMirror();
            Uint256Ref storage ref = _ref(
                $.operatorApprovals,
                address(uint160(_calldataload(0x04))), // `owner`.
                address(uint160(_calldataload(0x24))) // `operator`.
            );
            _return(ref.value);
        }
        // `ownerOf(uint256)`.
        if (fnSelector == 0x6352211e) {
            if (msg.sender != mirror) revert SenderNotMirror();
            _return(uint160(_ownerOf(_calldataload(0x04))));
        }
        // `ownerAt(uint256)`.
        if (fnSelector == 0x24359879) {
            if (msg.sender != mirror) revert SenderNotMirror();
            _return(uint160(_ownerAt(_calldataload(0x04))));
        }
        // `approveNFT(address,uint256,address)`.
        if (fnSelector == 0xd10b6e0c) {
            if (msg.sender != mirror) revert SenderNotMirror();
            address owner = _approveNFT(
                address(uint160(_calldataload(0x04))), // `spender`.
                _calldataload(0x24), // `id`.
                address(uint160(_calldataload(0x44))) // `msgSender`.
            );
            _return(uint160(owner));
        }
        // `getApproved(uint256)`.
        if (fnSelector == 0x081812fc) {
            if (msg.sender != mirror) revert SenderNotMirror();
            _return(uint160(_getApproved(_calldataload(0x04))));
        }
        // `balanceOfNFT(address)`.
        if (fnSelector == 0xf5b100ea) {
            if (msg.sender != mirror) revert SenderNotMirror();
            _return(_balanceOfNFT(address(uint160(_calldataload(0x04)))));
        }
        // `totalNFTSupply()`.
        if (fnSelector == 0xe2c79281) {
            if (msg.sender != mirror) revert SenderNotMirror();
            _return(_totalNFTSupply());
        }
        // `implementsDN404()`.
        if (fnSelector == 0xb7a94eb8) {
            _return(1);
        }
        _;
    }

    /// @dev Fallback function for calls from mirror NFT contract.
    /// Override this if you need to implement your custom
    /// fallback with utilities like Solady's `LibZip.cdFallback()`.
    /// And always remember to always wrap the fallback with `dn404Fallback`.
    fallback() external payable virtual dn404Fallback {
        revert FnSelectorNotRecognized(); // Not mandatory. Just for quality of life.
    }

    /// @dev This is to silence the compiler warning.
    /// Override and remove the revert if you want your contract to receive ETH via receive.
    receive() external payable virtual {
        if (msg.value != 0) revert();
    }

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                 INTERNAL / PRIVATE HELPERS                 */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Returns `(i - 1) << 1`.
    function _ownershipIndex(uint256 i) internal pure returns (uint256) {
        unchecked {
            return (i - 1) << 1; // Minus 1 as token IDs start from 1.
        }
    }

    /// @dev Returns `((i - 1) << 1) + 1`.
    function _ownedIndex(uint256 i) internal pure returns (uint256) {
        unchecked {
            return ((i - 1) << 1) + 1; // Minus 1 as token IDs start from 1.
        }
    }

    /// @dev Returns the uint32 value at `index` in `map`.
    function _get(Uint32Map storage map, uint256 index) internal view returns (uint32 result) {
        /// @solidity memory-safe-assembly
        assembly {
            let s := add(shl(96, map.slot), shr(3, index)) // Storage slot.
            result := and(0xffffffff, shr(shl(5, and(index, 7)), sload(s)))
        }
    }

    /// @dev Updates the uint32 value at `index` in `map`.
    function _set(Uint32Map storage map, uint256 index, uint32 value) internal {
        /// @solidity memory-safe-assembly
        assembly {
            let s := add(shl(96, map.slot), shr(3, index)) // Storage slot.
            let o := shl(5, and(index, 7)) // Storage slot offset (bits).
            let v := sload(s) // Storage slot value.
            sstore(s, xor(v, shl(o, and(0xffffffff, xor(value, shr(o, v))))))
        }
    }

    /// @dev Sets the owner alias and the owned index together.
    function _setOwnerAliasAndOwnedIndex(
        Uint32Map storage map,
        uint256 id,
        uint32 ownership,
        uint32 ownedIndex
    ) internal {
        /// @solidity memory-safe-assembly
        assembly {
            let i := sub(id, 1) // Index of the uint64 combined value.
            let s := add(shl(96, map.slot), shr(2, i)) // Storage slot.
            let v := sload(s) // Storage slot value.
            let o := shl(6, and(i, 3)) // Storage slot offset (bits).
            let combined := or(shl(32, ownedIndex), and(0xffffffff, ownership))
            sstore(s, xor(v, shl(o, and(0xffffffffffffffff, xor(shr(o, v), combined)))))
        }
    }

    /// @dev Returns the boolean value of the bit at `index` in `bitmap`.
    function _get(Bitmap storage bitmap, uint256 index) internal view returns (bool result) {
        /// @solidity memory-safe-assembly
        assembly {
            let s := add(shl(96, bitmap.slot), shr(8, index)) // Storage slot.
            result := and(1, shr(and(0xff, index), sload(s)))
        }
    }

    /// @dev Updates the bit at `index` in `bitmap` to `value`.
    function _set(Bitmap storage bitmap, uint256 index, bool value) internal {
        /// @solidity memory-safe-assembly
        assembly {
            let s := add(shl(96, bitmap.slot), shr(8, index)) // Storage slot.
            let o := and(0xff, index) // Storage slot offset (bits).
            sstore(s, or(and(sload(s), not(shl(o, 1))), shl(o, iszero(iszero(value)))))
        }
    }

    /// @dev Returns the index of the least significant unset bit in `[begin, end)`.
    /// If no unset bit is found, returns `type(uint256).max`.
    function _findFirstUnset(Bitmap storage bitmap, uint256 begin, uint256 end)
        internal
        view
        returns (uint256 unsetBitIndex)
    {
        /// @solidity memory-safe-assembly
        assembly {
            unsetBitIndex := not(0) // Initialize to `type(uint256).max`.
            let s := shl(96, bitmap.slot) // Storage offset of the bitmap.
            let bucket := add(s, shr(8, begin))
            let negBits := shl(and(0xff, begin), shr(and(0xff, begin), not(sload(bucket))))
            if iszero(negBits) {
                let lastBucket := add(s, shr(8, end))
                for {} 1 {} {
                    bucket := add(bucket, 1)
                    negBits := not(sload(bucket))
                    if or(negBits, gt(bucket, lastBucket)) { break }
                }
                if gt(bucket, lastBucket) {
                    negBits := shr(and(0xff, not(end)), shl(and(0xff, not(end)), negBits))
                }
            }
            if negBits {
                // Find-first-set routine.
                let b := and(negBits, add(not(negBits), 1)) // Isolate the least significant bit.
                let r := shl(7, lt(0xffffffffffffffffffffffffffffffff, b))
                r := or(r, shl(6, lt(0xffffffffffffffff, shr(r, b))))
                r := or(r, shl(5, lt(0xffffffff, shr(r, b))))
                // For the remaining 32 bits, use a De Bruijn lookup.
                // forgefmt: disable-next-item
                r := or(r, byte(and(div(0xd76453e0, shr(r, b)), 0x1f),
                    0x001f0d1e100c1d070f090b19131c1706010e11080a1a141802121b1503160405))
                r := or(shl(8, sub(bucket, s)), r)
                unsetBitIndex := or(r, sub(0, or(iszero(lt(r, end)), lt(r, begin))))
            }
        }
    }

    /// @dev Returns a storage reference to the value at (`a0`, `a1`) in `map`.
    function _ref(AddressPairToUint256RefMap storage map, address a0, address a1)
        internal
        pure
        returns (Uint256Ref storage ref)
    {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x28, a1)
            mstore(0x14, a0)
            mstore(0x00, map.slot)
            ref.slot := keccak256(0x00, 0x48)
            // Clear the part of the free memory pointer that was overwritten.
            mstore(0x28, 0x00)
        }
    }

    /// @dev Wraps the NFT ID.
    function _wrapNFTId(uint256 id, uint256 maxId) internal pure returns (uint256 result) {
        /// @solidity memory-safe-assembly
        assembly {
            result := or(mul(iszero(gt(id, maxId)), id), gt(id, maxId))
        }
    }

    /// @dev Returns `id > type(uint32).max ? 0 : id`.
    function _restrictNFTId(uint256 id) internal pure returns (uint256 result) {
        /// @solidity memory-safe-assembly
        assembly {
            result := mul(id, lt(id, 0x100000000))
        }
    }

    /// @dev Returns whether `amount` is a valid `totalSupply`.
    function _totalSupplyOverflows(uint256 amount) internal view returns (bool result) {
        uint256 unit = _unit();
        /// @solidity memory-safe-assembly
        assembly {
            result := iszero(iszero(or(shr(96, amount), lt(0xfffffffe, div(amount, unit)))))
        }
    }

    /// @dev Returns `max(0, x - y)`.
    function _zeroFloorSub(uint256 x, uint256 y) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := mul(gt(x, y), sub(x, y))
        }
    }

    /// @dev Returns `x < y ? x : y`.
    function _min(uint256 x, uint256 y) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            z := xor(x, mul(xor(x, y), lt(y, x)))
        }
    }

    /// @dev Returns `b ? 1 : 0`.
    function _toUint(bool b) internal pure returns (uint256 result) {
        /// @solidity memory-safe-assembly
        assembly {
            result := iszero(iszero(b))
        }
    }

    /// @dev Struct containing direct transfer log data for {Transfer} events to be
    /// emitted by the mirror NFT contract.
    struct _DNDirectLogs {
        uint256 offset;
        address from;
        address to;
        uint256[] logs;
    }

    /// @dev Initiates memory allocation for direct logs with `n` log items.
    function _directLogsMalloc(uint256 n, address from, address to)
        private
        pure
        returns (_DNDirectLogs memory p)
    {
        /// @solidity memory-safe-assembly
        assembly {
            // Note that `p` implicitly allocates and advances the free memory pointer by
            // 4 words, which we can safely mutate in `_directLogsSend`.
            let logs := mload(0x40)
            mstore(logs, n) // Store the length.
            let offset := add(0x20, logs) // Skip the word for `p.logs.length`.
            mstore(0x40, add(offset, shl(5, n))) // Allocate memory.
            mstore(add(0x60, p), logs) // Set `p.logs`.
            mstore(add(0x40, p), to) // Set `p.to`.
            mstore(add(0x20, p), from) // Set `p.from`.
            mstore(p, offset) // Set `p.offset`.
        }
    }

    /// @dev Adds a direct log item to `p` with token `id`.
    function _directLogsAppend(_DNDirectLogs memory p, uint256 id) private pure {
        /// @solidity memory-safe-assembly
        assembly {
            let offset := mload(p)
            mstore(offset, id)
            mstore(p, add(offset, 0x20))
        }
    }

    /// @dev Calls the `mirror` NFT contract to emit {Transfer} events for packed logs `p`.
    function _directLogsSend(_DNDirectLogs memory p, address mirror) private {
        /// @solidity memory-safe-assembly
        assembly {
            let logs := mload(add(p, 0x60))
            let n := add(0x84, shl(5, mload(logs))) // Length of calldata to send.
            let o := sub(logs, 0x80) // Start of calldata to send.
            mstore(o, 0x144027d3) // `logDirectTransfer(address,address,uint256[])`.
            let from := mload(add(0x20, p))
            let to := mload(add(0x40, p))
            mstore(add(o, 0x20), from)
            mstore(add(o, 0x40), to)
            mstore(add(o, 0x60), 0x60) // Offset of `logs` in the calldata to send.
            if iszero(and(eq(mload(o), 1), call(gas(), mirror, 0, add(o, 0x1c), n, o, 0x20))) {
                revert(o, 0x00)
            }
        }
    }

    /// @dev Struct containing packed log data for {Transfer} events to be
    /// emitted by the mirror NFT contract.
    struct _DNPackedLogs {
        uint256 offset;
        uint256 addressAndBit;
        uint256[] logs;
    }

    /// @dev Initiates memory allocation for packed logs with `n` log items.
    function _packedLogsMalloc(uint256 n) private pure returns (_DNPackedLogs memory p) {
        /// @solidity memory-safe-assembly
        assembly {
            // Note that `p` implicitly allocates and advances the free memory pointer by
            // 3 words, which we can safely mutate in `_packedLogsSend`.
            let logs := mload(0x40)
            mstore(logs, n) // Store the length.
            let offset := add(0x20, logs) // Skip the word for `p.logs.length`.
            mstore(0x40, add(offset, shl(5, n))) // Allocate memory.
            mstore(add(0x40, p), logs) // Set `p.logs`.
            mstore(p, offset) // Set `p.offset`.
        }
    }

    /// @dev Set the current address and the burn bit.
    function _packedLogsSet(_DNPackedLogs memory p, address a, uint256 burnBit) private pure {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(add(p, 0x20), or(shl(96, a), burnBit)) // Set `p.addressAndBit`.
        }
    }

    /// @dev Adds a packed log item to `p` with token `id`.
    function _packedLogsAppend(_DNPackedLogs memory p, uint256 id) private pure {
        /// @solidity memory-safe-assembly
        assembly {
            let offset := mload(p)
            mstore(offset, or(mload(add(p, 0x20)), shl(8, id))) // `p.addressAndBit | (id << 8)`.
            mstore(p, add(offset, 0x20))
        }
    }

    /// @dev Calls the `mirror` NFT contract to emit {Transfer} events for packed logs `p`.
    function _packedLogsSend(_DNPackedLogs memory p, address mirror) private {
        /// @solidity memory-safe-assembly
        assembly {
            let logs := mload(add(p, 0x40))
            let o := sub(logs, 0x40) // Start of calldata to send.
            mstore(o, 0x263c69d6) // `logTransfer(uint256[])`.
            mstore(add(o, 0x20), 0x20) // Offset of `logs` in the calldata to send.
            let n := add(0x44, shl(5, mload(logs))) // Length of calldata to send.
            if iszero(and(eq(mload(o), 1), call(gas(), mirror, 0, add(o, 0x1c), n, o, 0x20))) {
                revert(o, 0x00)
            }
        }
    }

    /// @dev Struct of temporary variables for transfers.
    struct _DNTransferTemps {
        uint256 numNFTBurns;
        uint256 numNFTMints;
        uint256 fromBalance;
        uint256 toBalance;
        uint256 fromOwnedLength;
        uint256 toOwnedLength;
        uint256 totalSupply;
        uint256 totalNFTSupply;
        uint256 fromEnd;
        uint256 toEnd;
        uint32 toAlias;
        uint256 nextTokenId;
        uint32 burnedPoolTail;
    }

    /// @dev Struct of temporary variables for mints.
    struct _DNMintTemps {
        uint256 nextTokenId;
        uint32 burnedPoolTail;
        uint256 toEnd;
        uint32 toAlias;
    }

    /// @dev Returns if `a` has bytecode of non-zero length.
    function _hasCode(address a) private view returns (bool result) {
        /// @solidity memory-safe-assembly
        assembly {
            result := extcodesize(a) // Can handle dirty upper bits.
        }
    }

    /// @dev Returns the calldata value at `offset`.
    function _calldataload(uint256 offset) private pure returns (uint256 value) {
        /// @solidity memory-safe-assembly
        assembly {
            value := calldataload(offset)
        }
    }

    /// @dev Executes a return opcode to return `x` and end the current call frame.
    function _return(uint256 x) private pure {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x00, x)
            return(0x00, 0x20)
        }
    }
}

File 11 of 19 : DN404Mirror.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

/// @title DN404Mirror
/// @notice DN404Mirror provides an interface for interacting with the
/// NFT tokens in a DN404 implementation.
///
/// @author vectorized.eth (@optimizoor)
/// @author Quit (@0xQuit)
/// @author Michael Amadi (@AmadiMichaels)
/// @author cygaar (@0xCygaar)
/// @author Thomas (@0xjustadev)
/// @author Harrison (@PopPunkOnChain)
///
/// @dev Note:
/// - The ERC721 data is stored in the base DN404 contract.
contract DN404Mirror {
    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                           EVENTS                           */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Emitted when token `id` is transferred from `from` to `to`.
    event Transfer(address indexed from, address indexed to, uint256 indexed id);

    /// @dev Emitted when `owner` enables `account` to manage the `id` token.
    event Approval(address indexed owner, address indexed account, uint256 indexed id);

    /// @dev Emitted when `owner` enables or disables `operator` to manage all of their tokens.
    event ApprovalForAll(address indexed owner, address indexed operator, bool isApproved);

    /// @dev The ownership is transferred from `oldOwner` to `newOwner`.
    /// This is for marketplace signaling purposes. This contract has a `pullOwner()`
    /// function that will sync the owner from the base contract.
    event OwnershipTransferred(address indexed oldOwner, address indexed newOwner);

    /// @dev `keccak256(bytes("Transfer(address,address,uint256)"))`.
    uint256 private constant _TRANSFER_EVENT_SIGNATURE =
        0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef;

    /// @dev `keccak256(bytes("Approval(address,address,uint256)"))`.
    uint256 private constant _APPROVAL_EVENT_SIGNATURE =
        0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925;

    /// @dev `keccak256(bytes("ApprovalForAll(address,address,bool)"))`.
    uint256 private constant _APPROVAL_FOR_ALL_EVENT_SIGNATURE =
        0x17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31;

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                        CUSTOM ERRORS                       */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Thrown when a call for an NFT function did not originate
    /// from the base DN404 contract.
    error SenderNotBase();

    /// @dev Thrown when a call for an NFT function did not originate from the deployer.
    error SenderNotDeployer();

    /// @dev Thrown when transferring an NFT to a contract address that
    /// does not implement ERC721Receiver.
    error TransferToNonERC721ReceiverImplementer();

    /// @dev Thrown when linking to the DN404 base contract and the
    /// DN404 supportsInterface check fails or the call reverts.
    error CannotLink();

    /// @dev Thrown when a linkMirrorContract call is received and the
    /// NFT mirror contract has already been linked to a DN404 base contract.
    error AlreadyLinked();

    /// @dev Thrown when retrieving the base DN404 address when a link has not
    /// been established.
    error NotLinked();

    /// @dev The function selector is not recognized.
    error FnSelectorNotRecognized();

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                          STORAGE                           */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Struct contain the NFT mirror contract storage.
    struct DN404NFTStorage {
        // Address of the ERC20 base contract.
        address baseERC20;
        // The deployer, if provided. If non-zero, the initialization of the
        // ERC20 <-> ERC721 link can only be done be the deployer via the ERC20 base contract.
        address deployer;
        // The owner of the ERC20 base contract. For marketplace signaling.
        address owner;
    }

    /// @dev Returns a storage pointer for DN404NFTStorage.
    function _getDN404NFTStorage() internal pure virtual returns (DN404NFTStorage storage $) {
        /// @solidity memory-safe-assembly
        assembly {
            // `uint72(bytes9(keccak256("DN404_MIRROR_STORAGE")))`.
            $.slot := 0x3602298b8c10b01230 // Truncate to 9 bytes to reduce bytecode size.
        }
    }

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                        CONSTRUCTOR                         */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    constructor(address deployer) {
        // For non-proxies, we will store the deployer so that only the deployer can
        // link the base contract.
        _getDN404NFTStorage().deployer = deployer;
    }

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                     ERC721 OPERATIONS                      */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Returns the token collection name from the base DN404 contract.
    function name() public view virtual returns (string memory) {
        return _readString(0x06fdde03, 0); // `name()`.
    }

    /// @dev Returns the token collection symbol from the base DN404 contract.
    function symbol() public view virtual returns (string memory) {
        return _readString(0x95d89b41, 0); // `symbol()`.
    }

    /// @dev Returns the Uniform Resource Identifier (URI) for token `id` from
    /// the base DN404 contract.
    function tokenURI(uint256 id) public view virtual returns (string memory) {
        return _readString(0xc87b56dd, id); // `tokenURI()`.
    }

    /// @dev Returns the total NFT supply from the base DN404 contract.
    function totalSupply() public view virtual returns (uint256) {
        return _readWord(0xe2c79281, 0, 0); // `totalNFTSupply()`.
    }

    /// @dev Returns the number of NFT tokens owned by `nftOwner` from the base DN404 contract.
    ///
    /// Requirements:
    /// - `nftOwner` must not be the zero address.
    function balanceOf(address nftOwner) public view virtual returns (uint256) {
        return _readWord(0xf5b100ea, uint160(nftOwner), 0); // `balanceOfNFT(address)`.
    }

    /// @dev Returns the owner of token `id` from the base DN404 contract.
    ///
    /// Requirements:
    /// - Token `id` must exist.
    function ownerOf(uint256 id) public view virtual returns (address) {
        return address(uint160(_readWord(0x6352211e, id, 0))); // `ownerOf(uint256)`.
    }

    /// @dev Returns the owner of token `id` from the base DN404 contract.
    /// Returns `address(0)` instead of reverting if the token does not exist.
    function ownerAt(uint256 id) public view virtual returns (address) {
        return address(uint160(_readWord(0x24359879, id, 0))); // `ownerAt(uint256)`.
    }

    /// @dev Sets `spender` as the approved account to manage token `id` in
    /// the base DN404 contract.
    ///
    /// Requirements:
    /// - Token `id` must exist.
    /// - The caller must be the owner of the token,
    ///   or an approved operator for the token owner.
    ///
    /// Emits an {Approval} event.
    function approve(address spender, uint256 id) public payable virtual {
        address base = baseERC20();
        /// @solidity memory-safe-assembly
        assembly {
            spender := shr(96, shl(96, spender))
            let m := mload(0x40)
            mstore(0x00, 0xd10b6e0c) // `approveNFT(address,uint256,address)`.
            mstore(0x20, spender)
            mstore(0x40, id)
            mstore(0x60, caller())
            if iszero(
                and( // Arguments of `and` are evaluated last to first.
                    gt(returndatasize(), 0x1f), // The call must return at least 32 bytes.
                    call(gas(), base, callvalue(), 0x1c, 0x64, 0x00, 0x20)
                )
            ) {
                returndatacopy(m, 0x00, returndatasize())
                revert(m, returndatasize())
            }
            mstore(0x40, m) // Restore the free memory pointer.
            mstore(0x60, 0) // Restore the zero pointer.
            // Emit the {Approval} event.
            log4(codesize(), 0x00, _APPROVAL_EVENT_SIGNATURE, shr(96, mload(0x0c)), spender, id)
        }
    }

    /// @dev Returns the account approved to manage token `id` from
    /// the base DN404 contract.
    ///
    /// Requirements:
    /// - Token `id` must exist.
    function getApproved(uint256 id) public view virtual returns (address) {
        return address(uint160(_readWord(0x081812fc, id, 0))); // `getApproved(uint256)`.
    }

    /// @dev Sets whether `operator` is approved to manage the tokens of the caller in
    /// the base DN404 contract.
    ///
    /// Emits an {ApprovalForAll} event.
    function setApprovalForAll(address operator, bool approved) public virtual {
        address base = baseERC20();
        /// @solidity memory-safe-assembly
        assembly {
            operator := shr(96, shl(96, operator))
            let m := mload(0x40)
            mstore(0x00, 0x813500fc) // `setApprovalForAll(address,bool,address)`.
            mstore(0x20, operator)
            mstore(0x40, iszero(iszero(approved)))
            mstore(0x60, caller())
            if iszero(
                and( // Arguments of `and` are evaluated last to first.
                    eq(mload(0x00), 1), // The call must return 1.
                    call(gas(), base, callvalue(), 0x1c, 0x64, 0x00, 0x20)
                )
            ) {
                returndatacopy(m, 0x00, returndatasize())
                revert(m, returndatasize())
            }
            // Emit the {ApprovalForAll} event.
            // The `approved` value is already at 0x40.
            log3(0x40, 0x20, _APPROVAL_FOR_ALL_EVENT_SIGNATURE, caller(), operator)
            mstore(0x40, m) // Restore the free memory pointer.
            mstore(0x60, 0) // Restore the zero pointer.
        }
    }

    /// @dev Returns whether `operator` is approved to manage the tokens of `nftOwner` from
    /// the base DN404 contract.
    function isApprovedForAll(address nftOwner, address operator)
        public
        view
        virtual
        returns (bool)
    {
        // `isApprovedForAll(address,address)`.
        return _readWord(0xe985e9c5, uint160(nftOwner), uint160(operator)) != 0;
    }

    /// @dev Transfers token `id` from `from` to `to`.
    ///
    /// Requirements:
    ///
    /// - Token `id` must exist.
    /// - `from` must be the owner of the token.
    /// - `to` cannot be the zero address.
    /// - The caller must be the owner of the token, or be approved to manage the token.
    ///
    /// Emits a {Transfer} event.
    function transferFrom(address from, address to, uint256 id) public payable virtual {
        address base = baseERC20();
        /// @solidity memory-safe-assembly
        assembly {
            from := shr(96, shl(96, from))
            to := shr(96, shl(96, to))
            let m := mload(0x40)
            mstore(m, 0xe5eb36c8) // `transferFromNFT(address,address,uint256,address)`.
            mstore(add(m, 0x20), from)
            mstore(add(m, 0x40), to)
            mstore(add(m, 0x60), id)
            mstore(add(m, 0x80), caller())
            if iszero(
                and( // Arguments of `and` are evaluated last to first.
                    eq(mload(m), 1), // The call must return 1.
                    call(gas(), base, callvalue(), add(m, 0x1c), 0x84, m, 0x20)
                )
            ) {
                returndatacopy(m, 0x00, returndatasize())
                revert(m, returndatasize())
            }
            // Emit the {Transfer} event.
            log4(codesize(), 0x00, _TRANSFER_EVENT_SIGNATURE, from, to, id)
        }
    }

    /// @dev Equivalent to `safeTransferFrom(from, to, id, "")`.
    function safeTransferFrom(address from, address to, uint256 id) public payable virtual {
        transferFrom(from, to, id);
        if (_hasCode(to)) _checkOnERC721Received(from, to, id, "");
    }

    /// @dev Transfers token `id` from `from` to `to`.
    ///
    /// Requirements:
    ///
    /// - Token `id` must exist.
    /// - `from` must be the owner of the token.
    /// - `to` cannot be the zero address.
    /// - The caller must be the owner of the token, or be approved to manage the token.
    /// - If `to` refers to a smart contract, it must implement
    ///   {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
    ///
    /// Emits a {Transfer} event.
    function safeTransferFrom(address from, address to, uint256 id, bytes calldata data)
        public
        payable
        virtual
    {
        transferFrom(from, to, id);
        if (_hasCode(to)) _checkOnERC721Received(from, to, id, data);
    }

    /// @dev Returns true if this contract implements the interface defined by `interfaceId`.
    /// See: https://eips.ethereum.org/EIPS/eip-165
    /// This function call must use less than 30000 gas.
    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool result) {
        /// @solidity memory-safe-assembly
        assembly {
            let s := shr(224, interfaceId)
            // ERC165: 0x01ffc9a7, ERC721: 0x80ac58cd, ERC721Metadata: 0x5b5e139f.
            result := or(or(eq(s, 0x01ffc9a7), eq(s, 0x80ac58cd)), eq(s, 0x5b5e139f))
        }
    }

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                  OWNER SYNCING OPERATIONS                  */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Returns the `owner` of the contract, for marketplace signaling purposes.
    function owner() public view virtual returns (address) {
        return _getDN404NFTStorage().owner;
    }

    /// @dev Permissionless function to pull the owner from the base DN404 contract
    /// if it implements ownable, for marketplace signaling purposes.
    function pullOwner() public virtual returns (bool) {
        address newOwner;
        address base = baseERC20();
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x00, 0x8da5cb5b) // `owner()`.
            let success := staticcall(gas(), base, 0x1c, 0x04, 0x00, 0x20)
            newOwner := mul(shr(96, mload(0x0c)), and(gt(returndatasize(), 0x1f), success))
        }
        DN404NFTStorage storage $ = _getDN404NFTStorage();
        address oldOwner = $.owner;
        if (oldOwner != newOwner) {
            $.owner = newOwner;
            emit OwnershipTransferred(oldOwner, newOwner);
        }
        return true;
    }

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                     MIRROR OPERATIONS                      */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Returns the address of the base DN404 contract.
    function baseERC20() public view virtual returns (address base) {
        base = _getDN404NFTStorage().baseERC20;
        if (base == address(0)) revert NotLinked();
    }

    /// @dev Fallback modifier to execute calls from the base DN404 contract.
    modifier dn404NFTFallback() virtual {
        DN404NFTStorage storage $ = _getDN404NFTStorage();

        uint256 fnSelector = _calldataload(0x00) >> 224;

        // `logTransfer(uint256[])`.
        if (fnSelector == 0x263c69d6) {
            if (msg.sender != $.baseERC20) revert SenderNotBase();
            /// @solidity memory-safe-assembly
            assembly {
                let o := add(0x24, calldataload(0x04)) // Packed logs offset.
                let end := add(o, shl(5, calldataload(sub(o, 0x20))))
                for {} iszero(eq(o, end)) { o := add(0x20, o) } {
                    let d := calldataload(o) // Entry in the packed logs.
                    let a := shr(96, d) // The address.
                    let b := and(1, d) // Whether it is a burn.
                    log4(
                        codesize(),
                        0x00,
                        _TRANSFER_EVENT_SIGNATURE,
                        mul(a, b), // `from`.
                        mul(a, iszero(b)), // `to`.
                        shr(168, shl(160, d)) // `id`.
                    )
                }
                mstore(0x00, 0x01)
                return(0x00, 0x20)
            }
        }
        // `logDirectTransfer(address,address,uint256[])`.
        if (fnSelector == 0x144027d3) {
            if (msg.sender != $.baseERC20) revert SenderNotBase();
            /// @solidity memory-safe-assembly
            assembly {
                let from := calldataload(0x04)
                let to := calldataload(0x24)
                let o := add(0x24, calldataload(0x44)) // Direct logs offset.
                let end := add(o, shl(5, calldataload(sub(o, 0x20))))
                for {} iszero(eq(o, end)) { o := add(0x20, o) } {
                    log4(codesize(), 0x00, _TRANSFER_EVENT_SIGNATURE, from, to, calldataload(o))
                }
                mstore(0x00, 0x01)
                return(0x00, 0x20)
            }
        }
        // `linkMirrorContract(address)`.
        if (fnSelector == 0x0f4599e5) {
            if ($.deployer != address(0)) {
                if (address(uint160(_calldataload(0x04))) != $.deployer) {
                    revert SenderNotDeployer();
                }
            }
            if ($.baseERC20 != address(0)) revert AlreadyLinked();
            $.baseERC20 = msg.sender;
            /// @solidity memory-safe-assembly
            assembly {
                mstore(0x00, 0x01)
                return(0x00, 0x20)
            }
        }
        _;
    }

    /// @dev Fallback function for calls from base DN404 contract.
    /// Override this if you need to implement your custom
    /// fallback with utilities like Solady's `LibZip.cdFallback()`.
    /// And always remember to always wrap the fallback with `dn404NFTFallback`.
    fallback() external payable virtual dn404NFTFallback {
        revert FnSelectorNotRecognized(); // Not mandatory. Just for quality of life.
    }

    /// @dev This is to silence the compiler warning.
    /// Override and remove the revert if you want your contract to receive ETH via receive.
    receive() external payable virtual {
        if (msg.value != 0) revert();
    }

    /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/
    /*                      PRIVATE HELPERS                       */
    /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/

    /// @dev Helper to read a string from the base DN404 contract.
    function _readString(uint256 fnSelector, uint256 arg0)
        private
        view
        returns (string memory result)
    {
        address base = baseERC20();
        /// @solidity memory-safe-assembly
        assembly {
            result := mload(0x40)
            mstore(0x00, fnSelector)
            mstore(0x20, arg0)
            if iszero(staticcall(gas(), base, 0x1c, 0x24, 0x00, 0x00)) {
                returndatacopy(result, 0x00, returndatasize())
                revert(result, returndatasize())
            }
            returndatacopy(0x00, 0x00, 0x20) // Copy the offset of the string in returndata.
            returndatacopy(result, mload(0x00), 0x20) // Copy the length of the string.
            returndatacopy(add(result, 0x20), add(mload(0x00), 0x20), mload(result)) // Copy the string.
            let end := add(add(result, 0x20), mload(result))
            mstore(end, 0) // Zeroize the word after the string.
            mstore(0x40, add(end, 0x20)) // Allocate memory.
        }
    }

    /// @dev Helper to read a word from the base DN404 contract.
    function _readWord(uint256 fnSelector, uint256 arg0, uint256 arg1)
        private
        view
        returns (uint256 result)
    {
        address base = baseERC20();
        /// @solidity memory-safe-assembly
        assembly {
            let m := mload(0x40)
            mstore(0x00, fnSelector)
            mstore(0x20, arg0)
            mstore(0x40, arg1)
            if iszero(
                and( // Arguments of `and` are evaluated last to first.
                    gt(returndatasize(), 0x1f), // The call must return at least 32 bytes.
                    staticcall(gas(), base, 0x1c, 0x44, 0x00, 0x20)
                )
            ) {
                returndatacopy(m, 0x00, returndatasize())
                revert(m, returndatasize())
            }
            mstore(0x40, m) // Restore the free memory pointer.
            result := mload(0x00)
        }
    }

    /// @dev Returns the calldata value at `offset`.
    function _calldataload(uint256 offset) private pure returns (uint256 value) {
        /// @solidity memory-safe-assembly
        assembly {
            value := calldataload(offset)
        }
    }

    /// @dev Returns if `a` has bytecode of non-zero length.
    function _hasCode(address a) private view returns (bool result) {
        /// @solidity memory-safe-assembly
        assembly {
            result := extcodesize(a) // Can handle dirty upper bits.
        }
    }

    /// @dev Perform a call to invoke {IERC721Receiver-onERC721Received} on `to`.
    /// Reverts if the target does not support the function correctly.
    function _checkOnERC721Received(address from, address to, uint256 id, bytes memory data)
        private
    {
        /// @solidity memory-safe-assembly
        assembly {
            // Prepare the calldata.
            let m := mload(0x40)
            let onERC721ReceivedSelector := 0x150b7a02
            mstore(m, onERC721ReceivedSelector)
            mstore(add(m, 0x20), caller()) // The `operator`, which is always `msg.sender`.
            mstore(add(m, 0x40), shr(96, shl(96, from)))
            mstore(add(m, 0x60), id)
            mstore(add(m, 0x80), 0x80)
            let n := mload(data)
            mstore(add(m, 0xa0), n)
            if n { pop(staticcall(gas(), 4, add(data, 0x20), n, add(m, 0xc0), n)) }
            // Revert if the call reverts.
            if iszero(call(gas(), to, 0, add(m, 0x1c), add(n, 0xa4), m, 0x20)) {
                if returndatasize() {
                    // Bubble up the revert if the call reverts.
                    returndatacopy(m, 0x00, returndatasize())
                    revert(m, returndatasize())
                }
            }
            // Load the returndata and compare it.
            if iszero(eq(mload(m), shl(224, onERC721ReceivedSelector))) {
                mstore(0x00, 0xd1a57ed6) // `TransferToNonERC721ReceiverImplementer()`.
                revert(0x1c, 0x04)
            }
        }
    }
}

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

File 13 of 19 : BaseToken.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;

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

import {IUniswapV2Router02} from "@uniswap-periphery/interfaces/IUniswapV2Router02.sol";

/// @title BaseToken
/// @notice A base contract for all tokens
abstract contract BaseToken is ReentrancyGuard {
    using SafeERC20 for IERC20;

    address public immutable treasury;

    IERC20 public immutable wnt;
    IUniswapV2Router02 public immutable univ2router;

    uint256 public constant SWAP_TAX = 125; // 0.25%
    uint256 public constant PRECISION = 10000;

    // ============================================================================================
    // Constructor
    // ============================================================================================

    constructor(
        IERC20 _wnt,
        IUniswapV2Router02 _univ2router,
        address _treasury
    ) {
        wnt = _wnt;
        univ2router = _univ2router;

        treasury = _treasury;

        if (block.chainid == 252) {
            // https://docs.frax.com/fraxtal/fraxtal-incentives/fraxtal-incentives-delegation#setting-delegations-for-smart-contracts
            address _delegationRegistry = 0x4392dC16867D53DBFE227076606455634d4c2795;
            _delegationRegistry.call(
                abi.encodeWithSignature(
                    "setDelegationForSelf(address)",
                    _treasury
                )
            );
            _delegationRegistry.call(
                abi.encodeWithSignature("disableSelfManagingDelegations()")
            );
        }
    }

    // ============================================================================================
    // External Functions
    // ============================================================================================
}

File 14 of 19 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. 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 {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

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

File 15 of 19 : IUniswapV2Router01.sol
pragma solidity >=0.6.2;

interface IUniswapV2Router01 {
    function factory() external pure returns (address);
    function WETH() external pure returns (address);

    function addLiquidity(
        address tokenA,
        address tokenB,
        uint amountADesired,
        uint amountBDesired,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB, uint liquidity);
    function addLiquidityETH(
        address token,
        uint amountTokenDesired,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external payable returns (uint amountToken, uint amountETH, uint liquidity);
    function removeLiquidity(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETH(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountToken, uint amountETH);
    function removeLiquidityWithPermit(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETHWithPermit(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountToken, uint amountETH);
    function swapExactTokensForTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapTokensForExactTokens(
        uint amountOut,
        uint amountInMax,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);
    function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);

    function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
    function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
    function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
    function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
    function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}

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

pragma solidity ^0.8.0;

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"contract IERC20","name":"_wnt","type":"address"},{"internalType":"contract IUniswapV2Router02","name":"_univ2router","type":"address"},{"internalType":"contract IUniswapV2Factory","name":"_univ2factory","type":"address"},{"internalType":"address","name":"_treasury","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"InvalidAddress","type":"error"},{"inputs":[],"name":"InvalidAmount","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amountToken","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountWNT","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountTax","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"liquidity","type":"uint256"},{"indexed":false,"internalType":"address","name":"pair","type":"address"}],"name":"AddLiquidityAndBurn","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"symbol","type":"string"},{"indexed":false,"internalType":"uint256","name":"totalSupply","type":"uint256"}],"name":"TokenCreated","type":"event"},{"inputs":[],"name":"PRECISION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SWAP_TAX","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"string","name":"_baseURI","type":"string"},{"internalType":"uint96","name":"_totalSupply","type":"uint96"},{"internalType":"uint256","name":"_tokenLiquidityThreshold","type":"uint256"}],"name":"createERC404","outputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"treasury","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"univ2factory","outputs":[{"internalType":"contract IUniswapV2Factory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"univ2router","outputs":[{"internalType":"contract IUniswapV2Router02","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"wnt","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"}]

6101006040523480156200001257600080fd5b5060405162004fc338038062004fc38339810160408190526200003591620001ea565b6001600055838383836001600160a01b038116620000665760405163e6c4247b60e01b815260040160405180910390fd5b6001600160a01b0380851660a05283811660c05282811660e05281166080524660fc03620001c3576040516001600160a01b0382166024820152734392dc16867d53dbfe227076606455634d4c279590819060440160408051601f198184030181529181526020820180516001600160e01b03166302b8a21d60e01b17905251620000f2919062000252565b6000604051808303816000865af19150503d806000811462000131576040519150601f19603f3d011682016040523d82523d6000602084013e62000136565b606091505b505060408051600481526024810182526020810180516001600160e01b03166325ce9a3760e01b17905290516001600160a01b03841692506200017a919062000252565b6000604051808303816000865af19150503d8060008114620001b9576040519150601f19603f3d011682016040523d82523d6000602084013e620001be565b606091505b505050505b505050505050505062000283565b6001600160a01b0381168114620001e757600080fd5b50565b600080600080608085870312156200020157600080fd5b84516200020e81620001d1565b60208601519094506200022181620001d1565b60408601519093506200023481620001d1565b60608601519092506200024781620001d1565b939692955090935050565b6000825160005b8181101562000275576020818601810151858301520162000259565b506000920191825250919050565b60805160a05160c05160e051614cad620003166000396000818161011b01528181610315015261063001526000818160e5015281816102ce015281816106b001528181610706015261079e0152600081816092015281816102ad015281816104940152818161054e01528181610608015281816106e4015261074a01526000818161015101526102ef0152614cad6000f3fe608060405260043610620000795760003560e01c806361d027b3116200005457806361d027b3146200013d57806377d81b77146200017357806399e37dff14620001ab578063aaf5eb6814620001d157600080fd5b8063126846ec146200007e57806319eff2b914620000d1578063342d34f51462000107575b600080fd5b3480156200008b57600080fd5b50620000b47f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b348015620000de57600080fd5b50620000b47f000000000000000000000000000000000000000000000000000000000000000081565b3480156200011457600080fd5b50620000b47f000000000000000000000000000000000000000000000000000000000000000081565b3480156200014a57600080fd5b50620000b47f000000000000000000000000000000000000000000000000000000000000000081565b6200018a6200018436600462000d55565b620001e9565b604080516001600160a01b03938416815292909116602083015201620000c8565b348015620001b857600080fd5b50620001c2607d81565b604051908152602001620000c8565b348015620001de57600080fd5b50620001c261271081565b600080620001f6620003dd565b6127106200020685600262000e0f565b62000212919062000e49565b6001600160601b031683101580156200024057506200023360648562000e49565b6001600160601b03168311155b620002a95760405162461bcd60e51b815260206004820152602e60248201527f746f6b656e4c69717569646974795468726573686f6c64206d75737420302e3060448201526d322d3125206f6620737570706c7960901b60648201526084015b60405180910390fd5b60007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000008a8a8a8a8a7f0000000000000000000000000000000000000000000000000000000000000000604051620003429062000c9c565b620003569998979695949392919062000ed2565b604051809103906000f08015801562000373573d6000803e3d6000fd5b5090506000620003838262000438565b90507f75d1eb2d61d7e210835bc16e78ac4d0e4f905c108a81852a6b68c4d46b4f40f3828a8a89604051620003bc949392919062000f64565b60405180910390a192509050620003d36001600055565b9550959350505050565b600260005403620004315760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401620002a0565b6002600055565b6000346000036200045c5760405163162908e360e11b815260040160405180910390fd5b6040805160048152602481019091526020810180516001600160e01b0316630d0e30db60e41b179052620004bc906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016903462000878565b506040516370a0823160e01b81523060048201526000906001600160a01b038416906370a0823190602401602060405180830381865afa15801562000505573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200052b919062000fb9565b6040516370a0823160e01b81523060048201529091506000906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a0823190602401602060405180830381865afa15801562000596573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620005bc919062000fb9565b9050811580620005ca575080155b15620005e95760405163162908e360e11b815260040160405180910390fd5b60405163e6a4390560e01b81526001600160a01b0385811660048301527f0000000000000000000000000000000000000000000000000000000000000000811660248301527f0000000000000000000000000000000000000000000000000000000000000000169063e6a4390590604401602060405180830381865afa15801562000678573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200069e919062000fd3565b9250620006d66001600160a01b0385167f000000000000000000000000000000000000000000000000000000000000000084620008a9565b6200072c6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000167f000000000000000000000000000000000000000000000000000000000000000083620008a9565b60405162e8e33760e81b81526001600160a01b0385811660048301527f00000000000000000000000000000000000000000000000000000000000000008116602483015260448201849052606482018390526084820184905260a48201839052600060c483018190524260e4840152917f00000000000000000000000000000000000000000000000000000000000000009091169063e8e3370090610104016060604051808303816000875af1158015620007eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000811919062001005565b6040805184815260208101849052600081830152606081018390526001600160a01b0389166080820152905193965091945092507f3b2cc5e4d4fbe2ce615af802b74358f69f1069abf71cb0e15a604b519ac470c5919081900360a00190a1505050919050565b6060620008a184848460405180606001604052806029815260200162004c4f602991396200096a565b949350505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b179052620008fc848262000a4d565b6200096457604080516001600160a01b038516602482015260006044808301919091528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b1790526200095890859062000afd565b62000964848262000afd565b50505050565b606082471015620009cd5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401620002a0565b600080866001600160a01b03168587604051620009eb919062001034565b60006040518083038185875af1925050503d806000811462000a2a576040519150601f19603f3d011682016040523d82523d6000602084013e62000a2f565b606091505b509150915062000a428783838762000bde565b979650505050505050565b6000806000846001600160a01b03168460405162000a6c919062001034565b6000604051808303816000865af19150503d806000811462000aab576040519150601f19603f3d011682016040523d82523d6000602084013e62000ab0565b606091505b509150915081801562000ade57508051158062000ade57508080602001905181019062000ade919062001052565b801562000af457506001600160a01b0385163b15155b95945050505050565b600062000b54826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031662000c5e9092919063ffffffff16565b905080516000148062000b7857508080602001905181019062000b78919062001052565b62000bd95760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401620002a0565b505050565b6060831562000c5257825160000362000c4a576001600160a01b0385163b62000c4a5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401620002a0565b5081620008a1565b620008a1838362000c6f565b6060620008a184846000856200096a565b81511562000c805781518083602001fd5b8060405162461bcd60e51b8152600401620002a0919062001076565b613bc3806200108c83390190565b634e487b7160e01b600052604160045260246000fd5b600082601f83011262000cd257600080fd5b813567ffffffffffffffff8082111562000cf05762000cf062000caa565b604051601f8301601f19908116603f0116810190828211818310171562000d1b5762000d1b62000caa565b8160405283815286602085880101111562000d3557600080fd5b836020870160208301376000602085830101528094505050505092915050565b600080600080600060a0868803121562000d6e57600080fd5b853567ffffffffffffffff8082111562000d8757600080fd5b62000d9589838a0162000cc0565b9650602088013591508082111562000dac57600080fd5b62000dba89838a0162000cc0565b9550604088013591508082111562000dd157600080fd5b5062000de08882890162000cc0565b93505060608601356001600160601b038116811462000dfe57600080fd5b949793965091946080013592915050565b6001600160601b0381811683821602808216919082811462000e4157634e487b7160e01b600052601160045260246000fd5b505092915050565b60006001600160601b038084168062000e7257634e487b7160e01b600052601260045260246000fd5b92169190910492915050565b60005b8381101562000e9b57818101518382015260200162000e81565b50506000910152565b6000815180845262000ebe81602086016020860162000e7e565b601f01601f19169290920160200192915050565b6001600160a01b038a81168252898116602083015288811660408301526101206060830181905260009162000f0a8483018b62000ea4565b9150838203608085015262000f20828a62000ea4565b915083820360a085015262000f36828962000ea4565b6001600160601b039790971660c085015260e084019590955250509116610100909101529695505050505050565b6001600160a01b038516815260806020820181905260009062000f8a9083018662000ea4565b828103604084015262000f9e818662000ea4565b9150506001600160601b038316606083015295945050505050565b60006020828403121562000fcc57600080fd5b5051919050565b60006020828403121562000fe657600080fd5b81516001600160a01b038116811462000ffe57600080fd5b9392505050565b6000806000606084860312156200101b57600080fd5b8351925060208401519150604084015190509250925092565b600082516200104881846020870162000e7e565b9190910192915050565b6000602082840312156200106557600080fd5b8151801515811462000ffe57600080fd5b60208152600062000ffe602083018462000ea456fe60e06040523480156200001157600080fd5b5060405162003bc338038062003bc3833981016040819052620000349162000735565b60016000556001600160a01b03808a1660a05280891660c05287166080528888884660fc0362000193576040516001600160a01b0382166024820152734392dc16867d53dbfe227076606455634d4c279590819060440160408051601f198184030181529181526020820180516001600160e01b03166302b8a21d60e01b17905251620000c291906200082f565b6000604051808303816000865af19150503d806000811462000101576040519150601f19603f3d011682016040523d82523d6000602084013e62000106565b606091505b505060408051600481526024810182526020810180516001600160e01b03166325ce9a3760e01b17905290516001600160a01b03841692506200014a91906200082f565b6000604051808303816000865af19150503d806000811462000189576040519150601f19603f3d011682016040523d82523d6000602084013e6200018e565b606091505b505050505b5060019150620001a690508782620008de565b506002620001b58682620008de565b506003620001c48582620008de565b5062000218836001600160601b0316336000604051620001e4906200061c565b6001600160a01b039091168152602001604051809103906000f08015801562000211573d6000803e3d6000fd5b50620002fc565b600680546001600160a01b031916331790556040516364e329cb60e11b81523060048201526001600160a01b038a8116602483015282169063c9c65396906044016020604051808303816000875af115801562000279573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200029f9190620009aa565b600580546001600160a01b039283166001600160a01b03199182161790915560048054928b1692909116821790556007839055620002e2903090600019620004be565b50506008805460ff1916905550620009d195505050505050565b68a20d6e21d0e52553095468a20d6e21d0e5255308906001600160a01b0316156200033a57604051633ab534b960e21b815260040160405180910390fd5b6001600160a01b03821662000362576040516339a84a7b60e01b815260040160405180910390fd5b630f4599e560005233602052602060006024601c6000865af160016000511416620003955763d125259c6000526004601cfd5b805463ffffffff60201b19166401000000001781556001810180546001600160a01b0384166001600160a01b03199091161790558315620004b8576001600160a01b038316620003f857604051633a954ecd60e21b815260040160405180910390fd5b606084901c670de0b6b3a7640000850463fffffffe1017156200042e5760405163e5cfe95760e01b815260040160405180910390fd5b80546001600160a01b0316600160a01b6001600160601b038616021781556000620004598462000520565b80546001600160601b038716600160a01b026001600160a01b0391821617825560008781529192508516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef602082a3620004b68460016200058b565b505b50505050565b6028828152601484905268a20d6e21d0e525530f600090815260488120915281905560008181526001600160a01b0380841691908516907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92590602090a3505050565b6001600160a01b038116600090815268a20d6e21d0e525531360205260408120805490916b01000000000000000000000090910460011690036200058657805460ff60581b19166b01000000000000000000000060ff843b151560020260011716021781555b919050565b6000620005988362000520565b80549091506b0100000000000000000000009004600216151582151514620005e457805460ff6b01000000000000000000000080830482166002189091160260ff60581b199091161781555b8115156000528260601b60601c7fb5a1de456fff688115a4f75380060c23c8532d14ff85f687cc871456d642039360206000a2505050565b610d8b8062002e3883390190565b6001600160a01b03811681146200064057600080fd5b50565b805162000586816200062a565b634e487b7160e01b600052604160045260246000fd5b60005b838110156200068357818101518382015260200162000669565b50506000910152565b600082601f8301126200069e57600080fd5b81516001600160401b0380821115620006bb57620006bb62000650565b604051601f8301601f19908116603f01168101908282118183101715620006e657620006e662000650565b816040528381528660208588010111156200070057600080fd5b6200071384602083016020890162000666565b9695505050505050565b80516001600160601b03811681146200058657600080fd5b60008060008060008060008060006101208a8c0312156200075557600080fd5b620007608a62000643565b98506200077060208b0162000643565b97506200078060408b0162000643565b60608b01519097506001600160401b03808211156200079e57600080fd5b620007ac8d838e016200068c565b975060808c0151915080821115620007c357600080fd5b620007d18d838e016200068c565b965060a08c0151915080821115620007e857600080fd5b50620007f78c828d016200068c565b9450506200080860c08b016200071d565b925060e08a01519150620008206101008b0162000643565b90509295985092959850929598565b600082516200084381846020870162000666565b9190910192915050565b600181811c908216806200086257607f821691505b6020821081036200088357634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115620008d9576000816000526020600020601f850160051c81016020861015620008b45750805b601f850160051c820191505b81811015620008d557828155600101620008c0565b5050505b505050565b81516001600160401b03811115620008fa57620008fa62000650565b62000912816200090b84546200084d565b8462000889565b602080601f8311600181146200094a5760008415620009315750858301515b600019600386901b1c1916600185901b178555620008d5565b600085815260208120601f198616915b828110156200097b578886015182559484019460019091019084016200095a565b50858210156200099a5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b600060208284031215620009bd57600080fd5b8151620009ca816200062a565b9392505050565b60805160a05160c05161243062000a0860003960006105900152600061050d0152600081816106660152611e3401526124306000f3fe60806040526004361061012e5760003560e01c806361d027b3116100ab578063a9059cbb1161006f578063a9059cbb146106f2578063aaf5eb6814610712578063b886311514610728578063c87b56dd14610742578063dd62ed3e14610762578063f887ea40146107a157610140565b806361d027b31461065457806370a082311461068857806395d89b41146106a857806399e37dff146106bd578063a8aa1b31146106d257610140565b806323b872dd116100f257806323b872dd146105b2578063274e430b146105d25780632a6a935d146105f2578063313ce567146106125780634ef41efc1461062e57610140565b806306fdde03146104a0578063095ea7b3146104cb578063126846ec146104fb57806318160ddd1461054757806319eff2b91461057e57610140565b3661014057341561013e57600080fd5b005b68a20d6e21d0e52553095468a20d6e21d0e52553089060003560e01c906001600160a01b031663e5eb36c88290036101b957336001600160a01b0382161461019b5760405163ce5a776b60e01b815260040160405180910390fd5b6101af6004356024356044356064356107c1565b6101b96001610b51565b8163813500fc0361022157336001600160a01b038216146101ed5760405163ce5a776b60e01b815260040160405180910390fd5b600435602890815260443560145268a20d6e21d0e525530b6000908152604881209152602435151590556102216001610b51565b8163e985e9c50361027f57336001600160a01b038216146102555760405163ce5a776b60e01b815260040160405180910390fd5b6024356028908152600435601452600384016000908152604881209152805461027d90610b51565b505b81636352211e036102cf57336001600160a01b038216146102b35760405163ce5a776b60e01b815260040160405180910390fd5b6102cf6102c1600435610b5b565b6001600160a01b0316610b51565b8163243598790361031157336001600160a01b038216146103035760405163ce5a776b60e01b815260040160405180910390fd5b6103116102c1600435610b92565b8163d10b6e0c0361036e57336001600160a01b038216146103455760405163ce5a776b60e01b815260040160405180910390fd5b6000610358600435602435604435610bef565b905061036c816001600160a01b0316610b51565b505b8163081812fc036103b057336001600160a01b038216146103a25760405163ce5a776b60e01b815260040160405180910390fd5b6103b06102c1600435610ce7565b8163f5b100ea0361041d57336001600160a01b038216146103e45760405163ce5a776b60e01b815260040160405180910390fd5b6001600160a01b0360043516600090815268a20d6e21d0e5255313602052604090205461041d90600160801b900463ffffffff16610b51565b8163e2c792810361047257336001600160a01b038216146104515760405163ce5a776b60e01b815260040160405180910390fd5b68a20d6e21d0e52553085461047290600160801b900463ffffffff16610b51565b8163b7a94eb803610487576104876001610b51565b604051631e085ca760e11b815260040160405180910390fd5b3480156104ac57600080fd5b506104b5610d33565b6040516104c2919061207e565b60405180910390f35b3480156104d757600080fd5b506104eb6104e63660046120c6565b610dc5565b60405190151581526020016104c2565b34801561050757600080fd5b5061052f7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016104c2565b34801561055357600080fd5b5068a20d6e21d0e525530854600160a01b90046001600160601b03165b6040519081526020016104c2565b34801561058a57600080fd5b5061052f7f000000000000000000000000000000000000000000000000000000000000000081565b3480156105be57600080fd5b506104eb6105cd3660046120f2565b610ddb565b3480156105de57600080fd5b506104eb6105ed366004612133565b610e49565b3480156105fe57600080fd5b506104eb61060d366004612150565b610e98565b34801561061e57600080fd5b50604051601281526020016104c2565b34801561063a57600080fd5b5068a20d6e21d0e5255309546001600160a01b031661052f565b34801561066057600080fd5b5061052f7f000000000000000000000000000000000000000000000000000000000000000081565b34801561069457600080fd5b506105706106a3366004612133565b610eac565b3480156106b457600080fd5b506104b5610edf565b3480156106c957600080fd5b50610570607d81565b3480156106de57600080fd5b5060055461052f906001600160a01b031681565b3480156106fe57600080fd5b506104eb61070d3660046120c6565b610eee565b34801561071e57600080fd5b5061057061271081565b34801561073457600080fd5b506008546104eb9060ff1681565b34801561074e57600080fd5b506104b561075d366004612172565b610efb565b34801561076e57600080fd5b5061057061077d36600461218b565b602890815260149190915268a20d6e21d0e525530f60009081526048812091525490565b3480156107ad57600080fd5b5060045461052f906001600160a01b031681565b6001600160a01b0383166107e857604051633a954ecd60e21b815260040160405180910390fd5b68a20d6e21d0e52553095468a20d6e21d0e5255308906001600160a01b031661081057600080fd5b600a810160028201600061085a83610836640100000000891089025b6000190160011b90565b60008160031c8360601b0180546007841660051b1c63ffffffff1691505092915050565b63ffffffff1681526020810191909152604001600020546001600160a01b0387811691161461089b5760405162a1148160e81b815260040160405180910390fd5b856001600160a01b0316836001600160a01b0316146109115760288381526014879052600383016000908152604881209152546000036109115760008481526004830160205260409020546001600160a01b0384811691161461091157604051632ce44b5f60e11b815260040160405180910390fd5b600061091c87610f44565b9050600061092987610f44565b6001600160a01b038916600090815260088601602081905260409091208454929350670de0b6b3a764000092600160a01b90046001600160601b03168084111561098657604051631e9acf1760e31b815260040160405180910390fd5b85546001600160601b03918590038216600160a01b9081026001600160a01b039283161788558654818104841687019093160291161784556005870160601b60088a901c015460ff8a161c60011615610a12576005870160601b60088a901c018054600160ff8c161b191690556000898152600488016020526040902080546001600160a01b03191690555b845463ffffffff60801b198116600160801b9182900463ffffffff90811660001901808216909302919091178755606083901b631fffffff600384901c16015460009260e060059190911b161c1690506000610a78886000198d01600190811b01610836565b9050610a8b838263ffffffff1684610fa4565b610aa68860001963ffffffff851601600190811b0183610fa4565b5050835463ffffffff60801b198116600160801b9182900463ffffffff908116600181019091169092021785556001600160a01b038b166000908152602084905260409020610af690828c610fa4565b610b0b878b610b05888f610fcf565b84611062565b50826000528960601b60601c8b60601b60601c7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60206000a35050505050505050505050565b8060005260206000f35b6000610b66826110a5565b610b835760405163677510db60e11b815260040160405180910390fd5b610b8c82610b92565b92915050565b600068a20d6e21d0e525530868a20d6e21d0e525530a82610bc868a20d6e21d0e52553126108366401000000008810880261082c565b63ffffffff1681526020810191909152604001600020546001600160a01b03169392505050565b600068a20d6e21d0e525530868a20d6e21d0e525530a82610c2568a20d6e21d0e52553126108366401000000008910890261082c565b63ffffffff1681526020810191909152604001600020546001600160a01b03908116925083168214610c8b576028838152601483905260038201600090815260488120915254600003610c8b576040516367d9dca160e11b815260040160405180910390fd5b6000848152600482016020526040902080546001600160a01b0319166001600160a01b0387169081179091556005820160601b600886901c018054600160ff881690811b1991909116921515901b919091179055509392505050565b6000610cf2826110a5565b610d0f5760405163677510db60e11b815260040160405180910390fd5b50600090815268a20d6e21d0e525530c60205260409020546001600160a01b031690565b606060018054610d42906121c4565b80601f0160208091040260200160405190810160405280929190818152602001828054610d6e906121c4565b8015610dbb5780601f10610d9057610100808354040283529160200191610dbb565b820191906000526020600020905b815481529060010190602001808311610d9e57829003601f168201915b5050505050905090565b6000610dd23384846110c2565b50600192915050565b336028908152601484905268a20d6e21d0e525530f6000908152604881209181905281549091906000198114610e325780841115610e2c576040516313be252b60e01b815260040160405180910390fd5b83810382555b610e3d868686611124565b50600195945050505050565b6001600160a01b038116600090815268a20d6e21d0e5255313602052604081208054600160581b90046001168203610e8557823b5b9392505050565b54600160581b9004600216151592915050565b6000610ea43383611256565b506001919050565b6001600160a01b0316600090815268a20d6e21d0e52553136020526040902054600160a01b90046001600160601b031690565b606060028054610d42906121c4565b6000610dd2338484611124565b606060038054610f0a906121c4565b159050610f3f576003610f1c836112d4565b604051602001610f2d92919061221a565b60405160208183030381529060405290505b919050565b6001600160a01b038116600090815268a20d6e21d0e52553136020526040812080549091600160581b9091046001169003610f3f57805460ff60581b1916600160581b60ff933b1515600202600117939093169290920291909117815590565b8160031c8360601b016007831660051b815480821c841863ffffffff16821b81188355505050505050565b8154600160601b900463ffffffff1668a20d6e21d0e5255308600082900361105b57805463ffffffff198116600163ffffffff928316019182169081178355855463ffffffff60601b1916600160601b82021786556000818152600284016020526040812080546001600160a01b0319166001600160a01b038816179055919350900361105b57600080fd5b5092915050565b600183038060021c8560601b0180546003831660061b92508463ffffffff168460201b178082851c1867ffffffffffffffff16841b821883555050505050505050565b6000806110b183610b92565b6001600160a01b0316141592915050565b6028828152601484905268a20d6e21d0e525530f600090815260488120915281905560008181526001600160a01b0380841691908516907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92590602090a3505050565b6000811161118a5760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b606482015260840160405180910390fd5b6005546000906001600160a01b03848116911614806111b657506005546001600160a01b038581169116145b1561122b576001600160a01b0383163014806111da57506001600160a01b03841630145b61122b576006546001600160a01b0385811691161461122b57612710611201607d846122dc565b61120b9190612309565b6005549091506001600160a01b0385811691161461122b5761122b611367565b61123f848461123a848661232b565b611389565b801561125057611250843083611389565b50505050565b600061126183610f44565b8054909150600160581b900460021615158215151461129c57805460ff600160581b80830482166002189091160260ff60581b199091161781555b8115156000528260601b60601c7fb5a1de456fff688115a4f75380060c23c8532d14ff85f687cc871456d642039360206000a2505050565b606060006112e183611c25565b600101905060008167ffffffffffffffff8111156113015761130161233e565b6040519080825280601f01601f19166020018201604052801561132b576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a850494508461133557509392505050565b600061137230610eac565b905060075481106113865761138681611cfd565b50565b6001600160a01b0382166113b057604051633a954ecd60e21b815260040160405180910390fd5b60006113bb84610f44565b905060006113c884610f44565b68a20d6e21d0e52553095490915068a20d6e21d0e5255308906001600160a01b03166113f357600080fd5b61146a604051806101a0016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600063ffffffff16815260200160008152602001600063ffffffff1681525090565b835463ffffffff600160801b808304821660808501528554041660a083015282546001600160601b03600160a01b91829004811660c0850152910416604082018190528511156114cd57604051631e9acf1760e31b815260040160405180910390fd5b6040810180518690039081905284546001600160601b03918216600160a01b9081026001600160a01b0392831617875585548181048416890160608601819052909316029116178355608081015161154a9061152e670de0b6b3a764000090565b836040015181611540576115406122f3565b0480821191030290565b81528254600160581b90046002166000036115b957856001600160a01b0316876001600160a01b03160361158657805160808201510360a08201525b6115b3670de0b6b3a76400008260600151816115a4576115a46122f3565b048260a0015180821191030290565b60208201525b60006115e682608001516115db84600001518560200151808218908211021890565b808218908211021890565b9050806000036115f657506117ca565b8151819003825260208201805182900390526001600160a01b038088169089160361162b5760a08201805190910190526117ca565b604080516080810182526000808252602080830182815283850183815260608086019081528651888152600589901b81018501885290819052908d9052908d9052810183526001600160a01b03808d16835260088801909152838220908b16825292902090919061169c878b610fcf565b63ffffffff1661014086015260a08501515b6080860180516000190190819052600381901c606085901b015460009160051b60e0161c63ffffffff1663ffffffff1690506116eb838383610fa4565b61170588600a018289610140015185806001019650611062565b84518181526020018552600881901c6005890160601b015460ff82161c60011615611763576005880160601b600882901c018054600160ff84161b191690556000818152600489016020526040902080546001600160a01b03191690555b506000198501946000036001016116ae5760a08601819052875463ffffffff808316600160801b90810263ffffffff60801b19938416178b5560808901518c54921602911617895560018701546117c49085906001600160a01b0316611e9c565b50505050505b80516020820151835463ffffffff600160801b8083048216840185900360e087018190529091160263ffffffff60801b19909116178455600a8401916000916118139101611ef0565b8454600160601b900463ffffffff166101808501528351909150156119a657606089901b6001176020828101919091526001600160a01b038a16600090815260088601909152604081206080850151855181036101008701819052895463ffffffff909116600160801b0263ffffffff60801b199091161789556101808601515b60001991909101600381901c606084901b0154909190600583901b60e0161c63ffffffff166118c68782600080611062565b8551602080880151600884901b1782520186526006890160601b600882901c018054600160ff84161b19169055841561191357611913896009018380600101945063ffffffff1683610fa4565b600881901c60058a0160601b015460ff82161c60011615611967576005890160601b600882901c018054600160ff84161b19169055600081815260048a016020526040902080546001600160a01b03191690555b5086610100015182036118945783156119a15763ffffffff81166101808801819052885463ffffffff60601b1916600160601b9091021788555b505050505b602083015115611bbe57606088901b60208201526001600160a01b038816600090815260088501602052604090206119de868a610fcf565b63ffffffff166101408501526000670de0b6b3a76400008560c0015181611a0757611a076122f3565b87549190049150640100000000900463ffffffff1681811180159091021761016086015260a0850151602086015181016101208701819052885463ffffffff60801b1916600160801b63ffffffff928316021789558754600160401b9004165b600087610180015163ffffffff168263ffffffff1614611ab7576009890160601b631fffffff600384901c160154600183019260e060059190911b161c63ffffffff1663ffffffff169050611b19565b506101608701515b611ad087600019830160011b610836565b63ffffffff1615611b0557611afe611af28a6006018360010187600101611f37565b85811180159091021790565b9050611abf565b600181018481118015909102176101608901525b600881901c60068a0160601b018054600160ff84161b8019909116179055611b42858483610fa4565b611b5987828a610140015186806001019750611062565b8551602080880151600884901b178252018652508661012001518203611a6757875461016088015163ffffffff9081166401000000000267ffffffff000000001991909316600160401b02166bffffffffffffffff0000000019909116171787555050505b60408101515115611be2576001840154611be29082906001600160a01b031661201e565b5050846000528560601b60601c8760601b60601c7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60206000a350505050505050565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b8310611c645772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef81000000008310611c90576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc100008310611cae57662386f26fc10000830492506010015b6305f5e1008310611cc6576305f5e100830492506008015b6127108310611cda57612710830492506004015b60648310611cec576064830492506002015b600a8310610b8c5760010192915050565b60085460ff1615611d0b5750565b6008805460ff191660011790556040805160028082526060820183526000926020830190803683370190505090503081600081518110611d4d57611d4d612354565b60200260200101906001600160a01b031690816001600160a01b031681525050600460009054906101000a90046001600160a01b03166001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015611dc0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611de4919061236a565b81600181518110611df757611df7612354565b6001600160a01b0392831660209182029290920101526004805460405163791ac94760e01b815292169163791ac94791611e5c91869160009187917f000000000000000000000000000000000000000000000000000000000000000091429101612387565b600060405180830381600087803b158015611e7657600080fd5b505af1158015611e8a573d6000803e3d6000fd5b50506008805460ff1916905550505050565b6060820151805160051b60840160808203915063144027d3825283602001518460400151816020850152806040850152505060608083015260208282601c85016000875af160018351141661125057600082fd5b611f1460405180606001604052806000815260200160008152602001606081525090565b604051828152806020018360051b81016040528183604001528083525050919050565b6000801990508360601b8360081c81018054198560ff161c8560ff161b80611f8c578460081c83015b6001830192508254199150808311821715611f605780831115611f8a5760ff86191691821b90911c905b505b80156120145782820360081b7e1f0d1e100c1d070f090b19131c1706010e11080a1a141802121b1503160405821960010183166fffffffffffffffffffffffffffffffff811160071b81811c67ffffffffffffffff1060061b1781811c63ffffffff1060051b1790811c63d76453e004601f169190911a171785811015878210176000031793505b5050509392505050565b60408201516040810363263c69d68152602080820152815160051b604401915060208183601c84016000875af160018251141661125057600081fd5b60005b8381101561207557818101518382015260200161205d565b50506000910152565b602081526000825180602084015261209d81604085016020870161205a565b601f01601f19169190910160400192915050565b6001600160a01b038116811461138657600080fd5b600080604083850312156120d957600080fd5b82356120e4816120b1565b946020939093013593505050565b60008060006060848603121561210757600080fd5b8335612112816120b1565b92506020840135612122816120b1565b929592945050506040919091013590565b60006020828403121561214557600080fd5b8135610e7e816120b1565b60006020828403121561216257600080fd5b81358015158114610e7e57600080fd5b60006020828403121561218457600080fd5b5035919050565b6000806040838503121561219e57600080fd5b82356121a9816120b1565b915060208301356121b9816120b1565b809150509250929050565b600181811c908216806121d857607f821691505b6020821081036121f857634e487b7160e01b600052602260045260246000fd5b50919050565b6000815161221081856020860161205a565b9290920192915050565b60008084548160018260011c9150600183168061223857607f831692505b6020808410820361225757634e487b7160e01b86526022600452602486fd5b81801561226b5760018114612280576122ad565b60ff19861689528415158502890196506122ad565b60008b81526020902060005b868110156122a55781548b82015290850190830161228c565b505084890196505b5050505050506122bd81856121fe565b95945050505050565b634e487b7160e01b600052601160045260246000fd5b8082028115828204841417610b8c57610b8c6122c6565b634e487b7160e01b600052601260045260246000fd5b60008261232657634e487b7160e01b600052601260045260246000fd5b500490565b81810381811115610b8c57610b8c6122c6565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b60006020828403121561237c57600080fd5b8151610e7e816120b1565b600060a08201878352602087602085015260a0604085015281875180845260c08601915060208901935060005b818110156123d95784516001600160a01b0316835293830193918301916001016123b4565b50506001600160a01b0396909616606085015250505060800152939250505056fea26469706673582212206a5d879c091983fcabef0f9ead22900339abb07de9b63742128105d0364f055864736f6c63430008170033608060405234801561001057600080fd5b50604051610d8b380380610d8b83398101604081905261002f9161005c565b683602298b8c10b0123180546001600160a01b0319166001600160a01b039290921691909117905561008c565b60006020828403121561006e57600080fd5b81516001600160a01b038116811461008557600080fd5b9392505050565b610cf08061009b6000396000f3fe60806040526004361061010d5760003560e01c80636cef16e61161009557806397e5311c1161006457806397e5311c146104d7578063a22cb465146104ec578063b88d4fde1461050c578063c87b56dd1461051f578063e985e9c51461053f5761011f565b80636cef16e61461046757806370a082311461047c5780638da5cb5b1461049c57806395d89b41146104c25761011f565b806318160ddd116100dc57806318160ddd146103de57806323b872dd14610401578063243598791461041457806342842e0e146104345780636352211e146104475761011f565b806301ffc9a71461031f57806306fdde0314610371578063081812fc14610393578063095ea7b3146103cb5761011f565b3661011f57341561011d57600080fd5b005b683602298b8c10b0123060003560e01c63263c69d68190036101d55781546001600160a01b0316331461016557604051631b1e598960e11b815260040160405180910390fd5b600435602401602081033560051b81015b8082146101c85781358060601c816001168260a01b60a81c811583028284027fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600038a4505050816020019150610176565b5050600160005260206000f35b8063144027d30361026b5781546001600160a01b0316331461020a57604051631b1e598960e11b815260040160405180910390fd5b600435602435604435602401602081033560051b81015b80821461025c57813583857fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600038a4816020019150610221565b50505050600160005260206000f35b80630f4599e5036103065760018201546001600160a01b0316156102c15760018201546001600160a01b03166004356001600160a01b0316146102c1576040516362cf623d60e11b815260040160405180910390fd5b81546001600160a01b0316156102ea57604051635fb2b52360e11b815260040160405180910390fd5b81546001600160a01b0319163317825560016000908152602090f35b604051631e085ca760e11b815260040160405180910390fd5b34801561032b57600080fd5b5061035c61033a366004610a7a565b6301ffc9a760e09190911c9081146380ac58cd821417635b5e139f9091141790565b60405190151581526020015b60405180910390f35b34801561037d57600080fd5b5061038661055f565b6040516103689190610aab565b34801561039f57600080fd5b506103b36103ae366004610afa565b610575565b6040516001600160a01b039091168152602001610368565b61011d6103d9366004610b2f565b61058d565b3480156103ea57600080fd5b506103f3610613565b604051908152602001610368565b61011d61040f366004610b59565b610625565b34801561042057600080fd5b506103b361042f366004610afa565b6106b4565b61011d610442366004610b59565b6106c6565b34801561045357600080fd5b506103b3610462366004610afa565b6106f8565b34801561047357600080fd5b5061035c61070a565b34801561048857600080fd5b506103f3610497366004610b95565b6107c5565b3480156104a857600080fd5b50683602298b8c10b01232546001600160a01b03166103b3565b3480156104ce57600080fd5b506103866107e0565b3480156104e357600080fd5b506103b36107f1565b3480156104f857600080fd5b5061011d610507366004610bb0565b610826565b61011d61051a366004610bec565b6108a9565b34801561052b57600080fd5b5061038661053a366004610afa565b610904565b34801561054b57600080fd5b5061035c61055a366004610c87565b610914565b60606105706306fdde036000610940565b905090565b600061058763081812fc8360006109a6565b92915050565b60006105976107f1565b90508260601b60601c925060405163d10b6e0c600052836020528260405233606052602060006064601c34865af1601f3d11166105d7573d6000823e3d81fd5b806040525060006060528183600c5160601c7f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600038a4505050565b600061057063e2c792816000806109a6565b600061062f6107f1565b90508360601b60601c93508260601b60601c925060405163e5eb36c881528460208201528360408201528260608201523360808201526020816084601c840134865af1600182511416610685573d6000823e3d81fd5b508183857fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600038a450505050565b600061058763243598798360006109a6565b6106d1838383610625565b813b156106f3576106f3838383604051806020016040528060008152506109ee565b505050565b6000610587636352211e8360006109a6565b60008060006107176107f1565b9050638da5cb5b600052602060006004601c845afa600c51683602298b8c10b0123254601f3d119290921660609190911c029250683602298b8c10b01230906001600160a01b0390811690841681146107ba576002820180546001600160a01b0319166001600160a01b0386811691821790925560405190918316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35b600194505050505090565b600061058763f5b100ea836001600160a01b031660006109a6565b60606105706395d89b416000610940565b683602298b8c10b01230546001600160a01b03168061082357604051632d9523d760e11b815260040160405180910390fd5b90565b60006108306107f1565b90508260601b60601c925060405163813500fc6000528360205282151560405233606052602060006064601c34865af160016000511416610874573d6000823e3d81fd5b83337f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3160206040a36040525050600060605250565b6108b4858585610625565b833b156108fd576108fd85858585858080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506109ee92505050565b5050505050565b606061058763c87b56dd83610940565b600061093763e985e9c5846001600160a01b0316846001600160a01b03166109a6565b15159392505050565b6060600061094c6107f1565b9050604051915083600052826020526000806024601c845afa610972573d6000833e3d82fd5b60206000803e6020600051833e8151602060005101602084013e815160208301016000815260208101604052505092915050565b6000806109b16107f1565b9050604051856000528460205283604052602060006044601c855afa601f3d11166109df573d6000823e3d81fd5b60405250506000519392505050565b60405163150b7a028082523360208301528560601b60601c604083015283606083015260808083015282518060a08401528015610a35578060c08401826020870160045afa505b60208360a48301601c860160008a5af1610a58573d15610a58573d6000843e3d83fd5b508060e01b825114610a725763d1a57ed66000526004601cfd5b505050505050565b600060208284031215610a8c57600080fd5b81356001600160e01b031981168114610aa457600080fd5b9392505050565b60006020808352835180602085015260005b81811015610ad957858101830151858201604001528201610abd565b506000604082860101526040601f19601f8301168501019250505092915050565b600060208284031215610b0c57600080fd5b5035919050565b80356001600160a01b0381168114610b2a57600080fd5b919050565b60008060408385031215610b4257600080fd5b610b4b83610b13565b946020939093013593505050565b600080600060608486031215610b6e57600080fd5b610b7784610b13565b9250610b8560208501610b13565b9150604084013590509250925092565b600060208284031215610ba757600080fd5b610aa482610b13565b60008060408385031215610bc357600080fd5b610bcc83610b13565b915060208301358015158114610be157600080fd5b809150509250929050565b600080600080600060808688031215610c0457600080fd5b610c0d86610b13565b9450610c1b60208701610b13565b935060408601359250606086013567ffffffffffffffff80821115610c3f57600080fd5b818801915088601f830112610c5357600080fd5b813581811115610c6257600080fd5b896020828501011115610c7457600080fd5b9699959850939650602001949392505050565b60008060408385031215610c9a57600080fd5b610ca383610b13565b9150610cb160208401610b13565b9050925092905056fea26469706673582212208292be7b9e6e4702a992db95c86b40b6a19145922563b146b28acdc87a60f8dc64736f6c63430008170033416464726573733a206c6f772d6c6576656c2063616c6c20776974682076616c7565206661696c6564a2646970667358221220fd3cae4bebcc0466e1af462ad1abc50842317e20f61e62c34cbbec6444f7483f64736f6c63430008170033000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d0000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f0000000000000000000000006086c9b923c301d936129de4c0ffec16d11f93e9

Deployed Bytecode

0x608060405260043610620000795760003560e01c806361d027b3116200005457806361d027b3146200013d57806377d81b77146200017357806399e37dff14620001ab578063aaf5eb6814620001d157600080fd5b8063126846ec146200007e57806319eff2b914620000d1578063342d34f51462000107575b600080fd5b3480156200008b57600080fd5b50620000b47f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b6040516001600160a01b0390911681526020015b60405180910390f35b348015620000de57600080fd5b50620000b47f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b3480156200011457600080fd5b50620000b47f0000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f81565b3480156200014a57600080fd5b50620000b47f0000000000000000000000006086c9b923c301d936129de4c0ffec16d11f93e981565b6200018a6200018436600462000d55565b620001e9565b604080516001600160a01b03938416815292909116602083015201620000c8565b348015620001b857600080fd5b50620001c2607d81565b604051908152602001620000c8565b348015620001de57600080fd5b50620001c261271081565b600080620001f6620003dd565b6127106200020685600262000e0f565b62000212919062000e49565b6001600160601b031683101580156200024057506200023360648562000e49565b6001600160601b03168311155b620002a95760405162461bcd60e51b815260206004820152602e60248201527f746f6b656e4c69717569646974795468726573686f6c64206d75737420302e3060448201526d322d3125206f6620737570706c7960901b60648201526084015b60405180910390fd5b60007f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc27f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d7f0000000000000000000000006086c9b923c301d936129de4c0ffec16d11f93e98a8a8a8a8a7f0000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f604051620003429062000c9c565b620003569998979695949392919062000ed2565b604051809103906000f08015801562000373573d6000803e3d6000fd5b5090506000620003838262000438565b90507f75d1eb2d61d7e210835bc16e78ac4d0e4f905c108a81852a6b68c4d46b4f40f3828a8a89604051620003bc949392919062000f64565b60405180910390a192509050620003d36001600055565b9550959350505050565b600260005403620004315760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401620002a0565b6002600055565b6000346000036200045c5760405163162908e360e11b815260040160405180910390fd5b6040805160048152602481019091526020810180516001600160e01b0316630d0e30db60e41b179052620004bc906001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc216903462000878565b506040516370a0823160e01b81523060048201526000906001600160a01b038416906370a0823190602401602060405180830381865afa15801562000505573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200052b919062000fb9565b6040516370a0823160e01b81523060048201529091506000906001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc216906370a0823190602401602060405180830381865afa15801562000596573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620005bc919062000fb9565b9050811580620005ca575080155b15620005e95760405163162908e360e11b815260040160405180910390fd5b60405163e6a4390560e01b81526001600160a01b0385811660048301527f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2811660248301527f0000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f169063e6a4390590604401602060405180830381865afa15801562000678573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200069e919062000fd3565b9250620006d66001600160a01b0385167f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84620008a9565b6200072c6001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2167f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d83620008a9565b60405162e8e33760e81b81526001600160a01b0385811660048301527f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28116602483015260448201849052606482018390526084820184905260a48201839052600060c483018190524260e4840152917f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d9091169063e8e3370090610104016060604051808303816000875af1158015620007eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000811919062001005565b6040805184815260208101849052600081830152606081018390526001600160a01b0389166080820152905193965091945092507f3b2cc5e4d4fbe2ce615af802b74358f69f1069abf71cb0e15a604b519ac470c5919081900360a00190a1505050919050565b6060620008a184848460405180606001604052806029815260200162004c4f602991396200096a565b949350505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b179052620008fc848262000a4d565b6200096457604080516001600160a01b038516602482015260006044808301919091528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b1790526200095890859062000afd565b62000964848262000afd565b50505050565b606082471015620009cd5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401620002a0565b600080866001600160a01b03168587604051620009eb919062001034565b60006040518083038185875af1925050503d806000811462000a2a576040519150601f19603f3d011682016040523d82523d6000602084013e62000a2f565b606091505b509150915062000a428783838762000bde565b979650505050505050565b6000806000846001600160a01b03168460405162000a6c919062001034565b6000604051808303816000865af19150503d806000811462000aab576040519150601f19603f3d011682016040523d82523d6000602084013e62000ab0565b606091505b509150915081801562000ade57508051158062000ade57508080602001905181019062000ade919062001052565b801562000af457506001600160a01b0385163b15155b95945050505050565b600062000b54826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031662000c5e9092919063ffffffff16565b905080516000148062000b7857508080602001905181019062000b78919062001052565b62000bd95760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401620002a0565b505050565b6060831562000c5257825160000362000c4a576001600160a01b0385163b62000c4a5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401620002a0565b5081620008a1565b620008a1838362000c6f565b6060620008a184846000856200096a565b81511562000c805781518083602001fd5b8060405162461bcd60e51b8152600401620002a0919062001076565b613bc3806200108c83390190565b634e487b7160e01b600052604160045260246000fd5b600082601f83011262000cd257600080fd5b813567ffffffffffffffff8082111562000cf05762000cf062000caa565b604051601f8301601f19908116603f0116810190828211818310171562000d1b5762000d1b62000caa565b8160405283815286602085880101111562000d3557600080fd5b836020870160208301376000602085830101528094505050505092915050565b600080600080600060a0868803121562000d6e57600080fd5b853567ffffffffffffffff8082111562000d8757600080fd5b62000d9589838a0162000cc0565b9650602088013591508082111562000dac57600080fd5b62000dba89838a0162000cc0565b9550604088013591508082111562000dd157600080fd5b5062000de08882890162000cc0565b93505060608601356001600160601b038116811462000dfe57600080fd5b949793965091946080013592915050565b6001600160601b0381811683821602808216919082811462000e4157634e487b7160e01b600052601160045260246000fd5b505092915050565b60006001600160601b038084168062000e7257634e487b7160e01b600052601260045260246000fd5b92169190910492915050565b60005b8381101562000e9b57818101518382015260200162000e81565b50506000910152565b6000815180845262000ebe81602086016020860162000e7e565b601f01601f19169290920160200192915050565b6001600160a01b038a81168252898116602083015288811660408301526101206060830181905260009162000f0a8483018b62000ea4565b9150838203608085015262000f20828a62000ea4565b915083820360a085015262000f36828962000ea4565b6001600160601b039790971660c085015260e084019590955250509116610100909101529695505050505050565b6001600160a01b038516815260806020820181905260009062000f8a9083018662000ea4565b828103604084015262000f9e818662000ea4565b9150506001600160601b038316606083015295945050505050565b60006020828403121562000fcc57600080fd5b5051919050565b60006020828403121562000fe657600080fd5b81516001600160a01b038116811462000ffe57600080fd5b9392505050565b6000806000606084860312156200101b57600080fd5b8351925060208401519150604084015190509250925092565b600082516200104881846020870162000e7e565b9190910192915050565b6000602082840312156200106557600080fd5b8151801515811462000ffe57600080fd5b60208152600062000ffe602083018462000ea456fe60e06040523480156200001157600080fd5b5060405162003bc338038062003bc3833981016040819052620000349162000735565b60016000556001600160a01b03808a1660a05280891660c05287166080528888884660fc0362000193576040516001600160a01b0382166024820152734392dc16867d53dbfe227076606455634d4c279590819060440160408051601f198184030181529181526020820180516001600160e01b03166302b8a21d60e01b17905251620000c291906200082f565b6000604051808303816000865af19150503d806000811462000101576040519150601f19603f3d011682016040523d82523d6000602084013e62000106565b606091505b505060408051600481526024810182526020810180516001600160e01b03166325ce9a3760e01b17905290516001600160a01b03841692506200014a91906200082f565b6000604051808303816000865af19150503d806000811462000189576040519150601f19603f3d011682016040523d82523d6000602084013e6200018e565b606091505b505050505b5060019150620001a690508782620008de565b506002620001b58682620008de565b506003620001c48582620008de565b5062000218836001600160601b0316336000604051620001e4906200061c565b6001600160a01b039091168152602001604051809103906000f08015801562000211573d6000803e3d6000fd5b50620002fc565b600680546001600160a01b031916331790556040516364e329cb60e11b81523060048201526001600160a01b038a8116602483015282169063c9c65396906044016020604051808303816000875af115801562000279573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200029f9190620009aa565b600580546001600160a01b039283166001600160a01b03199182161790915560048054928b1692909116821790556007839055620002e2903090600019620004be565b50506008805460ff1916905550620009d195505050505050565b68a20d6e21d0e52553095468a20d6e21d0e5255308906001600160a01b0316156200033a57604051633ab534b960e21b815260040160405180910390fd5b6001600160a01b03821662000362576040516339a84a7b60e01b815260040160405180910390fd5b630f4599e560005233602052602060006024601c6000865af160016000511416620003955763d125259c6000526004601cfd5b805463ffffffff60201b19166401000000001781556001810180546001600160a01b0384166001600160a01b03199091161790558315620004b8576001600160a01b038316620003f857604051633a954ecd60e21b815260040160405180910390fd5b606084901c670de0b6b3a7640000850463fffffffe1017156200042e5760405163e5cfe95760e01b815260040160405180910390fd5b80546001600160a01b0316600160a01b6001600160601b038616021781556000620004598462000520565b80546001600160601b038716600160a01b026001600160a01b0391821617825560008781529192508516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef602082a3620004b68460016200058b565b505b50505050565b6028828152601484905268a20d6e21d0e525530f600090815260488120915281905560008181526001600160a01b0380841691908516907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92590602090a3505050565b6001600160a01b038116600090815268a20d6e21d0e525531360205260408120805490916b01000000000000000000000090910460011690036200058657805460ff60581b19166b01000000000000000000000060ff843b151560020260011716021781555b919050565b6000620005988362000520565b80549091506b0100000000000000000000009004600216151582151514620005e457805460ff6b01000000000000000000000080830482166002189091160260ff60581b199091161781555b8115156000528260601b60601c7fb5a1de456fff688115a4f75380060c23c8532d14ff85f687cc871456d642039360206000a2505050565b610d8b8062002e3883390190565b6001600160a01b03811681146200064057600080fd5b50565b805162000586816200062a565b634e487b7160e01b600052604160045260246000fd5b60005b838110156200068357818101518382015260200162000669565b50506000910152565b600082601f8301126200069e57600080fd5b81516001600160401b0380821115620006bb57620006bb62000650565b604051601f8301601f19908116603f01168101908282118183101715620006e657620006e662000650565b816040528381528660208588010111156200070057600080fd5b6200071384602083016020890162000666565b9695505050505050565b80516001600160601b03811681146200058657600080fd5b60008060008060008060008060006101208a8c0312156200075557600080fd5b620007608a62000643565b98506200077060208b0162000643565b97506200078060408b0162000643565b60608b01519097506001600160401b03808211156200079e57600080fd5b620007ac8d838e016200068c565b975060808c0151915080821115620007c357600080fd5b620007d18d838e016200068c565b965060a08c0151915080821115620007e857600080fd5b50620007f78c828d016200068c565b9450506200080860c08b016200071d565b925060e08a01519150620008206101008b0162000643565b90509295985092959850929598565b600082516200084381846020870162000666565b9190910192915050565b600181811c908216806200086257607f821691505b6020821081036200088357634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115620008d9576000816000526020600020601f850160051c81016020861015620008b45750805b601f850160051c820191505b81811015620008d557828155600101620008c0565b5050505b505050565b81516001600160401b03811115620008fa57620008fa62000650565b62000912816200090b84546200084d565b8462000889565b602080601f8311600181146200094a5760008415620009315750858301515b600019600386901b1c1916600185901b178555620008d5565b600085815260208120601f198616915b828110156200097b578886015182559484019460019091019084016200095a565b50858210156200099a5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b600060208284031215620009bd57600080fd5b8151620009ca816200062a565b9392505050565b60805160a05160c05161243062000a0860003960006105900152600061050d0152600081816106660152611e3401526124306000f3fe60806040526004361061012e5760003560e01c806361d027b3116100ab578063a9059cbb1161006f578063a9059cbb146106f2578063aaf5eb6814610712578063b886311514610728578063c87b56dd14610742578063dd62ed3e14610762578063f887ea40146107a157610140565b806361d027b31461065457806370a082311461068857806395d89b41146106a857806399e37dff146106bd578063a8aa1b31146106d257610140565b806323b872dd116100f257806323b872dd146105b2578063274e430b146105d25780632a6a935d146105f2578063313ce567146106125780634ef41efc1461062e57610140565b806306fdde03146104a0578063095ea7b3146104cb578063126846ec146104fb57806318160ddd1461054757806319eff2b91461057e57610140565b3661014057341561013e57600080fd5b005b68a20d6e21d0e52553095468a20d6e21d0e52553089060003560e01c906001600160a01b031663e5eb36c88290036101b957336001600160a01b0382161461019b5760405163ce5a776b60e01b815260040160405180910390fd5b6101af6004356024356044356064356107c1565b6101b96001610b51565b8163813500fc0361022157336001600160a01b038216146101ed5760405163ce5a776b60e01b815260040160405180910390fd5b600435602890815260443560145268a20d6e21d0e525530b6000908152604881209152602435151590556102216001610b51565b8163e985e9c50361027f57336001600160a01b038216146102555760405163ce5a776b60e01b815260040160405180910390fd5b6024356028908152600435601452600384016000908152604881209152805461027d90610b51565b505b81636352211e036102cf57336001600160a01b038216146102b35760405163ce5a776b60e01b815260040160405180910390fd5b6102cf6102c1600435610b5b565b6001600160a01b0316610b51565b8163243598790361031157336001600160a01b038216146103035760405163ce5a776b60e01b815260040160405180910390fd5b6103116102c1600435610b92565b8163d10b6e0c0361036e57336001600160a01b038216146103455760405163ce5a776b60e01b815260040160405180910390fd5b6000610358600435602435604435610bef565b905061036c816001600160a01b0316610b51565b505b8163081812fc036103b057336001600160a01b038216146103a25760405163ce5a776b60e01b815260040160405180910390fd5b6103b06102c1600435610ce7565b8163f5b100ea0361041d57336001600160a01b038216146103e45760405163ce5a776b60e01b815260040160405180910390fd5b6001600160a01b0360043516600090815268a20d6e21d0e5255313602052604090205461041d90600160801b900463ffffffff16610b51565b8163e2c792810361047257336001600160a01b038216146104515760405163ce5a776b60e01b815260040160405180910390fd5b68a20d6e21d0e52553085461047290600160801b900463ffffffff16610b51565b8163b7a94eb803610487576104876001610b51565b604051631e085ca760e11b815260040160405180910390fd5b3480156104ac57600080fd5b506104b5610d33565b6040516104c2919061207e565b60405180910390f35b3480156104d757600080fd5b506104eb6104e63660046120c6565b610dc5565b60405190151581526020016104c2565b34801561050757600080fd5b5061052f7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016104c2565b34801561055357600080fd5b5068a20d6e21d0e525530854600160a01b90046001600160601b03165b6040519081526020016104c2565b34801561058a57600080fd5b5061052f7f000000000000000000000000000000000000000000000000000000000000000081565b3480156105be57600080fd5b506104eb6105cd3660046120f2565b610ddb565b3480156105de57600080fd5b506104eb6105ed366004612133565b610e49565b3480156105fe57600080fd5b506104eb61060d366004612150565b610e98565b34801561061e57600080fd5b50604051601281526020016104c2565b34801561063a57600080fd5b5068a20d6e21d0e5255309546001600160a01b031661052f565b34801561066057600080fd5b5061052f7f000000000000000000000000000000000000000000000000000000000000000081565b34801561069457600080fd5b506105706106a3366004612133565b610eac565b3480156106b457600080fd5b506104b5610edf565b3480156106c957600080fd5b50610570607d81565b3480156106de57600080fd5b5060055461052f906001600160a01b031681565b3480156106fe57600080fd5b506104eb61070d3660046120c6565b610eee565b34801561071e57600080fd5b5061057061271081565b34801561073457600080fd5b506008546104eb9060ff1681565b34801561074e57600080fd5b506104b561075d366004612172565b610efb565b34801561076e57600080fd5b5061057061077d36600461218b565b602890815260149190915268a20d6e21d0e525530f60009081526048812091525490565b3480156107ad57600080fd5b5060045461052f906001600160a01b031681565b6001600160a01b0383166107e857604051633a954ecd60e21b815260040160405180910390fd5b68a20d6e21d0e52553095468a20d6e21d0e5255308906001600160a01b031661081057600080fd5b600a810160028201600061085a83610836640100000000891089025b6000190160011b90565b60008160031c8360601b0180546007841660051b1c63ffffffff1691505092915050565b63ffffffff1681526020810191909152604001600020546001600160a01b0387811691161461089b5760405162a1148160e81b815260040160405180910390fd5b856001600160a01b0316836001600160a01b0316146109115760288381526014879052600383016000908152604881209152546000036109115760008481526004830160205260409020546001600160a01b0384811691161461091157604051632ce44b5f60e11b815260040160405180910390fd5b600061091c87610f44565b9050600061092987610f44565b6001600160a01b038916600090815260088601602081905260409091208454929350670de0b6b3a764000092600160a01b90046001600160601b03168084111561098657604051631e9acf1760e31b815260040160405180910390fd5b85546001600160601b03918590038216600160a01b9081026001600160a01b039283161788558654818104841687019093160291161784556005870160601b60088a901c015460ff8a161c60011615610a12576005870160601b60088a901c018054600160ff8c161b191690556000898152600488016020526040902080546001600160a01b03191690555b845463ffffffff60801b198116600160801b9182900463ffffffff90811660001901808216909302919091178755606083901b631fffffff600384901c16015460009260e060059190911b161c1690506000610a78886000198d01600190811b01610836565b9050610a8b838263ffffffff1684610fa4565b610aa68860001963ffffffff851601600190811b0183610fa4565b5050835463ffffffff60801b198116600160801b9182900463ffffffff908116600181019091169092021785556001600160a01b038b166000908152602084905260409020610af690828c610fa4565b610b0b878b610b05888f610fcf565b84611062565b50826000528960601b60601c8b60601b60601c7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60206000a35050505050505050505050565b8060005260206000f35b6000610b66826110a5565b610b835760405163677510db60e11b815260040160405180910390fd5b610b8c82610b92565b92915050565b600068a20d6e21d0e525530868a20d6e21d0e525530a82610bc868a20d6e21d0e52553126108366401000000008810880261082c565b63ffffffff1681526020810191909152604001600020546001600160a01b03169392505050565b600068a20d6e21d0e525530868a20d6e21d0e525530a82610c2568a20d6e21d0e52553126108366401000000008910890261082c565b63ffffffff1681526020810191909152604001600020546001600160a01b03908116925083168214610c8b576028838152601483905260038201600090815260488120915254600003610c8b576040516367d9dca160e11b815260040160405180910390fd5b6000848152600482016020526040902080546001600160a01b0319166001600160a01b0387169081179091556005820160601b600886901c018054600160ff881690811b1991909116921515901b919091179055509392505050565b6000610cf2826110a5565b610d0f5760405163677510db60e11b815260040160405180910390fd5b50600090815268a20d6e21d0e525530c60205260409020546001600160a01b031690565b606060018054610d42906121c4565b80601f0160208091040260200160405190810160405280929190818152602001828054610d6e906121c4565b8015610dbb5780601f10610d9057610100808354040283529160200191610dbb565b820191906000526020600020905b815481529060010190602001808311610d9e57829003601f168201915b5050505050905090565b6000610dd23384846110c2565b50600192915050565b336028908152601484905268a20d6e21d0e525530f6000908152604881209181905281549091906000198114610e325780841115610e2c576040516313be252b60e01b815260040160405180910390fd5b83810382555b610e3d868686611124565b50600195945050505050565b6001600160a01b038116600090815268a20d6e21d0e5255313602052604081208054600160581b90046001168203610e8557823b5b9392505050565b54600160581b9004600216151592915050565b6000610ea43383611256565b506001919050565b6001600160a01b0316600090815268a20d6e21d0e52553136020526040902054600160a01b90046001600160601b031690565b606060028054610d42906121c4565b6000610dd2338484611124565b606060038054610f0a906121c4565b159050610f3f576003610f1c836112d4565b604051602001610f2d92919061221a565b60405160208183030381529060405290505b919050565b6001600160a01b038116600090815268a20d6e21d0e52553136020526040812080549091600160581b9091046001169003610f3f57805460ff60581b1916600160581b60ff933b1515600202600117939093169290920291909117815590565b8160031c8360601b016007831660051b815480821c841863ffffffff16821b81188355505050505050565b8154600160601b900463ffffffff1668a20d6e21d0e5255308600082900361105b57805463ffffffff198116600163ffffffff928316019182169081178355855463ffffffff60601b1916600160601b82021786556000818152600284016020526040812080546001600160a01b0319166001600160a01b038816179055919350900361105b57600080fd5b5092915050565b600183038060021c8560601b0180546003831660061b92508463ffffffff168460201b178082851c1867ffffffffffffffff16841b821883555050505050505050565b6000806110b183610b92565b6001600160a01b0316141592915050565b6028828152601484905268a20d6e21d0e525530f600090815260488120915281905560008181526001600160a01b0380841691908516907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92590602090a3505050565b6000811161118a5760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b606482015260840160405180910390fd5b6005546000906001600160a01b03848116911614806111b657506005546001600160a01b038581169116145b1561122b576001600160a01b0383163014806111da57506001600160a01b03841630145b61122b576006546001600160a01b0385811691161461122b57612710611201607d846122dc565b61120b9190612309565b6005549091506001600160a01b0385811691161461122b5761122b611367565b61123f848461123a848661232b565b611389565b801561125057611250843083611389565b50505050565b600061126183610f44565b8054909150600160581b900460021615158215151461129c57805460ff600160581b80830482166002189091160260ff60581b199091161781555b8115156000528260601b60601c7fb5a1de456fff688115a4f75380060c23c8532d14ff85f687cc871456d642039360206000a2505050565b606060006112e183611c25565b600101905060008167ffffffffffffffff8111156113015761130161233e565b6040519080825280601f01601f19166020018201604052801561132b576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a850494508461133557509392505050565b600061137230610eac565b905060075481106113865761138681611cfd565b50565b6001600160a01b0382166113b057604051633a954ecd60e21b815260040160405180910390fd5b60006113bb84610f44565b905060006113c884610f44565b68a20d6e21d0e52553095490915068a20d6e21d0e5255308906001600160a01b03166113f357600080fd5b61146a604051806101a0016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600063ffffffff16815260200160008152602001600063ffffffff1681525090565b835463ffffffff600160801b808304821660808501528554041660a083015282546001600160601b03600160a01b91829004811660c0850152910416604082018190528511156114cd57604051631e9acf1760e31b815260040160405180910390fd5b6040810180518690039081905284546001600160601b03918216600160a01b9081026001600160a01b0392831617875585548181048416890160608601819052909316029116178355608081015161154a9061152e670de0b6b3a764000090565b836040015181611540576115406122f3565b0480821191030290565b81528254600160581b90046002166000036115b957856001600160a01b0316876001600160a01b03160361158657805160808201510360a08201525b6115b3670de0b6b3a76400008260600151816115a4576115a46122f3565b048260a0015180821191030290565b60208201525b60006115e682608001516115db84600001518560200151808218908211021890565b808218908211021890565b9050806000036115f657506117ca565b8151819003825260208201805182900390526001600160a01b038088169089160361162b5760a08201805190910190526117ca565b604080516080810182526000808252602080830182815283850183815260608086019081528651888152600589901b81018501885290819052908d9052908d9052810183526001600160a01b03808d16835260088801909152838220908b16825292902090919061169c878b610fcf565b63ffffffff1661014086015260a08501515b6080860180516000190190819052600381901c606085901b015460009160051b60e0161c63ffffffff1663ffffffff1690506116eb838383610fa4565b61170588600a018289610140015185806001019650611062565b84518181526020018552600881901c6005890160601b015460ff82161c60011615611763576005880160601b600882901c018054600160ff84161b191690556000818152600489016020526040902080546001600160a01b03191690555b506000198501946000036001016116ae5760a08601819052875463ffffffff808316600160801b90810263ffffffff60801b19938416178b5560808901518c54921602911617895560018701546117c49085906001600160a01b0316611e9c565b50505050505b80516020820151835463ffffffff600160801b8083048216840185900360e087018190529091160263ffffffff60801b19909116178455600a8401916000916118139101611ef0565b8454600160601b900463ffffffff166101808501528351909150156119a657606089901b6001176020828101919091526001600160a01b038a16600090815260088601909152604081206080850151855181036101008701819052895463ffffffff909116600160801b0263ffffffff60801b199091161789556101808601515b60001991909101600381901c606084901b0154909190600583901b60e0161c63ffffffff166118c68782600080611062565b8551602080880151600884901b1782520186526006890160601b600882901c018054600160ff84161b19169055841561191357611913896009018380600101945063ffffffff1683610fa4565b600881901c60058a0160601b015460ff82161c60011615611967576005890160601b600882901c018054600160ff84161b19169055600081815260048a016020526040902080546001600160a01b03191690555b5086610100015182036118945783156119a15763ffffffff81166101808801819052885463ffffffff60601b1916600160601b9091021788555b505050505b602083015115611bbe57606088901b60208201526001600160a01b038816600090815260088501602052604090206119de868a610fcf565b63ffffffff166101408501526000670de0b6b3a76400008560c0015181611a0757611a076122f3565b87549190049150640100000000900463ffffffff1681811180159091021761016086015260a0850151602086015181016101208701819052885463ffffffff60801b1916600160801b63ffffffff928316021789558754600160401b9004165b600087610180015163ffffffff168263ffffffff1614611ab7576009890160601b631fffffff600384901c160154600183019260e060059190911b161c63ffffffff1663ffffffff169050611b19565b506101608701515b611ad087600019830160011b610836565b63ffffffff1615611b0557611afe611af28a6006018360010187600101611f37565b85811180159091021790565b9050611abf565b600181018481118015909102176101608901525b600881901c60068a0160601b018054600160ff84161b8019909116179055611b42858483610fa4565b611b5987828a610140015186806001019750611062565b8551602080880151600884901b178252018652508661012001518203611a6757875461016088015163ffffffff9081166401000000000267ffffffff000000001991909316600160401b02166bffffffffffffffff0000000019909116171787555050505b60408101515115611be2576001840154611be29082906001600160a01b031661201e565b5050846000528560601b60601c8760601b60601c7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60206000a350505050505050565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b8310611c645772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef81000000008310611c90576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc100008310611cae57662386f26fc10000830492506010015b6305f5e1008310611cc6576305f5e100830492506008015b6127108310611cda57612710830492506004015b60648310611cec576064830492506002015b600a8310610b8c5760010192915050565b60085460ff1615611d0b5750565b6008805460ff191660011790556040805160028082526060820183526000926020830190803683370190505090503081600081518110611d4d57611d4d612354565b60200260200101906001600160a01b031690816001600160a01b031681525050600460009054906101000a90046001600160a01b03166001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015611dc0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611de4919061236a565b81600181518110611df757611df7612354565b6001600160a01b0392831660209182029290920101526004805460405163791ac94760e01b815292169163791ac94791611e5c91869160009187917f000000000000000000000000000000000000000000000000000000000000000091429101612387565b600060405180830381600087803b158015611e7657600080fd5b505af1158015611e8a573d6000803e3d6000fd5b50506008805460ff1916905550505050565b6060820151805160051b60840160808203915063144027d3825283602001518460400151816020850152806040850152505060608083015260208282601c85016000875af160018351141661125057600082fd5b611f1460405180606001604052806000815260200160008152602001606081525090565b604051828152806020018360051b81016040528183604001528083525050919050565b6000801990508360601b8360081c81018054198560ff161c8560ff161b80611f8c578460081c83015b6001830192508254199150808311821715611f605780831115611f8a5760ff86191691821b90911c905b505b80156120145782820360081b7e1f0d1e100c1d070f090b19131c1706010e11080a1a141802121b1503160405821960010183166fffffffffffffffffffffffffffffffff811160071b81811c67ffffffffffffffff1060061b1781811c63ffffffff1060051b1790811c63d76453e004601f169190911a171785811015878210176000031793505b5050509392505050565b60408201516040810363263c69d68152602080820152815160051b604401915060208183601c84016000875af160018251141661125057600081fd5b60005b8381101561207557818101518382015260200161205d565b50506000910152565b602081526000825180602084015261209d81604085016020870161205a565b601f01601f19169190910160400192915050565b6001600160a01b038116811461138657600080fd5b600080604083850312156120d957600080fd5b82356120e4816120b1565b946020939093013593505050565b60008060006060848603121561210757600080fd5b8335612112816120b1565b92506020840135612122816120b1565b929592945050506040919091013590565b60006020828403121561214557600080fd5b8135610e7e816120b1565b60006020828403121561216257600080fd5b81358015158114610e7e57600080fd5b60006020828403121561218457600080fd5b5035919050565b6000806040838503121561219e57600080fd5b82356121a9816120b1565b915060208301356121b9816120b1565b809150509250929050565b600181811c908216806121d857607f821691505b6020821081036121f857634e487b7160e01b600052602260045260246000fd5b50919050565b6000815161221081856020860161205a565b9290920192915050565b60008084548160018260011c9150600183168061223857607f831692505b6020808410820361225757634e487b7160e01b86526022600452602486fd5b81801561226b5760018114612280576122ad565b60ff19861689528415158502890196506122ad565b60008b81526020902060005b868110156122a55781548b82015290850190830161228c565b505084890196505b5050505050506122bd81856121fe565b95945050505050565b634e487b7160e01b600052601160045260246000fd5b8082028115828204841417610b8c57610b8c6122c6565b634e487b7160e01b600052601260045260246000fd5b60008261232657634e487b7160e01b600052601260045260246000fd5b500490565b81810381811115610b8c57610b8c6122c6565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b60006020828403121561237c57600080fd5b8151610e7e816120b1565b600060a08201878352602087602085015260a0604085015281875180845260c08601915060208901935060005b818110156123d95784516001600160a01b0316835293830193918301916001016123b4565b50506001600160a01b0396909616606085015250505060800152939250505056fea26469706673582212206a5d879c091983fcabef0f9ead22900339abb07de9b63742128105d0364f055864736f6c63430008170033608060405234801561001057600080fd5b50604051610d8b380380610d8b83398101604081905261002f9161005c565b683602298b8c10b0123180546001600160a01b0319166001600160a01b039290921691909117905561008c565b60006020828403121561006e57600080fd5b81516001600160a01b038116811461008557600080fd5b9392505050565b610cf08061009b6000396000f3fe60806040526004361061010d5760003560e01c80636cef16e61161009557806397e5311c1161006457806397e5311c146104d7578063a22cb465146104ec578063b88d4fde1461050c578063c87b56dd1461051f578063e985e9c51461053f5761011f565b80636cef16e61461046757806370a082311461047c5780638da5cb5b1461049c57806395d89b41146104c25761011f565b806318160ddd116100dc57806318160ddd146103de57806323b872dd14610401578063243598791461041457806342842e0e146104345780636352211e146104475761011f565b806301ffc9a71461031f57806306fdde0314610371578063081812fc14610393578063095ea7b3146103cb5761011f565b3661011f57341561011d57600080fd5b005b683602298b8c10b0123060003560e01c63263c69d68190036101d55781546001600160a01b0316331461016557604051631b1e598960e11b815260040160405180910390fd5b600435602401602081033560051b81015b8082146101c85781358060601c816001168260a01b60a81c811583028284027fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600038a4505050816020019150610176565b5050600160005260206000f35b8063144027d30361026b5781546001600160a01b0316331461020a57604051631b1e598960e11b815260040160405180910390fd5b600435602435604435602401602081033560051b81015b80821461025c57813583857fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600038a4816020019150610221565b50505050600160005260206000f35b80630f4599e5036103065760018201546001600160a01b0316156102c15760018201546001600160a01b03166004356001600160a01b0316146102c1576040516362cf623d60e11b815260040160405180910390fd5b81546001600160a01b0316156102ea57604051635fb2b52360e11b815260040160405180910390fd5b81546001600160a01b0319163317825560016000908152602090f35b604051631e085ca760e11b815260040160405180910390fd5b34801561032b57600080fd5b5061035c61033a366004610a7a565b6301ffc9a760e09190911c9081146380ac58cd821417635b5e139f9091141790565b60405190151581526020015b60405180910390f35b34801561037d57600080fd5b5061038661055f565b6040516103689190610aab565b34801561039f57600080fd5b506103b36103ae366004610afa565b610575565b6040516001600160a01b039091168152602001610368565b61011d6103d9366004610b2f565b61058d565b3480156103ea57600080fd5b506103f3610613565b604051908152602001610368565b61011d61040f366004610b59565b610625565b34801561042057600080fd5b506103b361042f366004610afa565b6106b4565b61011d610442366004610b59565b6106c6565b34801561045357600080fd5b506103b3610462366004610afa565b6106f8565b34801561047357600080fd5b5061035c61070a565b34801561048857600080fd5b506103f3610497366004610b95565b6107c5565b3480156104a857600080fd5b50683602298b8c10b01232546001600160a01b03166103b3565b3480156104ce57600080fd5b506103866107e0565b3480156104e357600080fd5b506103b36107f1565b3480156104f857600080fd5b5061011d610507366004610bb0565b610826565b61011d61051a366004610bec565b6108a9565b34801561052b57600080fd5b5061038661053a366004610afa565b610904565b34801561054b57600080fd5b5061035c61055a366004610c87565b610914565b60606105706306fdde036000610940565b905090565b600061058763081812fc8360006109a6565b92915050565b60006105976107f1565b90508260601b60601c925060405163d10b6e0c600052836020528260405233606052602060006064601c34865af1601f3d11166105d7573d6000823e3d81fd5b806040525060006060528183600c5160601c7f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600038a4505050565b600061057063e2c792816000806109a6565b600061062f6107f1565b90508360601b60601c93508260601b60601c925060405163e5eb36c881528460208201528360408201528260608201523360808201526020816084601c840134865af1600182511416610685573d6000823e3d81fd5b508183857fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600038a450505050565b600061058763243598798360006109a6565b6106d1838383610625565b813b156106f3576106f3838383604051806020016040528060008152506109ee565b505050565b6000610587636352211e8360006109a6565b60008060006107176107f1565b9050638da5cb5b600052602060006004601c845afa600c51683602298b8c10b0123254601f3d119290921660609190911c029250683602298b8c10b01230906001600160a01b0390811690841681146107ba576002820180546001600160a01b0319166001600160a01b0386811691821790925560405190918316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35b600194505050505090565b600061058763f5b100ea836001600160a01b031660006109a6565b60606105706395d89b416000610940565b683602298b8c10b01230546001600160a01b03168061082357604051632d9523d760e11b815260040160405180910390fd5b90565b60006108306107f1565b90508260601b60601c925060405163813500fc6000528360205282151560405233606052602060006064601c34865af160016000511416610874573d6000823e3d81fd5b83337f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3160206040a36040525050600060605250565b6108b4858585610625565b833b156108fd576108fd85858585858080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506109ee92505050565b5050505050565b606061058763c87b56dd83610940565b600061093763e985e9c5846001600160a01b0316846001600160a01b03166109a6565b15159392505050565b6060600061094c6107f1565b9050604051915083600052826020526000806024601c845afa610972573d6000833e3d82fd5b60206000803e6020600051833e8151602060005101602084013e815160208301016000815260208101604052505092915050565b6000806109b16107f1565b9050604051856000528460205283604052602060006044601c855afa601f3d11166109df573d6000823e3d81fd5b60405250506000519392505050565b60405163150b7a028082523360208301528560601b60601c604083015283606083015260808083015282518060a08401528015610a35578060c08401826020870160045afa505b60208360a48301601c860160008a5af1610a58573d15610a58573d6000843e3d83fd5b508060e01b825114610a725763d1a57ed66000526004601cfd5b505050505050565b600060208284031215610a8c57600080fd5b81356001600160e01b031981168114610aa457600080fd5b9392505050565b60006020808352835180602085015260005b81811015610ad957858101830151858201604001528201610abd565b506000604082860101526040601f19601f8301168501019250505092915050565b600060208284031215610b0c57600080fd5b5035919050565b80356001600160a01b0381168114610b2a57600080fd5b919050565b60008060408385031215610b4257600080fd5b610b4b83610b13565b946020939093013593505050565b600080600060608486031215610b6e57600080fd5b610b7784610b13565b9250610b8560208501610b13565b9150604084013590509250925092565b600060208284031215610ba757600080fd5b610aa482610b13565b60008060408385031215610bc357600080fd5b610bcc83610b13565b915060208301358015158114610be157600080fd5b809150509250929050565b600080600080600060808688031215610c0457600080fd5b610c0d86610b13565b9450610c1b60208701610b13565b935060408601359250606086013567ffffffffffffffff80821115610c3f57600080fd5b818801915088601f830112610c5357600080fd5b813581811115610c6257600080fd5b896020828501011115610c7457600080fd5b9699959850939650602001949392505050565b60008060408385031215610c9a57600080fd5b610ca383610b13565b9150610cb160208401610b13565b9050925092905056fea26469706673582212208292be7b9e6e4702a992db95c86b40b6a19145922563b146b28acdc87a60f8dc64736f6c63430008170033416464726573733a206c6f772d6c6576656c2063616c6c20776974682076616c7565206661696c6564a2646970667358221220fd3cae4bebcc0466e1af462ad1abc50842317e20f61e62c34cbbec6444f7483f64736f6c63430008170033

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

000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d0000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f0000000000000000000000006086c9b923c301d936129de4c0ffec16d11f93e9

-----Decoded View---------------
Arg [0] : _wnt (address): 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
Arg [1] : _univ2router (address): 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D
Arg [2] : _univ2factory (address): 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f
Arg [3] : _treasury (address): 0x6086C9b923c301D936129De4C0FFEc16d11f93e9

-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
Arg [1] : 0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d
Arg [2] : 0000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f
Arg [3] : 0000000000000000000000006086c9b923c301d936129de4c0ffec16d11f93e9


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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