false
false
0
The new Blockscout UI is now open source! Learn how to deploy it here

Contract Address Details

0x99568Ce6c9901097150403B7629CF426B859BC22

Contract Name
Swap
Creator
0x3768be–aa289b at 0x8ef866–228b48
Balance
0 ETH
Tokens
Fetching tokens...
Transactions
0 Transactions
Transfers
0 Transfers
Gas Used
Fetching gas used...
Last Balance Update
4863979
Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
Contract name:
Swap




Optimization enabled
true
Compiler version
v0.8.17+commit.8df45f5f




Optimization runs
999999
Verified at
2023-04-12T21:14:58.104087Z

Constructor Arguments

000000000000000000000000000000000000000000000000000000000000008036372b070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000070000000000000000000000003768bec96a282273fe3756a92c4f6d7d06aa289b0000000000000000000000000000000000000000000000000000000000000003000000000000000000000000a9964a60a620c00150114614f745646b898cfe32000000000000000000000000cb3839a953533339273e251dd179515b7ba9a309000000000000000000000000d82fa167727a4dc6d6f55830a2c47abbb4b3a0f8
              

contracts/Swap.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import "@openzeppelin/contracts/access/Ownable2Step.sol";
import "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
import "@openzeppelin/contracts/interfaces/IERC2981.sol";
import "./interfaces/IAdapter.sol";
import "./interfaces/ISwap.sol";

/**
 * @title AirSwap: Atomic Token Swap
 * @notice https://www.airswap.io/
 */
contract Swap is ISwap, Ownable2Step, EIP712 {
  bytes32 internal constant ORDER_TYPEHASH =
    keccak256(
      abi.encodePacked(
        "Order(uint256 nonce,uint256 expiry,uint256 protocolFee,Party signer,Party sender,address affiliateWallet,uint256 affiliateAmount)",
        "Party(address wallet,address token,bytes4 kind,uint256 id,uint256 amount)"
      )
    );

  bytes32 internal constant PARTY_TYPEHASH =
    keccak256(
      "Party(address wallet,address token,bytes4 kind,uint256 id,uint256 amount)"
    );

  // Domain name and version for use in EIP712 signatures
  string public constant DOMAIN_NAME = "SWAP";
  string public constant DOMAIN_VERSION = "4";
  uint256 public immutable DOMAIN_CHAIN_ID;
  bytes32 public immutable DOMAIN_SEPARATOR;

  uint256 public constant FEE_DIVISOR = 10000;
  uint256 internal constant MAX_ERROR_COUNT = 16;

  // Mapping of ERC165 interface ID to token adapter
  mapping(bytes4 => IAdapter) public adapters;

  // Mapping of signer to authorized signatory
  mapping(address => address) public override authorized;

  // Mapping of signatory address to a minimum valid nonce
  mapping(address => uint256) public signatoryMinimumNonce;

  /**
   * @notice Double mapping of signers to nonce groups to nonce states
   * @dev The nonce group is computed as nonce / 256, so each group of 256 sequential nonces uses the same key
   * @dev The nonce states are encoded as 256 bits, for each nonce in the group 0 means available and 1 means used
   */
  mapping(address => mapping(uint256 => uint256)) internal _nonceGroups;

  bytes4 public requiredSenderKind;
  uint256 public protocolFee;
  address public protocolFeeWallet;

  /**
   * @notice Constructor
   * @dev Sets domain and version for EIP712 signatures
   * @param _adapters IAdapter[] array of token adapters
   * @param _protocolFee uin256 fee to be assessed on swaps
   * @param _protocolFeeWallet address destination for fees
   */
  constructor(
    IAdapter[] memory _adapters,
    bytes4 _requiredSenderKind,
    uint256 _protocolFee,
    address _protocolFeeWallet
  ) EIP712(DOMAIN_NAME, DOMAIN_VERSION) {
    if (_protocolFee >= FEE_DIVISOR) revert FeeInvalid();
    if (_protocolFeeWallet == address(0)) revert FeeWalletInvalid();
    if (_adapters.length == 0) revert AdaptersInvalid();

    DOMAIN_CHAIN_ID = block.chainid;
    DOMAIN_SEPARATOR = _domainSeparatorV4();

    for (uint256 i = 0; i < _adapters.length; i++) {
      adapters[_adapters[i].interfaceId()] = _adapters[i];
    }
    requiredSenderKind = _requiredSenderKind;
    protocolFee = _protocolFee;
    protocolFeeWallet = _protocolFeeWallet;
  }

  /**
   * @notice Atomic Token Swap
   * @param order Order to settle
   */
  function swap(
    address recipient,
    uint256 maxRoyalty,
    Order calldata order
  ) external {
    // Ensure order is valid for signer
    _check(order);

    // Ensure msg.sender matches order if specified
    if (order.sender.wallet != address(0) && order.sender.wallet != msg.sender)
      revert SenderInvalid();

    // Transfer from sender to signer
    _transfer(
      msg.sender,
      order.signer.wallet,
      order.sender.amount,
      order.sender.id,
      order.sender.token,
      order.sender.kind
    );

    // Transfer from signer to recipient
    _transfer(
      order.signer.wallet,
      recipient,
      order.signer.amount,
      order.signer.id,
      order.signer.token,
      order.signer.kind
    );

    // Transfer from sender to affiliate if specified
    if (order.affiliateWallet != address(0)) {
      _transfer(
        order.sender.wallet,
        order.affiliateWallet,
        order.affiliateAmount,
        order.sender.id,
        order.sender.token,
        order.sender.kind
      );
    }

    // Transfer protocol fee from sender if possible
    uint256 protocolFeeAmount = (order.sender.amount * protocolFee) /
      FEE_DIVISOR;
    if (protocolFeeAmount > 0) {
      _transfer(
        order.sender.wallet,
        protocolFeeWallet,
        protocolFeeAmount,
        order.sender.id,
        order.sender.token,
        order.sender.kind
      );
    }

    // Transfer royalty from sender if supported by signer token
    if (supportsRoyalties(order.signer.token)) {
      address royaltyRecipient;
      uint256 royaltyAmount;
      (royaltyRecipient, royaltyAmount) = IERC2981(order.signer.token)
        .royaltyInfo(order.signer.id, order.sender.amount);
      if (royaltyAmount > 0) {
        if (royaltyAmount > maxRoyalty) revert RoyaltyExceedsMax(royaltyAmount);
        _transfer(
          order.sender.wallet,
          royaltyRecipient,
          royaltyAmount,
          order.sender.id,
          order.sender.token,
          order.sender.kind
        );
      }
    }

    emit Swap(
      order.nonce,
      order.signer.wallet,
      order.signer.amount,
      order.signer.id,
      order.signer.token,
      msg.sender,
      order.sender.amount,
      order.sender.id,
      order.sender.token,
      order.affiliateWallet,
      order.affiliateAmount
    );
  }

  /**
   * @notice Set the fee
   * @param _protocolFee uint256 Value of the fee in basis points
   */
  function setProtocolFee(uint256 _protocolFee) external onlyOwner {
    // Ensure the fee is less than divisor
    if (_protocolFee >= FEE_DIVISOR) revert FeeInvalid();
    protocolFee = _protocolFee;
    emit SetProtocolFee(_protocolFee);
  }

  /**
   * @notice Set the fee wallet
   * @param _protocolFeeWallet address Wallet to transfer fee to
   */
  function setProtocolFeeWallet(address _protocolFeeWallet) external onlyOwner {
    // Ensure the new fee wallet is not null
    if (_protocolFeeWallet == address(0)) revert FeeWalletInvalid();
    protocolFeeWallet = _protocolFeeWallet;
    emit SetProtocolFeeWallet(_protocolFeeWallet);
  }

  /**
   * @notice Authorize a signer
   * @param signatory address Wallet of the signer to authorize
   * @dev Emits an Authorize event
   */
  function authorize(address signatory) external override {
    if (signatory == address(0)) revert SignatoryInvalid();
    authorized[msg.sender] = signatory;
    emit Authorize(signatory, msg.sender);
  }

  /**
   * @notice Revoke the signatory
   * @dev Emits a Revoke event
   */
  function revoke() external override {
    address tmp = authorized[msg.sender];
    delete authorized[msg.sender];
    emit Revoke(tmp, msg.sender);
  }

  /**
   * @notice Cancel one or more nonces
   * @dev Cancelled nonces are marked as used
   * @dev Emits a Cancel event
   * @dev Out of gas may occur in arrays of length > 400
   * @param nonces uint256[] List of nonces to cancel
   */
  function cancel(uint256[] calldata nonces) external override {
    for (uint256 i = 0; i < nonces.length; i++) {
      uint256 nonce = nonces[i];
      _markNonceAsUsed(msg.sender, nonce);
      emit Cancel(nonce, msg.sender);
    }
  }

  /**
   * @notice Cancels all orders below a nonce value
   * @dev Emits a CancelUpTo event
   * @param minimumNonce uint256 Minimum valid nonce
   */
  function cancelUpTo(uint256 minimumNonce) external {
    signatoryMinimumNonce[msg.sender] = minimumNonce;
    emit CancelUpTo(minimumNonce, msg.sender);
  }

  /**
   * @notice Validates Swap Order for any potential errors
   * @param order Order to settle
   */
  function check(
    address senderWallet,
    Order calldata order
  ) public view returns (bytes32[] memory, uint256) {
    uint256 errCount;
    bytes32[] memory errors = new bytes32[](MAX_ERROR_COUNT);
    (address signatory, ) = ECDSA.tryRecover(
      _getOrderHash(order),
      order.v,
      order.r,
      order.s
    );

    if (
      order.sender.wallet != address(0) && order.sender.wallet != senderWallet
    ) {
      errors[errCount] = "SenderInvalid";
      errCount++;
    }

    if (signatory == address(0)) {
      errors[errCount] = "SignatureInvalid";
      errCount++;
    } else {
      if (
        authorized[order.signer.wallet] != address(0) &&
        signatory != authorized[order.signer.wallet]
      ) {
        errors[errCount] = "SignatoryUnauthorized";
        errCount++;
      } else if (
        authorized[order.signer.wallet] == address(0) &&
        signatory != order.signer.wallet
      ) {
        errors[errCount] = "Unauthorized";
        errCount++;
      } else if (nonceUsed(signatory, order.nonce)) {
        errors[errCount] = "NonceAlreadyUsed";
        errCount++;
      }
      if (order.nonce < signatoryMinimumNonce[signatory]) {
        errors[errCount] = "NonceTooLow";
        errCount++;
      }
    }

    if (order.expiry < block.timestamp) {
      errors[errCount] = "OrderExpired";
      errCount++;
    }

    IAdapter signerTokenAdapter = adapters[order.signer.kind];

    if (address(signerTokenAdapter) == address(0)) {
      errors[errCount] = "SignerTokenKindUnknown";
      errCount++;
    } else {
      if (!signerTokenAdapter.hasAllowance(order.signer)) {
        errors[errCount] = "SignerAllowanceLow";
        errCount++;
      }
      if (!signerTokenAdapter.hasBalance(order.signer)) {
        errors[errCount] = "SignerBalanceLow";
        errCount++;
      }
    }

    IAdapter senderTokenAdapter = adapters[order.sender.kind];

    if (address(senderTokenAdapter) == address(0)) {
      errors[errCount] = "SenderTokenKindUnknown";
      errCount++;
    } else {
      if (order.sender.kind != requiredSenderKind) {
        errors[errCount] = "SenderTokenInvalid";
        errCount++;
      } else {
        uint256 protocolFeeAmount = (order.sender.amount * protocolFee) /
          FEE_DIVISOR;
        uint256 totalSenderAmount = order.sender.amount +
          protocolFeeAmount +
          order.affiliateAmount;
        Party memory sender = Party(
          senderWallet,
          order.sender.token,
          order.sender.kind,
          order.sender.id,
          totalSenderAmount
        );
        if (!senderTokenAdapter.hasAllowance(sender)) {
          errors[errCount] = "SenderAllowanceLow";
          errCount++;
        }
        if (!senderTokenAdapter.hasBalance(sender)) {
          errors[errCount] = "SenderBalanceLow";
          errCount++;
        }
        if (order.sender.amount < order.affiliateAmount) {
          errors[errCount] = "AffiliateAmountInvalid";
          errCount++;
        }
      }
    }

    if (order.protocolFee != protocolFee) {
      errors[errCount] = "FeeInvalid";
      errCount++;
    }

    return (errors, errCount);
  }

  /**
   * @notice Returns true if the nonce has been used
   * @param signer address Address of the signer
   * @param nonce uint256 Nonce being checked
   */
  function nonceUsed(
    address signer,
    uint256 nonce
  ) public view override returns (bool) {
    uint256 groupKey = nonce / 256;
    uint256 indexInGroup = nonce % 256;
    return (_nonceGroups[signer][groupKey] >> indexInGroup) & 1 == 1;
  }

  /**
   * @notice Marks a nonce as used for the given signatory
   * @param signatory  address Address of the signer for which to mark the nonce as used
   * @param nonce uint256 Nonce to be marked as used
   */
  function _markNonceAsUsed(address signatory, uint256 nonce) internal {
    uint256 groupKey = nonce / 256;
    uint256 indexInGroup = nonce % 256;
    uint256 group = _nonceGroups[signatory][groupKey];

    // Revert if nonce is already used
    if ((group >> indexInGroup) & 1 == 1) {
      revert NonceAlreadyUsed(nonce);
    }

    _nonceGroups[signatory][groupKey] = group | (uint256(1) << indexInGroup);
  }

  /**
   * @notice Function to indicate whether the party token implements EIP-2981
   * @param token Contract address from which royalty need to be considered
   */
  function supportsRoyalties(address token) internal view returns (bool) {
    try IERC165(token).supportsInterface(type(IERC2981).interfaceId) returns (
      bool result
    ) {
      return result;
    } catch {
      return false;
    }
  }

  /**
   * @notice Tests whether signature and signer are valid
   * @param order Order to validate
   */

  function _check(Order calldata order) internal {
    // Ensure execution on the intended chain
    if (DOMAIN_CHAIN_ID != block.chainid) revert ChainIdChanged();

    // Ensure the sender token is the required kind
    if (order.sender.kind != requiredSenderKind) revert SenderTokenInvalid();

    // Ensure the sender amount is greater than affiliate amount
    if (order.sender.amount < order.affiliateAmount)
      revert AffiliateAmountInvalid();

    // Recover the signatory from the hash and signature
    (address signatory, ) = ECDSA.tryRecover(
      _getOrderHash(order),
      order.v,
      order.r,
      order.s
    );

    // Ensure the signatory is not null
    if (signatory == address(0)) revert SignatureInvalid();

    // Ensure signatory is authorized to sign
    if (authorized[order.signer.wallet] != address(0)) {
      // If one is set by signer wallet, signatory must be authorized
      if (signatory != authorized[order.signer.wallet])
        revert SignatoryUnauthorized();
    } else {
      // Otherwise, signatory must be signer wallet
      if (signatory != order.signer.wallet) revert Unauthorized();
    }

    // Ensure the nonce is not yet used and if not mark it used
    _markNonceAsUsed(signatory, order.nonce);

    // Ensure the nonce is not below the minimum nonce set by cancelUpTo
    if (order.nonce < signatoryMinimumNonce[signatory]) revert NonceTooLow();

    // Ensure the expiry is not passed
    if (order.expiry <= block.timestamp) revert OrderExpired();
  }

  /**
   * @notice Hash an order into bytes32
   * @dev EIP-191 header and domain separator included
   * @param order Order The order to be hashed
   * @return bytes32 A keccak256 abi.encodePacked value
   */
  function _getOrderHash(Order calldata order) internal view returns (bytes32) {
    return
      keccak256(
        abi.encodePacked(
          "\x19\x01", // EIP191: Indicates EIP712
          DOMAIN_SEPARATOR,
          keccak256(
            abi.encode(
              ORDER_TYPEHASH,
              order.nonce,
              order.expiry,
              protocolFee,
              keccak256(abi.encode(PARTY_TYPEHASH, order.signer)),
              keccak256(abi.encode(PARTY_TYPEHASH, order.sender)),
              order.affiliateWallet,
              order.affiliateAmount
            )
          )
        )
      );
  }

  /**
   * @notice Perform token transfer for tokens in registry
   * @dev Transfer type specified by the bytes4 kind param
   * @dev ERC721: uses transferFrom for transfer
   * @dev ERC20: Takes into account non-standard ERC-20 tokens.
   * @param from address Wallet address to transfer from
   * @param to address Wallet address to transfer to
   * @param amount uint256 Amount for ERC-20
   * @param id token ID for ERC-721
   * @param token address Contract address of token
   * @param kind bytes4 EIP-165 interface ID of the token
   */
  function _transfer(
    address from,
    address to,
    uint256 amount,
    uint256 id,
    address token,
    bytes4 kind
  ) internal {
    IAdapter adapter = adapters[kind];
    if (address(adapter) == address(0)) revert TokenKindUnknown();
    // Use delegatecall so underlying transfer is called as Swap
    (bool success, ) = address(adapter).delegatecall(
      abi.encodeWithSelector(
        adapter.transfer.selector,
        from,
        to,
        amount,
        id,
        token
      )
    );
    if (!success) revert TransferFailed(from, to);
  }
}
        

