ETH Price: $3,067.75 (+1.00%)
Gas: 4 Gwei

Token

Saddle Cross-Asset Swap (SaddleSynthSwap)
 

Overview

Max Total Supply

27 SaddleSynthSwap

Holders

25

Market

Volume (24H)

N/A

Min Price (24H)

N/A

Max Price (24H)

N/A

Other Info

Balance
1 SaddleSynthSwap
0x4dD0D2b69ef1208F9AEbd10Ad53665B420D15e3f
Loading...
Loading
Loading...
Loading
Loading...
Loading

Click here to update the token information / general information
# Exchange Pair Price  24H Volume % Volume
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.

Contract Source Code Verified (Exact Match)

Contract Name:
Bridge

Compiler Version
v0.6.12+commit.27d51765

Optimization Enabled:
Yes with 10000 runs

Other Settings:
default evmVersion, MIT license
File 1 of 29 : Initializable.sol
// SPDX-License-Identifier: MIT

// solhint-disable-next-line compiler-version
pragma solidity >=0.4.24 <0.8.0;

import "../utils/AddressUpgradeable.sol";

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 */
abstract contract Initializable {

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

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

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        require(_initializing || _isConstructor() || !_initialized, "Initializable: contract is already initialized");

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

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }

    /// @dev Returns true if and only if the function is running in the constructor
    function _isConstructor() private view returns (bool) {
        return !AddressUpgradeable.isContract(address(this));
    }
}

File 2 of 29 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.2 <0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        // solhint-disable-next-line no-inline-assembly
        assembly { size := extcodesize(account) }
        return size > 0;
    }

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

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (bool success, ) = recipient.call{ value: amount }("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

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

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

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

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

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: value }(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.staticcall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 3 of 29 : ERC165.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

import "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts may inherit from this and call {_registerInterface} to declare
 * their support of an interface.
 */
abstract contract ERC165 is IERC165 {
    /*
     * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7
     */
    bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;

    /**
     * @dev Mapping of interface ids to whether or not it's supported.
     */
    mapping(bytes4 => bool) private _supportedInterfaces;

    constructor () internal {
        // Derived contracts need only register support for their own interfaces,
        // we register support for ERC165 itself here
        _registerInterface(_INTERFACE_ID_ERC165);
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     *
     * Time complexity O(1), guaranteed to always use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return _supportedInterfaces[interfaceId];
    }

    /**
     * @dev Registers the contract as an implementer of the interface defined by
     * `interfaceId`. Support of the actual ERC165 interface is automatic and
     * registering its interface id is not required.
     *
     * See {IERC165-supportsInterface}.
     *
     * Requirements:
     *
     * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`).
     */
    function _registerInterface(bytes4 interfaceId) internal virtual {
        require(interfaceId != 0xffffffff, "ERC165: invalid interface id");
        _supportedInterfaces[interfaceId] = true;
    }
}

File 4 of 29 : IERC165.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

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

File 5 of 29 : SafeMath.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

File 6 of 29 : Clones.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for
 * deploying minimal proxy contracts, also known as "clones".
 *
 * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies
 * > a minimal bytecode implementation that delegates all calls to a known, fixed address.
 *
 * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2`
 * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the
 * deterministic method.
 *
 * _Available since v3.4._
 */
library Clones {
    /**
     * @dev Deploys and returns the address of a clone that mimics the behaviour of `master`.
     *
     * This function uses the create opcode, which should never revert.
     */
    function clone(address master) internal returns (address instance) {
        // solhint-disable-next-line no-inline-assembly
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
            mstore(add(ptr, 0x14), shl(0x60, master))
            mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
            instance := create(0, ptr, 0x37)
        }
        require(instance != address(0), "ERC1167: create failed");
    }

    /**
     * @dev Deploys and returns the address of a clone that mimics the behaviour of `master`.
     *
     * This function uses the create2 opcode and a `salt` to deterministically deploy
     * the clone. Using the same `master` and `salt` multiple time will revert, since
     * the clones cannot be deployed twice at the same address.
     */
    function cloneDeterministic(address master, bytes32 salt) internal returns (address instance) {
        // solhint-disable-next-line no-inline-assembly
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
            mstore(add(ptr, 0x14), shl(0x60, master))
            mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
            instance := create2(0, ptr, 0x37, salt)
        }
        require(instance != address(0), "ERC1167: create2 failed");
    }

    /**
     * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
     */
    function predictDeterministicAddress(address master, bytes32 salt, address deployer) internal pure returns (address predicted) {
        // solhint-disable-next-line no-inline-assembly
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
            mstore(add(ptr, 0x14), shl(0x60, master))
            mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf3ff00000000000000000000000000000000)
            mstore(add(ptr, 0x38), shl(0x60, deployer))
            mstore(add(ptr, 0x4c), salt)
            mstore(add(ptr, 0x6c), keccak256(ptr, 0x37))
            predicted := keccak256(add(ptr, 0x37), 0x55)
        }
    }

    /**
     * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
     */
    function predictDeterministicAddress(address master, bytes32 salt) internal view returns (address predicted) {
        return predictDeterministicAddress(master, salt, address(this));
    }
}

File 7 of 29 : ERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

import "../../utils/Context.sol";
import "./IERC20.sol";
import "../../math/SafeMath.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin guidelines: functions revert instead
 * of returning `false` on failure. This behavior is nonetheless conventional
 * and does not conflict with the expectations of ERC20 applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20 is Context, IERC20 {
    using SafeMath for uint256;

    mapping (address => uint256) private _balances;

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

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;
    uint8 private _decimals;

    /**
     * @dev Sets the values for {name} and {symbol}, initializes {decimals} with
     * a default value of 18.
     *
     * To select a different value for {decimals}, use {_setupDecimals}.
     *
     * All three of these values are immutable: they can only be set once during
     * construction.
     */
    constructor (string memory name_, string memory symbol_) public {
        _name = name_;
        _symbol = symbol_;
        _decimals = 18;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view virtual returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5,05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
     * called.
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual returns (uint8) {
        return _decimals;
    }

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual override returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `recipient` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(_msgSender(), recipient, amount);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual override returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        _approve(_msgSender(), spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * Requirements:
     *
     * - `sender` and `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     * - the caller must have allowance for ``sender``'s tokens of at least
     * `amount`.
     */
    function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(sender, recipient, amount);
        _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
        return true;
    }

    /**
     * @dev Moves tokens `amount` from `sender` to `recipient`.
     *
     * This is internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `sender` cannot be the zero address.
     * - `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     */
    function _transfer(address sender, address recipient, uint256 amount) internal virtual {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(sender, recipient, amount);

        _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
        _balances[recipient] = _balances[recipient].add(amount);
        emit Transfer(sender, recipient, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

        _totalSupply = _totalSupply.add(amount);
        _balances[account] = _balances[account].add(amount);
        emit Transfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
        _totalSupply = _totalSupply.sub(amount);
        emit Transfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(address owner, address spender, uint256 amount) internal virtual {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    /**
     * @dev Sets {decimals} to a value other than the default one of 18.
     *
     * WARNING: This function should only be called from the constructor. Most
     * applications that interact with token contracts will not expect
     * {decimals} to ever change, and may work incorrectly if it does.
     */
    function _setupDecimals(uint8 decimals_) internal virtual {
        _decimals = decimals_;
    }

    /**
     * @dev Hook that is called before any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * will be to transferred to `to`.
     * - when `from` is zero, `amount` tokens will be minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
}

File 8 of 29 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @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 `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, 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 `sender` to `recipient` 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 sender, address recipient, uint256 amount) external returns (bool);

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

File 9 of 29 : SafeERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

import "./IERC20.sol";
import "../../math/SafeMath.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 SafeMath for uint256;
    using Address for address;

    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    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'
        // solhint-disable-next-line max-line-length
        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));
    }

    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender).add(value);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    /**
     * @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");
        if (returndata.length > 0) { // Return data is optional
            // solhint-disable-next-line max-line-length
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 10 of 29 : ERC721.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

import "../../utils/Context.sol";
import "./IERC721.sol";
import "./IERC721Metadata.sol";
import "./IERC721Enumerable.sol";
import "./IERC721Receiver.sol";
import "../../introspection/ERC165.sol";
import "../../math/SafeMath.sol";
import "../../utils/Address.sol";
import "../../utils/EnumerableSet.sol";
import "../../utils/EnumerableMap.sol";
import "../../utils/Strings.sol";

/**
 * @title ERC721 Non-Fungible Token Standard basic implementation
 * @dev see https://eips.ethereum.org/EIPS/eip-721
 */
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable {
    using SafeMath for uint256;
    using Address for address;
    using EnumerableSet for EnumerableSet.UintSet;
    using EnumerableMap for EnumerableMap.UintToAddressMap;
    using Strings for uint256;

    // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
    // which can be also obtained as `IERC721Receiver(0).onERC721Received.selector`
    bytes4 private constant _ERC721_RECEIVED = 0x150b7a02;

    // Mapping from holder address to their (enumerable) set of owned tokens
    mapping (address => EnumerableSet.UintSet) private _holderTokens;

    // Enumerable mapping from token ids to their owners
    EnumerableMap.UintToAddressMap private _tokenOwners;

    // Mapping from token ID to approved address
    mapping (uint256 => address) private _tokenApprovals;

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

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    // Optional mapping for token URIs
    mapping (uint256 => string) private _tokenURIs;

    // Base URI
    string private _baseURI;

    /*
     *     bytes4(keccak256('balanceOf(address)')) == 0x70a08231
     *     bytes4(keccak256('ownerOf(uint256)')) == 0x6352211e
     *     bytes4(keccak256('approve(address,uint256)')) == 0x095ea7b3
     *     bytes4(keccak256('getApproved(uint256)')) == 0x081812fc
     *     bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465
     *     bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5
     *     bytes4(keccak256('transferFrom(address,address,uint256)')) == 0x23b872dd
     *     bytes4(keccak256('safeTransferFrom(address,address,uint256)')) == 0x42842e0e
     *     bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) == 0xb88d4fde
     *
     *     => 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^
     *        0xa22cb465 ^ 0xe985e9c5 ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd
     */
    bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd;

    /*
     *     bytes4(keccak256('name()')) == 0x06fdde03
     *     bytes4(keccak256('symbol()')) == 0x95d89b41
     *     bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd
     *
     *     => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f
     */
    bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f;

    /*
     *     bytes4(keccak256('totalSupply()')) == 0x18160ddd
     *     bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) == 0x2f745c59
     *     bytes4(keccak256('tokenByIndex(uint256)')) == 0x4f6ccce7
     *
     *     => 0x18160ddd ^ 0x2f745c59 ^ 0x4f6ccce7 == 0x780e9d63
     */
    bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63;

    /**
     * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
     */
    constructor (string memory name_, string memory symbol_) public {
        _name = name_;
        _symbol = symbol_;

        // register the supported interfaces to conform to ERC721 via ERC165
        _registerInterface(_INTERFACE_ID_ERC721);
        _registerInterface(_INTERFACE_ID_ERC721_METADATA);
        _registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE);
    }

    /**
     * @dev See {IERC721-balanceOf}.
     */
    function balanceOf(address owner) public view virtual override returns (uint256) {
        require(owner != address(0), "ERC721: balance query for the zero address");
        return _holderTokens[owner].length();
    }

    /**
     * @dev See {IERC721-ownerOf}.
     */
    function ownerOf(uint256 tokenId) public view virtual override returns (address) {
        return _tokenOwners.get(tokenId, "ERC721: owner query for nonexistent token");
    }

    /**
     * @dev See {IERC721Metadata-name}.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev See {IERC721Metadata-symbol}.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");

        string memory _tokenURI = _tokenURIs[tokenId];
        string memory base = baseURI();

        // If there is no base URI, return the token URI.
        if (bytes(base).length == 0) {
            return _tokenURI;
        }
        // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked).
        if (bytes(_tokenURI).length > 0) {
            return string(abi.encodePacked(base, _tokenURI));
        }
        // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI.
        return string(abi.encodePacked(base, tokenId.toString()));
    }

    /**
    * @dev Returns the base URI set via {_setBaseURI}. This will be
    * automatically added as a prefix in {tokenURI} to each token's URI, or
    * to the token ID if no specific URI is set for that token ID.
    */
    function baseURI() public view virtual returns (string memory) {
        return _baseURI;
    }

    /**
     * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
        return _holderTokens[owner].at(index);
    }

    /**
     * @dev See {IERC721Enumerable-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        // _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds
        return _tokenOwners.length();
    }

    /**
     * @dev See {IERC721Enumerable-tokenByIndex}.
     */
    function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
        (uint256 tokenId, ) = _tokenOwners.at(index);
        return tokenId;
    }

    /**
     * @dev See {IERC721-approve}.
     */
    function approve(address to, uint256 tokenId) public virtual override {
        address owner = ERC721.ownerOf(tokenId);
        require(to != owner, "ERC721: approval to current owner");

        require(_msgSender() == owner || ERC721.isApprovedForAll(owner, _msgSender()),
            "ERC721: approve caller is not owner nor approved for all"
        );

        _approve(to, tokenId);
    }

    /**
     * @dev See {IERC721-getApproved}.
     */
    function getApproved(uint256 tokenId) public view virtual override returns (address) {
        require(_exists(tokenId), "ERC721: approved query for nonexistent token");

        return _tokenApprovals[tokenId];
    }

    /**
     * @dev See {IERC721-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved) public virtual override {
        require(operator != _msgSender(), "ERC721: approve to caller");

        _operatorApprovals[_msgSender()][operator] = approved;
        emit ApprovalForAll(_msgSender(), operator, approved);
    }

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

    /**
     * @dev See {IERC721-transferFrom}.
     */
    function transferFrom(address from, address to, uint256 tokenId) public virtual override {
        //solhint-disable-next-line max-line-length
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");

        _transfer(from, to, tokenId);
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override {
        safeTransferFrom(from, to, tokenId, "");
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override {
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
        _safeTransfer(from, to, tokenId, _data);
    }

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * `_data` is additional data, it has no specified format and it is sent in call to `to`.
     *
     * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
     * implement alternative mechanisms to perform token transfer, such as signature-based.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual {
        _transfer(from, to, tokenId);
        require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
    }

    /**
     * @dev Returns whether `tokenId` exists.
     *
     * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
     *
     * Tokens start existing when they are minted (`_mint`),
     * and stop existing when they are burned (`_burn`).
     */
    function _exists(uint256 tokenId) internal view virtual returns (bool) {
        return _tokenOwners.contains(tokenId);
    }

    /**
     * @dev Returns whether `spender` is allowed to manage `tokenId`.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
        require(_exists(tokenId), "ERC721: operator query for nonexistent token");
        address owner = ERC721.ownerOf(tokenId);
        return (spender == owner || getApproved(tokenId) == spender || ERC721.isApprovedForAll(owner, spender));
    }

    /**
     * @dev Safely mints `tokenId` and transfers it to `to`.
     *
     * Requirements:
     d*
     * - `tokenId` must not exist.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeMint(address to, uint256 tokenId) internal virtual {
        _safeMint(to, tokenId, "");
    }

    /**
     * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
     * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
     */
    function _safeMint(address to, uint256 tokenId, bytes memory _data) internal virtual {
        _mint(to, tokenId);
        require(_checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
    }

    /**
     * @dev Mints `tokenId` and transfers it to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - `to` cannot be the zero address.
     *
     * Emits a {Transfer} event.
     */
    function _mint(address to, uint256 tokenId) internal virtual {
        require(to != address(0), "ERC721: mint to the zero address");
        require(!_exists(tokenId), "ERC721: token already minted");

        _beforeTokenTransfer(address(0), to, tokenId);

        _holderTokens[to].add(tokenId);

        _tokenOwners.set(tokenId, to);

        emit Transfer(address(0), to, tokenId);
    }

    /**
     * @dev Destroys `tokenId`.
     * The approval is cleared when the token is burned.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     *
     * Emits a {Transfer} event.
     */
    function _burn(uint256 tokenId) internal virtual {
        address owner = ERC721.ownerOf(tokenId); // internal owner

        _beforeTokenTransfer(owner, address(0), tokenId);

        // Clear approvals
        _approve(address(0), tokenId);

        // Clear metadata (if any)
        if (bytes(_tokenURIs[tokenId]).length != 0) {
            delete _tokenURIs[tokenId];
        }

        _holderTokens[owner].remove(tokenId);

        _tokenOwners.remove(tokenId);

        emit Transfer(owner, address(0), tokenId);
    }

    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *  As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     *
     * Emits a {Transfer} event.
     */
    function _transfer(address from, address to, uint256 tokenId) internal virtual {
        require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); // internal owner
        require(to != address(0), "ERC721: transfer to the zero address");

        _beforeTokenTransfer(from, to, tokenId);

        // Clear approvals from the previous owner
        _approve(address(0), tokenId);

        _holderTokens[from].remove(tokenId);
        _holderTokens[to].add(tokenId);

        _tokenOwners.set(tokenId, to);

        emit Transfer(from, to, tokenId);
    }

    /**
     * @dev Sets `_tokenURI` as the tokenURI of `tokenId`.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual {
        require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token");
        _tokenURIs[tokenId] = _tokenURI;
    }

    /**
     * @dev Internal function to set the base URI for all token IDs. It is
     * automatically added as a prefix to the value returned in {tokenURI},
     * or to the token ID if {tokenURI} is empty.
     */
    function _setBaseURI(string memory baseURI_) internal virtual {
        _baseURI = baseURI_;
    }

    /**
     * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
     * The call is not executed if the target address is not a contract.
     *
     * @param from address representing the previous owner of the given token ID
     * @param to target address that will receive the tokens
     * @param tokenId uint256 ID of the token to be transferred
     * @param _data bytes optional data to send along with the call
     * @return bool whether the call correctly returned the expected magic value
     */
    function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data)
        private returns (bool)
    {
        if (!to.isContract()) {
            return true;
        }
        bytes memory returndata = to.functionCall(abi.encodeWithSelector(
            IERC721Receiver(to).onERC721Received.selector,
            _msgSender(),
            from,
            tokenId,
            _data
        ), "ERC721: transfer to non ERC721Receiver implementer");
        bytes4 retval = abi.decode(returndata, (bytes4));
        return (retval == _ERC721_RECEIVED);
    }

    /**
     * @dev Approve `to` to operate on `tokenId`
     *
     * Emits an {Approval} event.
     */
    function _approve(address to, uint256 tokenId) internal virtual {
        _tokenApprovals[tokenId] = to;
        emit Approval(ERC721.ownerOf(tokenId), to, tokenId); // internal owner
    }

    /**
     * @dev Hook that is called before any token transfer. This includes minting
     * and burning.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
     * transferred to `to`.
     * - When `from` is zero, `tokenId` will be minted for `to`.
     * - When `to` is zero, ``from``'s `tokenId` will be burned.
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual { }
}

File 11 of 29 : IERC721.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.2 <0.8.0;

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

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

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

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - 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 tokenId) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool _approved) external;

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);

    /**
      * @dev Safely transfers `tokenId` token from `from` to `to`.
      *
      * Requirements:
      *
      * - `from` cannot be the zero address.
      * - `to` cannot be the zero address.
      * - `tokenId` token must exist and be owned by `from`.
      * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
      * - 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 tokenId, bytes calldata data) external;
}

File 12 of 29 : IERC721Enumerable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.2 <0.8.0;

import "./IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Enumerable is IERC721 {

    /**
     * @dev Returns the total amount of tokens stored by the contract.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns a token ID owned by `owner` at a given `index` of its token list.
     * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);

    /**
     * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
     * Use along with {totalSupply} to enumerate all tokens.
     */
    function tokenByIndex(uint256 index) external view returns (uint256);
}

File 13 of 29 : IERC721Metadata.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.2 <0.8.0;

import "./IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Metadata is IERC721 {

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

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

    /**
     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
     */
    function tokenURI(uint256 tokenId) external view returns (string memory);
}

File 14 of 29 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @title ERC721 token receiver interface
 * @dev Interface for any contract that wants to support safeTransfers
 * from ERC721 asset contracts.
 */
interface IERC721Receiver {
    /**
     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
     * by `operator` from `from`, this function is called.
     *
     * It must return its Solidity selector to confirm the token transfer.
     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
     *
     * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
     */
    function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4);
}

File 15 of 29 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.2 <0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        // solhint-disable-next-line no-inline-assembly
        assembly { size := extcodesize(account) }
        return size > 0;
    }

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

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (bool success, ) = recipient.call{ value: amount }("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

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

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

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

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

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: value }(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.staticcall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 16 of 29 : Context.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <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 GSN 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 payable) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes memory) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}