@openzeppelin/contracts/utils/introspection/IERC165.sol

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

pragma solidity ^0.8.0;

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

@openzeppelin/contracts/access/Ownable.sol

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

@openzeppelin/contracts/access/Ownable2Step.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (access/Ownable2Step.sol)

pragma solidity ^0.8.0;

import "./Ownable.sol";

/**
 * @dev Contract module which provides access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership} and {acceptOwnership}.
 *
 * This module is used through inheritance. It will make available all functions
 * from parent (Ownable).
 */
abstract contract Ownable2Step is Ownable {
    address private _pendingOwner;

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

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

    /**
     * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual override onlyOwner {
        _pendingOwner = newOwner;
        emit OwnershipTransferStarted(owner(), newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual override {
        delete _pendingOwner;
        super._transferOwnership(newOwner);
    }

    /**
     * @dev The new owner accepts the ownership transfer.
     */
    function acceptOwnership() external {
        address sender = _msgSender();
        require(pendingOwner() == sender, "Ownable2Step: caller is not the new owner");
        _transferOwnership(sender);
    }
}
          

@openzeppelin/contracts/interfaces/IERC2981.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (interfaces/IERC2981.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev Interface for the NFT Royalty Standard.
 *
 * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal
 * support for royalty payments across all NFT marketplaces and ecosystem participants.
 *
 * _Available since v4.5._
 */
interface IERC2981 is IERC165 {
    /**
     * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of
     * exchange. The royalty amount is denominated and should be paid in that same unit of exchange.
     */
    function royaltyInfo(uint256 tokenId, uint256 salePrice)
        external
        view
        returns (address receiver, uint256 royaltyAmount);
}
          

@openzeppelin/contracts/utils/Context.sol

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

pragma solidity ^0.8.0;

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

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

@openzeppelin/contracts/utils/Strings.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/Math.sol";

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

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

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

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

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

@openzeppelin/contracts/utils/cryptography/ECDSA.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.0;

import "../Strings.sol";

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSA {
    enum RecoverError {
        NoError,
        InvalidSignature,
        InvalidSignatureLength,
        InvalidSignatureS,
        InvalidSignatureV // Deprecated in v4.8
    }

    function _throwError(RecoverError error) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert("ECDSA: invalid signature");
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert("ECDSA: invalid signature length");
        } else if (error == RecoverError.InvalidSignatureS) {
            revert("ECDSA: invalid signature 's' value");
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature` or error string. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            /// @solidity memory-safe-assembly
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength);
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, signature);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address, RecoverError) {
        bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
        uint8 v = uint8((uint256(vs) >> 255) + 27);
        return tryRecover(hash, v, r, s);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
     *
     * _Available since v4.2._
     */
    function recover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, r, vs);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address, RecoverError) {
        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
        // signatures from current libraries generate a unique signature with an s-value in the lower half order.
        //
        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
        // these malleable signatures as well.
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            return (address(0), RecoverError.InvalidSignatureS);
        }

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        if (signer == address(0)) {
            return (address(0), RecoverError.InvalidSignature);
        }

        return (signer, RecoverError.NoError);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function recover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, v, r, s);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from a `hash`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
        // 32 is the length in bytes of hash,
        // enforced by the type signature above
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from `s`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
    }

    /**
     * @dev Returns an Ethereum Signed Typed Data, created from a
     * `domainSeparator` and a `structHash`. This produces hash corresponding
     * to the one signed with the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
     * JSON-RPC method as part of EIP-712.
     *
     * See {recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
    }
}
          

@openzeppelin/contracts/utils/cryptography/EIP712.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/EIP712.sol)

pragma solidity ^0.8.0;

import "./ECDSA.sol";

/**
 * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.
 *
 * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,
 * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding
 * they need in their contracts using a combination of `abi.encode` and `keccak256`.
 *
 * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
 * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
 * ({_hashTypedDataV4}).
 *
 * The implementation of the domain separator was designed to be as efficient as possible while still properly updating
 * the chain id to protect against replay attacks on an eventual fork of the chain.
 *
 * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
 * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
 *
 * _Available since v3.4._
 */
abstract contract EIP712 {
    /* solhint-disable var-name-mixedcase */
    // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to
    // invalidate the cached domain separator if the chain id changes.
    bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;
    uint256 private immutable _CACHED_CHAIN_ID;
    address private immutable _CACHED_THIS;

    bytes32 private immutable _HASHED_NAME;
    bytes32 private immutable _HASHED_VERSION;
    bytes32 private immutable _TYPE_HASH;

    /* solhint-enable var-name-mixedcase */

    /**
     * @dev Initializes the domain separator and parameter caches.
     *
     * The meaning of `name` and `version` is specified in
     * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:
     *
     * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
     * - `version`: the current major version of the signing domain.
     *
     * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
     * contract upgrade].
     */
    constructor(string memory name, string memory version) {
        bytes32 hashedName = keccak256(bytes(name));
        bytes32 hashedVersion = keccak256(bytes(version));
        bytes32 typeHash = keccak256(
            "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
        );
        _HASHED_NAME = hashedName;
        _HASHED_VERSION = hashedVersion;
        _CACHED_CHAIN_ID = block.chainid;
        _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);
        _CACHED_THIS = address(this);
        _TYPE_HASH = typeHash;
    }

    /**
     * @dev Returns the domain separator for the current chain.
     */
    function _domainSeparatorV4() internal view returns (bytes32) {
        if (address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID) {
            return _CACHED_DOMAIN_SEPARATOR;
        } else {
            return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);
        }
    }

    function _buildDomainSeparator(
        bytes32 typeHash,
        bytes32 nameHash,
        bytes32 versionHash
    ) private view returns (bytes32) {
        return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));
    }

    /**
     * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this
     * function returns the hash of the fully encoded EIP712 message for this domain.
     *
     * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:
     *
     * ```solidity
     * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
     *     keccak256("Mail(address to,string contents)"),
     *     mailTo,
     *     keccak256(bytes(mailContents))
     * )));
     * address signer = ECDSA.recover(digest, signature);
     * ```
     */
    function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
        return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);
    }
}
          

@openzeppelin/contracts/utils/math/Math.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

contracts/interfaces/IAdapter.sol

// SPDX-License-Identifier: MIT

pragma solidity 0.8.17;

struct Party {
  address wallet; // Wallet address of the party
  address token; // Contract address of the token
  bytes4 kind; // Interface ID of the token
  uint256 id; // ID for ERC-721 or ERC-1155
  uint256 amount; // Amount for ERC-20 or ERC-1155
}

/**
 * @title IAdapter: Adapter for various token kinds
 */
interface IAdapter {
  /**
   * @notice Revert if provided an invalid transfer argument
   */
  error InvalidArgument(string);

  /**
   * @notice Return the ERC165 interfaceId this adapter supports
   */
  function interfaceId() external view returns (bytes4);

  /**
   * @notice Function to wrap token transfer for different token types
   * @param party Party from whom swap would be made
   */
  function hasAllowance(Party calldata party) external view returns (bool);

  /**
   * @notice Function to wrap token transfer for different token types
   * @param party Party from whom swap would be made
   */
  function hasBalance(Party calldata party) external view returns (bool);

  /**
   * @notice Function to wrap token transfer for different token types
   * @param from address Wallet address to transfer from
   * @param to address Wallet address to transfer to
   * @param amount uint256 Amount for ERC-20
   * @param id token ID for ERC-721
   * @param token address Contract address of token
   */
  function transfer(
    address from,
    address to,
    uint256 amount,
    uint256 id,
    address token
  ) external;
}
          

contracts/interfaces/ISwap.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import "./IAdapter.sol";

interface ISwap {
  struct Order {
    uint256 nonce; // Unique number per signatory per order
    uint256 expiry; // Expiry time (seconds since unix epoch)
    uint256 protocolFee; // Protocol fee numerator
    Party signer; // Party to the swap that sets terms
    Party sender; // Party to the swap that accepts terms
    address affiliateWallet; // Party tipped for facilitating (optional)
    uint256 affiliateAmount;
    uint8 v; // ECDSA
    bytes32 r;
    bytes32 s;
  }

  event Swap(
    uint256 indexed nonce,
    address indexed signerWallet,
    uint256 signerAmount,
    uint256 signerId,
    address signerToken,
    address indexed senderWallet,
    uint256 senderAmount,
    uint256 senderId,
    address senderToken,
    address affiliateWallet,
    uint256 affiliateAmount
  );
  event Cancel(uint256 indexed nonce, address indexed signerWallet);
  event CancelUpTo(uint256 indexed nonce, address indexed signerWallet);
  event SetProtocolFee(uint256 protocolFee);
  event SetProtocolFeeWallet(address indexed feeWallet);
  event Authorize(address indexed signer, address indexed signerWallet);
  event Revoke(address indexed signer, address indexed signerWallet);

  error ChainIdChanged();
  error AdaptersInvalid();
  error FeeInvalid();
  error FeeWalletInvalid();
  error NonceAlreadyUsed(uint256);
  error NonceTooLow();
  error OrderExpired();
  error SenderInvalid();
  error SenderTokenInvalid();
  error AffiliateAmountInvalid();
  error SignatureInvalid();
  error SignatoryInvalid();
  error RoyaltyExceedsMax(uint256);
  error TokenKindUnknown();
  error TransferFailed(address, address);
  error SignatoryUnauthorized();
  error Unauthorized();

  function swap(
    address recipient,
    uint256 maxRoyalty,
    Order calldata order
  ) external;

  function cancel(uint256[] calldata nonces) external;

  function cancelUpTo(uint256 minimumNonce) external;

  function nonceUsed(address, uint256) external view returns (bool);

  function authorize(address sender) external;

  function revoke() external;

  function adapters(bytes4) external view returns (IAdapter);

  function authorized(address) external view returns (address);

  function signatoryMinimumNonce(address) external view returns (uint256);
}
          

Compiler Settings

{"outputSelection":{"*":{"*":["abi","evm.bytecode","evm.deployedBytecode","evm.methodIdentifiers","metadata"],"":["ast"]}},"optimizer":{"runs":999999,"enabled":true},"libraries":{}}
              

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address[]","name":"_adapters","internalType":"contract IAdapter[]"},{"type":"bytes4","name":"_requiredSenderKind","internalType":"bytes4"},{"type":"uint256","name":"_protocolFee","internalType":"uint256"},{"type":"address","name":"_protocolFeeWallet","internalType":"address"}]},{"type":"error","name":"AdaptersInvalid","inputs":[]},{"type":"error","name":"AffiliateAmountInvalid","inputs":[]},{"type":"error","name":"ChainIdChanged","inputs":[]},{"type":"error","name":"FeeInvalid","inputs":[]},{"type":"error","name":"FeeWalletInvalid","inputs":[]},{"type":"error","name":"NonceAlreadyUsed","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"error","name":"NonceTooLow","inputs":[]},{"type":"error","name":"OrderExpired","inputs":[]},{"type":"error","name":"RoyaltyExceedsMax","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"error","name":"SenderInvalid","inputs":[]},{"type":"error","name":"SenderTokenInvalid","inputs":[]},{"type":"error","name":"SignatoryInvalid","inputs":[]},{"type":"error","name":"SignatoryUnauthorized","inputs":[]},{"type":"error","name":"SignatureInvalid","inputs":[]},{"type":"error","name":"TokenKindUnknown","inputs":[]},{"type":"error","name":"TransferFailed","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"address","name":"","internalType":"address"}]},{"type":"error","name":"Unauthorized","inputs":[]},{"type":"event","name":"Authorize","inputs":[{"type":"address","name":"signer","internalType":"address","indexed":true},{"type":"address","name":"signerWallet","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Cancel","inputs":[{"type":"uint256","name":"nonce","internalType":"uint256","indexed":true},{"type":"address","name":"signerWallet","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"CancelUpTo","inputs":[{"type":"uint256","name":"nonce","internalType":"uint256","indexed":true},{"type":"address","name":"signerWallet","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"OwnershipTransferStarted","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Revoke","inputs":[{"type":"address","name":"signer","internalType":"address","indexed":true},{"type":"address","name":"signerWallet","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"SetProtocolFee","inputs":[{"type":"uint256","name":"protocolFee","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"SetProtocolFeeWallet","inputs":[{"type":"address","name":"feeWallet","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Swap","inputs":[{"type":"uint256","name":"nonce","internalType":"uint256","indexed":true},{"type":"address","name":"signerWallet","internalType":"address","indexed":true},{"type":"uint256","name":"signerAmount","internalType":"uint256","indexed":false},{"type":"uint256","name":"signerId","internalType":"uint256","indexed":false},{"type":"address","name":"signerToken","internalType":"address","indexed":false},{"type":"address","name":"senderWallet","internalType":"address","indexed":true},{"type":"uint256","name":"senderAmount","internalType":"uint256","indexed":false},{"type":"uint256","name":"senderId","internalType":"uint256","indexed":false},{"type":"address","name":"senderToken","internalType":"address","indexed":false},{"type":"address","name":"affiliateWallet","internalType":"address","indexed":false},{"type":"uint256","name":"affiliateAmount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"DOMAIN_CHAIN_ID","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"DOMAIN_NAME","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"DOMAIN_SEPARATOR","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"DOMAIN_VERSION","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"FEE_DIVISOR","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"acceptOwnership","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IAdapter"}],"name":"adapters","inputs":[{"type":"bytes4","name":"","internalType":"bytes4"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"authorize","inputs":[{"type":"address","name":"signatory","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"authorized","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"cancel","inputs":[{"type":"uint256[]","name":"nonces","internalType":"uint256[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"cancelUpTo","inputs":[{"type":"uint256","name":"minimumNonce","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32[]","name":"","internalType":"bytes32[]"},{"type":"uint256","name":"","internalType":"uint256"}],"name":"check","inputs":[{"type":"address","name":"senderWallet","internalType":"address"},{"type":"tuple","name":"order","internalType":"struct ISwap.Order","components":[{"type":"uint256","name":"nonce","internalType":"uint256"},{"type":"uint256","name":"expiry","internalType":"uint256"},{"type":"uint256","name":"protocolFee","internalType":"uint256"},{"type":"tuple","name":"signer","internalType":"struct Party","components":[{"type":"address","name":"wallet","internalType":"address"},{"type":"address","name":"token","internalType":"address"},{"type":"bytes4","name":"kind","internalType":"bytes4"},{"type":"uint256","name":"id","internalType":"uint256"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"tuple","name":"sender","internalType":"struct Party","components":[{"type":"address","name":"wallet","internalType":"address"},{"type":"address","name":"token","internalType":"address"},{"type":"bytes4","name":"kind","internalType":"bytes4"},{"type":"uint256","name":"id","internalType":"uint256"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"address","name":"affiliateWallet","internalType":"address"},{"type":"uint256","name":"affiliateAmount","internalType":"uint256"},{"type":"uint8","name":"v","internalType":"uint8"},{"type":"bytes32","name":"r","internalType":"bytes32"},{"type":"bytes32","name":"s","internalType":"bytes32"}]}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"nonceUsed","inputs":[{"type":"address","name":"signer","internalType":"address"},{"type":"uint256","name":"nonce","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"pendingOwner","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"protocolFee","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"protocolFeeWallet","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes4","name":"","internalType":"bytes4"}],"name":"requiredSenderKind","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"revoke","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setProtocolFee","inputs":[{"type":"uint256","name":"_protocolFee","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setProtocolFeeWallet","inputs":[{"type":"address","name":"_protocolFeeWallet","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"signatoryMinimumNonce","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"swap","inputs":[{"type":"address","name":"recipient","internalType":"address"},{"type":"uint256","name":"maxRoyalty","internalType":"uint256"},{"type":"tuple","name":"order","internalType":"struct ISwap.Order","components":[{"type":"uint256","name":"nonce","internalType":"uint256"},{"type":"uint256","name":"expiry","internalType":"uint256"},{"type":"uint256","name":"protocolFee","internalType":"uint256"},{"type":"tuple","name":"signer","internalType":"struct Party","components":[{"type":"address","name":"wallet","internalType":"address"},{"type":"address","name":"token","internalType":"address"},{"type":"bytes4","name":"kind","internalType":"bytes4"},{"type":"uint256","name":"id","internalType":"uint256"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"tuple","name":"sender","internalType":"struct Party","components":[{"type":"address","name":"wallet","internalType":"address"},{"type":"address","name":"token","internalType":"address"},{"type":"bytes4","name":"kind","internalType":"bytes4"},{"type":"uint256","name":"id","internalType":"uint256"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"address","name":"affiliateWallet","internalType":"address"},{"type":"uint256","name":"affiliateAmount","internalType":"uint256"},{"type":"uint8","name":"v","internalType":"uint8"},{"type":"bytes32","name":"r","internalType":"bytes32"},{"type":"bytes32","name":"s","internalType":"bytes32"}]}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]}]
              

Contract Creation Code

0x6101806040523480156200001257600080fd5b50604051620031de380380620031de83398101604081905262000035916200043b565b604051806040016040528060048152602001630535741560e41b815250604051806040016040528060018152602001600d60fa1b8152506200008662000080620002d460201b60201c565b620002d8565b815160209283012081519183019190912060e08290526101008190524660a0818152604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f818801819052818301969096526060810194909452608080850193909352308483018190528151808603909301835260c09485019091528151919095012090529190915261012052612710821062000138576040516352dadcf960e01b815260040160405180910390fd5b6001600160a01b0381166200016057604051636b8df36360e01b815260040160405180910390fd5b83516000036200018357604051632cb13a8760e21b815260040160405180910390fd5b4661014052620001926200034b565b6101605260005b84518110156200029257848181518110620001b857620001b86200053d565b602002602001015160026000878481518110620001d957620001d96200053d565b60200260200101516001600160a01b031663a64d0cd46040518163ffffffff1660e01b8152600401602060405180830381865afa1580156200021f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000245919062000553565b6001600160e01b0319168152602081019190915260400160002080546001600160a01b0319166001600160a01b039290921691909117905580620002898162000578565b91505062000199565b506006805463ffffffff191660e09490941c93909317909255600755600880546001600160a01b0319166001600160a01b0390921691909117905550620005a0565b3390565b600180546001600160a01b0319169055620002ff816200039f602090811b62001a8217901c565b50565b6040805160208101859052908101839052606081018290524660808201523060a082015260009060c0016040516020818303038152906040528051906020012090509392505050565b600060c0516001600160a01b0316306001600160a01b031614801562000372575060a05146145b156200037f575060805190565b6200039a6101205160e051610100516200030260201b60201c565b905090565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b634e487b7160e01b600052604160045260246000fd5b80516001600160a01b03811681146200041d57600080fd5b919050565b80516001600160e01b0319811681146200041d57600080fd5b600080600080608085870312156200045257600080fd5b84516001600160401b03808211156200046a57600080fd5b818701915087601f8301126200047f57600080fd5b8151602082821115620004965762000496620003ef565b8160051b604051601f19603f83011681018181108682111715620004be57620004be620003ef565b60405292835281830193508481018201928b841115620004dd57600080fd5b948201945b838610156200050657620004f68662000405565b85529482019493820193620004e2565b985062000517905089820162000422565b96505050505060408501519150620005326060860162000405565b905092959194509250565b634e487b7160e01b600052603260045260246000fd5b6000602082840312156200056657600080fd5b620005718262000422565b9392505050565b6000600182016200059957634e487b7160e01b600052601160045260246000fd5b5060010190565b60805160a05160c05160e05161010051610120516101405161016051612bdc620006026000396000818161022801526122bf0152600081816102700152611c820152600050506000505060005050600050506000505060005050612bdc6000f3fe608060405234801561001057600080fd5b50600436106101a35760003560e01c80637cf8e60f116100ee578063b6549f7511610097578063cbf7c6c311610071578063cbf7c6c31461045c578063e30c39781461047c578063e728bfa51461049a578063f2fde38b146104bb57600080fd5b8063b6549f751461040b578063b6a5d7de14610413578063b91816111461042657600080fd5b8063acb8cc49116100c8578063acb8cc49146103a6578063b0dd4943146103e2578063b0e21e8a1461040257600080fd5b80637cf8e60f1461036c5780638da5cb5b1461037f5780639e93ad8e1461039d57600080fd5b80636e03875211610150578063796f077b1161012a578063796f077b1461030857806379ba5097146103515780637ce785251461035957600080fd5b80636e03875214610292578063715018a6146102ed578063787dce3d146102f557600080fd5b80633644e515116101815780633644e515146102235780633c64191014610258578063416f281d1461026b57600080fd5b806306a6ea74146101a85780631647795e146101eb5780632e3408231461020e575b600080fd5b6006546101b59060e01b81565b6040517fffffffff0000000000000000000000000000000000000000000000000000000090911681526020015b60405180910390f35b6101fe6101f93660046126e6565b6104ce565b60405190151581526020016101e2565b61022161021c366004612712565b610533565b005b61024a7f000000000000000000000000000000000000000000000000000000000000000081565b6040519081526020016101e2565b610221610266366004612787565b6105aa565b61024a7f000000000000000000000000000000000000000000000000000000000000000081565b6102c86102a03660046127d0565b60026020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101e2565b6102216105e6565b610221610303366004612787565b6105fa565b6103446040518060400160405280600481526020017f535741500000000000000000000000000000000000000000000000000000000081525081565b6040516101e29190612816565b610221610678565b610221610367366004612867565b610732565b61022161037a36600461289d565b6107f6565b60005473ffffffffffffffffffffffffffffffffffffffff166102c8565b61024a61271081565b6103446040518060400160405280600181526020017f340000000000000000000000000000000000000000000000000000000000000081525081565b61024a6103f0366004612867565b60046020526000908152604090205481565b61024a60075481565b610221610c67565b610221610421366004612867565b610ce4565b6102c8610434366004612867565b60036020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b6008546102c89073ffffffffffffffffffffffffffffffffffffffff1681565b60015473ffffffffffffffffffffffffffffffffffffffff166102c8565b6104ad6104a83660046128dd565b610dac565b6040516101e2929190612914565b6102216104c9366004612867565b6119d2565b6000806104dd610100846129ba565b905060006104ed610100856129ce565b73ffffffffffffffffffffffffffffffffffffffff8616600090815260056020908152604080832095835294905292909220546001921c82169091149150505b92915050565b60005b818110156105a5576000838383818110610552576105526129e2565b9050602002013590506105653382611af7565b604051339082907f8dd3c361eb2366ff27c2db0eb07b9261f1d052570742ab8c9a0c326f37aa576d90600090a3508061059d81612a11565b915050610536565b505050565b336000818152600460205260408082208490555183917f863123978d9b13946753a916c935c0688a01802440d3ffc668d04d2720c4e11091a350565b6105ee611bcd565b6105f86000611c4e565b565b610602611bcd565b612710811061063d576040517f52dadcf900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60078190556040518181527fdc0410a296e1e33943a772020d333d5f99319d7fcad932a484c53889f7aaa2b19060200160405180910390a150565b600154339073ffffffffffffffffffffffffffffffffffffffff168114610726576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f74207468652060448201527f6e6577206f776e6572000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b61072f81611c4e565b50565b61073a611bcd565b73ffffffffffffffffffffffffffffffffffffffff8116610787576040517f6b8df36300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600880547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040517f8b2a800ce9e2e7ccdf4741ae0e41b1f16983192291080ae3b78ac4296ddf598a90600090a250565b6107ff81611c7f565b600061081361012083016101008401612867565b73ffffffffffffffffffffffffffffffffffffffff161415801561085e57503361084561012083016101008401612867565b73ffffffffffffffffffffffffffffffffffffffff1614155b15610895576040517fa7202ef600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6108de336108a96080840160608501612867565b6101808401356101608501356108c761014087016101208801612867565b6108d9610160880161014089016127d0565b612012565b61091c6108f16080830160608401612867565b8460e084013560c085013561090c60a0870160808801612867565b6108d960c0880160a089016127d0565b60006109306101c083016101a08401612867565b73ffffffffffffffffffffffffffffffffffffffff16146109905761099061096061012083016101008401612867565b6109726101c084016101a08501612867565b6101c08401356101608501356108c761014087016101208801612867565b600754600090612710906109a990610180850135612a49565b6109b391906129ba565b90508015610a1457610a146109d061012084016101008501612867565b60085473ffffffffffffffffffffffffffffffffffffffff1683610160860135610a0261014088016101208901612867565b6108d961016089016101408a016127d0565b610a2c610a2760a0840160808501612867565b6121e3565b15610b6e57600080610a4460a0850160808601612867565b6040517f2a55205a00000000000000000000000000000000000000000000000000000000815260c08601356004820152610180860135602482015273ffffffffffffffffffffffffffffffffffffffff9190911690632a55205a906044016040805180830381865afa158015610abe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ae29190612a60565b90925090508015610b6b5784811115610b2a576040517f9c08743a0000000000000000000000000000000000000000000000000000000081526004810182905260240161071d565b610b6b610b3f61012086016101008701612867565b8383610160880135610b596101408a016101208b01612867565b6108d96101608b016101408c016127d0565b50505b33610b7f6080840160608501612867565b73ffffffffffffffffffffffffffffffffffffffff1683357f182e847dc18073123e8aa17e204b9e3874caf71387e52fe3083ffb98716d3d6b60e086013560c0870135610bd260a0890160808a01612867565b6101808901356101608a0135610bf06101408c016101208d01612867565b610c026101c08d016101a08e01612867565b60408051978852602088019690965273ffffffffffffffffffffffffffffffffffffffff9485169587019590955260608601929092526080850152811660a08401521660c08201526101c087013560e08201526101000160405180910390a450505050565b3360008181526003602052604080822080547fffffffffffffffffffffffff00000000000000000000000000000000000000008116909155905173ffffffffffffffffffffffffffffffffffffffff909116929183917fd7426110292f20fe59e73ccf52124e0f5440a756507c91c7b0a6c50e1eb1a23a9190a350565b73ffffffffffffffffffffffffffffffffffffffff8116610d31576040517fcd4b78cf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3360008181526003602052604080822080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8616908117909155905190917f30468de898bda644e26bab66e5a2241a3aa6aaf527257f5ca54e0f65204ba14a91a350565b6040805160108082526102208201909252606091600091829182919060208201610200803683370190505090506000610e0a610de7876122bb565b610df961020089016101e08a01612a8e565b8861020001358961022001356125d5565b5090506000610e2161012088016101008901612867565b73ffffffffffffffffffffffffffffffffffffffff1614158015610e82575073ffffffffffffffffffffffffffffffffffffffff8716610e6961012088016101008901612867565b73ffffffffffffffffffffffffffffffffffffffff1614155b15610ed3577f53656e646572496e76616c696400000000000000000000000000000000000000828481518110610eba57610eba6129e2565b602090810291909101015282610ecf81612a11565b9350505b73ffffffffffffffffffffffffffffffffffffffff8116610f3e577f5369676e6174757265496e76616c696400000000000000000000000000000000828481518110610f2157610f216129e2565b602090810291909101015282610f3681612a11565b9350506111b5565b6000600381610f5360808a0160608b01612867565b73ffffffffffffffffffffffffffffffffffffffff90811682526020820192909252604001600020541614801590610fcb575060036000610f9a6080890160608a01612867565b73ffffffffffffffffffffffffffffffffffffffff9081168252602082019290925260400160002054828216911614155b15611020577f5369676e61746f7279556e617574686f72697a65640000000000000000000000828481518110611003576110036129e2565b60209081029190910101528261101881612a11565b93505061113b565b600060038161103560808a0160608b01612867565b73ffffffffffffffffffffffffffffffffffffffff9081168252602082019290925260400160002054161480156110a757506110776080870160608801612867565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614155b156110df577f556e617574686f72697a65640000000000000000000000000000000000000000828481518110611003576110036129e2565b6110ea8187356104ce565b1561113b577f4e6f6e6365416c72656164795573656400000000000000000000000000000000828481518110611122576111226129e2565b60209081029190910101528261113781612a11565b9350505b73ffffffffffffffffffffffffffffffffffffffff8116600090815260046020526040902054863510156111b5577f4e6f6e6365546f6f4c6f7700000000000000000000000000000000000000000082848151811061119c5761119c6129e2565b6020908102919091010152826111b181612a11565b9350505b428660200135101561120d577f4f726465724578706972656400000000000000000000000000000000000000008284815181106111f4576111f46129e2565b60209081029190910101528261120981612a11565b9350505b600060028161122260c08a0160a08b016127d0565b7fffffffff0000000000000000000000000000000000000000000000000000000016815260208101919091526040016000205473ffffffffffffffffffffffffffffffffffffffff169050806112c2577f5369676e6572546f6b656e4b696e64556e6b6e6f776e000000000000000000008385815181106112a5576112a56129e2565b6020908102919091010152836112ba81612a11565b94505061148e565b6040517f3170f63d00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821690633170f63d906113179060608b0190600401612b33565b602060405180830381865afa158015611334573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113589190612b41565b6113a8577f5369676e6572416c6c6f77616e63654c6f77000000000000000000000000000083858151811061138f5761138f6129e2565b6020908102919091010152836113a481612a11565b9450505b6040517fd1190df900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82169063d1190df9906113fd9060608b0190600401612b33565b602060405180830381865afa15801561141a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061143e9190612b41565b61148e577f5369676e657242616c616e63654c6f7700000000000000000000000000000000838581518110611475576114756129e2565b60209081029190910101528361148a81612a11565b9450505b60006002816114a56101608b016101408c016127d0565b7fffffffff0000000000000000000000000000000000000000000000000000000016815260208101919091526040016000205473ffffffffffffffffffffffffffffffffffffffff16905080611545577f53656e646572546f6b656e4b696e64556e6b6e6f776e00000000000000000000848681518110611528576115286129e2565b60209081029190910101528461153d81612a11565b95505061196a565b60065460e01b7fffffffff000000000000000000000000000000000000000000000000000000001661157f6101608a016101408b016127d0565b7fffffffff0000000000000000000000000000000000000000000000000000000016146115d9577f53656e646572546f6b656e496e76616c69640000000000000000000000000000848681518110611528576115286129e2565b600754600090612710906115f2906101808c0135612a49565b6115fc91906129ba565b905060006101c08a0135611615836101808d0135612b63565b61161f9190612b63565b6040805160a0810190915273ffffffffffffffffffffffffffffffffffffffff8d1681529091506000906020810161165f6101408e016101208f01612867565b73ffffffffffffffffffffffffffffffffffffffff16815260200161168c6101608e016101408f016127d0565b7fffffffff0000000000000000000000000000000000000000000000000000000090811682526101608e0135602080840191909152604092830186905282517f3170f63d000000000000000000000000000000000000000000000000000000008152845173ffffffffffffffffffffffffffffffffffffffff90811660048301529185015182166024820152928401519091166044830152606083015160648301526080830151608483015291925090851690633170f63d9060a401602060405180830381865afa158015611765573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117899190612b41565b6117d9577f53656e646572416c6c6f77616e63654c6f7700000000000000000000000000008789815181106117c0576117c06129e2565b6020908102919091010152876117d581612a11565b9850505b604080517fd1190df9000000000000000000000000000000000000000000000000000000008152825173ffffffffffffffffffffffffffffffffffffffff9081166004830152602084015181166024830152918301517fffffffff0000000000000000000000000000000000000000000000000000000016604482015260608301516064820152608083015160848201529085169063d1190df99060a401602060405180830381865afa158015611894573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118b89190612b41565b611908577f53656e64657242616c616e63654c6f77000000000000000000000000000000008789815181106118ef576118ef6129e2565b60209081029190910101528761190481612a11565b9850505b6101c08b01356101808c01351015611966577f416666696c69617465416d6f756e74496e76616c69640000000000000000000087898151811061194d5761194d6129e2565b60209081029190910101528761196281612a11565b9850505b5050505b6007548860400135146119c3577f466565496e76616c6964000000000000000000000000000000000000000000008486815181106119aa576119aa6129e2565b6020908102919091010152846119bf81612a11565b9550505b50919792965091945050505050565b6119da611bcd565b6001805473ffffffffffffffffffffffffffffffffffffffff83167fffffffffffffffffffffffff00000000000000000000000000000000000000009091168117909155611a3d60005473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000611b05610100836129ba565b90506000611b15610100846129ce565b73ffffffffffffffffffffffffffffffffffffffff85166000908152600560209081526040808320868452909152902054909150600181831c81169003611b8b576040517f91cab5040000000000000000000000000000000000000000000000000000000081526004810185905260240161071d565b73ffffffffffffffffffffffffffffffffffffffff909416600090815260056020908152604080832094835293905291909120600190911b9290921790915550565b60005473ffffffffffffffffffffffffffffffffffffffff1633146105f8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161071d565b600180547fffffffffffffffffffffffff000000000000000000000000000000000000000016905561072f81611a82565b467f000000000000000000000000000000000000000000000000000000000000000014611cd8576040517fc614eff800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60065460e01b7fffffffff0000000000000000000000000000000000000000000000000000000016611d12610160830161014084016127d0565b7fffffffff000000000000000000000000000000000000000000000000000000001614611d6b576040517fd0bd721a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6101c08101356101808201351015611daf576040517f3b71bbca00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000611de0611dbd836122bb565b611dcf61020085016101e08601612a8e565b8461020001358561022001356125d5565b50905073ffffffffffffffffffffffffffffffffffffffff8116611e30576040517f37e8456b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000600381611e456080860160608701612867565b73ffffffffffffffffffffffffffffffffffffffff90811682526020820192909252604001600020541614611ef25760036000611e886080850160608601612867565b73ffffffffffffffffffffffffffffffffffffffff9081168252602082019290925260400160002054828216911614611eed576040517f9e7fe83900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611f66565b611f026080830160608401612867565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614611f66576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611f71818335611af7565b73ffffffffffffffffffffffffffffffffffffffff811660009081526004602052604090205482351015611fd1576040517fd24d82a400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b4282602001351161200e576040517fc56873ba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050565b7fffffffff00000000000000000000000000000000000000000000000000000000811660009081526002602052604090205473ffffffffffffffffffffffffffffffffffffffff1680612091576040517f33c8207c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805173ffffffffffffffffffffffffffffffffffffffff89811660248301528881166044830152606482018890526084820187905285811660a4808401919091528351808403909101815260c490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f47338bc300000000000000000000000000000000000000000000000000000000179052915160009284169161213e91612b76565b600060405180830381855af49150503d8060008114612179576040519150601f19603f3d011682016040523d82523d6000602084013e61217e565b606091505b50509050806121d9576040517f523c3aaa00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff808a1660048301528816602482015260440161071d565b5050505050505050565b6040517f01ffc9a70000000000000000000000000000000000000000000000000000000081527f2a55205a00000000000000000000000000000000000000000000000000000000600482015260009073ffffffffffffffffffffffffffffffffffffffff8316906301ffc9a790602401602060405180830381865afa9250505080156122aa575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682019092526122a791810190612b41565b60015b61052d57506000919050565b919050565b60007f000000000000000000000000000000000000000000000000000000000000000060405160200161241b907f4f726465722875696e74323536206e6f6e63652c75696e74323536206578706981527f72792c75696e743235362070726f746f636f6c4665652c50617274792073696760208201527f6e65722c50617274792073656e6465722c6164647265737320616666696c696160408201527f746557616c6c65742c75696e7432353620616666696c69617465416d6f756e7460608201527f290000000000000000000000000000000000000000000000000000000000000060808201527f506172747928616464726573732077616c6c65742c6164647265737320746f6b60818201527f656e2c627974657334206b696e642c75696e743235362069642c75696e74323560a18201527f3620616d6f756e7429000000000000000000000000000000000000000000000060c182015260ca0190565b60405160208183030381529060405280519060200120836000013584602001356007547f224ed05dccb4f5c1e21e6e85fb29dd6c83074e33458fdfefb184d03fe8742f4f87606001604051602001612474929190612b92565b604051602081830303815290604052805190602001207f224ed05dccb4f5c1e21e6e85fb29dd6c83074e33458fdfefb184d03fe8742f4f88610100016040516020016124c1929190612b92565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291905280516020909101206125096101c08a016101a08b01612867565b6040805160208101989098528701959095526060860193909352608085019190915260a084015260c083015273ffffffffffffffffffffffffffffffffffffffff1660e08201526101c084013561010082015261012001604051602081830303815290604052805190602001206040516020016125b89291907f190100000000000000000000000000000000000000000000000000000000000081526002810192909252602282015260420190565b604051602081830303815290604052805190602001209050919050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561260c57506000905060036126bb565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015612660573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff81166126b4576000600192509250506126bb565b9150600090505b94509492505050565b73ffffffffffffffffffffffffffffffffffffffff8116811461072f57600080fd5b600080604083850312156126f957600080fd5b8235612704816126c4565b946020939093013593505050565b6000806020838503121561272557600080fd5b823567ffffffffffffffff8082111561273d57600080fd5b818501915085601f83011261275157600080fd5b81358181111561276057600080fd5b8660208260051b850101111561277557600080fd5b60209290920196919550909350505050565b60006020828403121561279957600080fd5b5035919050565b80357fffffffff00000000000000000000000000000000000000000000000000000000811681146122b657600080fd5b6000602082840312156127e257600080fd5b6127eb826127a0565b9392505050565b60005b8381101561280d5781810151838201526020016127f5565b50506000910152565b60208152600082518060208401526128358160408501602087016127f2565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b60006020828403121561287957600080fd5b81356127eb816126c4565b6000610240828403121561289757600080fd5b50919050565b600080600061028084860312156128b357600080fd5b83356128be816126c4565b9250602084013591506128d48560408601612884565b90509250925092565b60008061026083850312156128f157600080fd5b82356128fc816126c4565b915061290b8460208501612884565b90509250929050565b604080825283519082018190526000906020906060840190828701845b8281101561294d57815184529284019290840190600101612931565b50505092019290925292915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000826129c9576129c961295c565b500490565b6000826129dd576129dd61295c565b500690565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203612a4257612a4261298b565b5060010190565b808202811582820484141761052d5761052d61298b565b60008060408385031215612a7357600080fd5b8251612a7e816126c4565b6020939093015192949293505050565b600060208284031215612aa057600080fd5b813560ff811681146127eb57600080fd5b8035612abc816126c4565b73ffffffffffffffffffffffffffffffffffffffff9081168352602082013590612ae5826126c4565b1660208301527fffffffff00000000000000000000000000000000000000000000000000000000612b18604083016127a0565b16604083015260608181013590830152608090810135910152565b60a0810161052d8284612ab1565b600060208284031215612b5357600080fd5b815180151581146127eb57600080fd5b8082018082111561052d5761052d61298b565b60008251612b888184602087016127f2565b9190910192915050565b82815260c081016127eb6020830184612ab156fea26469706673582212206540fcdaf7e0e494fdcbd48b6edf28b205a1c48b8a2cf220d80ccb50a2ff21fe64736f6c63430008110033000000000000000000000000000000000000000000000000000000000000008036372b070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000070000000000000000000000003768bec96a282273fe3756a92c4f6d7d06aa289b0000000000000000000000000000000000000000000000000000000000000003000000000000000000000000a9964a60a620c00150114614f745646b898cfe32000000000000000000000000cb3839a953533339273e251dd179515b7ba9a309000000000000000000000000d82fa167727a4dc6d6f55830a2c47abbb4b3a0f8

Deployed ByteCode

0x608060405234801561001057600080fd5b50600436106101a35760003560e01c80637cf8e60f116100ee578063b6549f7511610097578063cbf7c6c311610071578063cbf7c6c31461045c578063e30c39781461047c578063e728bfa51461049a578063f2fde38b146104bb57600080fd5b8063b6549f751461040b578063b6a5d7de14610413578063b91816111461042657600080fd5b8063acb8cc49116100c8578063acb8cc49146103a6578063b0dd4943146103e2578063b0e21e8a1461040257600080fd5b80637cf8e60f1461036c5780638da5cb5b1461037f5780639e93ad8e1461039d57600080fd5b80636e03875211610150578063796f077b1161012a578063796f077b1461030857806379ba5097146103515780637ce785251461035957600080fd5b80636e03875214610292578063715018a6146102ed578063787dce3d146102f557600080fd5b80633644e515116101815780633644e515146102235780633c64191014610258578063416f281d1461026b57600080fd5b806306a6ea74146101a85780631647795e146101eb5780632e3408231461020e575b600080fd5b6006546101b59060e01b81565b6040517fffffffff0000000000000000000000000000000000000000000000000000000090911681526020015b60405180910390f35b6101fe6101f93660046126e6565b6104ce565b60405190151581526020016101e2565b61022161021c366004612712565b610533565b005b61024a7f20b25bb74945e91dc3134cfd9762a7d60c5f249f3b3e52f05aac03c8b02944eb81565b6040519081526020016101e2565b610221610266366004612787565b6105aa565b61024a7f000000000000000000000000000000000000000000000000000000000000e70481565b6102c86102a03660046127d0565b60026020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101e2565b6102216105e6565b610221610303366004612787565b6105fa565b6103446040518060400160405280600481526020017f535741500000000000000000000000000000000000000000000000000000000081525081565b6040516101e29190612816565b610221610678565b610221610367366004612867565b610732565b61022161037a36600461289d565b6107f6565b60005473ffffffffffffffffffffffffffffffffffffffff166102c8565b61024a61271081565b6103446040518060400160405280600181526020017f340000000000000000000000000000000000000000000000000000000000000081525081565b61024a6103f0366004612867565b60046020526000908152604090205481565b61024a60075481565b610221610c67565b610221610421366004612867565b610ce4565b6102c8610434366004612867565b60036020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b6008546102c89073ffffffffffffffffffffffffffffffffffffffff1681565b60015473ffffffffffffffffffffffffffffffffffffffff166102c8565b6104ad6104a83660046128dd565b610dac565b6040516101e2929190612914565b6102216104c9366004612867565b6119d2565b6000806104dd610100846129ba565b905060006104ed610100856129ce565b73ffffffffffffffffffffffffffffffffffffffff8616600090815260056020908152604080832095835294905292909220546001921c82169091149150505b92915050565b60005b818110156105a5576000838383818110610552576105526129e2565b9050602002013590506105653382611af7565b604051339082907f8dd3c361eb2366ff27c2db0eb07b9261f1d052570742ab8c9a0c326f37aa576d90600090a3508061059d81612a11565b915050610536565b505050565b336000818152600460205260408082208490555183917f863123978d9b13946753a916c935c0688a01802440d3ffc668d04d2720c4e11091a350565b6105ee611bcd565b6105f86000611c4e565b565b610602611bcd565b612710811061063d576040517f52dadcf900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60078190556040518181527fdc0410a296e1e33943a772020d333d5f99319d7fcad932a484c53889f7aaa2b19060200160405180910390a150565b600154339073ffffffffffffffffffffffffffffffffffffffff168114610726576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f74207468652060448201527f6e6577206f776e6572000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b61072f81611c4e565b50565b61073a611bcd565b73ffffffffffffffffffffffffffffffffffffffff8116610787576040517f6b8df36300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600880547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040517f8b2a800ce9e2e7ccdf4741ae0e41b1f16983192291080ae3b78ac4296ddf598a90600090a250565b6107ff81611c7f565b600061081361012083016101008401612867565b73ffffffffffffffffffffffffffffffffffffffff161415801561085e57503361084561012083016101008401612867565b73ffffffffffffffffffffffffffffffffffffffff1614155b15610895576040517fa7202ef600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6108de336108a96080840160608501612867565b6101808401356101608501356108c761014087016101208801612867565b6108d9610160880161014089016127d0565b612012565b61091c6108f16080830160608401612867565b8460e084013560c085013561090c60a0870160808801612867565b6108d960c0880160a089016127d0565b60006109306101c083016101a08401612867565b73ffffffffffffffffffffffffffffffffffffffff16146109905761099061096061012083016101008401612867565b6109726101c084016101a08501612867565b6101c08401356101608501356108c761014087016101208801612867565b600754600090612710906109a990610180850135612a49565b6109b391906129ba565b90508015610a1457610a146109d061012084016101008501612867565b60085473ffffffffffffffffffffffffffffffffffffffff1683610160860135610a0261014088016101208901612867565b6108d961016089016101408a016127d0565b610a2c610a2760a0840160808501612867565b6121e3565b15610b6e57600080610a4460a0850160808601612867565b6040517f2a55205a00000000000000000000000000000000000000000000000000000000815260c08601356004820152610180860135602482015273ffffffffffffffffffffffffffffffffffffffff9190911690632a55205a906044016040805180830381865afa158015610abe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ae29190612a60565b90925090508015610b6b5784811115610b2a576040517f9c08743a0000000000000000000000000000000000000000000000000000000081526004810182905260240161071d565b610b6b610b3f61012086016101008701612867565b8383610160880135610b596101408a016101208b01612867565b6108d96101608b016101408c016127d0565b50505b33610b7f6080840160608501612867565b73ffffffffffffffffffffffffffffffffffffffff1683357f182e847dc18073123e8aa17e204b9e3874caf71387e52fe3083ffb98716d3d6b60e086013560c0870135610bd260a0890160808a01612867565b6101808901356101608a0135610bf06101408c016101208d01612867565b610c026101c08d016101a08e01612867565b60408051978852602088019690965273ffffffffffffffffffffffffffffffffffffffff9485169587019590955260608601929092526080850152811660a08401521660c08201526101c087013560e08201526101000160405180910390a450505050565b3360008181526003602052604080822080547fffffffffffffffffffffffff00000000000000000000000000000000000000008116909155905173ffffffffffffffffffffffffffffffffffffffff909116929183917fd7426110292f20fe59e73ccf52124e0f5440a756507c91c7b0a6c50e1eb1a23a9190a350565b73ffffffffffffffffffffffffffffffffffffffff8116610d31576040517fcd4b78cf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3360008181526003602052604080822080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8616908117909155905190917f30468de898bda644e26bab66e5a2241a3aa6aaf527257f5ca54e0f65204ba14a91a350565b6040805160108082526102208201909252606091600091829182919060208201610200803683370190505090506000610e0a610de7876122bb565b610df961020089016101e08a01612a8e565b8861020001358961022001356125d5565b5090506000610e2161012088016101008901612867565b73ffffffffffffffffffffffffffffffffffffffff1614158015610e82575073ffffffffffffffffffffffffffffffffffffffff8716610e6961012088016101008901612867565b73ffffffffffffffffffffffffffffffffffffffff1614155b15610ed3577f53656e646572496e76616c696400000000000000000000000000000000000000828481518110610eba57610eba6129e2565b602090810291909101015282610ecf81612a11565b9350505b73ffffffffffffffffffffffffffffffffffffffff8116610f3e577f5369676e6174757265496e76616c696400000000000000000000000000000000828481518110610f2157610f216129e2565b602090810291909101015282610f3681612a11565b9350506111b5565b6000600381610f5360808a0160608b01612867565b73ffffffffffffffffffffffffffffffffffffffff90811682526020820192909252604001600020541614801590610fcb575060036000610f9a6080890160608a01612867565b73ffffffffffffffffffffffffffffffffffffffff9081168252602082019290925260400160002054828216911614155b15611020577f5369676e61746f7279556e617574686f72697a65640000000000000000000000828481518110611003576110036129e2565b60209081029190910101528261101881612a11565b93505061113b565b600060038161103560808a0160608b01612867565b73ffffffffffffffffffffffffffffffffffffffff9081168252602082019290925260400160002054161480156110a757506110776080870160608801612867565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614155b156110df577f556e617574686f72697a65640000000000000000000000000000000000000000828481518110611003576110036129e2565b6110ea8187356104ce565b1561113b577f4e6f6e6365416c72656164795573656400000000000000000000000000000000828481518110611122576111226129e2565b60209081029190910101528261113781612a11565b9350505b73ffffffffffffffffffffffffffffffffffffffff8116600090815260046020526040902054863510156111b5577f4e6f6e6365546f6f4c6f7700000000000000000000000000000000000000000082848151811061119c5761119c6129e2565b6020908102919091010152826111b181612a11565b9350505b428660200135101561120d577f4f726465724578706972656400000000000000000000000000000000000000008284815181106111f4576111f46129e2565b60209081029190910101528261120981612a11565b9350505b600060028161122260c08a0160a08b016127d0565b7fffffffff0000000000000000000000000000000000000000000000000000000016815260208101919091526040016000205473ffffffffffffffffffffffffffffffffffffffff169050806112c2577f5369676e6572546f6b656e4b696e64556e6b6e6f776e000000000000000000008385815181106112a5576112a56129e2565b6020908102919091010152836112ba81612a11565b94505061148e565b6040517f3170f63d00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821690633170f63d906113179060608b0190600401612b33565b602060405180830381865afa158015611334573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113589190612b41565b6113a8577f5369676e6572416c6c6f77616e63654c6f77000000000000000000000000000083858151811061138f5761138f6129e2565b6020908102919091010152836113a481612a11565b9450505b6040517fd1190df900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82169063d1190df9906113fd9060608b0190600401612b33565b602060405180830381865afa15801561141a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061143e9190612b41565b61148e577f5369676e657242616c616e63654c6f7700000000000000000000000000000000838581518110611475576114756129e2565b60209081029190910101528361148a81612a11565b9450505b60006002816114a56101608b016101408c016127d0565b7fffffffff0000000000000000000000000000000000000000000000000000000016815260208101919091526040016000205473ffffffffffffffffffffffffffffffffffffffff16905080611545577f53656e646572546f6b656e4b696e64556e6b6e6f776e00000000000000000000848681518110611528576115286129e2565b60209081029190910101528461153d81612a11565b95505061196a565b60065460e01b7fffffffff000000000000000000000000000000000000000000000000000000001661157f6101608a016101408b016127d0565b7fffffffff0000000000000000000000000000000000000000000000000000000016146115d9577f53656e646572546f6b656e496e76616c69640000000000000000000000000000848681518110611528576115286129e2565b600754600090612710906115f2906101808c0135612a49565b6115fc91906129ba565b905060006101c08a0135611615836101808d0135612b63565b61161f9190612b63565b6040805160a0810190915273ffffffffffffffffffffffffffffffffffffffff8d1681529091506000906020810161165f6101408e016101208f01612867565b73ffffffffffffffffffffffffffffffffffffffff16815260200161168c6101608e016101408f016127d0565b7fffffffff0000000000000000000000000000000000000000000000000000000090811682526101608e0135602080840191909152604092830186905282517f3170f63d000000000000000000000000000000000000000000000000000000008152845173ffffffffffffffffffffffffffffffffffffffff90811660048301529185015182166024820152928401519091166044830152606083015160648301526080830151608483015291925090851690633170f63d9060a401602060405180830381865afa158015611765573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117899190612b41565b6117d9577f53656e646572416c6c6f77616e63654c6f7700000000000000000000000000008789815181106117c0576117c06129e2565b6020908102919091010152876117d581612a11565b9850505b604080517fd1190df9000000000000000000000000000000000000000000000000000000008152825173ffffffffffffffffffffffffffffffffffffffff9081166004830152602084015181166024830152918301517fffffffff0000000000000000000000000000000000000000000000000000000016604482015260608301516064820152608083015160848201529085169063d1190df99060a401602060405180830381865afa158015611894573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118b89190612b41565b611908577f53656e64657242616c616e63654c6f77000000000000000000000000000000008789815181106118ef576118ef6129e2565b60209081029190910101528761190481612a11565b9850505b6101c08b01356101808c01351015611966577f416666696c69617465416d6f756e74496e76616c69640000000000000000000087898151811061194d5761194d6129e2565b60209081029190910101528761196281612a11565b9850505b5050505b6007548860400135146119c3577f466565496e76616c6964000000000000000000000000000000000000000000008486815181106119aa576119aa6129e2565b6020908102919091010152846119bf81612a11565b9550505b50919792965091945050505050565b6119da611bcd565b6001805473ffffffffffffffffffffffffffffffffffffffff83167fffffffffffffffffffffffff00000000000000000000000000000000000000009091168117909155611a3d60005473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000611b05610100836129ba565b90506000611b15610100846129ce565b73ffffffffffffffffffffffffffffffffffffffff85166000908152600560209081526040808320868452909152902054909150600181831c81169003611b8b576040517f91cab5040000000000000000000000000000000000000000000000000000000081526004810185905260240161071d565b73ffffffffffffffffffffffffffffffffffffffff909416600090815260056020908152604080832094835293905291909120600190911b9290921790915550565b60005473ffffffffffffffffffffffffffffffffffffffff1633146105f8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161071d565b600180547fffffffffffffffffffffffff000000000000000000000000000000000000000016905561072f81611a82565b467f000000000000000000000000000000000000000000000000000000000000e70414611cd8576040517fc614eff800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60065460e01b7fffffffff0000000000000000000000000000000000000000000000000000000016611d12610160830161014084016127d0565b7fffffffff000000000000000000000000000000000000000000000000000000001614611d6b576040517fd0bd721a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6101c08101356101808201351015611daf576040517f3b71bbca00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000611de0611dbd836122bb565b611dcf61020085016101e08601612a8e565b8461020001358561022001356125d5565b50905073ffffffffffffffffffffffffffffffffffffffff8116611e30576040517f37e8456b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000600381611e456080860160608701612867565b73ffffffffffffffffffffffffffffffffffffffff90811682526020820192909252604001600020541614611ef25760036000611e886080850160608601612867565b73ffffffffffffffffffffffffffffffffffffffff9081168252602082019290925260400160002054828216911614611eed576040517f9e7fe83900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611f66565b611f026080830160608401612867565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614611f66576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611f71818335611af7565b73ffffffffffffffffffffffffffffffffffffffff811660009081526004602052604090205482351015611fd1576040517fd24d82a400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b4282602001351161200e576040517fc56873ba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050565b7fffffffff00000000000000000000000000000000000000000000000000000000811660009081526002602052604090205473ffffffffffffffffffffffffffffffffffffffff1680612091576040517f33c8207c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805173ffffffffffffffffffffffffffffffffffffffff89811660248301528881166044830152606482018890526084820187905285811660a4808401919091528351808403909101815260c490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f47338bc300000000000000000000000000000000000000000000000000000000179052915160009284169161213e91612b76565b600060405180830381855af49150503d8060008114612179576040519150601f19603f3d011682016040523d82523d6000602084013e61217e565b606091505b50509050806121d9576040517f523c3aaa00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff808a1660048301528816602482015260440161071d565b5050505050505050565b6040517f01ffc9a70000000000000000000000000000000000000000000000000000000081527f2a55205a00000000000000000000000000000000000000000000000000000000600482015260009073ffffffffffffffffffffffffffffffffffffffff8316906301ffc9a790602401602060405180830381865afa9250505080156122aa575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682019092526122a791810190612b41565b60015b61052d57506000919050565b919050565b60007f20b25bb74945e91dc3134cfd9762a7d60c5f249f3b3e52f05aac03c8b02944eb60405160200161241b907f4f726465722875696e74323536206e6f6e63652c75696e74323536206578706981527f72792c75696e743235362070726f746f636f6c4665652c50617274792073696760208201527f6e65722c50617274792073656e6465722c6164647265737320616666696c696160408201527f746557616c6c65742c75696e7432353620616666696c69617465416d6f756e7460608201527f290000000000000000000000000000000000000000000000000000000000000060808201527f506172747928616464726573732077616c6c65742c6164647265737320746f6b60818201527f656e2c627974657334206b696e642c75696e743235362069642c75696e74323560a18201527f3620616d6f756e7429000000000000000000000000000000000000000000000060c182015260ca0190565b60405160208183030381529060405280519060200120836000013584602001356007547f224ed05dccb4f5c1e21e6e85fb29dd6c83074e33458fdfefb184d03fe8742f4f87606001604051602001612474929190612b92565b604051602081830303815290604052805190602001207f224ed05dccb4f5c1e21e6e85fb29dd6c83074e33458fdfefb184d03fe8742f4f88610100016040516020016124c1929190612b92565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291905280516020909101206125096101c08a016101a08b01612867565b6040805160208101989098528701959095526060860193909352608085019190915260a084015260c083015273ffffffffffffffffffffffffffffffffffffffff1660e08201526101c084013561010082015261012001604051602081830303815290604052805190602001206040516020016125b89291907f190100000000000000000000000000000000000000000000000000000000000081526002810192909252602282015260420190565b604051602081830303815290604052805190602001209050919050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561260c57506000905060036126bb565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015612660573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff81166126b4576000600192509250506126bb565b9150600090505b94509492505050565b73ffffffffffffffffffffffffffffffffffffffff8116811461072f57600080fd5b600080604083850312156126f957600080fd5b8235612704816126c4565b946020939093013593505050565b6000806020838503121561272557600080fd5b823567ffffffffffffffff8082111561273d57600080fd5b818501915085601f83011261275157600080fd5b81358181111561276057600080fd5b8660208260051b850101111561277557600080fd5b60209290920196919550909350505050565b60006020828403121561279957600080fd5b5035919050565b80357fffffffff00000000000000000000000000000000000000000000000000000000811681146122b657600080fd5b6000602082840312156127e257600080fd5b6127eb826127a0565b9392505050565b60005b8381101561280d5781810151838201526020016127f5565b50506000910152565b60208152600082518060208401526128358160408501602087016127f2565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b60006020828403121561287957600080fd5b81356127eb816126c4565b6000610240828403121561289757600080fd5b50919050565b600080600061028084860312156128b357600080fd5b83356128be816126c4565b9250602084013591506128d48560408601612884565b90509250925092565b60008061026083850312156128f157600080fd5b82356128fc816126c4565b915061290b8460208501612884565b90509250929050565b604080825283519082018190526000906020906060840190828701845b8281101561294d57815184529284019290840190600101612931565b50505092019290925292915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000826129c9576129c961295c565b500490565b6000826129dd576129dd61295c565b500690565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203612a4257612a4261298b565b5060010190565b808202811582820484141761052d5761052d61298b565b60008060408385031215612a7357600080fd5b8251612a7e816126c4565b6020939093015192949293505050565b600060208284031215612aa057600080fd5b813560ff811681146127eb57600080fd5b8035612abc816126c4565b73ffffffffffffffffffffffffffffffffffffffff9081168352602082013590612ae5826126c4565b1660208301527fffffffff00000000000000000000000000000000000000000000000000000000612b18604083016127a0565b16604083015260608181013590830152608090810135910152565b60a0810161052d8284612ab1565b600060208284031215612b5357600080fd5b815180151581146127eb57600080fd5b8082018082111561052d5761052d61298b565b60008251612b888184602087016127f2565b9190910192915050565b82815260c081016127eb6020830184612ab156fea26469706673582212206540fcdaf7e0e494fdcbd48b6edf28b205a1c48b8a2cf220d80ccb50a2ff21fe64736f6c63430008110033