File 17 of 29 : EnumerableMap.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Library for managing an enumerable variant of Solidity's
 * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`]
 * type.
 *
 * Maps have the following properties:
 *
 * - Entries are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Entries are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableMap for EnumerableMap.UintToAddressMap;
 *
 *     // Declare a set state variable
 *     EnumerableMap.UintToAddressMap private myMap;
 * }
 * ```
 *
 * As of v3.0.0, only maps of type `uint256 -> address` (`UintToAddressMap`) are
 * supported.
 */
library EnumerableMap {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Map type with
    // bytes32 keys and values.
    // The Map implementation uses private functions, and user-facing
    // implementations (such as Uint256ToAddressMap) are just wrappers around
    // the underlying Map.
    // This means that we can only create new EnumerableMaps for types that fit
    // in bytes32.

    struct MapEntry {
        bytes32 _key;
        bytes32 _value;
    }

    struct Map {
        // Storage of map keys and values
        MapEntry[] _entries;

        // Position of the entry defined by a key in the `entries` array, plus 1
        // because index 0 means a key is not in the map.
        mapping (bytes32 => uint256) _indexes;
    }

    /**
     * @dev Adds a key-value pair to a map, or updates the value for an existing
     * key. O(1).
     *
     * Returns true if the key was added to the map, that is if it was not
     * already present.
     */
    function _set(Map storage map, bytes32 key, bytes32 value) private returns (bool) {
        // We read and store the key's index to prevent multiple reads from the same storage slot
        uint256 keyIndex = map._indexes[key];

        if (keyIndex == 0) { // Equivalent to !contains(map, key)
            map._entries.push(MapEntry({ _key: key, _value: value }));
            // The entry is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            map._indexes[key] = map._entries.length;
            return true;
        } else {
            map._entries[keyIndex - 1]._value = value;
            return false;
        }
    }

    /**
     * @dev Removes a key-value pair from a map. O(1).
     *
     * Returns true if the key was removed from the map, that is if it was present.
     */
    function _remove(Map storage map, bytes32 key) private returns (bool) {
        // We read and store the key's index to prevent multiple reads from the same storage slot
        uint256 keyIndex = map._indexes[key];

        if (keyIndex != 0) { // Equivalent to contains(map, key)
            // To delete a key-value pair from the _entries array in O(1), we swap the entry to delete with the last one
            // in the array, and then remove the last entry (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = keyIndex - 1;
            uint256 lastIndex = map._entries.length - 1;

            // When the entry to delete is the last one, the swap operation is unnecessary. However, since this occurs
            // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.

            MapEntry storage lastEntry = map._entries[lastIndex];

            // Move the last entry to the index where the entry to delete is
            map._entries[toDeleteIndex] = lastEntry;
            // Update the index for the moved entry
            map._indexes[lastEntry._key] = toDeleteIndex + 1; // All indexes are 1-based

            // Delete the slot where the moved entry was stored
            map._entries.pop();

            // Delete the index for the deleted slot
            delete map._indexes[key];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the key is in the map. O(1).
     */
    function _contains(Map storage map, bytes32 key) private view returns (bool) {
        return map._indexes[key] != 0;
    }

    /**
     * @dev Returns the number of key-value pairs in the map. O(1).
     */
    function _length(Map storage map) private view returns (uint256) {
        return map._entries.length;
    }

   /**
    * @dev Returns the key-value pair stored at position `index` in the map. O(1).
    *
    * Note that there are no guarantees on the ordering of entries inside the
    * array, and it may change when more entries are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function _at(Map storage map, uint256 index) private view returns (bytes32, bytes32) {
        require(map._entries.length > index, "EnumerableMap: index out of bounds");

        MapEntry storage entry = map._entries[index];
        return (entry._key, entry._value);
    }

    /**
     * @dev Tries to returns the value associated with `key`.  O(1).
     * Does not revert if `key` is not in the map.
     */
    function _tryGet(Map storage map, bytes32 key) private view returns (bool, bytes32) {
        uint256 keyIndex = map._indexes[key];
        if (keyIndex == 0) return (false, 0); // Equivalent to contains(map, key)
        return (true, map._entries[keyIndex - 1]._value); // All indexes are 1-based
    }

    /**
     * @dev Returns the value associated with `key`.  O(1).
     *
     * Requirements:
     *
     * - `key` must be in the map.
     */
    function _get(Map storage map, bytes32 key) private view returns (bytes32) {
        uint256 keyIndex = map._indexes[key];
        require(keyIndex != 0, "EnumerableMap: nonexistent key"); // Equivalent to contains(map, key)
        return map._entries[keyIndex - 1]._value; // All indexes are 1-based
    }

    /**
     * @dev Same as {_get}, with a custom error message when `key` is not in the map.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {_tryGet}.
     */
    function _get(Map storage map, bytes32 key, string memory errorMessage) private view returns (bytes32) {
        uint256 keyIndex = map._indexes[key];
        require(keyIndex != 0, errorMessage); // Equivalent to contains(map, key)
        return map._entries[keyIndex - 1]._value; // All indexes are 1-based
    }

    // UintToAddressMap

    struct UintToAddressMap {
        Map _inner;
    }

    /**
     * @dev Adds a key-value pair to a map, or updates the value for an existing
     * key. O(1).
     *
     * Returns true if the key was added to the map, that is if it was not
     * already present.
     */
    function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) {
        return _set(map._inner, bytes32(key), bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the key was removed from the map, that is if it was present.
     */
    function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) {
        return _remove(map._inner, bytes32(key));
    }

    /**
     * @dev Returns true if the key is in the map. O(1).
     */
    function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) {
        return _contains(map._inner, bytes32(key));
    }

    /**
     * @dev Returns the number of elements in the map. O(1).
     */
    function length(UintToAddressMap storage map) internal view returns (uint256) {
        return _length(map._inner);
    }

   /**
    * @dev Returns the element stored at position `index` in the set. O(1).
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) {
        (bytes32 key, bytes32 value) = _at(map._inner, index);
        return (uint256(key), address(uint160(uint256(value))));
    }

    /**
     * @dev Tries to returns the value associated with `key`.  O(1).
     * Does not revert if `key` is not in the map.
     *
     * _Available since v3.4._
     */
    function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) {
        (bool success, bytes32 value) = _tryGet(map._inner, bytes32(key));
        return (success, address(uint160(uint256(value))));
    }

    /**
     * @dev Returns the value associated with `key`.  O(1).
     *
     * Requirements:
     *
     * - `key` must be in the map.
     */
    function get(UintToAddressMap storage map, uint256 key) internal view returns (address) {
        return address(uint160(uint256(_get(map._inner, bytes32(key)))));
    }

    /**
     * @dev Same as {get}, with a custom error message when `key` is not in the map.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryGet}.
     */
    function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) {
        return address(uint160(uint256(_get(map._inner, bytes32(key), errorMessage))));
    }
}

File 18 of 29 : EnumerableSet.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;

        // Position of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping (bytes32 => uint256) _indexes;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._indexes[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 0) { // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
            // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.

            bytes32 lastvalue = set._values[lastIndex];

            // Move the last value to the index where the value to delete is
            set._values[toDeleteIndex] = lastvalue;
            // Update the index for the moved value
            set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._indexes[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        require(set._values.length > index, "EnumerableSet: index out of bounds");
        return set._values[index];
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint160(uint256(_at(set._inner, index))));
    }


    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }
}

File 19 of 29 : Strings.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev String operations.
 */
library Strings {
    /**
     * @dev Converts a `uint256` to its ASCII `string` representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        uint256 index = digits - 1;
        temp = value;
        while (temp != 0) {
            buffer[index--] = bytes1(uint8(48 + temp % 10));
            temp /= 10;
        }
        return string(buffer);
    }
}

File 20 of 29 : Bridge.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/proxy/Clones.sol";
import "synthetix/contracts/interfaces/IAddressResolver.sol";
import "synthetix/contracts/interfaces/IExchanger.sol";
import "synthetix/contracts/interfaces/IExchangeRates.sol";
import "../interfaces/ISwap.sol";
import "./SynthSwapper.sol";

contract Proxy {
    address public target;
}

contract Target {
    address public proxy;
}

/**
 * @title Bridge
 * @notice This contract is responsible for cross-asset swaps using the Synthetix protocol as the bridging exchange.
 * There are three types of supported cross-asset swaps, tokenToSynth, synthToToken, and tokenToToken.
 *
 * 1) tokenToSynth
 * Swaps a supported token in a saddle pool to any synthetic asset (e.g. tBTC -> sAAVE).
 *
 * 2) synthToToken
 * Swaps any synthetic asset to a suported token in a saddle pool (e.g. sDEFI -> USDC).
 *
 * 3) tokenToToken
 * Swaps a supported token in a saddle pool to one in another pool (e.g. renBTC -> DAI).
 *
 * Due to the settlement periods of synthetic assets, the users must wait until the trades can be completed.
 * Users will receive an ERC721 token that represents pending cross-asset swap. Once the waiting period is over,
 * the trades can be settled and completed by calling the `completeToSynth` or the `completeToToken` function.
 * In the cases of pending `synthToToken` or `tokenToToken` swaps, the owners of the pending swaps can also choose
 * to withdraw the bridging synthetic assets instead of completing the swap.
 */
contract Bridge is ERC721 {
    using SafeMath for uint256;
    using SafeERC20 for IERC20;

    event SynthIndex(
        address indexed swap,
        uint8 synthIndex,
        bytes32 currencyKey,
        address synthAddress
    );
    event TokenToSynth(
        address indexed requester,
        uint256 indexed itemId,
        ISwap swapPool,
        uint8 tokenFromIndex,
        uint256 tokenFromInAmount,
        bytes32 synthToKey
    );
    event SynthToToken(
        address indexed requester,
        uint256 indexed itemId,
        ISwap swapPool,
        bytes32 synthFromKey,
        uint256 synthFromInAmount,
        uint8 tokenToIndex
    );
    event TokenToToken(
        address indexed requester,
        uint256 indexed itemId,
        ISwap[2] swapPools,
        uint8 tokenFromIndex,
        uint256 tokenFromAmount,
        uint8 tokenToIndex
    );
    event Settle(
        address indexed requester,
        uint256 indexed itemId,
        IERC20 settleFrom,
        uint256 settleFromAmount,
        IERC20 settleTo,
        uint256 settleToAmount,
        bool isFinal
    );
    event Withdraw(
        address indexed requester,
        uint256 indexed itemId,
        IERC20 synth,
        uint256 synthAmount,
        bool isFinal
    );

    // The addresses for all Synthetix contracts can be found in the below URL.
    // https://docs.synthetix.io/addresses/#mainnet-contracts
    //
    // Since the Synthetix protocol is upgradable, we must use the proxy pairs of each contract such that
    // the composability is not broken after the protocol upgrade.
    //
    // SYNTHETIX_RESOLVER points to `ReadProxyAddressResolver` (0x4E3b31eB0E5CB73641EE1E65E7dCEFe520bA3ef2).
    // This contract is a read proxy of `AddressResolver` which is responsible for storing the addresses of the contracts
    // used by the Synthetix protocol.
    IAddressResolver public constant SYNTHETIX_RESOLVER =
        IAddressResolver(0x4E3b31eB0E5CB73641EE1E65E7dCEFe520bA3ef2);

    // EXCHANGER points to `Exchanger`. There is no proxy pair for this contract so we need to update this variable
    // when the protocol is upgraded. This contract is used to settle synths held by SynthSwapper.
    IExchanger public exchanger;

    // CONSTANTS

    // Available types of cross-asset swaps
    enum PendingSwapType {
        Null,
        TokenToSynth,
        SynthToToken,
        TokenToToken
    }

    uint256 public constant MAX_UINT256 = 2**256 - 1;
    uint8 public constant MAX_UINT8 = 2**8 - 1;
    bytes32 public constant EXCHANGE_RATES_NAME = "ExchangeRates";
    bytes32 public constant EXCHANGER_NAME = "Exchanger";
    address public immutable SYNTH_SWAPPER_MASTER;

    // MAPPINGS FOR STORING PENDING SETTLEMENTS
    // The below two mappings never share the same key.
    mapping(uint256 => PendingToSynthSwap) public pendingToSynthSwaps;
    mapping(uint256 => PendingToTokenSwap) public pendingToTokenSwaps;
    uint256 public pendingSwapsLength;
    mapping(uint256 => PendingSwapType) private pendingSwapType;

    // MAPPINGS FOR STORING SYNTH INFO
    mapping(address => SwapContractInfo) private swapContracts;

    // Structs holding information about pending settlements
    struct PendingToSynthSwap {
        SynthSwapper swapper;
        bytes32 synthKey;
    }

    struct PendingToTokenSwap {
        SynthSwapper swapper;
        bytes32 synthKey;
        ISwap swap;
        uint8 tokenToIndex;
    }

    struct SwapContractInfo {
        // index of the supported synth + 1
        uint8 synthIndexPlusOne;
        // address of the supported synth
        address synthAddress;
        // bytes32 key of the supported synth
        bytes32 synthKey;
        // array of tokens supported by the contract
        IERC20[] tokens;
    }

    /**
     * @notice Deploys this contract and initializes the master version of the SynthSwapper contract. The address to
     * the Synthetix protocol's Exchanger contract is also set on deployment.
     */
    constructor(address synthSwapperAddress)
        public
        ERC721("Saddle Cross-Asset Swap", "SaddleSynthSwap")
    {
        SYNTH_SWAPPER_MASTER = synthSwapperAddress;
        updateExchangerCache();
    }

    /**
     * @notice Returns the address of the proxy contract targeting the synthetic asset with the given `synthKey`.
     * @param synthKey the currency key of the synth
     * @return address of the proxy contract
     */
    function getProxyAddressFromTargetSynthKey(bytes32 synthKey)
        public
        view
        returns (IERC20)
    {
        return IERC20(Target(SYNTHETIX_RESOLVER.getSynth(synthKey)).proxy());
    }

    /**
     * @notice Returns various information of a pending swap represented by the given `itemId`. Information includes
     * the type of the pending swap, the number of seconds left until it can be settled, the address and the balance
     * of the synth this swap currently holds, and the address of the destination token.
     * @param itemId ID of the pending swap
     * @return swapType the type of the pending virtual swap,
     * secsLeft number of seconds left until this swap can be settled,
     * synth address of the synth this swap uses,
     * synthBalance amount of the synth this swap holds,
     * tokenTo the address of the destination token
     */
    function getPendingSwapInfo(uint256 itemId)
        external
        view
        returns (
            PendingSwapType swapType,
            uint256 secsLeft,
            address synth,
            uint256 synthBalance,
            address tokenTo
        )
    {
        swapType = pendingSwapType[itemId];
        require(swapType != PendingSwapType.Null, "invalid itemId");

        SynthSwapper synthSwapper;
        bytes32 synthKey;

        if (swapType == PendingSwapType.TokenToSynth) {
            synthSwapper = pendingToSynthSwaps[itemId].swapper;
            synthKey = pendingToSynthSwaps[itemId].synthKey;
            synth = address(getProxyAddressFromTargetSynthKey(synthKey));
            tokenTo = synth;
        } else {
            PendingToTokenSwap memory pendingToTokenSwap = pendingToTokenSwaps[
                itemId
            ];
            synthSwapper = pendingToTokenSwap.swapper;
            synthKey = pendingToTokenSwap.synthKey;
            synth = address(getProxyAddressFromTargetSynthKey(synthKey));
            tokenTo = address(
                swapContracts[address(pendingToTokenSwap.swap)].tokens[
                    pendingToTokenSwap.tokenToIndex
                ]
            );
        }

        secsLeft = exchanger.maxSecsLeftInWaitingPeriod(
            address(synthSwapper),
            synthKey
        );
        synthBalance = IERC20(synth).balanceOf(address(synthSwapper));
    }

    // Settles the synth only.
    function _settle(address synthOwner, bytes32 synthKey) internal {
        // Settle synth
        exchanger.settle(synthOwner, synthKey);
    }

    /**
     * @notice Settles and withdraws the synthetic asset without swapping it to a token in a Saddle pool. Only the owner
     * of the ERC721 token of `itemId` can call this function. Reverts if the given `itemId` does not represent a
     * `synthToToken` or a `tokenToToken` swap.
     * @param itemId ID of the pending swap
     * @param amount the amount of the synth to withdraw
     */
    function withdraw(uint256 itemId, uint256 amount) external {
        address nftOwner = ownerOf(itemId);
        require(nftOwner == msg.sender, "not owner");
        require(
            pendingSwapType[itemId] > PendingSwapType.TokenToSynth,
            "invalid itemId"
        );
        PendingToTokenSwap memory pendingToTokenSwap = pendingToTokenSwaps[
            itemId
        ];
        _settle(
            address(pendingToTokenSwap.swapper),
            pendingToTokenSwap.synthKey
        );

        IERC20 synth = getProxyAddressFromTargetSynthKey(
            pendingToTokenSwap.synthKey
        );
        bool shouldDestroy;

        if (amount >= synth.balanceOf(address(pendingToTokenSwap.swapper))) {
            _burn(itemId);
            delete pendingToTokenSwaps[itemId];
            delete pendingSwapType[itemId];
            shouldDestroy = true;
        }

        pendingToTokenSwap.swapper.withdraw(
            synth,
            nftOwner,
            amount,
            shouldDestroy
        );
        emit Withdraw(msg.sender, itemId, synth, amount, shouldDestroy);
    }

    /**
     * @notice Completes the pending `tokenToSynth` swap by settling and withdrawing the synthetic asset.
     * Reverts if the given `itemId` does not represent a `tokenToSynth` swap.
     * @param itemId ERC721 token ID representing a pending `tokenToSynth` swap
     */
    function completeToSynth(uint256 itemId) external {
        address nftOwner = ownerOf(itemId);
        require(nftOwner == msg.sender, "not owner");
        require(
            pendingSwapType[itemId] == PendingSwapType.TokenToSynth,
            "invalid itemId"
        );

        PendingToSynthSwap memory pendingToSynthSwap = pendingToSynthSwaps[
            itemId
        ];
        _settle(
            address(pendingToSynthSwap.swapper),
            pendingToSynthSwap.synthKey
        );

        IERC20 synth = getProxyAddressFromTargetSynthKey(
            pendingToSynthSwap.synthKey
        );

        // Burn the corresponding ERC721 token and delete storage for gas
        _burn(itemId);
        delete pendingToTokenSwaps[itemId];
        delete pendingSwapType[itemId];

        // After settlement, withdraw the synth and send it to the recipient
        uint256 synthBalance = synth.balanceOf(
            address(pendingToSynthSwap.swapper)
        );
        pendingToSynthSwap.swapper.withdraw(
            synth,
            nftOwner,
            synthBalance,
            true
        );

        emit Settle(
            msg.sender,
            itemId,
            synth,
            synthBalance,
            synth,
            synthBalance,
            true
        );
    }

    /**
     * @notice Calculates the expected amount of the token to receive on calling `completeToToken()` with
     * the given `swapAmount`.
     * @param itemId ERC721 token ID representing a pending `SynthToToken` or `TokenToToken` swap
     * @param swapAmount the amount of bridging synth to swap from
     * @return expected amount of the token the user will receive
     */
    function calcCompleteToToken(uint256 itemId, uint256 swapAmount)
        external
        view
        returns (uint256)
    {
        require(
            pendingSwapType[itemId] > PendingSwapType.TokenToSynth,
            "invalid itemId"
        );

        PendingToTokenSwap memory pendingToTokenSwap = pendingToTokenSwaps[
            itemId
        ];
        return
            pendingToTokenSwap.swap.calculateSwap(
                getSynthIndex(pendingToTokenSwap.swap),
                pendingToTokenSwap.tokenToIndex,
                swapAmount
            );
    }

    /**
     * @notice Completes the pending `SynthToToken` or `TokenToToken` swap by settling the bridging synth and swapping
     * it to the desired token. Only the owners of the pending swaps can call this function.
     * @param itemId ERC721 token ID representing a pending `SynthToToken` or `TokenToToken` swap
     * @param swapAmount the amount of bridging synth to swap from
     * @param minAmount the minimum amount of the token to receive - reverts if this amount is not reached
     * @param deadline the timestamp representing the deadline for this transaction - reverts if deadline is not met
     */
    function completeToToken(
        uint256 itemId,
        uint256 swapAmount,
        uint256 minAmount,
        uint256 deadline
    ) external {
        require(swapAmount != 0, "amount must be greater than 0");
        address nftOwner = ownerOf(itemId);
        require(msg.sender == nftOwner, "must own itemId");
        require(
            pendingSwapType[itemId] > PendingSwapType.TokenToSynth,
            "invalid itemId"
        );

        PendingToTokenSwap memory pendingToTokenSwap = pendingToTokenSwaps[
            itemId
        ];

        _settle(
            address(pendingToTokenSwap.swapper),
            pendingToTokenSwap.synthKey
        );
        IERC20 synth = getProxyAddressFromTargetSynthKey(
            pendingToTokenSwap.synthKey
        );
        bool shouldDestroyClone;

        if (
            swapAmount >= synth.balanceOf(address(pendingToTokenSwap.swapper))
        ) {
            _burn(itemId);
            delete pendingToTokenSwaps[itemId];
            delete pendingSwapType[itemId];
            shouldDestroyClone = true;
        }

        // Try swapping the synth to the desired token via the stored swap pool contract
        // If the external call succeeds, send the token to the owner of token with itemId.
        (IERC20 tokenTo, uint256 amountOut) = pendingToTokenSwap
            .swapper
            .swapSynthToToken(
                pendingToTokenSwap.swap,
                synth,
                getSynthIndex(pendingToTokenSwap.swap),
                pendingToTokenSwap.tokenToIndex,
                swapAmount,
                minAmount,
                deadline,
                nftOwner
            );

        if (shouldDestroyClone) {
            pendingToTokenSwap.swapper.destroy();
        }

        emit Settle(
            msg.sender,
            itemId,
            synth,
            swapAmount,
            tokenTo,
            amountOut,
            shouldDestroyClone
        );
    }

    // Add the given pending synth settlement struct to the list
    function _addToPendingSynthSwapList(
        PendingToSynthSwap memory pendingToSynthSwap
    ) internal returns (uint256) {
        require(
            pendingSwapsLength < MAX_UINT256,
            "pendingSwapsLength reached max size"
        );
        pendingToSynthSwaps[pendingSwapsLength] = pendingToSynthSwap;
        return pendingSwapsLength++;
    }

    // Add the given pending synth to token settlement struct to the list
    function _addToPendingSynthToTokenSwapList(
        PendingToTokenSwap memory pendingToTokenSwap
    ) internal returns (uint256) {
        require(
            pendingSwapsLength < MAX_UINT256,
            "pendingSwapsLength reached max size"
        );
        pendingToTokenSwaps[pendingSwapsLength] = pendingToTokenSwap;
        return pendingSwapsLength++;
    }

    /**
     * @notice Calculates the expected amount of the desired synthetic asset the caller will receive after completing
     * a `TokenToSynth` swap with the given parameters. This calculation does not consider the settlement periods.
     * @param swap the address of a Saddle pool to use to swap the given token to a bridging synth
     * @param tokenFromIndex the index of the token to swap from
     * @param synthOutKey the currency key of the desired synthetic asset
     * @param tokenInAmount the amount of the token to swap form
     * @return the expected amount of the desired synth
     */
    function calcTokenToSynth(
        ISwap swap,
        uint8 tokenFromIndex,
        bytes32 synthOutKey,
        uint256 tokenInAmount
    ) external view returns (uint256) {
        uint8 mediumSynthIndex = getSynthIndex(swap);
        uint256 expectedMediumSynthAmount = swap.calculateSwap(
            tokenFromIndex,
            mediumSynthIndex,
            tokenInAmount
        );
        bytes32 mediumSynthKey = getSynthKey(swap);

        IExchangeRates exchangeRates = IExchangeRates(
            SYNTHETIX_RESOLVER.getAddress(EXCHANGE_RATES_NAME)
        );
        return
            exchangeRates.effectiveValue(
                mediumSynthKey,
                expectedMediumSynthAmount,
                synthOutKey
            );
    }

    /**
     * @notice Initiates a cross-asset swap from a token supported in the `swap` pool to any synthetic asset.
     * The caller will receive an ERC721 token representing their ownership of the pending cross-asset swap.
     * @param swap the address of a Saddle pool to use to swap the given token to a bridging synth
     * @param tokenFromIndex the index of the token to swap from
     * @param synthOutKey the currency key of the desired synthetic asset
     * @param tokenInAmount the amount of the token to swap form
     * @param minAmount the amount of the token to swap form
     * @return ID of the ERC721 token sent to the caller
     */
    function tokenToSynth(
        ISwap swap,
        uint8 tokenFromIndex,
        bytes32 synthOutKey,
        uint256 tokenInAmount,
        uint256 minAmount
    ) external returns (uint256) {
        require(tokenInAmount != 0, "amount must be greater than 0");
        // Create a SynthSwapper clone
        SynthSwapper synthSwapper = SynthSwapper(
            Clones.clone(SYNTH_SWAPPER_MASTER)
        );
        synthSwapper.initialize();

        // Add the synthswapper to the pending settlement list
        uint256 itemId = _addToPendingSynthSwapList(
            PendingToSynthSwap(synthSwapper, synthOutKey)
        );
        pendingSwapType[itemId] = PendingSwapType.TokenToSynth;

        // Mint an ERC721 token that represents ownership of the pending synth settlement to msg.sender
        _mint(msg.sender, itemId);

        // Transfer token from msg.sender
        IERC20 tokenFrom = swapContracts[address(swap)].tokens[tokenFromIndex]; // revert when token not found in swap pool
        tokenFrom.safeTransferFrom(msg.sender, address(this), tokenInAmount);
        tokenInAmount = tokenFrom.balanceOf(address(this));

        // Swap the synth to the medium synth
        uint256 mediumSynthAmount = swap.swap(
            tokenFromIndex,
            getSynthIndex(swap),
            tokenInAmount,
            0,
            block.timestamp
        );

        // Swap synths via Synthetix network
        IERC20(getSynthAddress(swap)).safeTransfer(
            address(synthSwapper),
            mediumSynthAmount
        );
        require(
            synthSwapper.swapSynth(
                getSynthKey(swap),
                mediumSynthAmount,
                synthOutKey
            ) >= minAmount,
            "minAmount not reached"
        );

        // Emit TokenToSynth event with relevant data
        emit TokenToSynth(
            msg.sender,
            itemId,
            swap,
            tokenFromIndex,
            tokenInAmount,
            synthOutKey
        );

        return (itemId);
    }

    /**
     * @notice Calculates the expected amount of the desired token the caller will receive after completing
     * a `SynthToToken` swap with the given parameters. This calculation does not consider the settlement periods or
     * any potential changes of the `swap` pool composition.
     * @param swap the address of a Saddle pool to use to swap the given token to a bridging synth
     * @param synthInKey the currency key of the synth to swap from
     * @param tokenToIndex the index of the token to swap to
     * @param synthInAmount the amount of the synth to swap form
     * @return the expected amount of the bridging synth and the expected amount of the desired token
     */
    function calcSynthToToken(
        ISwap swap,
        bytes32 synthInKey,
        uint8 tokenToIndex,
        uint256 synthInAmount
    ) external view returns (uint256, uint256) {
        IExchangeRates exchangeRates = IExchangeRates(
            SYNTHETIX_RESOLVER.getAddress(EXCHANGE_RATES_NAME)
        );

        uint8 mediumSynthIndex = getSynthIndex(swap);
        bytes32 mediumSynthKey = getSynthKey(swap);
        require(synthInKey != mediumSynthKey, "use normal swap");

        uint256 expectedMediumSynthAmount = exchangeRates.effectiveValue(
            synthInKey,
            synthInAmount,
            mediumSynthKey
        );

        return (
            expectedMediumSynthAmount,
            swap.calculateSwap(
                mediumSynthIndex,
                tokenToIndex,
                expectedMediumSynthAmount
            )
        );
    }

    /**
     * @notice Initiates a cross-asset swap from a synthetic asset to a supported token. The caller will receive
     * an ERC721 token representing their ownership of the pending cross-asset swap.
     * @param swap the address of a Saddle pool to use to swap the given token to a bridging synth
     * @param synthInKey the currency key of the synth to swap from
     * @param tokenToIndex the index of the token to swap to
     * @param synthInAmount the amount of the synth to swap form
     * @param minMediumSynthAmount the minimum amount of the bridging synth at pre-settlement stage
     * @return the ID of the ERC721 token sent to the caller
     */
    function synthToToken(
        ISwap swap,
        bytes32 synthInKey,
        uint8 tokenToIndex,
        uint256 synthInAmount,
        uint256 minMediumSynthAmount
    ) external returns (uint256) {
        require(synthInAmount != 0, "amount must be greater than 0");
        bytes32 mediumSynthKey = getSynthKey(swap);
        require(
            synthInKey != mediumSynthKey,
            "synth is supported via normal swap"
        );

        // Create a SynthSwapper clone
        SynthSwapper synthSwapper = SynthSwapper(
            Clones.clone(SYNTH_SWAPPER_MASTER)
        );
        synthSwapper.initialize();

        // Add the synthswapper to the pending synth to token settlement list
        uint256 itemId = _addToPendingSynthToTokenSwapList(
            PendingToTokenSwap(synthSwapper, mediumSynthKey, swap, tokenToIndex)
        );
        pendingSwapType[itemId] = PendingSwapType.SynthToToken;

        // Mint an ERC721 token that represents ownership of the pending synth to token settlement to msg.sender
        _mint(msg.sender, itemId);

        // Receive synth from the user and swap it to another synth
        IERC20 synthFrom = getProxyAddressFromTargetSynthKey(synthInKey);
        synthFrom.safeTransferFrom(msg.sender, address(this), synthInAmount);
        synthFrom.safeTransfer(address(synthSwapper), synthInAmount);
        require(
            synthSwapper.swapSynth(synthInKey, synthInAmount, mediumSynthKey) >=
                minMediumSynthAmount,
            "minMediumSynthAmount not reached"
        );

        // Emit SynthToToken event with relevant data
        emit SynthToToken(
            msg.sender,
            itemId,
            swap,
            synthInKey,
            synthInAmount,
            tokenToIndex
        );

        return (itemId);
    }

    /**
     * @notice Calculates the expected amount of the desired token the caller will receive after completing
     * a `TokenToToken` swap with the given parameters. This calculation does not consider the settlement periods or
     * any potential changes of the pool compositions.
     * @param swaps the addresses of the two Saddle pools used to do the cross-asset swap
     * @param tokenFromIndex the index of the token in the first `swaps` pool to swap from
     * @param tokenToIndex the index of the token in the second `swaps` pool to swap to
     * @param tokenFromAmount the amount of the token to swap from
     * @return the expected amount of bridging synth at pre-settlement stage and the expected amount of the desired
     * token
     */
    function calcTokenToToken(
        ISwap[2] calldata swaps,
        uint8 tokenFromIndex,
        uint8 tokenToIndex,
        uint256 tokenFromAmount
    ) external view returns (uint256, uint256) {
        IExchangeRates exchangeRates = IExchangeRates(
            SYNTHETIX_RESOLVER.getAddress(EXCHANGE_RATES_NAME)
        );

        uint256 firstSynthAmount = swaps[0].calculateSwap(
            tokenFromIndex,
            getSynthIndex(swaps[0]),
            tokenFromAmount
        );

        uint256 mediumSynthAmount = exchangeRates.effectiveValue(
            getSynthKey(swaps[0]),
            firstSynthAmount,
            getSynthKey(swaps[1])
        );

        return (
            mediumSynthAmount,
            swaps[1].calculateSwap(
                getSynthIndex(swaps[1]),
                tokenToIndex,
                mediumSynthAmount
            )
        );
    }

    /**
     * @notice Initiates a cross-asset swap from a token in one Saddle pool to one in another. The caller will receive
     * an ERC721 token representing their ownership of the pending cross-asset swap.
     * @param swaps the addresses of the two Saddle pools used to do the cross-asset swap
     * @param tokenFromIndex the index of the token in the first `swaps` pool to swap from
     * @param tokenToIndex the index of the token in the second `swaps` pool to swap to
     * @param tokenFromAmount the amount of the token to swap from
     * @param minMediumSynthAmount the minimum amount of the bridging synth at pre-settlement stage
     * @return the ID of the ERC721 token sent to the caller
     */
    function tokenToToken(
        ISwap[2] calldata swaps,
        uint8 tokenFromIndex,
        uint8 tokenToIndex,
        uint256 tokenFromAmount,
        uint256 minMediumSynthAmount
    ) external returns (uint256) {
        // Create a SynthSwapper clone
        require(tokenFromAmount != 0, "amount must be greater than 0");
        SynthSwapper synthSwapper = SynthSwapper(
            Clones.clone(SYNTH_SWAPPER_MASTER)
        );
        synthSwapper.initialize();
        bytes32 mediumSynthKey = getSynthKey(swaps[1]);

        // Add the synthswapper to the pending synth to token settlement list
        uint256 itemId = _addToPendingSynthToTokenSwapList(
            PendingToTokenSwap(
                synthSwapper,
                mediumSynthKey,
                swaps[1],
                tokenToIndex
            )
        );
        pendingSwapType[itemId] = PendingSwapType.TokenToToken;

        // Mint an ERC721 token that represents ownership of the pending swap to msg.sender
        _mint(msg.sender, itemId);

        // Receive token from the user
        ISwap swap = swaps[0];
        {
            IERC20 tokenFrom = swapContracts[address(swap)].tokens[
                tokenFromIndex
            ];
            tokenFrom.safeTransferFrom(
                msg.sender,
                address(this),
                tokenFromAmount
            );
        }

        uint256 firstSynthAmount = swap.swap(
            tokenFromIndex,
            getSynthIndex(swap),
            tokenFromAmount,
            0,
            block.timestamp
        );

        // Swap the synth to another synth
        IERC20(getSynthAddress(swap)).safeTransfer(
            address(synthSwapper),
            firstSynthAmount
        );
        require(
            synthSwapper.swapSynth(
                getSynthKey(swap),
                firstSynthAmount,
                mediumSynthKey
            ) >= minMediumSynthAmount,
            "minMediumSynthAmount not reached"
        );

        // Emit TokenToToken event with relevant data
        emit TokenToToken(
            msg.sender,
            itemId,
            swaps,
            tokenFromIndex,
            tokenFromAmount,
            tokenToIndex
        );

        return (itemId);
    }

    /**
     * @notice Registers the index and the address of the supported synth from the given `swap` pool. The matching currency key must
     * be supplied for a successful registration.
     * @param swap the address of the pool that contains the synth
     * @param synthIndex the index of the supported synth in the given `swap` pool
     * @param currencyKey the currency key of the synth in bytes32 form
     */
    function setSynthIndex(
        ISwap swap,
        uint8 synthIndex,
        bytes32 currencyKey
    ) external {
        require(synthIndex < MAX_UINT8, "index is too large");
        SwapContractInfo storage swapContractInfo = swapContracts[
            address(swap)
        ];
        // Check if the pool has already been added
        require(swapContractInfo.synthIndexPlusOne == 0, "Pool already added");
        // Ensure the synth with the same currency key exists at the given `synthIndex`
        IERC20 synth = swap.getToken(synthIndex);
        require(
            ISynth(Proxy(address(synth)).target()).currencyKey() == currencyKey,
            "currencyKey does not match"
        );
        swapContractInfo.synthIndexPlusOne = synthIndex + 1;
        swapContractInfo.synthAddress = address(synth);
        swapContractInfo.synthKey = currencyKey;
        swapContractInfo.tokens = new IERC20[](0);

        for (uint8 i = 0; i < MAX_UINT8; i++) {
            IERC20 token;
            if (i == synthIndex) {
                token = synth;
            } else {
                try swap.getToken(i) returns (IERC20 token_) {
                    token = token_;
                } catch {
                    break;
                }
            }
            swapContractInfo.tokens.push(token);
            token.safeApprove(address(swap), MAX_UINT256);
        }

        emit SynthIndex(address(swap), synthIndex, currencyKey, address(synth));
    }

    /**
     * @notice Returns the index of the supported synth in the given `swap` pool. Reverts if the `swap` pool
     * is not registered.
     * @param swap the address of the pool that contains the synth
     * @return the index of the supported synth
     */
    function getSynthIndex(ISwap swap) public view returns (uint8) {
        uint8 synthIndexPlusOne = swapContracts[address(swap)]
            .synthIndexPlusOne;
        require(synthIndexPlusOne > 0, "synth index not found for given pool");
        return synthIndexPlusOne - 1;
    }

    /**
     * @notice Returns the address of the supported synth in the given `swap` pool. Reverts if the `swap` pool
     * is not registered.
     * @param swap the address of the pool that contains the synth
     * @return the address of the supported synth
     */
    function getSynthAddress(ISwap swap) public view returns (address) {
        address synthAddress = swapContracts[address(swap)].synthAddress;
        require(
            synthAddress != address(0),
            "synth addr not found for given pool"
        );
        return synthAddress;
    }

    /**
     * @notice Returns the currency key of the supported synth in the given `swap` pool. Reverts if the `swap` pool
     * is not registered.
     * @param swap the address of the pool that contains the synth
     * @return the currency key of the supported synth
     */
    function getSynthKey(ISwap swap) public view returns (bytes32) {
        bytes32 synthKey = swapContracts[address(swap)].synthKey;
        require(synthKey != 0x0, "synth key not found for given pool");
        return synthKey;
    }

    /**
     * @notice Updates the stored address of the `EXCHANGER` contract. When the Synthetix team upgrades their protocol,
     * a new Exchanger contract is deployed. This function manually updates the stored address.
     */
    function updateExchangerCache() public {
        exchanger = IExchanger(SYNTHETIX_RESOLVER.getAddress(EXCHANGER_NAME));
    }
}

File 21 of 29 : SynthSwapper.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

import "synthetix/contracts/interfaces/ISynthetix.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol";
import "../interfaces/ISwap.sol";

/**
 * @title SynthSwapper
 * @notice Replacement of Virtual Synths in favor of gas savings. Allows swapping synths via the Synthetix protocol
 * or Saddle's pools. The `Bridge.sol` contract will deploy minimal clones of this contract upon initiating
 * any cross-asset swaps.
 */
contract SynthSwapper is Initializable {
    using SafeERC20 for IERC20;

    address payable owner;
    // SYNTHETIX points to `ProxyERC20` (0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F).
    // This contract is a proxy of `Synthetix` and is used to exchange synths.
    ISynthetix public constant SYNTHETIX =
        ISynthetix(0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F);
    // "SADDLE" in bytes32 form
    bytes32 public constant TRACKING =
        0x534144444c450000000000000000000000000000000000000000000000000000;

    /**
     * @notice Initializes the contract when deploying this directly. This prevents
     * others from calling initialize() on the target contract and setting themself as the owner.
     */
    constructor() public {
        initialize();
    }

    /**
     * @notice This modifier checks if the caller is the owner
     */
    modifier onlyOwner() {
        require(msg.sender == owner, "is not owner");
        _;
    }

    /**
     * @notice Sets the `owner` as the caller of this function
     */
    function initialize() public initializer {
        require(owner == address(0), "owner already set");
        owner = msg.sender;
    }

    /**
     * @notice Swaps the synth to another synth via the Synthetix protocol.
     * @param sourceKey currency key of the source synth
     * @param synthAmount amount of the synth to swap
     * @param destKey currency key of the destination synth
     * @return amount of the destination synth received
     */
    function swapSynth(
        bytes32 sourceKey,
        uint256 synthAmount,
        bytes32 destKey
    ) external onlyOwner returns (uint256) {
        return
            SYNTHETIX.exchangeWithTracking(
                sourceKey,
                synthAmount,
                destKey,
                msg.sender,
                TRACKING
            );
    }

    /**
     * @notice Approves the given `tokenFrom` and swaps it to another token via the given `swap` pool.
     * @param swap the address of a pool to swap through
     * @param tokenFrom the address of the stored synth
     * @param tokenFromIndex the index of the token to swap from
     * @param tokenToIndex the token the user wants to swap to
     * @param tokenFromAmount the amount of the token to swap
     * @param minAmount the min amount the user would like to receive, or revert.
     * @param deadline latest timestamp to accept this transaction
     * @param recipient the address of the recipient
     */
    function swapSynthToToken(
        ISwap swap,
        IERC20 tokenFrom,
        uint8 tokenFromIndex,
        uint8 tokenToIndex,
        uint256 tokenFromAmount,
        uint256 minAmount,
        uint256 deadline,
        address recipient
    ) external onlyOwner returns (IERC20, uint256) {
        tokenFrom.approve(address(swap), tokenFromAmount);
        swap.swap(
            tokenFromIndex,
            tokenToIndex,
            tokenFromAmount,
            minAmount,
            deadline
        );
        IERC20 tokenTo = swap.getToken(tokenToIndex);
        uint256 balance = tokenTo.balanceOf(address(this));
        tokenTo.safeTransfer(recipient, balance);
        return (tokenTo, balance);
    }

    /**
     * @notice Withdraws the given amount of `token` to the `recipient`.
     * @param token the address of the token to withdraw
     * @param recipient the address of the account to receive the token
     * @param withdrawAmount the amount of the token to withdraw
     * @param shouldDestroy whether this contract should be destroyed after this call
     */
    function withdraw(
        IERC20 token,
        address recipient,
        uint256 withdrawAmount,
        bool shouldDestroy
    ) external onlyOwner {
        token.safeTransfer(recipient, withdrawAmount);
        if (shouldDestroy) {
            _destroy();
        }
    }

    /**
     * @notice Destroys this contract. Only owner can call this function.
     */
    function destroy() external onlyOwner {
        _destroy();
    }

    function _destroy() internal {
        selfdestruct(msg.sender);
    }
}

File 22 of 29 : IAllowlist.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

interface IAllowlist {
    function getPoolAccountLimit(address poolAddress)
        external
        view
        returns (uint256);

    function getPoolCap(address poolAddress) external view returns (uint256);

    function verifyAddress(address account, bytes32[] calldata merkleProof)
        external
        returns (bool);
}

File 23 of 29 : ISwap.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "./IAllowlist.sol";

interface ISwap {
    // pool data view functions
    function getA() external view returns (uint256);

    function getAllowlist() external view returns (IAllowlist);

    function getToken(uint8 index) external view returns (IERC20);

    function getTokenIndex(address tokenAddress) external view returns (uint8);

    function getTokenBalance(uint8 index) external view returns (uint256);

    function getVirtualPrice() external view returns (uint256);

    function isGuarded() external view returns (bool);

    // min return calculation functions
    function calculateSwap(
        uint8 tokenIndexFrom,
        uint8 tokenIndexTo,
        uint256 dx
    ) external view returns (uint256);

    function calculateTokenAmount(uint256[] calldata amounts, bool deposit)
        external
        view
        returns (uint256);

    function calculateRemoveLiquidity(uint256 amount)
        external
        view
        returns (uint256[] memory);

    function calculateRemoveLiquidityOneToken(
        uint256 tokenAmount,
        uint8 tokenIndex
    ) external view returns (uint256 availableTokenAmount);

    // state modifying functions
    function initialize(
        IERC20[] memory pooledTokens,
        uint8[] memory decimals,
        string memory lpTokenName,
        string memory lpTokenSymbol,
        uint256 a,
        uint256 fee,
        uint256 adminFee,
        address lpTokenTargetAddress
    ) external;

    function swap(
        uint8 tokenIndexFrom,
        uint8 tokenIndexTo,
        uint256 dx,
        uint256 minDy,
        uint256 deadline
    ) external returns (uint256);

    function addLiquidity(
        uint256[] calldata amounts,
        uint256 minToMint,
        uint256 deadline
    ) external returns (uint256);

    function removeLiquidity(
        uint256 amount,
        uint256[] calldata minAmounts,
        uint256 deadline
    ) external returns (uint256[] memory);

    function removeLiquidityOneToken(
        uint256 tokenAmount,
        uint8 tokenIndex,
        uint256 minAmount,
        uint256 deadline
    ) external returns (uint256);

    function removeLiquidityImbalance(
        uint256[] calldata amounts,
        uint256 maxBurnAmount,
        uint256 deadline
    ) external returns (uint256);
}

File 24 of 29 : IAddressResolver.sol
pragma solidity >=0.4.24;

// https://docs.synthetix.io/contracts/source/interfaces/iaddressresolver
interface IAddressResolver {
    function getAddress(bytes32 name) external view returns (address);

    function getSynth(bytes32 key) external view returns (address);

    function requireAndGetAddress(bytes32 name, string calldata reason) external view returns (address);
}

File 25 of 29 : IExchangeRates.sol
pragma solidity >=0.4.24;

// https://docs.synthetix.io/contracts/source/interfaces/iexchangerates
interface IExchangeRates {
    // Structs
    struct RateAndUpdatedTime {
        uint216 rate;
        uint40 time;
    }

    struct InversePricing {
        uint entryPoint;
        uint upperLimit;
        uint lowerLimit;
        bool frozenAtUpperLimit;
        bool frozenAtLowerLimit;
    }

    // Views
    function aggregators(bytes32 currencyKey) external view returns (address);

    function aggregatorWarningFlags() external view returns (address);

    function anyRateIsInvalid(bytes32[] calldata currencyKeys) external view returns (bool);

    function canFreezeRate(bytes32 currencyKey) external view returns (bool);

    function currentRoundForRate(bytes32 currencyKey) external view returns (uint);

    function currenciesUsingAggregator(address aggregator) external view returns (bytes32[] memory);

    function effectiveValue(
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey
    ) external view returns (uint value);

    function effectiveValueAndRates(
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey
    )
        external
        view
        returns (
            uint value,
            uint sourceRate,
            uint destinationRate
        );

    function effectiveValueAtRound(
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey,
        uint roundIdForSrc,
        uint roundIdForDest
    ) external view returns (uint value);

    function getCurrentRoundId(bytes32 currencyKey) external view returns (uint);

    function getLastRoundIdBeforeElapsedSecs(
        bytes32 currencyKey,
        uint startingRoundId,
        uint startingTimestamp,
        uint timediff
    ) external view returns (uint);

    function inversePricing(bytes32 currencyKey)
        external
        view
        returns (
            uint entryPoint,
            uint upperLimit,
            uint lowerLimit,
            bool frozenAtUpperLimit,
            bool frozenAtLowerLimit
        );

    function lastRateUpdateTimes(bytes32 currencyKey) external view returns (uint256);

    function oracle() external view returns (address);

    function rateAndTimestampAtRound(bytes32 currencyKey, uint roundId) external view returns (uint rate, uint time);

    function rateAndUpdatedTime(bytes32 currencyKey) external view returns (uint rate, uint time);

    function rateAndInvalid(bytes32 currencyKey) external view returns (uint rate, bool isInvalid);

    function rateForCurrency(bytes32 currencyKey) external view returns (uint);

    function rateIsFlagged(bytes32 currencyKey) external view returns (bool);

    function rateIsFrozen(bytes32 currencyKey) external view returns (bool);

    function rateIsInvalid(bytes32 currencyKey) external view returns (bool);

    function rateIsStale(bytes32 currencyKey) external view returns (bool);

    function rateStalePeriod() external view returns (uint);

    function ratesAndUpdatedTimeForCurrencyLastNRounds(bytes32 currencyKey, uint numRounds)
        external
        view
        returns (uint[] memory rates, uint[] memory times);

    function ratesAndInvalidForCurrencies(bytes32[] calldata currencyKeys)
        external
        view
        returns (uint[] memory rates, bool anyRateInvalid);

    function ratesForCurrencies(bytes32[] calldata currencyKeys) external view returns (uint[] memory);

    // Mutative functions
    function freezeRate(bytes32 currencyKey) external;
}

File 26 of 29 : IExchanger.sol
pragma solidity >=0.4.24;

import "./IVirtualSynth.sol";

// https://docs.synthetix.io/contracts/source/interfaces/iexchanger
interface IExchanger {
    // Views
    function calculateAmountAfterSettlement(
        address from,
        bytes32 currencyKey,
        uint amount,
        uint refunded
    ) external view returns (uint amountAfterSettlement);

    function isSynthRateInvalid(bytes32 currencyKey) external view returns (bool);

    function maxSecsLeftInWaitingPeriod(address account, bytes32 currencyKey) external view returns (uint);

    function settlementOwing(address account, bytes32 currencyKey)
        external
        view
        returns (
            uint reclaimAmount,
            uint rebateAmount,
            uint numEntries
        );

    function hasWaitingPeriodOrSettlementOwing(address account, bytes32 currencyKey) external view returns (bool);

    function feeRateForExchange(bytes32 sourceCurrencyKey, bytes32 destinationCurrencyKey)
        external
        view
        returns (uint exchangeFeeRate);

    function getAmountsForExchange(
        uint sourceAmount,
        bytes32 sourceCurrencyKey,
        bytes32 destinationCurrencyKey
    )
        external
        view
        returns (
            uint amountReceived,
            uint fee,
            uint exchangeFeeRate
        );

    function priceDeviationThresholdFactor() external view returns (uint);

    function waitingPeriodSecs() external view returns (uint);

    // Mutative functions
    function exchange(
        address from,
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey,
        address destinationAddress
    ) external returns (uint amountReceived);

    function exchangeOnBehalf(
        address exchangeForAddress,
        address from,
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey
    ) external returns (uint amountReceived);

    function exchangeWithTracking(
        address from,
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey,
        address destinationAddress,
        address originator,
        bytes32 trackingCode
    ) external returns (uint amountReceived);

    function exchangeOnBehalfWithTracking(
        address exchangeForAddress,
        address from,
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey,
        address originator,
        bytes32 trackingCode
    ) external returns (uint amountReceived);

    function exchangeWithVirtual(
        address from,
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey,
        address destinationAddress,
        bytes32 trackingCode
    ) external returns (uint amountReceived, IVirtualSynth vSynth);

    function settle(address from, bytes32 currencyKey)
        external
        returns (
            uint reclaimed,
            uint refunded,
            uint numEntries
        );

    function setLastExchangeRateForSynth(bytes32 currencyKey, uint rate) external;

    function suspendSynthWithInvalidRate(bytes32 currencyKey) external;
}

File 27 of 29 : ISynth.sol
pragma solidity >=0.4.24;

// https://docs.synthetix.io/contracts/source/interfaces/isynth
interface ISynth {
    // Views
    function currencyKey() external view returns (bytes32);

    function transferableSynths(address account) external view returns (uint);

    // Mutative functions
    function transferAndSettle(address to, uint value) external returns (bool);

    function transferFromAndSettle(
        address from,
        address to,
        uint value
    ) external returns (bool);

    // Restricted: used internally to Synthetix
    function burn(address account, uint amount) external;

    function issue(address account, uint amount) external;
}

File 28 of 29 : ISynthetix.sol
pragma solidity >=0.4.24;

import "./ISynth.sol";
import "./IVirtualSynth.sol";

// https://docs.synthetix.io/contracts/source/interfaces/isynthetix
interface ISynthetix {
    // Views
    function anySynthOrSNXRateIsInvalid() external view returns (bool anyRateInvalid);

    function availableCurrencyKeys() external view returns (bytes32[] memory);

    function availableSynthCount() external view returns (uint);

    function availableSynths(uint index) external view returns (ISynth);

    function collateral(address account) external view returns (uint);

    function collateralisationRatio(address issuer) external view returns (uint);

    function debtBalanceOf(address issuer, bytes32 currencyKey) external view returns (uint);

    function isWaitingPeriod(bytes32 currencyKey) external view returns (bool);

    function maxIssuableSynths(address issuer) external view returns (uint maxIssuable);

    function remainingIssuableSynths(address issuer)
        external
        view
        returns (
            uint maxIssuable,
            uint alreadyIssued,
            uint totalSystemDebt
        );

    function synths(bytes32 currencyKey) external view returns (ISynth);

    function synthsByAddress(address synthAddress) external view returns (bytes32);

    function totalIssuedSynths(bytes32 currencyKey) external view returns (uint);

    function totalIssuedSynthsExcludeEtherCollateral(bytes32 currencyKey) external view returns (uint);

    function transferableSynthetix(address account) external view returns (uint transferable);

    // Mutative Functions
    function burnSynths(uint amount) external;

    function burnSynthsOnBehalf(address burnForAddress, uint amount) external;

    function burnSynthsToTarget() external;

    function burnSynthsToTargetOnBehalf(address burnForAddress) external;

    function exchange(
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey
    ) external returns (uint amountReceived);

    function exchangeOnBehalf(
        address exchangeForAddress,
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey
    ) external returns (uint amountReceived);

    function exchangeWithTracking(
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey,
        address originator,
        bytes32 trackingCode
    ) external returns (uint amountReceived);

    function exchangeOnBehalfWithTracking(
        address exchangeForAddress,
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey,
        address originator,
        bytes32 trackingCode
    ) external returns (uint amountReceived);

    function exchangeWithVirtual(
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey,
        bytes32 trackingCode
    ) external returns (uint amountReceived, IVirtualSynth vSynth);

    function issueMaxSynths() external;

    function issueMaxSynthsOnBehalf(address issueForAddress) external;

    function issueSynths(uint amount) external;

    function issueSynthsOnBehalf(address issueForAddress, uint amount) external;

    function mint() external returns (bool);

    function settle(bytes32 currencyKey)
        external
        returns (
            uint reclaimed,
            uint refunded,
            uint numEntries
        );

    // Liquidations
    function liquidateDelinquentAccount(address account, uint susdAmount) external returns (bool);

    // Restricted Functions

    function mintSecondary(address account, uint amount) external;

    function mintSecondaryRewards(uint amount) external;

    function burnSecondary(address account, uint amount) external;
}

File 29 of 29 : IVirtualSynth.sol
pragma solidity >=0.4.24;

import "./ISynth.sol";

interface IVirtualSynth {
    // Views
    function balanceOfUnderlying(address account) external view returns (uint);

    function rate() external view returns (uint);

    function readyToSettle() external view returns (bool);

    function secsLeftInWaitingPeriod() external view returns (uint);

    function settled() external view returns (bool);

    function synth() external view returns (ISynth);

    // Mutative functions
    function settle(address account) external;
}

Settings
{
  "evmVersion": "istanbul",
  "libraries": {},
  "metadata": {
    "bytecodeHash": "ipfs",
    "useLiteralContent": true
  },
  "optimizer": {
    "enabled": true,
    "runs": 10000
  },
  "remappings": [],
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "abi"
      ]
    }
  }
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"synthSwapperAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"requester","type":"address"},{"indexed":true,"internalType":"uint256","name":"itemId","type":"uint256"},{"indexed":false,"internalType":"contract IERC20","name":"settleFrom","type":"address"},{"indexed":false,"internalType":"uint256","name":"settleFromAmount","type":"uint256"},{"indexed":false,"internalType":"contract IERC20","name":"settleTo","type":"address"},{"indexed":false,"internalType":"uint256","name":"settleToAmount","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isFinal","type":"bool"}],"name":"Settle","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"swap","type":"address"},{"indexed":false,"internalType":"uint8","name":"synthIndex","type":"uint8"},{"indexed":false,"internalType":"bytes32","name":"currencyKey","type":"bytes32"},{"indexed":false,"internalType":"address","name":"synthAddress","type":"address"}],"name":"SynthIndex","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"requester","type":"address"},{"indexed":true,"internalType":"uint256","name":"itemId","type":"uint256"},{"indexed":false,"internalType":"contract ISwap","name":"swapPool","type":"address"},{"indexed":false,"internalType":"bytes32","name":"synthFromKey","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"synthFromInAmount","type":"uint256"},{"indexed":false,"internalType":"uint8","name":"tokenToIndex","type":"uint8"}],"name":"SynthToToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"requester","type":"address"},{"indexed":true,"internalType":"uint256","name":"itemId","type":"uint256"},{"indexed":false,"internalType":"contract ISwap","name":"swapPool","type":"address"},{"indexed":false,"internalType":"uint8","name":"tokenFromIndex","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"tokenFromInAmount","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"synthToKey","type":"bytes32"}],"name":"TokenToSynth","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"requester","type":"address"},{"indexed":true,"internalType":"uint256","name":"itemId","type":"uint256"},{"indexed":false,"internalType":"contract ISwap[2]","name":"swapPools","type":"address[2]"},{"indexed":false,"internalType":"uint8","name":"tokenFromIndex","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"tokenFromAmount","type":"uint256"},{"indexed":false,"internalType":"uint8","name":"tokenToIndex","type":"uint8"}],"name":"TokenToToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"requester","type":"address"},{"indexed":true,"internalType":"uint256","name":"itemId","type":"uint256"},{"indexed":false,"internalType":"contract IERC20","name":"synth","type":"address"},{"indexed":false,"internalType":"uint256","name":"synthAmount","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isFinal","type":"bool"}],"name":"Withdraw","type":"event"},{"inputs":[],"name":"EXCHANGER_NAME","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"EXCHANGE_RATES_NAME","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_UINT256","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_UINT8","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SYNTHETIX_RESOLVER","outputs":[{"internalType":"contract IAddressResolver","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SYNTH_SWAPPER_MASTER","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"itemId","type":"uint256"},{"internalType":"uint256","name":"swapAmount","type":"uint256"}],"name":"calcCompleteToToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ISwap","name":"swap","type":"address"},{"internalType":"bytes32","name":"synthInKey","type":"bytes32"},{"internalType":"uint8","name":"tokenToIndex","type":"uint8"},{"internalType":"uint256","name":"synthInAmount","type":"uint256"}],"name":"calcSynthToToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ISwap","name":"swap","type":"address"},{"internalType":"uint8","name":"tokenFromIndex","type":"uint8"},{"internalType":"bytes32","name":"synthOutKey","type":"bytes32"},{"internalType":"uint256","name":"tokenInAmount","type":"uint256"}],"name":"calcTokenToSynth","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ISwap[2]","name":"swaps","type":"address[2]"},{"internalType":"uint8","name":"tokenFromIndex","type":"uint8"},{"internalType":"uint8","name":"tokenToIndex","type":"uint8"},{"internalType":"uint256","name":"tokenFromAmount","type":"uint256"}],"name":"calcTokenToToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"itemId","type":"uint256"}],"name":"completeToSynth","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"itemId","type":"uint256"},{"internalType":"uint256","name":"swapAmount","type":"uint256"},{"internalType":"uint256","name":"minAmount","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"completeToToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"exchanger","outputs":[{"internalType":"contract IExchanger","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"itemId","type":"uint256"}],"name":"getPendingSwapInfo","outputs":[{"internalType":"enum Bridge.PendingSwapType","name":"swapType","type":"uint8"},{"internalType":"uint256","name":"secsLeft","type":"uint256"},{"internalType":"address","name":"synth","type":"address"},{"internalType":"uint256","name":"synthBalance","type":"uint256"},{"internalType":"address","name":"tokenTo","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"synthKey","type":"bytes32"}],"name":"getProxyAddressFromTargetSynthKey","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ISwap","name":"swap","type":"address"}],"name":"getSynthAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ISwap","name":"swap","type":"address"}],"name":"getSynthIndex","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ISwap","name":"swap","type":"address"}],"name":"getSynthKey","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingSwapsLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"pendingToSynthSwaps","outputs":[{"internalType":"contract SynthSwapper","name":"swapper","type":"address"},{"internalType":"bytes32","name":"synthKey","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"pendingToTokenSwaps","outputs":[{"internalType":"contract SynthSwapper","name":"swapper","type":"address"},{"internalType":"bytes32","name":"synthKey","type":"bytes32"},{"internalType":"contract ISwap","name":"swap","type":"address"},{"internalType":"uint8","name":"tokenToIndex","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ISwap","name":"swap","type":"address"},{"internalType":"uint8","name":"synthIndex","type":"uint8"},{"internalType":"bytes32","name":"currencyKey","type":"bytes32"}],"name":"setSynthIndex","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ISwap","name":"swap","type":"address"},{"internalType":"bytes32","name":"synthInKey","type":"bytes32"},{"internalType":"uint8","name":"tokenToIndex","type":"uint8"},{"internalType":"uint256","name":"synthInAmount","type":"uint256"},{"internalType":"uint256","name":"minMediumSynthAmount","type":"uint256"}],"name":"synthToToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ISwap","name":"swap","type":"address"},{"internalType":"uint8","name":"tokenFromIndex","type":"uint8"},{"internalType":"bytes32","name":"synthOutKey","type":"bytes32"},{"internalType":"uint256","name":"tokenInAmount","type":"uint256"},{"internalType":"uint256","name":"minAmount","type":"uint256"}],"name":"tokenToSynth","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ISwap[2]","name":"swaps","type":"address[2]"},{"internalType":"uint8","name":"tokenFromIndex","type":"uint8"},{"internalType":"uint8","name":"tokenToIndex","type":"uint8"},{"internalType":"uint256","name":"tokenFromAmount","type":"uint256"},{"internalType":"uint256","name":"minMediumSynthAmount","type":"uint256"}],"name":"tokenToToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"updateExchangerCache","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"itemId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60a06040523480156200001157600080fd5b506040516200591938038062005919833981810160405260208110156200003757600080fd5b5051604080518082018252601781527f536164646c652043726f73732d417373657420537761700000000000000000006020828101919091528251808401909352600f83526e0536164646c6553796e74685377617608c1b9083015290620000a66301ffc9a760e01b6200012d565b8151620000bb9060069060208501906200025f565b508051620000d19060079060208401906200025f565b50620000e46380ac58cd60e01b6200012d565b620000f6635b5e139f60e01b6200012d565b6200010863780e9d6360e01b6200012d565b50506001600160601b0319606082901b1660805262000126620001b2565b50620002fb565b6001600160e01b031980821614156200018d576040805162461bcd60e51b815260206004820152601c60248201527f4552433136353a20696e76616c696420696e7465726661636520696400000000604482015290519081900360640190fd5b6001600160e01b0319166000908152602081905260409020805460ff19166001179055565b604080516321f8a72160e01b81526822bc31b430b733b2b960b91b60048201529051734e3b31eb0e5cb73641ee1e65e7dcefe520ba3ef2916321f8a721916024808301926020929190829003018186803b1580156200021057600080fd5b505afa15801562000225573d6000803e3d6000fd5b505050506040513d60208110156200023c57600080fd5b5051600a80546001600160a01b0319166001600160a01b03909216919091179055565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10620002a257805160ff1916838001178555620002d2565b82800160010185558215620002d2579182015b82811115620002d2578251825591602001919060010190620002b5565b50620002e0929150620002e4565b5090565b5b80821115620002e05760008155600101620002e5565b60805160601c6155f16200032860003980610fca528061124f528061248b528061346c52506155f16000f3fe608060405234801561001057600080fd5b50600436106102f45760003560e01c80637d3913ca11610191578063b6bd8dcb116100e3578063d488743711610097578063ea4e9eb611610071578063ea4e9eb614610a4e578063ee1e709014610a8f578063fce3ee4114610abe576102f4565b8063d488743714610a10578063e504e7aa14610a18578063e985e9c514610a20576102f4565b8063c05b1bd4116100c8578063c05b1bd414610965578063c87b56dd146109c2578063cbc3c495146109df576102f4565b8063b6bd8dcb14610897578063b88d4fde1461089f576102f4565b8063892e196d11610145578063a042d45f1161011f578063a042d45f146107c1578063a22cb4651461082d578063b04a74ab1461085b576102f4565b8063892e196d1461078b57806395d89b4114610793578063a000a45d1461079b576102f4565b80638501259c116101765780638501259c146106fd578063859c9e6d1461071a57806387911b0d14610755576102f4565b80637d3913ca146106bd5780637fabc495146106da576102f4565b80632f745c591161024a5780634f6ccce7116101fe5780636352211e116101d85780636352211e146106725780636c0360eb1461068f57806370a0823114610697576102f4565b80634f6ccce7146105fa5780635af0feb3146106175780636141db901461064c576102f4565b806342842e0e1161022f57806342842e0e14610599578063441a3e70146105cf5780634d12fca4146105f2576102f4565b80632f745c591461056557806333a581d214610591576102f4565b80630aa07ba3116102ac578063218a89ad11610286578063218a89ad1461051f57806323b872dd1461052757806326cdb6d81461055d576102f4565b80630aa07ba31461048457806318160ddd146104d757806318f0595c146104df576102f4565b8063081812fc116102dd578063081812fc146103c9578063095ea7b3146104025780630a82660614610430576102f4565b806301ffc9a7146102f957806306fdde031461034c575b600080fd5b6103386004803603602081101561030f57600080fd5b50357fffffffff0000000000000000000000000000000000000000000000000000000016610ac6565b604080519115158252519081900360200190f35b610354610b01565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561038e578181015183820152602001610376565b50505050905090810190601f1680156103bb5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103e6600480360360208110156103df57600080fd5b5035610b97565b604080516001600160a01b039092168252519081900360200190f35b61042e6004803603604081101561041857600080fd5b506001600160a01b038135169060200135610bf9565b005b61046b6004803603608081101561044657600080fd5b506001600160a01b038135169060208101359060ff6040820135169060600135610cd4565b6040805192835260208301919091528051918290030190f35b6104c5600480360360a081101561049a57600080fd5b506001600160a01b038135169060208101359060ff6040820135169060608101359060800135610f23565b60408051918252519081900360200190f35b6104c5611217565b6104fc600480360360208110156104f557600080fd5b5035611228565b604080516001600160a01b03909316835260208301919091528051918290030190f35b6103e661124d565b61042e6004803603606081101561053d57600080fd5b506001600160a01b03813581169160208101359091169060400135611271565b6104c56112c8565b6104c56004803603604081101561057b57600080fd5b506001600160a01b0381351690602001356112ec565b6104c5611317565b61042e600480360360608110156105af57600080fd5b506001600160a01b0381358116916020810135909116906040013561131d565b61042e600480360360408110156105e557600080fd5b5080359060200135611338565b6103e6611691565b6104c56004803603602081101561061057600080fd5b50356116a0565b61042e6004803603606081101561062d57600080fd5b506001600160a01b038135169060ff60208201351690604001356116b6565b6104c56004803603602081101561066257600080fd5b50356001600160a01b0316611b38565b6103e66004803603602081101561068857600080fd5b5035611b90565b610354611bb8565b6104c5600480360360208110156106ad57600080fd5b50356001600160a01b0316611c19565b6103e6600480360360208110156106d357600080fd5b5035611c81565b6104c5600480360360408110156106f057600080fd5b5080359060200135611d94565b61042e6004803603602081101561071357600080fd5b5035611f06565b6104c56004803603608081101561073057600080fd5b506001600160a01b038135169060ff6020820135169060408101359060600135612238565b6104c5600480360360c081101561076b57600080fd5b5060ff6040820135811690606083013516608083013560a0840135612430565b61042e612822565b610354612911565b6103e6600480360360208110156107b157600080fd5b50356001600160a01b0316612972565b6107de600480360360208110156107d757600080fd5b50356129d1565b604051808660038111156107ee57fe5b8152602001858152602001846001600160a01b03168152602001838152602001826001600160a01b031681526020019550505050505060405180910390f35b61042e6004803603604081101561084357600080fd5b506001600160a01b0381351690602001351515612ca5565b6108816004803603602081101561087157600080fd5b50356001600160a01b0316612daa565b6040805160ff9092168252519081900360200190f35b6104c5612e0c565b61042e600480360360808110156108b557600080fd5b6001600160a01b038235811692602081013590911691604082013591908101906080810160608201356401000000008111156108f057600080fd5b82018360208201111561090257600080fd5b8035906020019184600183028401116401000000008311171561092457600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550612e12945050505050565b6109826004803603602081101561097b57600080fd5b5035612e70565b60405180856001600160a01b03168152602001848152602001836001600160a01b031681526020018260ff16815260200194505050505060405180910390f35b610354600480360360208110156109d857600080fd5b5035612eb9565b61046b600480360360a08110156109f557600080fd5b5060ff6040820135811690606083013516608083013561313c565b6108816133c6565b6103e66133cb565b61033860048036036040811015610a3657600080fd5b506001600160a01b03813581169160200135166133e3565b6104c5600480360360a0811015610a6457600080fd5b506001600160a01b038135169060ff6020820135169060408101359060608101359060800135613411565b61042e60048036036080811015610aa557600080fd5b5080359060208101359060408101359060600135613801565b6104c5613c81565b7fffffffff00000000000000000000000000000000000000000000000000000000811660009081526020819052604090205460ff165b919050565b60068054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610b8d5780601f10610b6257610100808354040283529160200191610b8d565b820191906000526020600020905b815481529060010190602001808311610b7057829003601f168201915b5050505050905090565b6000610ba282613ca5565b610bdd5760405162461bcd60e51b815260040180806020018281038252602c81526020018061543f602c913960400191505060405180910390fd5b506000908152600460205260409020546001600160a01b031690565b6000610c0482611b90565b9050806001600160a01b0316836001600160a01b03161415610c575760405162461bcd60e51b81526004018080602001828103825260218152602001806154e76021913960400191505060405180910390fd5b806001600160a01b0316610c69613cb2565b6001600160a01b03161480610c8a5750610c8a81610c85613cb2565b6133e3565b610cc55760405162461bcd60e51b815260040180806020018281038252603881526020018061536f6038913960400191505060405180910390fd5b610ccf8383613cb6565b505050565b6000806000734e3b31eb0e5cb73641ee1e65e7dcefe520ba3ef26001600160a01b03166321f8a7217f45786368616e67655261746573000000000000000000000000000000000000006040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015610d5157600080fd5b505afa158015610d65573d6000803e3d6000fd5b505050506040513d6020811015610d7b57600080fd5b505190506000610d8a88612daa565b90506000610d9789611b38565b905080881415610dee576040805162461bcd60e51b815260206004820152600f60248201527f757365206e6f726d616c20737761700000000000000000000000000000000000604482015290519081900360640190fd5b6000836001600160a01b031663654a60ac8a89856040518463ffffffff1660e01b815260040180848152602001838152602001828152602001935050505060206040518083038186803b158015610e4457600080fd5b505afa158015610e58573d6000803e3d6000fd5b505050506040513d6020811015610e6e57600080fd5b5051604080517fa95b089f00000000000000000000000000000000000000000000000000000000815260ff80871660048301528b16602482015260448101839052905191925082916001600160a01b038d169163a95b089f916064808301926020929190829003018186803b158015610ee657600080fd5b505afa158015610efa573d6000803e3d6000fd5b505050506040513d6020811015610f1057600080fd5b5051909b909a5098505050505050505050565b600082610f77576040805162461bcd60e51b815260206004820152601d60248201527f616d6f756e74206d7573742062652067726561746572207468616e2030000000604482015290519081900360640190fd5b6000610f8287611b38565b905080861415610fc35760405162461bcd60e51b81526004018080602001828103825260228152602001806152fb6022913960400191505060405180910390fd5b6000610fee7f0000000000000000000000000000000000000000000000000000000000000000613d3c565b9050806001600160a01b0316638129fc1c6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561102b57600080fd5b505af115801561103f573d6000803e3d6000fd5b5050505060006110836040518060800160405280846001600160a01b031681526020018581526020018b6001600160a01b031681526020018960ff16815250613df7565b6000818152600e60205260409020805460ff1916600217905590506110a83382613efe565b60006110b389611c81565b90506110ca6001600160a01b03821633308a61402c565b6110de6001600160a01b03821684896140b4565b85836001600160a01b031663775723ca8b8a886040518463ffffffff1660e01b8152600401808481526020018381526020018281526020019350505050602060405180830381600087803b15801561113557600080fd5b505af1158015611149573d6000803e3d6000fd5b505050506040513d602081101561115f57600080fd5b505110156111b4576040805162461bcd60e51b815260206004820181905260248201527f6d696e4d656469756d53796e7468416d6f756e74206e6f742072656163686564604482015290519081900360640190fd5b604080516001600160a01b038c168152602081018b905280820189905260ff8a1660608201529051839133917fa21c38f889cd13904eb94938d8d6589dfe0b0cfbb34a86b456aa93d80359355f9181900360800190a35098975050505050505050565b60006112236002614134565b905090565b600b60205260009081526040902080546001909101546001600160a01b039091169082565b7f000000000000000000000000000000000000000000000000000000000000000081565b61128261127c613cb2565b8261413f565b6112bd5760405162461bcd60e51b81526004018080602001828103825260318152602001806155086031913960400191505060405180910390fd5b610ccf8383836141db565b7f45786368616e676552617465730000000000000000000000000000000000000081565b6001600160a01b038216600090815260016020526040812061130e9083614327565b90505b92915050565b60001981565b610ccf83838360405180602001604052806000815250612e12565b600061134383611b90565b90506001600160a01b03811633146113a2576040805162461bcd60e51b815260206004820152600960248201527f6e6f74206f776e65720000000000000000000000000000000000000000000000604482015290519081900360640190fd5b60016000848152600e602052604090205460ff1660038111156113c157fe5b11611413576040805162461bcd60e51b815260206004820152600e60248201527f696e76616c6964206974656d4964000000000000000000000000000000000000604482015290519081900360640190fd5b61141b615112565b506000838152600c6020908152604091829020825160808101845281546001600160a01b039081168083526001840154948301859052600290930154908116948201949094527401000000000000000000000000000000000000000090930460ff16606084015261148b91614333565b600061149a8260200151611c81565b90506000816001600160a01b03166370a0823184600001516040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156114ef57600080fd5b505afa158015611503573d6000803e3d6000fd5b505050506040513d602081101561151957600080fd5b505185106115a65761152a866143cc565b506000858152600c6020908152604080832080547fffffffffffffffffffffffff00000000000000000000000000000000000000001681556001808201859055600290910180547fffffffffffffffffffffff000000000000000000000000000000000000000000169055600e909252909120805460ff191690555b8251604080517f934785b70000000000000000000000000000000000000000000000000000000081526001600160a01b03858116600483015287811660248301526044820189905284151560648301529151919092169163934785b791608480830192600092919082900301818387803b15801561162357600080fd5b505af1158015611637573d6000803e3d6000fd5b5050604080516001600160a01b0386168152602081018990528415158183015290518993503392507f21e5f2f8aec336e654683c109188a5e47a3728916cb4ea35bc2e973a13d3aed99181900360600190a3505050505050565b600a546001600160a01b031681565b6000806116ae600284614499565b509392505050565b60ff8281161061170d576040805162461bcd60e51b815260206004820152601260248201527f696e64657820697320746f6f206c617267650000000000000000000000000000604482015290519081900360640190fd5b6001600160a01b0383166000908152600f60205260409020805460ff161561177c576040805162461bcd60e51b815260206004820152601260248201527f506f6f6c20616c72656164792061646465640000000000000000000000000000604482015290519081900360640190fd5b6000846001600160a01b03166382b86600856040518263ffffffff1660e01b8152600401808260ff16815260200191505060206040518083038186803b1580156117c557600080fd5b505afa1580156117d9573d6000803e3d6000fd5b505050506040513d60208110156117ef57600080fd5b5051604080517fd4b83992000000000000000000000000000000000000000000000000000000008152905191925084916001600160a01b0384169163d4b83992916004808301926020929190829003018186803b15801561184f57600080fd5b505afa158015611863573d6000803e3d6000fd5b505050506040513d602081101561187957600080fd5b5051604080517fdbd06c8500000000000000000000000000000000000000000000000000000000815290516001600160a01b039092169163dbd06c8591600480820192602092909190829003018186803b1580156118d657600080fd5b505afa1580156118ea573d6000803e3d6000fd5b505050506040513d602081101561190057600080fd5b505114611954576040805162461bcd60e51b815260206004820152601a60248201527f63757272656e63794b657920646f6573206e6f74206d61746368000000000000604482015290519081900360640190fd5b815460ff1916600185810160ff16919091177fffffffffffffffffffffff0000000000000000000000000000000000000000ff166101006001600160a01b03841602178355820183905560006040519080825280602002602001820160405280156119c9578160200160208202803683370190505b5080516119e0916002850191602090910190615139565b5060005b60ff8181161015611ae05760008560ff168260ff161415611a06575081611a7f565b866001600160a01b03166382b86600836040518263ffffffff1660e01b8152600401808260ff16815260200191505060206040518083038186803b158015611a4d57600080fd5b505afa925050508015611a7257506040513d6020811015611a6d57600080fd5b505160015b611a7c5750611ae0565b90505b600284018054600181018255600091825260209091200180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038316908117909155611ad790886000196144b5565b506001016119e4565b506040805160ff86168152602081018590526001600160a01b03838116828401529151918716917f833c463701786828b452ddb35a89c3f0b5e679ca63d31801d8da6e7e8054c8f09181900360600190a25050505050565b6001600160a01b0381166000908152600f6020526040812060010154806113115760405162461bcd60e51b81526004018080602001828103825260228152602001806152b56022913960400191505060405180910390fd5b6000611311826040518060600160405280602981526020016153d1602991396002919061460f565b60098054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610b8d5780601f10610b6257610100808354040283529160200191610b8d565b60006001600160a01b038216611c605760405162461bcd60e51b815260040180806020018281038252602a8152602001806153a7602a913960400191505060405180910390fd5b6001600160a01b038216600090815260016020526040902061131190614134565b6000734e3b31eb0e5cb73641ee1e65e7dcefe520ba3ef26001600160a01b03166351456061836040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015611cdb57600080fd5b505afa158015611cef573d6000803e3d6000fd5b505050506040513d6020811015611d0557600080fd5b5051604080517fec55688900000000000000000000000000000000000000000000000000000000815290516001600160a01b039092169163ec55688991600480820192602092909190829003018186803b158015611d6257600080fd5b505afa158015611d76573d6000803e3d6000fd5b505050506040513d6020811015611d8c57600080fd5b505192915050565b600060016000848152600e602052604090205460ff166003811115611db557fe5b11611e07576040805162461bcd60e51b815260206004820152600e60248201527f696e76616c6964206974656d4964000000000000000000000000000000000000604482015290519081900360640190fd5b611e0f615112565b506000838152600c6020908152604091829020825160808101845281546001600160a01b0390811682526001830154938201939093526002909101549182169281018390527401000000000000000000000000000000000000000090910460ff1660608201529063a95b089f611e8482612daa565b8360600151866040518463ffffffff1660e01b8152600401808460ff1681526020018360ff168152602001828152602001935050505060206040518083038186803b158015611ed257600080fd5b505afa158015611ee6573d6000803e3d6000fd5b505050506040513d6020811015611efc57600080fd5b5051949350505050565b6000611f1182611b90565b90506001600160a01b0381163314611f70576040805162461bcd60e51b815260206004820152600960248201527f6e6f74206f776e65720000000000000000000000000000000000000000000000604482015290519081900360640190fd5b60016000838152600e602052604090205460ff166003811115611f8f57fe5b14611fe1576040805162461bcd60e51b815260206004820152600e60248201527f696e76616c6964206974656d4964000000000000000000000000000000000000604482015290519081900360640190fd5b611fe96151b6565b506000828152600b6020908152604091829020825180840190935280546001600160a01b031680845260019091015491830182905261202791614333565b60006120368260200151611c81565b9050612041846143cc565b6000848152600c6020908152604080832080547fffffffffffffffffffffffff00000000000000000000000000000000000000001681556001810184905560020180547fffffffffffffffffffffff000000000000000000000000000000000000000000169055600e8252808320805460ff19169055845181517f70a082310000000000000000000000000000000000000000000000000000000081526001600160a01b0391821660048201529151908516926370a082319260248082019391829003018186803b15801561211557600080fd5b505afa158015612129573d6000803e3d6000fd5b505050506040513d602081101561213f57600080fd5b50518351604080517f934785b70000000000000000000000000000000000000000000000000000000081526001600160a01b03868116600483015288811660248301526044820185905260016064830152915193945091169163934785b79160848082019260009290919082900301818387803b1580156121bf57600080fd5b505af11580156121d3573d6000803e3d6000fd5b5050604080516001600160a01b0386168082526020820186905281830152606081018590526001608082015290518893503392507f5044c8cd0fcfe21244aecba3091a52a10187be167694fb3b69dc02cd4ee0f6379181900360a00190a35050505050565b60008061224486612daa565b90506000866001600160a01b031663a95b089f8784876040518463ffffffff1660e01b8152600401808460ff1681526020018360ff168152602001828152602001935050505060206040518083038186803b1580156122a257600080fd5b505afa1580156122b6573d6000803e3d6000fd5b505050506040513d60208110156122cc57600080fd5b5051905060006122db88611b38565b90506000734e3b31eb0e5cb73641ee1e65e7dcefe520ba3ef26001600160a01b03166321f8a7217f45786368616e67655261746573000000000000000000000000000000000000006040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561235757600080fd5b505afa15801561236b573d6000803e3d6000fd5b505050506040513d602081101561238157600080fd5b5051604080517f654a60ac0000000000000000000000000000000000000000000000000000000081526004810185905260248101869052604481018a905290519192506001600160a01b0383169163654a60ac91606480820192602092909190829003018186803b1580156123f557600080fd5b505afa158015612409573d6000803e3d6000fd5b505050506040513d602081101561241f57600080fd5b50519450505050505b949350505050565b600082612484576040805162461bcd60e51b815260206004820152601d60248201527f616d6f756e74206d7573742062652067726561746572207468616e2030000000604482015290519081900360640190fd5b60006124af7f0000000000000000000000000000000000000000000000000000000000000000613d3c565b9050806001600160a01b0316638129fc1c6040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156124ec57600080fd5b505af1158015612500573d6000803e3d6000fd5b5050505060006125298860016002811061251657fe5b60200201356001600160a01b0316611b38565b905060006125856040518060800160405280856001600160a01b031681526020018481526020018b60016002811061255d57fe5b60200201356001600160a01b03166001600160a01b031681526020018960ff16815250613df7565b6000818152600e60205260409020805460ff1916600317905590506125aa3382613efe565b6001600160a01b038935166000818152600f60205260408120600201805460ff8c169081106125d557fe5b6000918252602090912001546001600160a01b031690506125f88133308b61402c565b506000816001600160a01b031663916955868b61261485612daa565b8b6000426040518663ffffffff1660e01b8152600401808660ff1681526020018560ff16815260200184815260200183815260200182815260200195505050505050602060405180830381600087803b15801561267057600080fd5b505af1158015612684573d6000803e3d6000fd5b505050506040513d602081101561269a57600080fd5b505190506126bc85826126ac85612972565b6001600160a01b031691906140b4565b86856001600160a01b031663775723ca6126d585611b38565b84886040518463ffffffff1660e01b8152600401808481526020018381526020018281526020019350505050602060405180830381600087803b15801561271b57600080fd5b505af115801561272f573d6000803e3d6000fd5b505050506040513d602081101561274557600080fd5b5051101561279a576040805162461bcd60e51b815260206004820181905260248201527f6d696e4d656469756d53796e7468416d6f756e74206e6f742072656163686564604482015290519081900360640190fd5b82336001600160a01b03167f9cb72339b25a9ccd60f0fa8704e7f991199f02bf9c80300dc82a75305fe04f028d8d8c8e604051808560026020028082843760008382015260ff968716601f909101601f19169092019182525060208101939093525090911660408083019190915251908190036060019150a350909998505050505050505050565b604080517f21f8a7210000000000000000000000000000000000000000000000000000000081527f45786368616e676572000000000000000000000000000000000000000000000060048201529051734e3b31eb0e5cb73641ee1e65e7dcefe520ba3ef2916321f8a721916024808301926020929190829003018186803b1580156128ac57600080fd5b505afa1580156128c0573d6000803e3d6000fd5b505050506040513d60208110156128d657600080fd5b5051600a80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03909216919091179055565b60078054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610b8d5780601f10610b6257610100808354040283529160200191610b8d565b6001600160a01b038082166000908152600f6020526040812054909161010090910416806113115760405162461bcd60e51b815260040180806020018281038252602381526020018061541c6023913960400191505060405180910390fd5b6000818152600e602052604081205460ff1690808080808560038111156129f457fe5b1415612a47576040805162461bcd60e51b815260206004820152600e60248201527f696e76616c6964206974656d4964000000000000000000000000000000000000604482015290519081900360640190fd5b6000806001876003811115612a5857fe5b1415612a955750506000868152600b6020526040902080546001909101546001600160a01b0390911690612a8b81611c81565b9450849250612b69565b612a9d615112565b5050506000868152600c6020908152604091829020825160808101845281546001600160a01b039081168083526001840154948301859052600290930154908116948201949094527401000000000000000000000000000000000000000090930460ff16606084015291612b1082611c81565b9550600f600082604001516001600160a01b03166001600160a01b03168152602001908152602001600020600201816060015160ff1681548110612b5057fe5b6000918252602090912001546001600160a01b03169350505b600a54604080517f059c29ec0000000000000000000000000000000000000000000000000000000081526001600160a01b038581166004830152602482018590529151919092169163059c29ec916044808301926020929190829003018186803b158015612bd657600080fd5b505afa158015612bea573d6000803e3d6000fd5b505050506040513d6020811015612c0057600080fd5b5051604080517f70a082310000000000000000000000000000000000000000000000000000000081526001600160a01b0385811660048301529151929850908716916370a0823191602480820192602092909190829003018186803b158015612c6857600080fd5b505afa158015612c7c573d6000803e3d6000fd5b505050506040513d6020811015612c9257600080fd5b5051969895975093959491935090915050565b612cad613cb2565b6001600160a01b0316826001600160a01b03161415612d13576040805162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604482015290519081900360640190fd5b8060056000612d20613cb2565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff191692151592909217909155612d64613cb2565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405180821515815260200191505060405180910390a35050565b6001600160a01b0381166000908152600f602052604081205460ff1680612e025760405162461bcd60e51b81526004018080602001828103825260248152602001806154c36024913960400191505060405180910390fd5b6000190192915050565b600d5481565b612e23612e1d613cb2565b8361413f565b612e5e5760405162461bcd60e51b81526004018080602001828103825260318152602001806155086031913960400191505060405180910390fd5b612e6a84848484614626565b50505050565b600c602052600090815260409020805460018201546002909201546001600160a01b03918216929181169074010000000000000000000000000000000000000000900460ff1684565b6060612ec482613ca5565b612eff5760405162461bcd60e51b815260040180806020018281038252602f815260200180615494602f913960400191505060405180910390fd5b60008281526008602090815260409182902080548351601f6002600019610100600186161502019093169290920491820184900484028101840190945280845260609392830182828015612f945780601f10612f6957610100808354040283529160200191612f94565b820191906000526020600020905b815481529060010190602001808311612f7757829003601f168201915b505050505090506060612fa5611bb8565b9050805160001415612fb957509050610afc565b81511561307a5780826040516020018083805190602001908083835b60208310612ff45780518252601f199092019160209182019101612fd5565b51815160209384036101000a600019018019909216911617905285519190930192850191508083835b6020831061303c5780518252601f19909201916020918201910161301d565b6001836020036101000a0380198251168184511680821785525050505050509050019250505060405160208183030381529060405292505050610afc565b8061308485614678565b6040516020018083805190602001908083835b602083106130b65780518252601f199092019160209182019101613097565b51815160209384036101000a600019018019909216911617905285519190930192850191508083835b602083106130fe5780518252601f1990920191602091820191016130df565b6001836020036101000a0380198251168184511680821785525050505050509050019250505060405160208183030381529060405292505050919050565b6000806000734e3b31eb0e5cb73641ee1e65e7dcefe520ba3ef26001600160a01b03166321f8a7217f45786368616e67655261746573000000000000000000000000000000000000006040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b1580156131b957600080fd5b505afa1580156131cd573d6000803e3d6000fd5b505050506040513d60208110156131e357600080fd5b5051905060006001600160a01b0388351663a95b089f886132138b855b60200201356001600160a01b0316612daa565b886040518463ffffffff1660e01b8152600401808460ff1681526020018360ff168152602001828152602001935050505060206040518083038186803b15801561325c57600080fd5b505afa158015613270573d6000803e3d6000fd5b505050506040513d602081101561328657600080fd5b5051905060006001600160a01b03831663654a60ac6132a58b84612516565b846132b18d6001612516565b6040518463ffffffff1660e01b815260040180848152602001838152602001828152602001935050505060206040518083038186803b1580156132f357600080fd5b505afa158015613307573d6000803e3d6000fd5b505050506040513d602081101561331d57600080fd5b50519050806001600160a01b0360208b01351663a95b089f6133408c6001613200565b8a856040518463ffffffff1660e01b8152600401808460ff1681526020018360ff168152602001828152602001935050505060206040518083038186803b15801561338a57600080fd5b505afa15801561339e573d6000803e3d6000fd5b505050506040513d60208110156133b457600080fd5b5051909a909950975050505050505050565b60ff81565b734e3b31eb0e5cb73641ee1e65e7dcefe520ba3ef281565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b600082613465576040805162461bcd60e51b815260206004820152601d60248201527f616d6f756e74206d7573742062652067726561746572207468616e2030000000604482015290519081900360640190fd5b60006134907f0000000000000000000000000000000000000000000000000000000000000000613d3c565b9050806001600160a01b0316638129fc1c6040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156134cd57600080fd5b505af11580156134e1573d6000803e3d6000fd5b50505050600061350d6040518060400160405280846001600160a01b0316815260200188815250614787565b6000818152600e60205260409020805460ff1916600117905590506135323382613efe565b6001600160a01b0388166000908152600f60205260408120600201805460ff8a1690811061355c57fe5b6000918252602090912001546001600160a01b0316905061357f8133308961402c565b604080517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015290516001600160a01b038316916370a08231916024808301926020929190829003018186803b1580156135de57600080fd5b505afa1580156135f2573d6000803e3d6000fd5b505050506040513d602081101561360857600080fd5b5051955060006001600160a01b038a1663916955868a6136278d612daa565b8a6000426040518663ffffffff1660e01b8152600401808660ff1681526020018560ff16815260200184815260200183815260200182815260200195505050505050602060405180830381600087803b15801561368357600080fd5b505af1158015613697573d6000803e3d6000fd5b505050506040513d60208110156136ad57600080fd5b505190506136bf84826126ac8d612972565b85846001600160a01b031663775723ca6136d88d611b38565b848c6040518463ffffffff1660e01b8152600401808481526020018381526020018281526020019350505050602060405180830381600087803b15801561371e57600080fd5b505af1158015613732573d6000803e3d6000fd5b505050506040513d602081101561374857600080fd5b5051101561379d576040805162461bcd60e51b815260206004820152601560248201527f6d696e416d6f756e74206e6f7420726561636865640000000000000000000000604482015290519081900360640190fd5b604080516001600160a01b038c16815260ff8b166020820152808201899052606081018a90529051849133917f305dca8d8466ac672b08bd22cbb17d3a12b15601bbd232a13ed2f8e85cde0fa99181900360800190a3509098975050505050505050565b82613853576040805162461bcd60e51b815260206004820152601d60248201527f616d6f756e74206d7573742062652067726561746572207468616e2030000000604482015290519081900360640190fd5b600061385e85611b90565b9050336001600160a01b038216146138bd576040805162461bcd60e51b815260206004820152600f60248201527f6d757374206f776e206974656d49640000000000000000000000000000000000604482015290519081900360640190fd5b60016000868152600e602052604090205460ff1660038111156138dc57fe5b1161392e576040805162461bcd60e51b815260206004820152600e60248201527f696e76616c6964206974656d4964000000000000000000000000000000000000604482015290519081900360640190fd5b613936615112565b506000858152600c6020908152604091829020825160808101845281546001600160a01b039081168083526001840154948301859052600290930154908116948201949094527401000000000000000000000000000000000000000090930460ff1660608401526139a691614333565b60006139b58260200151611c81565b90506000816001600160a01b03166370a0823184600001516040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015613a0a57600080fd5b505afa158015613a1e573d6000803e3d6000fd5b505050506040513d6020811015613a3457600080fd5b50518710613ac157613a45886143cc565b506000878152600c6020908152604080832080547fffffffffffffffffffffffff00000000000000000000000000000000000000001681556001808201859055600290910180547fffffffffffffffffffffff000000000000000000000000000000000000000000169055600e909252909120805460ff191690555b60008084600001516001600160a01b0316635a3f4b23866040015186613aea8960400151612daa565b60608a0151604080517fffffffff0000000000000000000000000000000000000000000000000000000060e088901b1681526001600160a01b039586166004820152938516602485015260ff928316604485015291166064830152608482018e905260a482018d905260c482018c9052918a1660e4820152815161010480830193928290030181600087803b158015613b8257600080fd5b505af1158015613b96573d6000803e3d6000fd5b505050506040513d6040811015613bac57600080fd5b50805160209091015190925090508215613c185784600001516001600160a01b03166383197ef06040518163ffffffff1660e01b8152600401600060405180830381600087803b158015613bff57600080fd5b505af1158015613c13573d6000803e3d6000fd5b505050505b604080516001600160a01b038681168252602082018c905284168183015260608101839052841515608082015290518b9133917f5044c8cd0fcfe21244aecba3091a52a10187be167694fb3b69dc02cd4ee0f6379181900360a00190a350505050505050505050565b7f45786368616e676572000000000000000000000000000000000000000000000081565b6000611311600283614828565b3390565b600081815260046020526040902080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0384169081179091558190613d0382611b90565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60006040517f3d602d80600a3d3981f3363d3d373d3d3d363d7300000000000000000000000081528260601b60148201527f5af43d82803e903d91602b57fd5bf3000000000000000000000000000000000060288201526037816000f09150506001600160a01b038116610afc576040805162461bcd60e51b815260206004820152601660248201527f455243313136373a20637265617465206661696c656400000000000000000000604482015290519081900360640190fd5b6000600019600d5410613e3b5760405162461bcd60e51b81526004018080602001828103825260238152602001806155996023913960400191505060405180910390fd5b50600d80546000908152600c6020908152604091829020845181546001600160a01b039182167fffffffffffffffffffffffff0000000000000000000000000000000000000000918216178355928601516001808401919091559386015160029092018054606088015160ff1674010000000000000000000000000000000000000000027fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff94909316941693909317919091161790558154908101909155919050565b6001600160a01b038216613f59576040805162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015290519081900360640190fd5b613f6281613ca5565b15613fb4576040805162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015290519081900360640190fd5b613fc060008383610ccf565b6001600160a01b0382166000908152600160205260409020613fe29082614834565b50613fef60028284614840565b5060405181906001600160a01b038416906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd00000000000000000000000000000000000000000000000000000000179052612e6a908590614856565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb00000000000000000000000000000000000000000000000000000000179052610ccf908490614856565b600061131182614907565b600061414a82613ca5565b6141855760405162461bcd60e51b815260040180806020018281038252602c815260200180615343602c913960400191505060405180910390fd5b600061419083611b90565b9050806001600160a01b0316846001600160a01b031614806141cb5750836001600160a01b03166141c084610b97565b6001600160a01b0316145b80612428575061242881856133e3565b826001600160a01b03166141ee82611b90565b6001600160a01b0316146142335760405162461bcd60e51b815260040180806020018281038252602981526020018061546b6029913960400191505060405180910390fd5b6001600160a01b0382166142785760405162461bcd60e51b81526004018080602001828103825260248152602001806152d76024913960400191505060405180910390fd5b614283838383610ccf565b61428e600082613cb6565b6001600160a01b03831660009081526001602052604090206142b0908261490b565b506001600160a01b03821660009081526001602052604090206142d39082614834565b506142e060028284614840565b5080826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b600061130e8383614917565b600a54604080517f1b16802c0000000000000000000000000000000000000000000000000000000081526001600160a01b0385811660048301526024820185905291519190921691631b16802c9160448083019260609291908290030181600087803b1580156143a257600080fd5b505af11580156143b6573d6000803e3d6000fd5b505050506040513d6060811015612e6a57600080fd5b60006143d782611b90565b90506143e581600084610ccf565b6143f0600083613cb6565b600082815260086020526040902054600260001961010060018416150201909116041561442e57600082815260086020526040812061442e916151cd565b6001600160a01b0381166000908152600160205260409020614450908361490b565b5061445c60028361497b565b5060405182906000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b60008080806144a88686614987565b9097909650945050505050565b8015806145545750604080517fdd62ed3e0000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b15801561452657600080fd5b505afa15801561453a573d6000803e3d6000fd5b505050506040513d602081101561455057600080fd5b5051155b61458f5760405162461bcd60e51b81526004018080602001828103825260368152602001806155636036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b300000000000000000000000000000000000000000000000000000000179052610ccf908490614856565b600061461c848484614a02565b90505b9392505050565b6146318484846141db565b61463d84848484614acc565b612e6a5760405162461bcd60e51b81526004018080602001828103825260328152602001806152836032913960400191505060405180910390fd5b6060816146b9575060408051808201909152600181527f30000000000000000000000000000000000000000000000000000000000000006020820152610afc565b8160005b81156146d157600101600a820491506146bd565b60608167ffffffffffffffff811180156146ea57600080fd5b506040519080825280601f01601f191660200182016040528015614715576020820181803683370190505b50859350905060001982015b831561477e57600a840660300160f81b8282806001900393508151811061474457fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a84049350614721565b50949350505050565b6000600019600d54106147cb5760405162461bcd60e51b81526004018080602001828103825260238152602001806155996023913960400191505060405180910390fd5b50600d80546000908152600b60209081526040909120835181547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b039091161781559201516001928301558054918201905590565b600061130e8383614ca8565b600061130e8383614cc0565b600061461c84846001600160a01b038516614d0a565b60606148ab826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316614da19092919063ffffffff16565b805190915015610ccf578080602001905160208110156148ca57600080fd5b5051610ccf5760405162461bcd60e51b815260040180806020018281038252602a815260200180615539602a913960400191505060405180910390fd5b5490565b600061130e8383614db0565b815460009082106149595760405162461bcd60e51b81526004018080602001828103825260228152602001806152616022913960400191505060405180910390fd5b82600001828154811061496857fe5b9060005260206000200154905092915050565b600061130e8383614e76565b8154600090819083106149cb5760405162461bcd60e51b81526004018080602001828103825260228152602001806153fa6022913960400191505060405180910390fd5b60008460000184815481106149dc57fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b60008281526001840160205260408120548281614a9d5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015614a62578181015183820152602001614a4a565b50505050905090810190601f168015614a8f5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50846000016001820381548110614ab057fe5b9060005260206000209060020201600101549150509392505050565b6000614ae0846001600160a01b0316614f4a565b614aec57506001612428565b6060614c3d7f150b7a0200000000000000000000000000000000000000000000000000000000614b1a613cb2565b88878760405160240180856001600160a01b03168152602001846001600160a01b0316815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015614b81578181015183820152602001614b69565b50505050905090810190601f168015614bae5780820380516001836020036101000a031916815260200191505b5095505050505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051806060016040528060328152602001615283603291396001600160a01b0388169190614da1565b90506000818060200190516020811015614c5657600080fd5b50517fffffffff00000000000000000000000000000000000000000000000000000000167f150b7a02000000000000000000000000000000000000000000000000000000001492505050949350505050565b60009081526001919091016020526040902054151590565b6000614ccc8383614ca8565b614d0257508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155611311565b506000611311565b600082815260018401602052604081205480614d6f57505060408051808201825283815260208082018481528654600181810189556000898152848120955160029093029095019182559151908201558654868452818801909252929091205561461f565b82856000016001830381548110614d8257fe5b906000526020600020906002020160010181905550600091505061461f565b606061461c8484600085614f50565b60008181526001830160205260408120548015614e6c5783546000198083019190810190600090879083908110614de357fe5b9060005260206000200154905080876000018481548110614e0057fe5b600091825260208083209091019290925582815260018981019092526040902090840190558654879080614e3057fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050611311565b6000915050611311565b60008181526001830160205260408120548015614e6c5783546000198083019190810190600090879083908110614ea957fe5b9060005260206000209060020201905080876000018481548110614ec957fe5b600091825260208083208454600290930201918255600193840154918401919091558354825289830190526040902090840190558654879080614f0857fe5b60008281526020808220600260001990940193840201828155600190810183905592909355888152898201909252604082209190915594506113119350505050565b3b151590565b606082471015614f915760405162461bcd60e51b815260040180806020018281038252602681526020018061531d6026913960400191505060405180910390fd5b614f9a85614f4a565b614feb576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b6020831061502a5780518252601f19909201916020918201910161500b565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d806000811461508c576040519150601f19603f3d011682016040523d82523d6000602084013e615091565b606091505b50915091506150a18282866150ac565b979650505050505050565b606083156150bb57508161461f565b8251156150cb5782518084602001fd5b60405162461bcd60e51b8152602060048201818152845160248401528451859391928392604401919085019080838360008315614a62578181015183820152602001614a4a565b60408051608081018252600080825260208201819052918101829052606081019190915290565b8280548282559060005260206000209081019282156151a6579160200282015b828111156151a657825182547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03909116178255602090920191600190910190615159565b506151b2929150615214565b5090565b604080518082019091526000808252602082015290565b50805460018160011615610100020316600290046000825580601f106151f35750615211565b601f016020900490600052602060002090810190615211919061524b565b50565b5b808211156151b25780547fffffffffffffffffffffffff0000000000000000000000000000000000000000168155600101615215565b5b808211156151b2576000815560010161524c56fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e64734552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e74657273796e7468206b6579206e6f7420666f756e6420666f7220676976656e20706f6f6c4552433732313a207472616e7366657220746f20746865207a65726f206164647265737373796e746820697320737570706f7274656420766961206e6f726d616c2073776170416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c4552433732313a206f70657261746f7220717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76652063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f76656420666f7220616c6c4552433732313a2062616c616e636520717565727920666f7220746865207a65726f20616464726573734552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656e456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e647373796e74682061646472206e6f7420666f756e6420666f7220676976656e20706f6f6c4552433732313a20617070726f76656420717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a207472616e73666572206f6620746f6b656e2074686174206973206e6f74206f776e4552433732314d657461646174613a2055524920717565727920666f72206e6f6e6578697374656e7420746f6b656e73796e746820696e646578206e6f7420666f756e6420666f7220676976656e20706f6f6c4552433732313a20617070726f76616c20746f2063757272656e74206f776e65724552433732313a207472616e736665722063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f7665645361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e636570656e64696e6753776170734c656e6774682072656163686564206d61782073697a65a26469706673582212200c470228fcd7f605e29d2ebe6cb2642e97e8e7343c711b5457593e7d4fdef68864736f6c634300060c0033000000000000000000000000df815ea6b066ac9f3107d8863a6c19aa2a5d24d3

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106102f45760003560e01c80637d3913ca11610191578063b6bd8dcb116100e3578063d488743711610097578063ea4e9eb611610071578063ea4e9eb614610a4e578063ee1e709014610a8f578063fce3ee4114610abe576102f4565b8063d488743714610a10578063e504e7aa14610a18578063e985e9c514610a20576102f4565b8063c05b1bd4116100c8578063c05b1bd414610965578063c87b56dd146109c2578063cbc3c495146109df576102f4565b8063b6bd8dcb14610897578063b88d4fde1461089f576102f4565b8063892e196d11610145578063a042d45f1161011f578063a042d45f146107c1578063a22cb4651461082d578063b04a74ab1461085b576102f4565b8063892e196d1461078b57806395d89b4114610793578063a000a45d1461079b576102f4565b80638501259c116101765780638501259c146106fd578063859c9e6d1461071a57806387911b0d14610755576102f4565b80637d3913ca146106bd5780637fabc495146106da576102f4565b80632f745c591161024a5780634f6ccce7116101fe5780636352211e116101d85780636352211e146106725780636c0360eb1461068f57806370a0823114610697576102f4565b80634f6ccce7146105fa5780635af0feb3146106175780636141db901461064c576102f4565b806342842e0e1161022f57806342842e0e14610599578063441a3e70146105cf5780634d12fca4146105f2576102f4565b80632f745c591461056557806333a581d214610591576102f4565b80630aa07ba3116102ac578063218a89ad11610286578063218a89ad1461051f57806323b872dd1461052757806326cdb6d81461055d576102f4565b80630aa07ba31461048457806318160ddd146104d757806318f0595c146104df576102f4565b8063081812fc116102dd578063081812fc146103c9578063095ea7b3146104025780630a82660614610430576102f4565b806301ffc9a7146102f957806306fdde031461034c575b600080fd5b6103386004803603602081101561030f57600080fd5b50357fffffffff0000000000000000000000000000000000000000000000000000000016610ac6565b604080519115158252519081900360200190f35b610354610b01565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561038e578181015183820152602001610376565b50505050905090810190601f1680156103bb5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103e6600480360360208110156103df57600080fd5b5035610b97565b604080516001600160a01b039092168252519081900360200190f35b61042e6004803603604081101561041857600080fd5b506001600160a01b038135169060200135610bf9565b005b61046b6004803603608081101561044657600080fd5b506001600160a01b038135169060208101359060ff6040820135169060600135610cd4565b6040805192835260208301919091528051918290030190f35b6104c5600480360360a081101561049a57600080fd5b506001600160a01b038135169060208101359060ff6040820135169060608101359060800135610f23565b60408051918252519081900360200190f35b6104c5611217565b6104fc600480360360208110156104f557600080fd5b5035611228565b604080516001600160a01b03909316835260208301919091528051918290030190f35b6103e661124d565b61042e6004803603606081101561053d57600080fd5b506001600160a01b03813581169160208101359091169060400135611271565b6104c56112c8565b6104c56004803603604081101561057b57600080fd5b506001600160a01b0381351690602001356112ec565b6104c5611317565b61042e600480360360608110156105af57600080fd5b506001600160a01b0381358116916020810135909116906040013561131d565b61042e600480360360408110156105e557600080fd5b5080359060200135611338565b6103e6611691565b6104c56004803603602081101561061057600080fd5b50356116a0565b61042e6004803603606081101561062d57600080fd5b506001600160a01b038135169060ff60208201351690604001356116b6565b6104c56004803603602081101561066257600080fd5b50356001600160a01b0316611b38565b6103e66004803603602081101561068857600080fd5b5035611b90565b610354611bb8565b6104c5600480360360208110156106ad57600080fd5b50356001600160a01b0316611c19565b6103e6600480360360208110156106d357600080fd5b5035611c81565b6104c5600480360360408110156106f057600080fd5b5080359060200135611d94565b61042e6004803603602081101561071357600080fd5b5035611f06565b6104c56004803603608081101561073057600080fd5b506001600160a01b038135169060ff6020820135169060408101359060600135612238565b6104c5600480360360c081101561076b57600080fd5b5060ff6040820135811690606083013516608083013560a0840135612430565b61042e612822565b610354612911565b6103e6600480360360208110156107b157600080fd5b50356001600160a01b0316612972565b6107de600480360360208110156107d757600080fd5b50356129d1565b604051808660038111156107ee57fe5b8152602001858152602001846001600160a01b03168152602001838152602001826001600160a01b031681526020019550505050505060405180910390f35b61042e6004803603604081101561084357600080fd5b506001600160a01b0381351690602001351515612ca5565b6108816004803603602081101561087157600080fd5b50356001600160a01b0316612daa565b6040805160ff9092168252519081900360200190f35b6104c5612e0c565b61042e600480360360808110156108b557600080fd5b6001600160a01b038235811692602081013590911691604082013591908101906080810160608201356401000000008111156108f057600080fd5b82018360208201111561090257600080fd5b8035906020019184600183028401116401000000008311171561092457600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550612e12945050505050565b6109826004803603602081101561097b57600080fd5b5035612e70565b60405180856001600160a01b03168152602001848152602001836001600160a01b031681526020018260ff16815260200194505050505060405180910390f35b610354600480360360208110156109d857600080fd5b5035612eb9565b61046b600480360360a08110156109f557600080fd5b5060ff6040820135811690606083013516608083013561313c565b6108816133c6565b6103e66133cb565b61033860048036036040811015610a3657600080fd5b506001600160a01b03813581169160200135166133e3565b6104c5600480360360a0811015610a6457600080fd5b506001600160a01b038135169060ff6020820135169060408101359060608101359060800135613411565b61042e60048036036080811015610aa557600080fd5b5080359060208101359060408101359060600135613801565b6104c5613c81565b7fffffffff00000000000000000000000000000000000000000000000000000000811660009081526020819052604090205460ff165b919050565b60068054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610b8d5780601f10610b6257610100808354040283529160200191610b8d565b820191906000526020600020905b815481529060010190602001808311610b7057829003601f168201915b5050505050905090565b6000610ba282613ca5565b610bdd5760405162461bcd60e51b815260040180806020018281038252602c81526020018061543f602c913960400191505060405180910390fd5b506000908152600460205260409020546001600160a01b031690565b6000610c0482611b90565b9050806001600160a01b0316836001600160a01b03161415610c575760405162461bcd60e51b81526004018080602001828103825260218152602001806154e76021913960400191505060405180910390fd5b806001600160a01b0316610c69613cb2565b6001600160a01b03161480610c8a5750610c8a81610c85613cb2565b6133e3565b610cc55760405162461bcd60e51b815260040180806020018281038252603881526020018061536f6038913960400191505060405180910390fd5b610ccf8383613cb6565b505050565b6000806000734e3b31eb0e5cb73641ee1e65e7dcefe520ba3ef26001600160a01b03166321f8a7217f45786368616e67655261746573000000000000000000000000000000000000006040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015610d5157600080fd5b505afa158015610d65573d6000803e3d6000fd5b505050506040513d6020811015610d7b57600080fd5b505190506000610d8a88612daa565b90506000610d9789611b38565b905080881415610dee576040805162461bcd60e51b815260206004820152600f60248201527f757365206e6f726d616c20737761700000000000000000000000000000000000604482015290519081900360640190fd5b6000836001600160a01b031663654a60ac8a89856040518463ffffffff1660e01b815260040180848152602001838152602001828152602001935050505060206040518083038186803b158015610e4457600080fd5b505afa158015610e58573d6000803e3d6000fd5b505050506040513d6020811015610e6e57600080fd5b5051604080517fa95b089f00000000000000000000000000000000000000000000000000000000815260ff80871660048301528b16602482015260448101839052905191925082916001600160a01b038d169163a95b089f916064808301926020929190829003018186803b158015610ee657600080fd5b505afa158015610efa573d6000803e3d6000fd5b505050506040513d6020811015610f1057600080fd5b5051909b909a5098505050505050505050565b600082610f77576040805162461bcd60e51b815260206004820152601d60248201527f616d6f756e74206d7573742062652067726561746572207468616e2030000000604482015290519081900360640190fd5b6000610f8287611b38565b905080861415610fc35760405162461bcd60e51b81526004018080602001828103825260228152602001806152fb6022913960400191505060405180910390fd5b6000610fee7f000000000000000000000000df815ea6b066ac9f3107d8863a6c19aa2a5d24d3613d3c565b9050806001600160a01b0316638129fc1c6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561102b57600080fd5b505af115801561103f573d6000803e3d6000fd5b5050505060006110836040518060800160405280846001600160a01b031681526020018581526020018b6001600160a01b031681526020018960ff16815250613df7565b6000818152600e60205260409020805460ff1916600217905590506110a83382613efe565b60006110b389611c81565b90506110ca6001600160a01b03821633308a61402c565b6110de6001600160a01b03821684896140b4565b85836001600160a01b031663775723ca8b8a886040518463ffffffff1660e01b8152600401808481526020018381526020018281526020019350505050602060405180830381600087803b15801561113557600080fd5b505af1158015611149573d6000803e3d6000fd5b505050506040513d602081101561115f57600080fd5b505110156111b4576040805162461bcd60e51b815260206004820181905260248201527f6d696e4d656469756d53796e7468416d6f756e74206e6f742072656163686564604482015290519081900360640190fd5b604080516001600160a01b038c168152602081018b905280820189905260ff8a1660608201529051839133917fa21c38f889cd13904eb94938d8d6589dfe0b0cfbb34a86b456aa93d80359355f9181900360800190a35098975050505050505050565b60006112236002614134565b905090565b600b60205260009081526040902080546001909101546001600160a01b039091169082565b7f000000000000000000000000df815ea6b066ac9f3107d8863a6c19aa2a5d24d381565b61128261127c613cb2565b8261413f565b6112bd5760405162461bcd60e51b81526004018080602001828103825260318152602001806155086031913960400191505060405180910390fd5b610ccf8383836141db565b7f45786368616e676552617465730000000000000000000000000000000000000081565b6001600160a01b038216600090815260016020526040812061130e9083614327565b90505b92915050565b60001981565b610ccf83838360405180602001604052806000815250612e12565b600061134383611b90565b90506001600160a01b03811633146113a2576040805162461bcd60e51b815260206004820152600960248201527f6e6f74206f776e65720000000000000000000000000000000000000000000000604482015290519081900360640190fd5b60016000848152600e602052604090205460ff1660038111156113c157fe5b11611413576040805162461bcd60e51b815260206004820152600e60248201527f696e76616c6964206974656d4964000000000000000000000000000000000000604482015290519081900360640190fd5b61141b615112565b506000838152600c6020908152604091829020825160808101845281546001600160a01b039081168083526001840154948301859052600290930154908116948201949094527401000000000000000000000000000000000000000090930460ff16606084015261148b91614333565b600061149a8260200151611c81565b90506000816001600160a01b03166370a0823184600001516040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156114ef57600080fd5b505afa158015611503573d6000803e3d6000fd5b505050506040513d602081101561151957600080fd5b505185106115a65761152a866143cc565b506000858152600c6020908152604080832080547fffffffffffffffffffffffff00000000000000000000000000000000000000001681556001808201859055600290910180547fffffffffffffffffffffff000000000000000000000000000000000000000000169055600e909252909120805460ff191690555b8251604080517f934785b70000000000000000000000000000000000000000000000000000000081526001600160a01b03858116600483015287811660248301526044820189905284151560648301529151919092169163934785b791608480830192600092919082900301818387803b15801561162357600080fd5b505af1158015611637573d6000803e3d6000fd5b5050604080516001600160a01b0386168152602081018990528415158183015290518993503392507f21e5f2f8aec336e654683c109188a5e47a3728916cb4ea35bc2e973a13d3aed99181900360600190a3505050505050565b600a546001600160a01b031681565b6000806116ae600284614499565b509392505050565b60ff8281161061170d576040805162461bcd60e51b815260206004820152601260248201527f696e64657820697320746f6f206c617267650000000000000000000000000000604482015290519081900360640190fd5b6001600160a01b0383166000908152600f60205260409020805460ff161561177c576040805162461bcd60e51b815260206004820152601260248201527f506f6f6c20616c72656164792061646465640000000000000000000000000000604482015290519081900360640190fd5b6000846001600160a01b03166382b86600856040518263ffffffff1660e01b8152600401808260ff16815260200191505060206040518083038186803b1580156117c557600080fd5b505afa1580156117d9573d6000803e3d6000fd5b505050506040513d60208110156117ef57600080fd5b5051604080517fd4b83992000000000000000000000000000000000000000000000000000000008152905191925084916001600160a01b0384169163d4b83992916004808301926020929190829003018186803b15801561184f57600080fd5b505afa158015611863573d6000803e3d6000fd5b505050506040513d602081101561187957600080fd5b5051604080517fdbd06c8500000000000000000000000000000000000000000000000000000000815290516001600160a01b039092169163dbd06c8591600480820192602092909190829003018186803b1580156118d657600080fd5b505afa1580156118ea573d6000803e3d6000fd5b505050506040513d602081101561190057600080fd5b505114611954576040805162461bcd60e51b815260206004820152601a60248201527f63757272656e63794b657920646f6573206e6f74206d61746368000000000000604482015290519081900360640190fd5b815460ff1916600185810160ff16919091177fffffffffffffffffffffff0000000000000000000000000000000000000000ff166101006001600160a01b03841602178355820183905560006040519080825280602002602001820160405280156119c9578160200160208202803683370190505b5080516119e0916002850191602090910190615139565b5060005b60ff8181161015611ae05760008560ff168260ff161415611a06575081611a7f565b866001600160a01b03166382b86600836040518263ffffffff1660e01b8152600401808260ff16815260200191505060206040518083038186803b158015611a4d57600080fd5b505afa925050508015611a7257506040513d6020811015611a6d57600080fd5b505160015b611a7c5750611ae0565b90505b600284018054600181018255600091825260209091200180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038316908117909155611ad790886000196144b5565b506001016119e4565b506040805160ff86168152602081018590526001600160a01b03838116828401529151918716917f833c463701786828b452ddb35a89c3f0b5e679ca63d31801d8da6e7e8054c8f09181900360600190a25050505050565b6001600160a01b0381166000908152600f6020526040812060010154806113115760405162461bcd60e51b81526004018080602001828103825260228152602001806152b56022913960400191505060405180910390fd5b6000611311826040518060600160405280602981526020016153d1602991396002919061460f565b60098054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610b8d5780601f10610b6257610100808354040283529160200191610b8d565b60006001600160a01b038216611c605760405162461bcd60e51b815260040180806020018281038252602a8152602001806153a7602a913960400191505060405180910390fd5b6001600160a01b038216600090815260016020526040902061131190614134565b6000734e3b31eb0e5cb73641ee1e65e7dcefe520ba3ef26001600160a01b03166351456061836040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015611cdb57600080fd5b505afa158015611cef573d6000803e3d6000fd5b505050506040513d6020811015611d0557600080fd5b5051604080517fec55688900000000000000000000000000000000000000000000000000000000815290516001600160a01b039092169163ec55688991600480820192602092909190829003018186803b158015611d6257600080fd5b505afa158015611d76573d6000803e3d6000fd5b505050506040513d6020811015611d8c57600080fd5b505192915050565b600060016000848152600e602052604090205460ff166003811115611db557fe5b11611e07576040805162461bcd60e51b815260206004820152600e60248201527f696e76616c6964206974656d4964000000000000000000000000000000000000604482015290519081900360640190fd5b611e0f615112565b506000838152600c6020908152604091829020825160808101845281546001600160a01b0390811682526001830154938201939093526002909101549182169281018390527401000000000000000000000000000000000000000090910460ff1660608201529063a95b089f611e8482612daa565b8360600151866040518463ffffffff1660e01b8152600401808460ff1681526020018360ff168152602001828152602001935050505060206040518083038186803b158015611ed257600080fd5b505afa158015611ee6573d6000803e3d6000fd5b505050506040513d6020811015611efc57600080fd5b5051949350505050565b6000611f1182611b90565b90506001600160a01b0381163314611f70576040805162461bcd60e51b815260206004820152600960248201527f6e6f74206f776e65720000000000000000000000000000000000000000000000604482015290519081900360640190fd5b60016000838152600e602052604090205460ff166003811115611f8f57fe5b14611fe1576040805162461bcd60e51b815260206004820152600e60248201527f696e76616c6964206974656d4964000000000000000000000000000000000000604482015290519081900360640190fd5b611fe96151b6565b506000828152600b6020908152604091829020825180840190935280546001600160a01b031680845260019091015491830182905261202791614333565b60006120368260200151611c81565b9050612041846143cc565b6000848152600c6020908152604080832080547fffffffffffffffffffffffff00000000000000000000000000000000000000001681556001810184905560020180547fffffffffffffffffffffff000000000000000000000000000000000000000000169055600e8252808320805460ff19169055845181517f70a082310000000000000000000000000000000000000000000000000000000081526001600160a01b0391821660048201529151908516926370a082319260248082019391829003018186803b15801561211557600080fd5b505afa158015612129573d6000803e3d6000fd5b505050506040513d602081101561213f57600080fd5b50518351604080517f934785b70000000000000000000000000000000000000000000000000000000081526001600160a01b03868116600483015288811660248301526044820185905260016064830152915193945091169163934785b79160848082019260009290919082900301818387803b1580156121bf57600080fd5b505af11580156121d3573d6000803e3d6000fd5b5050604080516001600160a01b0386168082526020820186905281830152606081018590526001608082015290518893503392507f5044c8cd0fcfe21244aecba3091a52a10187be167694fb3b69dc02cd4ee0f6379181900360a00190a35050505050565b60008061224486612daa565b90506000866001600160a01b031663a95b089f8784876040518463ffffffff1660e01b8152600401808460ff1681526020018360ff168152602001828152602001935050505060206040518083038186803b1580156122a257600080fd5b505afa1580156122b6573d6000803e3d6000fd5b505050506040513d60208110156122cc57600080fd5b5051905060006122db88611b38565b90506000734e3b31eb0e5cb73641ee1e65e7dcefe520ba3ef26001600160a01b03166321f8a7217f45786368616e67655261746573000000000000000000000000000000000000006040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561235757600080fd5b505afa15801561236b573d6000803e3d6000fd5b505050506040513d602081101561238157600080fd5b5051604080517f654a60ac0000000000000000000000000000000000000000000000000000000081526004810185905260248101869052604481018a905290519192506001600160a01b0383169163654a60ac91606480820192602092909190829003018186803b1580156123f557600080fd5b505afa158015612409573d6000803e3d6000fd5b505050506040513d602081101561241f57600080fd5b50519450505050505b949350505050565b600082612484576040805162461bcd60e51b815260206004820152601d60248201527f616d6f756e74206d7573742062652067726561746572207468616e2030000000604482015290519081900360640190fd5b60006124af7f000000000000000000000000df815ea6b066ac9f3107d8863a6c19aa2a5d24d3613d3c565b9050806001600160a01b0316638129fc1c6040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156124ec57600080fd5b505af1158015612500573d6000803e3d6000fd5b5050505060006125298860016002811061251657fe5b60200201356001600160a01b0316611b38565b905060006125856040518060800160405280856001600160a01b031681526020018481526020018b60016002811061255d57fe5b60200201356001600160a01b03166001600160a01b031681526020018960ff16815250613df7565b6000818152600e60205260409020805460ff1916600317905590506125aa3382613efe565b6001600160a01b038935166000818152600f60205260408120600201805460ff8c169081106125d557fe5b6000918252602090912001546001600160a01b031690506125f88133308b61402c565b506000816001600160a01b031663916955868b61261485612daa565b8b6000426040518663ffffffff1660e01b8152600401808660ff1681526020018560ff16815260200184815260200183815260200182815260200195505050505050602060405180830381600087803b15801561267057600080fd5b505af1158015612684573d6000803e3d6000fd5b505050506040513d602081101561269a57600080fd5b505190506126bc85826126ac85612972565b6001600160a01b031691906140b4565b86856001600160a01b031663775723ca6126d585611b38565b84886040518463ffffffff1660e01b8152600401808481526020018381526020018281526020019350505050602060405180830381600087803b15801561271b57600080fd5b505af115801561272f573d6000803e3d6000fd5b505050506040513d602081101561274557600080fd5b5051101561279a576040805162461bcd60e51b815260206004820181905260248201527f6d696e4d656469756d53796e7468416d6f756e74206e6f742072656163686564604482015290519081900360640190fd5b82336001600160a01b03167f9cb72339b25a9ccd60f0fa8704e7f991199f02bf9c80300dc82a75305fe04f028d8d8c8e604051808560026020028082843760008382015260ff968716601f909101601f19169092019182525060208101939093525090911660408083019190915251908190036060019150a350909998505050505050505050565b604080517f21f8a7210000000000000000000000000000000000000000000000000000000081527f45786368616e676572000000000000000000000000000000000000000000000060048201529051734e3b31eb0e5cb73641ee1e65e7dcefe520ba3ef2916321f8a721916024808301926020929190829003018186803b1580156128ac57600080fd5b505afa1580156128c0573d6000803e3d6000fd5b505050506040513d60208110156128d657600080fd5b5051600a80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03909216919091179055565b60078054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610b8d5780601f10610b6257610100808354040283529160200191610b8d565b6001600160a01b038082166000908152600f6020526040812054909161010090910416806113115760405162461bcd60e51b815260040180806020018281038252602381526020018061541c6023913960400191505060405180910390fd5b6000818152600e602052604081205460ff1690808080808560038111156129f457fe5b1415612a47576040805162461bcd60e51b815260206004820152600e60248201527f696e76616c6964206974656d4964000000000000000000000000000000000000604482015290519081900360640190fd5b6000806001876003811115612a5857fe5b1415612a955750506000868152600b6020526040902080546001909101546001600160a01b0390911690612a8b81611c81565b9450849250612b69565b612a9d615112565b5050506000868152600c6020908152604091829020825160808101845281546001600160a01b039081168083526001840154948301859052600290930154908116948201949094527401000000000000000000000000000000000000000090930460ff16606084015291612b1082611c81565b9550600f600082604001516001600160a01b03166001600160a01b03168152602001908152602001600020600201816060015160ff1681548110612b5057fe5b6000918252602090912001546001600160a01b03169350505b600a54604080517f059c29ec0000000000000000000000000000000000000000000000000000000081526001600160a01b038581166004830152602482018590529151919092169163059c29ec916044808301926020929190829003018186803b158015612bd657600080fd5b505afa158015612bea573d6000803e3d6000fd5b505050506040513d6020811015612c0057600080fd5b5051604080517f70a082310000000000000000000000000000000000000000000000000000000081526001600160a01b0385811660048301529151929850908716916370a0823191602480820192602092909190829003018186803b158015612c6857600080fd5b505afa158015612c7c573d6000803e3d6000fd5b505050506040513d6020811015612c9257600080fd5b5051969895975093959491935090915050565b612cad613cb2565b6001600160a01b0316826001600160a01b03161415612d13576040805162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604482015290519081900360640190fd5b8060056000612d20613cb2565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff191692151592909217909155612d64613cb2565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405180821515815260200191505060405180910390a35050565b6001600160a01b0381166000908152600f602052604081205460ff1680612e025760405162461bcd60e51b81526004018080602001828103825260248152602001806154c36024913960400191505060405180910390fd5b6000190192915050565b600d5481565b612e23612e1d613cb2565b8361413f565b612e5e5760405162461bcd60e51b81526004018080602001828103825260318152602001806155086031913960400191505060405180910390fd5b612e6a84848484614626565b50505050565b600c602052600090815260409020805460018201546002909201546001600160a01b03918216929181169074010000000000000000000000000000000000000000900460ff1684565b6060612ec482613ca5565b612eff5760405162461bcd60e51b815260040180806020018281038252602f815260200180615494602f913960400191505060405180910390fd5b60008281526008602090815260409182902080548351601f6002600019610100600186161502019093169290920491820184900484028101840190945280845260609392830182828015612f945780601f10612f6957610100808354040283529160200191612f94565b820191906000526020600020905b815481529060010190602001808311612f7757829003601f168201915b505050505090506060612fa5611bb8565b9050805160001415612fb957509050610afc565b81511561307a5780826040516020018083805190602001908083835b60208310612ff45780518252601f199092019160209182019101612fd5565b51815160209384036101000a600019018019909216911617905285519190930192850191508083835b6020831061303c5780518252601f19909201916020918201910161301d565b6001836020036101000a0380198251168184511680821785525050505050509050019250505060405160208183030381529060405292505050610afc565b8061308485614678565b6040516020018083805190602001908083835b602083106130b65780518252601f199092019160209182019101613097565b51815160209384036101000a600019018019909216911617905285519190930192850191508083835b602083106130fe5780518252601f1990920191602091820191016130df565b6001836020036101000a0380198251168184511680821785525050505050509050019250505060405160208183030381529060405292505050919050565b6000806000734e3b31eb0e5cb73641ee1e65e7dcefe520ba3ef26001600160a01b03166321f8a7217f45786368616e67655261746573000000000000000000000000000000000000006040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b1580156131b957600080fd5b505afa1580156131cd573d6000803e3d6000fd5b505050506040513d60208110156131e357600080fd5b5051905060006001600160a01b0388351663a95b089f886132138b855b60200201356001600160a01b0316612daa565b886040518463ffffffff1660e01b8152600401808460ff1681526020018360ff168152602001828152602001935050505060206040518083038186803b15801561325c57600080fd5b505afa158015613270573d6000803e3d6000fd5b505050506040513d602081101561328657600080fd5b5051905060006001600160a01b03831663654a60ac6132a58b84612516565b846132b18d6001612516565b6040518463ffffffff1660e01b815260040180848152602001838152602001828152602001935050505060206040518083038186803b1580156132f357600080fd5b505afa158015613307573d6000803e3d6000fd5b505050506040513d602081101561331d57600080fd5b50519050806001600160a01b0360208b01351663a95b089f6133408c6001613200565b8a856040518463ffffffff1660e01b8152600401808460ff1681526020018360ff168152602001828152602001935050505060206040518083038186803b15801561338a57600080fd5b505afa15801561339e573d6000803e3d6000fd5b505050506040513d60208110156133b457600080fd5b5051909a909950975050505050505050565b60ff81565b734e3b31eb0e5cb73641ee1e65e7dcefe520ba3ef281565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b600082613465576040805162461bcd60e51b815260206004820152601d60248201527f616d6f756e74206d7573742062652067726561746572207468616e2030000000604482015290519081900360640190fd5b60006134907f000000000000000000000000df815ea6b066ac9f3107d8863a6c19aa2a5d24d3613d3c565b9050806001600160a01b0316638129fc1c6040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156134cd57600080fd5b505af11580156134e1573d6000803e3d6000fd5b50505050600061350d6040518060400160405280846001600160a01b0316815260200188815250614787565b6000818152600e60205260409020805460ff1916600117905590506135323382613efe565b6001600160a01b0388166000908152600f60205260408120600201805460ff8a1690811061355c57fe5b6000918252602090912001546001600160a01b0316905061357f8133308961402c565b604080517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015290516001600160a01b038316916370a08231916024808301926020929190829003018186803b1580156135de57600080fd5b505afa1580156135f2573d6000803e3d6000fd5b505050506040513d602081101561360857600080fd5b5051955060006001600160a01b038a1663916955868a6136278d612daa565b8a6000426040518663ffffffff1660e01b8152600401808660ff1681526020018560ff16815260200184815260200183815260200182815260200195505050505050602060405180830381600087803b15801561368357600080fd5b505af1158015613697573d6000803e3d6000fd5b505050506040513d60208110156136ad57600080fd5b505190506136bf84826126ac8d612972565b85846001600160a01b031663775723ca6136d88d611b38565b848c6040518463ffffffff1660e01b8152600401808481526020018381526020018281526020019350505050602060405180830381600087803b15801561371e57600080fd5b505af1158015613732573d6000803e3d6000fd5b505050506040513d602081101561374857600080fd5b5051101561379d576040805162461bcd60e51b815260206004820152601560248201527f6d696e416d6f756e74206e6f7420726561636865640000000000000000000000604482015290519081900360640190fd5b604080516001600160a01b038c16815260ff8b166020820152808201899052606081018a90529051849133917f305dca8d8466ac672b08bd22cbb17d3a12b15601bbd232a13ed2f8e85cde0fa99181900360800190a3509098975050505050505050565b82613853576040805162461bcd60e51b815260206004820152601d60248201527f616d6f756e74206d7573742062652067726561746572207468616e2030000000604482015290519081900360640190fd5b600061385e85611b90565b9050336001600160a01b038216146138bd576040805162461bcd60e51b815260206004820152600f60248201527f6d757374206f776e206974656d49640000000000000000000000000000000000604482015290519081900360640190fd5b60016000868152600e602052604090205460ff1660038111156138dc57fe5b1161392e576040805162461bcd60e51b815260206004820152600e60248201527f696e76616c6964206974656d4964000000000000000000000000000000000000604482015290519081900360640190fd5b613936615112565b506000858152600c6020908152604091829020825160808101845281546001600160a01b039081168083526001840154948301859052600290930154908116948201949094527401000000000000000000000000000000000000000090930460ff1660608401526139a691614333565b60006139b58260200151611c81565b90506000816001600160a01b03166370a0823184600001516040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015613a0a57600080fd5b505afa158015613a1e573d6000803e3d6000fd5b505050506040513d6020811015613a3457600080fd5b50518710613ac157613a45886143cc565b506000878152600c6020908152604080832080547fffffffffffffffffffffffff00000000000000000000000000000000000000001681556001808201859055600290910180547fffffffffffffffffffffff000000000000000000000000000000000000000000169055600e909252909120805460ff191690555b60008084600001516001600160a01b0316635a3f4b23866040015186613aea8960400151612daa565b60608a0151604080517fffffffff0000000000000000000000000000000000000000000000000000000060e088901b1681526001600160a01b039586166004820152938516602485015260ff928316604485015291166064830152608482018e905260a482018d905260c482018c9052918a1660e4820152815161010480830193928290030181600087803b158015613b8257600080fd5b505af1158015613b96573d6000803e3d6000fd5b505050506040513d6040811015613bac57600080fd5b50805160209091015190925090508215613c185784600001516001600160a01b03166383197ef06040518163ffffffff1660e01b8152600401600060405180830381600087803b158015613bff57600080fd5b505af1158015613c13573d6000803e3d6000fd5b505050505b604080516001600160a01b038681168252602082018c905284168183015260608101839052841515608082015290518b9133917f5044c8cd0fcfe21244aecba3091a52a10187be167694fb3b69dc02cd4ee0f6379181900360a00190a350505050505050505050565b7f45786368616e676572000000000000000000000000000000000000000000000081565b6000611311600283614828565b3390565b600081815260046020526040902080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0384169081179091558190613d0382611b90565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60006040517f3d602d80600a3d3981f3363d3d373d3d3d363d7300000000000000000000000081528260601b60148201527f5af43d82803e903d91602b57fd5bf3000000000000000000000000000000000060288201526037816000f09150506001600160a01b038116610afc576040805162461bcd60e51b815260206004820152601660248201527f455243313136373a20637265617465206661696c656400000000000000000000604482015290519081900360640190fd5b6000600019600d5410613e3b5760405162461bcd60e51b81526004018080602001828103825260238152602001806155996023913960400191505060405180910390fd5b50600d80546000908152600c6020908152604091829020845181546001600160a01b039182167fffffffffffffffffffffffff0000000000000000000000000000000000000000918216178355928601516001808401919091559386015160029092018054606088015160ff1674010000000000000000000000000000000000000000027fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff94909316941693909317919091161790558154908101909155919050565b6001600160a01b038216613f59576040805162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015290519081900360640190fd5b613f6281613ca5565b15613fb4576040805162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015290519081900360640190fd5b613fc060008383610ccf565b6001600160a01b0382166000908152600160205260409020613fe29082614834565b50613fef60028284614840565b5060405181906001600160a01b038416906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd00000000000000000000000000000000000000000000000000000000179052612e6a908590614856565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb00000000000000000000000000000000000000000000000000000000179052610ccf908490614856565b600061131182614907565b600061414a82613ca5565b6141855760405162461bcd60e51b815260040180806020018281038252602c815260200180615343602c913960400191505060405180910390fd5b600061419083611b90565b9050806001600160a01b0316846001600160a01b031614806141cb5750836001600160a01b03166141c084610b97565b6001600160a01b0316145b80612428575061242881856133e3565b826001600160a01b03166141ee82611b90565b6001600160a01b0316146142335760405162461bcd60e51b815260040180806020018281038252602981526020018061546b6029913960400191505060405180910390fd5b6001600160a01b0382166142785760405162461bcd60e51b81526004018080602001828103825260248152602001806152d76024913960400191505060405180910390fd5b614283838383610ccf565b61428e600082613cb6565b6001600160a01b03831660009081526001602052604090206142b0908261490b565b506001600160a01b03821660009081526001602052604090206142d39082614834565b506142e060028284614840565b5080826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b600061130e8383614917565b600a54604080517f1b16802c0000000000000000000000000000000000000000000000000000000081526001600160a01b0385811660048301526024820185905291519190921691631b16802c9160448083019260609291908290030181600087803b1580156143a257600080fd5b505af11580156143b6573d6000803e3d6000fd5b505050506040513d6060811015612e6a57600080fd5b60006143d782611b90565b90506143e581600084610ccf565b6143f0600083613cb6565b600082815260086020526040902054600260001961010060018416150201909116041561442e57600082815260086020526040812061442e916151cd565b6001600160a01b0381166000908152600160205260409020614450908361490b565b5061445c60028361497b565b5060405182906000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b60008080806144a88686614987565b9097909650945050505050565b8015806145545750604080517fdd62ed3e0000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b15801561452657600080fd5b505afa15801561453a573d6000803e3d6000fd5b505050506040513d602081101561455057600080fd5b5051155b61458f5760405162461bcd60e51b81526004018080602001828103825260368152602001806155636036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b300000000000000000000000000000000000000000000000000000000179052610ccf908490614856565b600061461c848484614a02565b90505b9392505050565b6146318484846141db565b61463d84848484614acc565b612e6a5760405162461bcd60e51b81526004018080602001828103825260328152602001806152836032913960400191505060405180910390fd5b6060816146b9575060408051808201909152600181527f30000000000000000000000000000000000000000000000000000000000000006020820152610afc565b8160005b81156146d157600101600a820491506146bd565b60608167ffffffffffffffff811180156146ea57600080fd5b506040519080825280601f01601f191660200182016040528015614715576020820181803683370190505b50859350905060001982015b831561477e57600a840660300160f81b8282806001900393508151811061474457fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a84049350614721565b50949350505050565b6000600019600d54106147cb5760405162461bcd60e51b81526004018080602001828103825260238152602001806155996023913960400191505060405180910390fd5b50600d80546000908152600b60209081526040909120835181547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b039091161781559201516001928301558054918201905590565b600061130e8383614ca8565b600061130e8383614cc0565b600061461c84846001600160a01b038516614d0a565b60606148ab826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316614da19092919063ffffffff16565b805190915015610ccf578080602001905160208110156148ca57600080fd5b5051610ccf5760405162461bcd60e51b815260040180806020018281038252602a815260200180615539602a913960400191505060405180910390fd5b5490565b600061130e8383614db0565b815460009082106149595760405162461bcd60e51b81526004018080602001828103825260228152602001806152616022913960400191505060405180910390fd5b82600001828154811061496857fe5b9060005260206000200154905092915050565b600061130e8383614e76565b8154600090819083106149cb5760405162461bcd60e51b81526004018080602001828103825260228152602001806153fa6022913960400191505060405180910390fd5b60008460000184815481106149dc57fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b60008281526001840160205260408120548281614a9d5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015614a62578181015183820152602001614a4a565b50505050905090810190601f168015614a8f5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50846000016001820381548110614ab057fe5b9060005260206000209060020201600101549150509392505050565b6000614ae0846001600160a01b0316614f4a565b614aec57506001612428565b6060614c3d7f150b7a0200000000000000000000000000000000000000000000000000000000614b1a613cb2565b88878760405160240180856001600160a01b03168152602001846001600160a01b0316815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015614b81578181015183820152602001614b69565b50505050905090810190601f168015614bae5780820380516001836020036101000a031916815260200191505b5095505050505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051806060016040528060328152602001615283603291396001600160a01b0388169190614da1565b90506000818060200190516020811015614c5657600080fd5b50517fffffffff00000000000000000000000000000000000000000000000000000000167f150b7a02000000000000000000000000000000000000000000000000000000001492505050949350505050565b60009081526001919091016020526040902054151590565b6000614ccc8383614ca8565b614d0257508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155611311565b506000611311565b600082815260018401602052604081205480614d6f57505060408051808201825283815260208082018481528654600181810189556000898152848120955160029093029095019182559151908201558654868452818801909252929091205561461f565b82856000016001830381548110614d8257fe5b906000526020600020906002020160010181905550600091505061461f565b606061461c8484600085614f50565b60008181526001830160205260408120548015614e6c5783546000198083019190810190600090879083908110614de357fe5b9060005260206000200154905080876000018481548110614e0057fe5b600091825260208083209091019290925582815260018981019092526040902090840190558654879080614e3057fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050611311565b6000915050611311565b60008181526001830160205260408120548015614e6c5783546000198083019190810190600090879083908110614ea957fe5b9060005260206000209060020201905080876000018481548110614ec957fe5b600091825260208083208454600290930201918255600193840154918401919091558354825289830190526040902090840190558654879080614f0857fe5b60008281526020808220600260001990940193840201828155600190810183905592909355888152898201909252604082209190915594506113119350505050565b3b151590565b606082471015614f915760405162461bcd60e51b815260040180806020018281038252602681526020018061531d6026913960400191505060405180910390fd5b614f9a85614f4a565b614feb576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b6020831061502a5780518252601f19909201916020918201910161500b565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d806000811461508c576040519150601f19603f3d011682016040523d82523d6000602084013e615091565b606091505b50915091506150a18282866150ac565b979650505050505050565b606083156150bb57508161461f565b8251156150cb5782518084602001fd5b60405162461bcd60e51b8152602060048201818152845160248401528451859391928392604401919085019080838360008315614a62578181015183820152602001614a4a565b60408051608081018252600080825260208201819052918101829052606081019190915290565b8280548282559060005260206000209081019282156151a6579160200282015b828111156151a657825182547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03909116178255602090920191600190910190615159565b506151b2929150615214565b5090565b604080518082019091526000808252602082015290565b50805460018160011615610100020316600290046000825580601f106151f35750615211565b601f016020900490600052602060002090810190615211919061524b565b50565b5b808211156151b25780547fffffffffffffffffffffffff0000000000000000000000000000000000000000168155600101615215565b5b808211156151b2576000815560010161524c56fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e64734552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e74657273796e7468206b6579206e6f7420666f756e6420666f7220676976656e20706f6f6c4552433732313a207472616e7366657220746f20746865207a65726f206164647265737373796e746820697320737570706f7274656420766961206e6f726d616c2073776170416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c4552433732313a206f70657261746f7220717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76652063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f76656420666f7220616c6c4552433732313a2062616c616e636520717565727920666f7220746865207a65726f20616464726573734552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656e456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e647373796e74682061646472206e6f7420666f756e6420666f7220676976656e20706f6f6c4552433732313a20617070726f76656420717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a207472616e73666572206f6620746f6b656e2074686174206973206e6f74206f776e4552433732314d657461646174613a2055524920717565727920666f72206e6f6e6578697374656e7420746f6b656e73796e746820696e646578206e6f7420666f756e6420666f7220676976656e20706f6f6c4552433732313a20617070726f76616c20746f2063757272656e74206f776e65724552433732313a207472616e736665722063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f7665645361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e636570656e64696e6753776170734c656e6774682072656163686564206d61782073697a65a26469706673582212200c470228fcd7f605e29d2ebe6cb2642e97e8e7343c711b5457593e7d4fdef68864736f6c634300060c0033

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

000000000000000000000000df815ea6b066ac9f3107d8863a6c19aa2a5d24d3

-----Decoded View---------------
Arg [0] : synthSwapperAddress (address): 0xdf815Ea6b066Ac9f3107d8863a6c19aA2a5d24d3

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000df815ea6b066ac9f3107d8863a6c19aa2a5d24d3


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

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