xDAI Price: $0.99996 (-0.01%)
Gas: 1 GWei

Contract

0x3b9543e2851accAef9b4F6Fb42fCAea5E9231589

Overview

xDAI Balance

Gnosis Chain LogoGnosis Chain LogoGnosis Chain Logo0 xDAI

xDAI Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

View more zero value Internal Transactions in Advanced View mode

Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
RealTokenYamUpgradeableV3

Compiler Version
v0.8.4+commit.c7e474f2

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 20 : RealTokenYamUpgradeableV3.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { IERC20 } from "../interfaces/IERC20.sol";
import "../interfaces/IRealTokenYamUpgradeableV3.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";

contract RealTokenYamUpgradeableV3 is
  PausableUpgradeable,
  AccessControlUpgradeable,
  UUPSUpgradeable,
  ReentrancyGuardUpgradeable,
  IRealTokenYamUpgradeableV3
{
  bytes32 public constant UPGRADER_ROLE = keccak256("UPGRADER_ROLE");
  bytes32 public constant MODERATOR_ROLE = keccak256("MODERATOR_ROLE");

  mapping(uint256 => uint256) private prices;
  mapping(uint256 => uint256) private amounts;
  mapping(uint256 => address) private offerTokens;
  mapping(uint256 => address) private buyerTokens;
  mapping(uint256 => address) private sellers;
  mapping(uint256 => address) private buyers;
  mapping(address => TokenType) private tokenTypes;
  uint256 private offerCount;
  uint256 public fee; // fee in basis points
	mapping(uint256 => uint256) private offerBlockNumbers;

  /// @custom:oz-upgrades-unsafe-allow constructor
  constructor() {
    _disableInitializers();
  }

  /// @notice the initialize function to execute only once during the contract deployment
  /// @param admin_ address of the default admin account: whitelist tokens, delete frozen offers, upgrade the contract
  /// @param moderator_ address of the admin with unique responsibles
  function initialize(address admin_, address moderator_) external initializer {
    __AccessControl_init();
    __UUPSUpgradeable_init();

    _grantRole(DEFAULT_ADMIN_ROLE, admin_);
    _grantRole(UPGRADER_ROLE, admin_);
    _grantRole(MODERATOR_ROLE, moderator_);
    __ReentrancyGuard_init();
  }

  /// @notice The admin (with upgrader role) uses this function to update the contract
  /// @dev This function is always needed in future implementation contract versions, otherwise, the contract will not be upgradeable
  /// @param newImplementation is the address of the new implementation contract
  function _authorizeUpgrade(address newImplementation)
    internal
    override
    onlyRole(UPGRADER_ROLE)
  {}

  /**
   * @dev Only moderator or admin can call functions marked by this modifier.
   **/
  modifier onlyModeratorOrAdmin() {
    require(
      hasRole(MODERATOR_ROLE, _msgSender()) ||
        hasRole(DEFAULT_ADMIN_ROLE, _msgSender()),
      "caller is not moderator or admin"
    );
    _;
  }

  /**
   * @dev Only whitelisted token can be used by functions marked by this modifier.
   **/
  modifier onlyWhitelistTokenWithType(address token_) {
    require(
      tokenTypes[token_] != TokenType.NOTWHITELISTEDTOKEN,
      "Token is not whitelisted"
    );
    _;
  }

  function pause() external onlyRole(DEFAULT_ADMIN_ROLE) {
    _pause();
  }

  function unpause() external onlyRole(DEFAULT_ADMIN_ROLE) {
    _unpause();
  }

  /// @inheritdoc	IRealTokenYamUpgradeableV3
  function toggleWhitelistWithType(
    address[] calldata tokens_,
    TokenType[] calldata types_
  ) external override onlyRole(DEFAULT_ADMIN_ROLE) {
    uint256 length = tokens_.length;
    require(types_.length == length, "Lengths are not equal");
    for (uint256 i = 0; i < length; ) {
      tokenTypes[tokens_[i]] = types_[i];
      ++i;
    }
    emit TokenWhitelistWithTypeToggled(tokens_, types_);
  }

  /// @inheritdoc	IRealTokenYamUpgradeableV3
  function createOffer(
    address offerToken,
    address buyerToken,
    address buyer,
    uint256 price,
    uint256 amount
  ) public override whenNotPaused {
    // If the offerToken is a RealToken, isTransferValid need to be checked
    if (tokenTypes[offerToken] == TokenType.REALTOKEN) {
      require(
        _isTransferValid(offerToken, msg.sender, msg.sender, amount),
        "Seller can not transfer tokens"
      );
    }
    _createOffer(offerToken, buyerToken, buyer, price, amount);
  }

  /// @inheritdoc	IRealTokenYamUpgradeableV3
  function createOfferWithPermit(
    address offerToken,
    address buyerToken,
    address buyer,
    uint256 price,
    uint256 amount,
    uint256 newAllowance,
    uint256 deadline,
    uint8 v,
    bytes32 r,
    bytes32 s
  ) external override whenNotPaused {
    // If the offerToken is a RealToken, isTransferValid need to be checked
    if (tokenTypes[offerToken] == TokenType.REALTOKEN) {
      require(
        _isTransferValid(offerToken, msg.sender, msg.sender, amount),
        "Seller can not transfer tokens"
      );
    }

    // Create the offer
    _createOffer(offerToken, buyerToken, buyer, price, amount);

    IBridgeToken(offerToken).permit(
      msg.sender,
      address(this),
      newAllowance,
      deadline,
      v,
      r,
      s
    );
  }

  /// @inheritdoc	IRealTokenYamUpgradeableV3
  function buy(
    uint256 offerId,
    uint256 price,
    uint256 amount
  ) external override whenNotPaused {
    _buy(offerId, price, amount);
  }

  /// @inheritdoc	IRealTokenYamUpgradeableV3
  function buyWithPermit(
    uint256 offerId,
    uint256 price,
    uint256 amount,
    uint256 deadline,
    uint8 v,
    bytes32 r,
    bytes32 s
  ) external override whenNotPaused {
    // If the offerToken is a RealToken, isTransferValid need to be checked
    if (tokenTypes[offerTokens[offerId]] == TokenType.REALTOKEN) {
      require(
        _isTransferValid(
          offerTokens[offerId],
          sellers[offerId],
          msg.sender,
          amount
        ),
        "transfer is not valid"
      );
    }

    uint256 buyerTokenAmount = (price * amount) /
      (uint256(10)**IERC20(offerTokens[offerId]).decimals());
    IBridgeToken(buyerTokens[offerId]).permit(
      msg.sender,
      address(this),
      buyerTokenAmount,
      deadline,
      v,
      r,
      s
    );
    _buy(offerId, price, amount);
  }

  /// @inheritdoc	IRealTokenYamUpgradeableV3
  function updateOffer(
    uint256 offerId,
    uint256 price,
    uint256 amount
  ) external override whenNotPaused {
    _updateOffer(offerId, price, amount);
  }

  /// @inheritdoc	IRealTokenYamUpgradeableV3
  function updateOfferWithPermit(
    uint256 offerId,
    uint256 price,
    uint256 amount,
    uint256 newAllowance,
    uint256 deadline,
    uint8 v,
    bytes32 r,
    bytes32 s
  ) external override whenNotPaused {
    IBridgeToken(offerTokens[offerId]).permit(
      msg.sender,
      address(this),
      newAllowance,
      deadline,
      v,
      r,
      s
    );
    // Then update the offer
    _updateOffer(offerId, price, amount);
  }

  /// @inheritdoc	IRealTokenYamUpgradeableV3
  function deleteOffer(uint256 offerId) public override whenNotPaused {
    require(sellers[offerId] == msg.sender, "only the seller can delete offer");
    _deleteOffer(offerId);
  }

  /// @inheritdoc	IRealTokenYamUpgradeableV3
  function deleteOfferBatch(uint256[] calldata offerIds)
    external
    override
    whenNotPaused
  {
    uint256 length = offerIds.length;
    for (uint256 i = 0; i < length; ) {
      deleteOffer(offerIds[i]);
      ++i;
    }
  }

  /// @inheritdoc	IRealTokenYamUpgradeableV3
  function deleteOfferByAdmin(uint256[] calldata offerIds)
    external
    override
    onlyRole(DEFAULT_ADMIN_ROLE)
  {
    uint256 length = offerIds.length;
    for (uint256 i = 0; i < length; ) {
      _deleteOffer(offerIds[i]);
      ++i;
    }
  }

  /// @inheritdoc	IRealTokenYamUpgradeableV3
  function getOfferCount() external view override returns (uint256) {
    return offerCount;
  }

  /// @inheritdoc	IRealTokenYamUpgradeableV3
  function getTokenType(address token)
    external
    view
    override
    returns (TokenType)
  {
    return tokenTypes[token];
  }

  /// @inheritdoc	IRealTokenYamUpgradeableV3
  function tokenInfo(address tokenAddr)
    external
    view
    override
    returns (
      uint256,
      string memory,
      string memory
    )
  {
    IERC20 tokenInterface = IERC20(tokenAddr);
    return (
      tokenInterface.decimals(),
      tokenInterface.symbol(),
      tokenInterface.name()
    );
  }

  /// @inheritdoc	IRealTokenYamUpgradeableV3
  function getInitialOffer(uint256 offerId)
    external
    view
    override
    returns (
      address,
      address,
      address,
      address,
      uint256,
      uint256
    )
  {
    return (
      offerTokens[offerId],
      buyerTokens[offerId],
      sellers[offerId],
      buyers[offerId],
      prices[offerId],
      amounts[offerId]
    );
  }

  /// @inheritdoc	IRealTokenYamUpgradeableV3
  function showOffer(uint256 offerId)
    external
    view
    override
    returns (
      address,
      address,
      address,
      address,
      uint256,
      uint256
    )
  {
    // get offerTokens balance and allowance, whichever is lower is the available amount
    uint256 availableBalance = IERC20(offerTokens[offerId]).balanceOf(
      sellers[offerId]
    );
    uint256 availableAllow = IERC20(offerTokens[offerId]).allowance(
      sellers[offerId],
      address(this)
    );
    uint256 availableAmount = amounts[offerId];

    if (availableBalance < availableAmount) {
      availableAmount = availableBalance;
    }

    if (availableAllow < availableAmount) {
      availableAmount = availableAllow;
    }

    return (
      offerTokens[offerId],
      buyerTokens[offerId],
      sellers[offerId],
      buyers[offerId],
      prices[offerId],
      availableAmount
    );
  }

  /// @inheritdoc	IRealTokenYamUpgradeableV3
  function pricePreview(uint256 offerId, uint256 amount)
    external
    view
    override
    returns (uint256)
  {
    IERC20 offerTokenInterface = IERC20(offerTokens[offerId]);
    return
      (amount * prices[offerId]) /
      (uint256(10)**offerTokenInterface.decimals());
  }

  /// @inheritdoc	IRealTokenYamUpgradeableV3
  function saveLostTokens(address token)
    external
    override
    onlyModeratorOrAdmin
  {
    IERC20 tokenInterface = IERC20(token);
    tokenInterface.transfer(
      msg.sender,
      tokenInterface.balanceOf(address(this))
    );
  }

  /// @inheritdoc	IRealTokenYamUpgradeableV3
  function setFee(uint256 fee_) external override onlyRole(DEFAULT_ADMIN_ROLE) {
    emit FeeChanged(fee, fee_);
    fee = fee_;
  }

  /**
   * @notice Creates a new offer or updates an existing offer (call this again with the changed price + offerId)
   * @param _offerToken The address of the token to be sold
   * @param _buyerToken The address of the token to be bought
   * @param _price The price in base units of the token to be sold
   * @param _amount The amount of tokens to be sold
   **/
  function _createOffer(
    address _offerToken,
    address _buyerToken,
    address _buyer,
    uint256 _price,
    uint256 _amount
  )
    private
    onlyWhitelistTokenWithType(_offerToken)
    onlyWhitelistTokenWithType(_buyerToken)
  {
    // if no offerId is given a new offer is made, if offerId is given only the offers price is changed if owner matches
    uint256 _offerId = offerCount;
    offerCount++;
    if (_buyer != address(0)) {
      buyers[_offerId] = _buyer;
    }
    sellers[_offerId] = msg.sender;
    offerTokens[_offerId] = _offerToken;
    buyerTokens[_offerId] = _buyerToken;
    prices[_offerId] = _price;
    amounts[_offerId] = _amount;
		offerBlockNumbers[_offerId] = block.number;

		emit OfferCreated(
      _offerToken,
      _buyerToken,
      msg.sender,
      _buyer,
      _offerId,
      _price,
      _amount
    );
  }

  /**
   * @notice Creates a new offer or updates an existing offer (call this again with the changed price + offerId)
   * @param _offerId The address of the token to be sold
   * @param _price The address of the token to be bought
   * @param _amount The price in base units of the token to be sold
   **/
  function _updateOffer(
    uint256 _offerId,
    uint256 _price,
    uint256 _amount
  ) private {
    require(
      sellers[_offerId] == msg.sender,
      "only the seller can change offer"
    );
    emit OfferUpdated(
      _offerId,
      prices[_offerId],
      _price,
      amounts[_offerId],
      _amount
    );
    prices[_offerId] = _price;
    amounts[_offerId] = _amount;
  }

  /**
   * @notice Deletes an existing offer
   * @param _offerId The Id of the offer to be deleted
   **/
  function _deleteOffer(uint256 _offerId) private {
    delete sellers[_offerId];
    delete buyers[_offerId];
    delete offerTokens[_offerId];
    delete buyerTokens[_offerId];
    delete prices[_offerId];
    delete amounts[_offerId];
    emit OfferDeleted(_offerId);
  }

  /**
   * @notice Accepts an existing offer
   * @notice The buyer must bring the price correctly to ensure no frontrunning / changed offer
   * @notice If the offer is changed in meantime, it will not execute
   * @param _offerId The Id of the offer
   * @param _price The price in base units of the offer tokens
   * @param _amount The amount of offer tokens
   **/
  function _buy(
    uint256 _offerId,
    uint256 _price,
    uint256 _amount
  ) private {
    if (buyers[_offerId] != address(0)) {
      require(buyers[_offerId] == msg.sender, "private offer");
    }

    address seller = sellers[_offerId];
    address offerToken = offerTokens[_offerId];
    address buyerToken = buyerTokens[_offerId];

    IERC20 offerTokenInterface = IERC20(offerToken);
    IERC20 buyerTokenInterface = IERC20(buyerToken);

		// Check if the offer is validated in the last block
		require(
			block.number > offerBlockNumbers[_offerId],
			"can not buy in the same block as offer creation"
		);

    // given price is being checked with recorded data from mappings
    require(prices[_offerId] == _price, "offer price wrong");

    // calculate the price of the order
    require(_amount <= amounts[_offerId], "amount too high");
    require(
      _amount * _price > (uint256(10)**offerTokenInterface.decimals()),
      "amount too low"
    );
    uint256 buyerTokenAmount = (_amount * _price) /
      (uint256(10)**offerTokenInterface.decimals());

    // some old erc20 tokens give no return value so we must work around by getting their balance before and after the exchange
    uint256 oldBuyerBalance = buyerTokenInterface.balanceOf(msg.sender);
    uint256 oldSellerBalance = offerTokenInterface.balanceOf(seller);

    // Update amount in mapping
    amounts[_offerId] = amounts[_offerId] - _amount;

    // finally do the exchange
    buyerTokenInterface.transferFrom(msg.sender, seller, buyerTokenAmount);
    offerTokenInterface.transferFrom(seller, msg.sender, _amount);

    // now check if the balances changed on both accounts.
    // we do not check for exact amounts since some tokens behave differently with fees, burnings, etc
    // we assume if both balances are higher than before all is good
    require(
      oldBuyerBalance > buyerTokenInterface.balanceOf(msg.sender),
      "buyer error"
    );
    require(
      oldSellerBalance > offerTokenInterface.balanceOf(seller),
      "seller error"
    );

    emit OfferAccepted(
      _offerId,
      seller,
      msg.sender,
      offerToken,
      buyerToken,
      _price,
      _amount
    );
  }

  /**
   * @notice Returns true if the transfer is valid, false otherwise
   * @param _token The token address
   * @param _from The sender address
   * @param _to The receiver address
   * @param _amount The amount of tokens to be transferred
   * @return Whether the transfer is valid
   **/
  function _isTransferValid(
    address _token,
    address _from,
    address _to,
    uint256 _amount
  ) private view returns (bool) {
    // Generalize verifying rules (for example: 11, 1, 12)
    (bool isTransferValid, , ) = IBridgeToken(_token).canTransfer(
      _from,
      _to,
      _amount
    );

    // If everything is fine, return true
    return isTransferValid;
  }

  /// @inheritdoc	IRealTokenYamUpgradeableV3
  function createOfferBatch(
    address[] calldata _offerTokens,
    address[] calldata _buyerTokens,
    address[] calldata _buyers,
    uint256[] calldata _prices,
    uint256[] calldata _amounts
  ) external override whenNotPaused {
    uint256 length = _offerTokens.length;
    require(
      _buyerTokens.length == length &&
        _buyers.length == length &&
        _prices.length == length &&
        _amounts.length == length,
      "length mismatch"
    );
    for (uint256 i = 0; i < length; ) {
      createOffer(
        _offerTokens[i],
        _buyerTokens[i],
        _buyers[i],
        _prices[i],
        _amounts[i]
      );
      ++i;
    }
  }

  /// @inheritdoc	IRealTokenYamUpgradeableV3
  function updateOfferBatch(
    uint256[] calldata _offerIds,
    uint256[] calldata _prices,
    uint256[] calldata _amounts
  ) external override whenNotPaused {
    uint256 length = _offerIds.length;
    require(
      _prices.length == length && _amounts.length == length,
      "length mismatch"
    );
    for (uint256 i = 0; i < length; ) {
      _updateOffer(_offerIds[i], _prices[i], _amounts[i]);
      ++i;
    }
  }

  /// @inheritdoc	IRealTokenYamUpgradeableV3
  function buyOfferBatch(
    uint256[] calldata _offerIds,
    uint256[] calldata _prices,
    uint256[] calldata _amounts
  ) external override whenNotPaused {
    uint256 length = _offerIds.length;
    require(
      _prices.length == length && _amounts.length == length,
      "length mismatch"
    );
    for (uint256 i = 0; i < length; ) {
      _buy(_offerIds[i], _prices[i], _amounts[i]);
      ++i;
    }
  }
}

File 2 of 20 : IERC20.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IERC20 {
  function balanceOf(address account) external view returns (uint256);

  function allowance(address owner, address spender)
    external
    view
    returns (uint256);

  function approve(address spender, uint256 amount) external returns (bool);

  // no return value on transfer and transferFrom to tolerate old erc20 tokens
  // we work around that in the buy function by checking balance twice
  function transferFrom(
    address sender,
    address recipient,
    uint256 amount
  ) external;

  function transfer(address to, uint256 amount) external;

  function decimals() external view returns (uint256);

  function symbol() external view returns (string calldata);

  function name() external view returns (string calldata);
}

File 3 of 20 : IRealTokenYamUpgradeableV3.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IBridgeToken.sol";
import "./IComplianceRegistry.sol";

interface IRealTokenYamUpgradeableV3 {
  enum TokenType {
    NOTWHITELISTEDTOKEN,
    REALTOKEN,
    ERC20WITHPERMIT,
    ERC20WITHOUTPERMIT
  }

  /**
   * @dev Emitted after an offer is updated
   * @param tokens the token addresses
   **/
  event TokenWhitelistWithTypeToggled(
    address[] indexed tokens,
    TokenType[] indexed types
  );

  /**
   * @dev Emitted after an offer is created
   * @param offerToken the token you want to sell
   * @param buyerToken the token you want to buy
   * @param offerId the Id of the offer
   * @param price the price in baseunits of the token you want to sell
   * @param amount the amount of tokens you want to sell
   **/
  event OfferCreated(
    address indexed offerToken,
    address indexed buyerToken,
    address seller,
    address buyer,
    uint256 indexed offerId,
    uint256 price,
    uint256 amount
  );

  /**
   * @dev Emitted after an offer is updated
   * @param offerId the Id of the offer
   * @param oldPrice the old price of the token
   * @param newPrice the new price of the token
   * @param oldAmount the old amount of tokens
   * @param newAmount the new amount of tokens
   **/
  event OfferUpdated(
    uint256 indexed offerId,
    uint256 oldPrice,
    uint256 indexed newPrice,
    uint256 oldAmount,
    uint256 indexed newAmount
  );

  /**
   * @dev Emitted after an offer is deleted
   * @param offerId the Id of the offer to be deleted
   **/
  event OfferDeleted(uint256 indexed offerId);

  /**
   * @dev Emitted after an offer is accepted
   * @param offerId The Id of the offer that was accepted
   * @param seller the address of the seller
   * @param buyer the address of the buyer
   * @param price the price in baseunits of the token
   * @param amount the amount of tokens that the buyer bought
   **/
  event OfferAccepted(
    uint256 indexed offerId,
    address indexed seller,
    address indexed buyer,
    address offerToken,
    address buyerToken,
    uint256 price,
    uint256 amount
  );

  /**
   * @dev Emitted after an offer is deleted
   * @param oldFee the old fee basic points
   * @param newFee the new fee basic points
   **/
  event FeeChanged(uint256 indexed oldFee, uint256 indexed newFee);

  /**
   * @notice Creates a new offer or updates an existing offer
   * @param offerToken The address of the token to be sold
   * @param buyerToken The address of the token to be bought
   * @param buyer The address of the allowed buyer (zero address means anyone can buy)
   * @param price The price in base units of the token to be sold
   * @param amount The amount of the offer token
   **/
  function createOffer(
    address offerToken,
    address buyerToken,
    address buyer,
    uint256 price,
    uint256 amount
  ) external;

  /**
   * @notice Creates a new offer or updates an existing offer with permit
   * @param offerToken The address of the token to be sold
   * @param buyerToken The address of the token to be bought
   * @param buyer The address of the allowed buyer (zero address means anyone can buy)
   * @param price The price in base units of the token to be sold
   * @param amount The amount to be sold
   * @param newAllowance The amount to be permitted
   * @param deadline The deadline of the permit
   * @param v v of the signature
   * @param r r of the signature
   * @param s s of the signature
   **/
  function createOfferWithPermit(
    address offerToken,
    address buyerToken,
    address buyer,
    uint256 price,
    uint256 amount,
    uint256 newAllowance,
    uint256 deadline,
    uint8 v,
    bytes32 r,
    bytes32 s
  ) external;

  /**
   * @notice Updates an existing offer
   * @param offerId The Id of the offer
   * @param price The price in base units of the token to be sold
   * @param amount The amount of the offer token
   **/
  function updateOffer(
    uint256 offerId,
    uint256 price,
    uint256 amount
  ) external;

  /**
   * @notice Updates an existing offer
   * @param offerId The Id of the offer
   * @param price The price in base units of the token to be sold
   * @param amount The amount of the offer token
   * @param newAllowance The amount to be permitted
   * @param deadline The deadline of the permit
   * @param v v of the signature
   * @param r r of the signature
   * @param s s of the signature
   **/
  function updateOfferWithPermit(
    uint256 offerId,
    uint256 price,
    uint256 amount,
    uint256 newAllowance,
    uint256 deadline,
    uint8 v,
    bytes32 r,
    bytes32 s
  ) external;

  /**
   * @notice Deletes an existing offer, only the seller of the offer can do this
   * @param offerId The Id of the offer to be deleted
   **/
  function deleteOffer(uint256 offerId) external;

  /**
   * @notice Deletes an array of existing offers (for example in case tokens are frozen), only the admin can do this
   * @param offerIds The Ids array of the offers to be deleted
   **/
  function deleteOfferBatch(uint256[] calldata offerIds) external;

  /**
   * @notice Deletes an existing offer (for example in case tokens are frozen), only the admin can do this
   * @param offerIds The Id of the offer to be deleted
   **/
  function deleteOfferByAdmin(uint256[] calldata offerIds) external;

  /**
   * @notice Accepts an existing offer
   * @notice The buyer must bring the price correctly to ensure no frontrunning / changed offer
   * @notice If the offer is changed in meantime, it will not execute
   * @param offerId The Id of the offer
   * @param price The price in base units of the offer tokens
   * @param amount The amount of offer tokens
   **/
  function buy(
    uint256 offerId,
    uint256 price,
    uint256 amount
  ) external;

  /**
   * @notice Accepts an existing offer with permit
   * @notice The buyer must bring the price correctly to ensure no frontrunning / changed offer
   * @notice If the offer is changed in meantime, it will not execute
   * @param offerId The Id of the offer
   * @param price The price in base units of the offer tokens
   * @param amount The amount of offer tokens
   * @param deadline The deadline of the permit
   * @param v v of the signature
   * @param r r of the signature
   * @param s s of the signature
   **/
  function buyWithPermit(
    uint256 offerId,
    uint256 price,
    uint256 amount,
    uint256 deadline,
    uint8 v,
    bytes32 r,
    bytes32 s
  ) external;

  /**
   * @notice Returns the offer count
   * @return offerCount The offer count
   **/
  // return the total number of offers to loop through all offers
  // its the web frontends job to keep track of offers
  function getOfferCount() external view returns (uint256);

  /**
   * @notice Returns the offer count
   * @return offerCount The offer count
   **/
  function getTokenType(address token) external view returns (TokenType);

  /**
   * @notice Returns the token information: decimals, symbole, name
   * @param tokenAddress The address of the reference asset of the distribution
   * @return The decimals of the token
   * @return The symbol  of the token
   * @return The name of the token
   **/
  function tokenInfo(address tokenAddress)
    external
    view
    returns (
      uint256,
      string memory,
      string memory
    );

  /**
   * @notice Returns the offer information
   * @param offerId The offer Id
   * @return The offer token address
   * @return The buyer token address
   * @return The seller address
   * @return The buyer address
   * @return The price
   * @return The amount of the offer token
   **/
  function getInitialOffer(uint256 offerId)
    external
    view
    returns (
      address,
      address,
      address,
      address,
      uint256,
      uint256
    );

  /**
   * @notice Returns the offer information
   * @param offerId The offer Id
   * @return The offer token address
   * @return The buyer token address
   * @return The seller address
   * @return The buyer address
   * @return The price
   * @return The available balance
   **/
  function showOffer(uint256 offerId)
    external
    view
    returns (
      address,
      address,
      address,
      address,
      uint256,
      uint256
    );

  /**
   * @notice Returns price in buyertokens for the specified amount of offertokens
   * @param offerId The offer Id
   * @param amount The amount of offer tokens
   * @return The total amount to pay
   **/
  function pricePreview(uint256 offerId, uint256 amount)
    external
    view
    returns (uint256);

  /**
   * @notice Whitelist or unwhitelist a token
   * @param tokens The token addresses
   * @param types The token whitelist status, true for whitelisted and false for unwhitelisted
   **/
  function toggleWhitelistWithType(
    address[] calldata tokens,
    TokenType[] calldata types
  ) external;

  /**
   * @notice In case someone wrongfully directly sends erc20 to this contract address, the moderator can move them out
   * @param token The token address
   **/
  function saveLostTokens(address token) external;

  /**
   * @notice Admin sets the fee
   * @param fee The new fee basic points
   **/
  function setFee(uint256 fee) external;

  /**
   * @notice Creates a new offer or updates an existing offer (call this again with the changed price + offerId)
   * @param _offerTokens The array addresses of the tokens to be sold
   * @param _buyerTokens The array addresses of the tokens to be bought
   * @param _buyers The array addresses of the allowed buyers (zero address means anyone can buy)
   * @param _prices The array prices in base units of the tokens to be sold
   * @param _amounts The array amounts of the offer tokens
   **/
  function createOfferBatch(
    address[] calldata _offerTokens,
    address[] calldata _buyerTokens,
    address[] calldata _buyers,
    uint256[] calldata _prices,
    uint256[] calldata _amounts
  ) external;

  /**
   * @notice Updates an array of existing offers
   * @param _offerIds The array Ids of the offers
   * @param _prices The array prices in base units of the tokens to be sold
   * @param _amounts The array amounts of the offer tokens
   **/
  function updateOfferBatch(
    uint256[] calldata _offerIds,
    uint256[] calldata _prices,
    uint256[] calldata _amounts
  ) external;

  /**
   * @notice Accepts an existing offer
   * @notice The buyer must bring the price correctly to ensure no frontrunning / changed offer
   * @notice If the offer is changed in meantime, it will not execute
   * @param _offerIds The array Ids of the offers
   * @param _prices The array prices in base units of the offer tokens
   * @param _amounts The array amounts of offer tokens
   **/
  function buyOfferBatch(
    uint256[] calldata _offerIds,
    uint256[] calldata _prices,
    uint256[] calldata _amounts
  ) external;
}

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

pragma solidity ^0.8.0;

import "./IAccessControlUpgradeable.sol";
import "../utils/ContextUpgradeable.sol";
import "../utils/StringsUpgradeable.sol";
import "../utils/introspection/ERC165Upgradeable.sol";
import "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it.
 */
abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable {
    function __AccessControl_init() internal onlyInitializing {
    }

    function __AccessControl_init_unchained() internal onlyInitializing {
    }
    struct RoleData {
        mapping(address => bool) members;
        bytes32 adminRole;
    }

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with a standardized message including the required role.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

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

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
        return _roles[role].members[account];
    }

    /**
     * @dev Revert with a standard message if `_msgSender()` is missing `role`.
     * Overriding this function changes the behavior of the {onlyRole} modifier.
     *
     * Format of the revert message is described in {_checkRole}.
     *
     * _Available since v4.6._
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Revert with a standard message if `account` is missing `role`.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert(
                string(
                    abi.encodePacked(
                        "AccessControl: account ",
                        StringsUpgradeable.toHexString(uint160(account), 20),
                        " is missing role ",
                        StringsUpgradeable.toHexString(uint256(role), 32)
                    )
                )
            );
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleGranted} event.
     */
    function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleRevoked} event.
     */
    function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been revoked `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     *
     * May emit a {RoleRevoked} event.
     */
    function renounceRole(bytes32 role, address account) public virtual override {
        require(account == _msgSender(), "AccessControl: can only renounce roles for self");

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * May emit a {RoleGranted} event.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     *
     * NOTE: This function is deprecated in favor of {_grantRole}.
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        bytes32 previousAdminRole = getRoleAdmin(role);
        _roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleGranted} event.
     */
    function _grantRole(bytes32 role, address account) internal virtual {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleRevoked} event.
     */
    function _revokeRole(bytes32 role, address account) internal virtual {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

File 5 of 20 : PausableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

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

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    function __Pausable_init() internal onlyInitializing {
        __Pausable_init_unchained();
    }

    function __Pausable_init_unchained() internal onlyInitializing {
        _paused = false;
    }

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

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

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

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        require(!paused(), "Pausable: paused");
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        require(paused(), "Pausable: not paused");
    }

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

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

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

File 6 of 20 : UUPSUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/UUPSUpgradeable.sol)

pragma solidity ^0.8.0;

import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../ERC1967/ERC1967UpgradeUpgradeable.sol";
import "./Initializable.sol";

/**
 * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
 * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
 *
 * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
 * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
 * `UUPSUpgradeable` with a custom implementation of upgrades.
 *
 * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
 *
 * _Available since v4.1._
 */
abstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable {
    function __UUPSUpgradeable_init() internal onlyInitializing {
    }

    function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
    }
    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
    address private immutable __self = address(this);

    /**
     * @dev Check that the execution is being performed through a delegatecall call and that the execution context is
     * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case
     * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
     * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
     * fail.
     */
    modifier onlyProxy() {
        require(address(this) != __self, "Function must be called through delegatecall");
        require(_getImplementation() == __self, "Function must be called through active proxy");
        _;
    }

    /**
     * @dev Check that the execution is not being performed through a delegate call. This allows a function to be
     * callable on the implementing contract but not through proxies.
     */
    modifier notDelegated() {
        require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall");
        _;
    }

    /**
     * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the
     * implementation. It is used to validate that the this implementation remains valid after an upgrade.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
     */
    function proxiableUUID() external view virtual override notDelegated returns (bytes32) {
        return _IMPLEMENTATION_SLOT;
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     */
    function upgradeTo(address newImplementation) external virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, new bytes(0), false);
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
     * encoded in `data`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     */
    function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, data, true);
    }

    /**
     * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
     * {upgradeTo} and {upgradeToAndCall}.
     *
     * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
     *
     * ```solidity
     * function _authorizeUpgrade(address) internal override onlyOwner {}
     * ```
     */
    function _authorizeUpgrade(address newImplementation) internal virtual;

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

File 7 of 20 : ReentrancyGuardUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";

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

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

    uint256 private _status;

    function __ReentrancyGuard_init() internal onlyInitializing {
        __ReentrancyGuard_init_unchained();
    }

    function __ReentrancyGuard_init_unchained() internal onlyInitializing {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

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

        _;

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

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

File 8 of 20 : IBridgeToken.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IBridgeToken {
  function rules() external view returns (uint256[] memory, uint256[] memory);

  function rule(uint256 ruleId) external view returns (uint256, uint256);

  function owner() external view returns (address);

  function allowance(address _owner, address _spender)
    external
    view
    returns (uint256);

  function transferFrom(
    address _from,
    address _to,
    uint256 _value
  ) external returns (bool);

  function canTransfer(
    address _from,
    address _to,
    uint256 _amount
  )
    external
    view
    returns (
      bool,
      uint256,
      uint256
    );

  function permit(
    address owner,
    address spender,
    uint256 value,
    uint256 deadline,
    uint8 v,
    bytes32 r,
    bytes32 s
  ) external;
}

File 9 of 20 : IComplianceRegistry.sol
// SPDX-License-Identifier: CNU

/*
    Copyright (c) 2019 Mt Pelerin Group Ltd

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License version 3
    as published by the Free Software Foundation with the addition of the
    following permission added to Section 15 as permitted in Section 7(a):
    FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
    MT PELERIN GROUP LTD. MT PELERIN GROUP LTD DISCLAIMS THE WARRANTY OF NON INFRINGEMENT
    OF THIRD PARTY RIGHTS

    This program is distributed in the hope that it will be useful, but
    WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
    or FITNESS FOR A PARTICULAR PURPOSE.
    See the GNU Affero General Public License for more details.
    You should have received a copy of the GNU Affero General Public License
    along with this program; if not, see http://www.gnu.org/licenses or write to
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA, 02110-1301 USA, or download the license from the following URL:
    https://www.gnu.org/licenses/agpl-3.0.fr.html

    The interactive user interfaces in modified source and object code versions
    of this program must display Appropriate Legal Notices, as required under
    Section 5 of the GNU Affero General Public License.

    You can be released from the requirements of the license by purchasing
    a commercial license. Buying such a license is mandatory as soon as you
    develop commercial activities involving Mt Pelerin Group Ltd software without
    disclosing the source code of your own applications.
    These activities include: offering paid services based/using this product to customers,
    using this product in any application, distributing this product with a closed
    source product.

    For more information, please contact Mt Pelerin Group Ltd at this
    address: [email protected]
*/

pragma solidity ^0.8.0;

/**
 * @title IComplianceRegistry
 * @dev IComplianceRegistry interface
 **/
interface IComplianceRegistry {
  event AddressAttached(
    address indexed trustedIntermediary,
    uint256 indexed userId,
    address indexed address_
  );
  event AddressDetached(
    address indexed trustedIntermediary,
    uint256 indexed userId,
    address indexed address_
  );

  function userId(address[] calldata _trustedIntermediaries, address _address)
    external
    view
    returns (uint256, address);

  function validUntil(address _trustedIntermediary, uint256 _userId)
    external
    view
    returns (uint256);

  function attribute(
    address _trustedIntermediary,
    uint256 _userId,
    uint256 _key
  ) external view returns (uint256);

  function attributes(
    address _trustedIntermediary,
    uint256 _userId,
    uint256[] calldata _keys
  ) external view returns (uint256[] memory);

  function isAddressValid(
    address[] calldata _trustedIntermediaries,
    address _address
  ) external view returns (bool);

  function isValid(address _trustedIntermediary, uint256 _userId)
    external
    view
    returns (bool);

  function registerUser(
    address _address,
    uint256[] calldata _attributeKeys,
    uint256[] calldata _attributeValues
  ) external;

  function registerUsers(
    address[] calldata _addresses,
    uint256[] calldata _attributeKeys,
    uint256[] calldata _attributeValues
  ) external;

  function attachAddress(uint256 _userId, address _address) external;

  function attachAddresses(
    uint256[] calldata _userIds,
    address[] calldata _addresses
  ) external;

  function detachAddress(address _address) external;

  function detachAddresses(address[] calldata _addresses) external;

  function updateUserAttributes(
    uint256 _userId,
    uint256[] calldata _attributeKeys,
    uint256[] calldata _attributeValues
  ) external;

  function updateUsersAttributes(
    uint256[] calldata _userIds,
    uint256[] calldata _attributeKeys,
    uint256[] calldata _attributeValues
  ) external;

  function updateTransfers(
    address _realm,
    address _from,
    address _to,
    uint256 _value
  ) external;

  function monthlyTransfers(
    address _realm,
    address[] calldata _trustedIntermediaries,
    address _address
  ) external view returns (uint256);

  function yearlyTransfers(
    address _realm,
    address[] calldata _trustedIntermediaries,
    address _address
  ) external view returns (uint256);

  function monthlyInTransfers(
    address _realm,
    address[] calldata _trustedIntermediaries,
    address _address
  ) external view returns (uint256);

  function yearlyInTransfers(
    address _realm,
    address[] calldata _trustedIntermediaries,
    address _address
  ) external view returns (uint256);

  function monthlyOutTransfers(
    address _realm,
    address[] calldata _trustedIntermediaries,
    address _address
  ) external view returns (uint256);

  function yearlyOutTransfers(
    address _realm,
    address[] calldata _trustedIntermediaries,
    address _address
  ) external view returns (uint256);

  function addOnHoldTransfer(
    address trustedIntermediary,
    address token,
    address from,
    address to,
    uint256 amount
  ) external;

  function getOnHoldTransfers(address trustedIntermediary)
    external
    view
    returns (
      uint256 length,
      uint256[] memory id,
      address[] memory token,
      address[] memory from,
      address[] memory to,
      uint256[] memory amount
    );

  function processOnHoldTransfers(
    uint256[] calldata transfers,
    uint8[] calldata transferDecisions,
    bool skipMinBoundaryUpdate
  ) external;

  function updateOnHoldMinBoundary(uint256 maxIterations) external;

  event TransferOnHold(
    address indexed trustedIntermediary,
    address indexed token,
    address indexed from,
    address to,
    uint256 amount
  );
  event TransferApproved(
    address indexed trustedIntermediary,
    address indexed token,
    address indexed from,
    address to,
    uint256 amount
  );
  event TransferRejected(
    address indexed trustedIntermediary,
    address indexed token,
    address indexed from,
    address to,
    uint256 amount
  );
  event TransferCancelled(
    address indexed trustedIntermediary,
    address indexed token,
    address indexed from,
    address to,
    uint256 amount
  );
}

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

pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";

/**
 * @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 ContextUpgradeable is Initializable {
    function __Context_init() internal onlyInitializing {
    }

    function __Context_init_unchained() internal onlyInitializing {
    }
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

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

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

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

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library StringsUpgradeable {
    bytes16 private constant _HEX_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) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

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

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

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

File 12 of 20 : IAccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

pragma solidity ^0.8.0;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControlUpgradeable {
    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     *
     * _Available since v3.1._
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) external;
}

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

pragma solidity ^0.8.0;

import "./IERC165Upgradeable.sol";
import "../../proxy/utils/Initializable.sol";

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

    function __ERC165_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165Upgradeable).interfaceId;
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

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

pragma solidity ^0.8.2;

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

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
 * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
 * case an upgrade adds a module that needs to be initialized.
 *
 * For example:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * contract MyToken is ERC20Upgradeable {
 *     function initialize() initializer public {
 *         __ERC20_init("MyToken", "MTK");
 *     }
 * }
 * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
 *     function initializeV2() reinitializer(2) public {
 *         __ERC20Permit_init("MyToken");
 *     }
 * }
 * ```
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
 * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() {
 *     _disableInitializers();
 * }
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     * @custom:oz-retyped-from bool
     */
    uint8 private _initialized;

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

    /**
     * @dev Triggered when the contract has been initialized or reinitialized.
     */
    event Initialized(uint8 version);

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.
     */
    modifier initializer() {
        bool isTopLevelCall = !_initializing;
        require(
            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
            "Initializable: contract is already initialized"
        );
        _initialized = 1;
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original
     * initialization step. This is essential to configure modules that are added through upgrades and that require
     * initialization.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     */
    modifier reinitializer(uint8 version) {
        require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
        _initialized = version;
        _initializing = true;
        _;
        _initializing = false;
        emit Initialized(version);
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} and {reinitializer} modifiers, directly or indirectly.
     */
    modifier onlyInitializing() {
        require(_initializing, "Initializable: contract is not initializing");
        _;
    }

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     */
    function _disableInitializers() internal virtual {
        require(!_initializing, "Initializable: contract is initializing");
        if (_initialized < type(uint8).max) {
            _initialized = type(uint8).max;
            emit Initialized(type(uint8).max);
        }
    }
}

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

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

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

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

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly
                /// @solidity memory-safe-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 16 of 20 : IERC165Upgradeable.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 IERC165Upgradeable {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

File 17 of 20 : ERC1967UpgradeUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)

pragma solidity ^0.8.2;

import "../beacon/IBeaconUpgradeable.sol";
import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/StorageSlotUpgradeable.sol";
import "../utils/Initializable.sol";

/**
 * @dev This abstract contract provides getters and event emitting update functions for
 * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
 *
 * _Available since v4.1._
 *
 * @custom:oz-upgrades-unsafe-allow delegatecall
 */
abstract contract ERC1967UpgradeUpgradeable is Initializable {
    function __ERC1967Upgrade_init() internal onlyInitializing {
    }

    function __ERC1967Upgrade_init_unchained() internal onlyInitializing {
    }
    // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
    bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;

    /**
     * @dev Storage slot with the address of the current implementation.
     * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;

    /**
     * @dev Emitted when the implementation is upgraded.
     */
    event Upgraded(address indexed implementation);

    /**
     * @dev Returns the current implementation address.
     */
    function _getImplementation() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 implementation slot.
     */
    function _setImplementation(address newImplementation) private {
        require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract");
        StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
    }

    /**
     * @dev Perform implementation upgrade
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeTo(address newImplementation) internal {
        _setImplementation(newImplementation);
        emit Upgraded(newImplementation);
    }

    /**
     * @dev Perform implementation upgrade with additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCall(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        _upgradeTo(newImplementation);
        if (data.length > 0 || forceCall) {
            _functionDelegateCall(newImplementation, data);
        }
    }

    /**
     * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCallUUPS(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        // Upgrades from old implementations will perform a rollback test. This test requires the new
        // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
        // this special case will break upgrade paths from old UUPS implementation to new ones.
        if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) {
            _setImplementation(newImplementation);
        } else {
            try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) {
                require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
            } catch {
                revert("ERC1967Upgrade: new implementation is not UUPS");
            }
            _upgradeToAndCall(newImplementation, data, forceCall);
        }
    }

    /**
     * @dev Storage slot with the admin of the contract.
     * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;

    /**
     * @dev Emitted when the admin account has changed.
     */
    event AdminChanged(address previousAdmin, address newAdmin);

    /**
     * @dev Returns the current admin.
     */
    function _getAdmin() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 admin slot.
     */
    function _setAdmin(address newAdmin) private {
        require(newAdmin != address(0), "ERC1967: new admin is the zero address");
        StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
    }

    /**
     * @dev Changes the admin of the proxy.
     *
     * Emits an {AdminChanged} event.
     */
    function _changeAdmin(address newAdmin) internal {
        emit AdminChanged(_getAdmin(), newAdmin);
        _setAdmin(newAdmin);
    }

    /**
     * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
     * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
     */
    bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;

    /**
     * @dev Emitted when the beacon is upgraded.
     */
    event BeaconUpgraded(address indexed beacon);

    /**
     * @dev Returns the current beacon.
     */
    function _getBeacon() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value;
    }

    /**
     * @dev Stores a new beacon in the EIP1967 beacon slot.
     */
    function _setBeacon(address newBeacon) private {
        require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract");
        require(
            AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()),
            "ERC1967: beacon implementation is not a contract"
        );
        StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon;
    }

    /**
     * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
     * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
     *
     * Emits a {BeaconUpgraded} event.
     */
    function _upgradeBeaconToAndCall(
        address newBeacon,
        bytes memory data,
        bool forceCall
    ) internal {
        _setBeacon(newBeacon);
        emit BeaconUpgraded(newBeacon);
        if (data.length > 0 || forceCall) {
            _functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data);
        }
    }

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

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return AddressUpgradeable.verifyCallResult(success, returndata, "Address: low-level delegate call failed");
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

File 18 of 20 : draft-IERC1822Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)

pragma solidity ^0.8.0;

/**
 * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
 * proxy whose upgrades are fully controlled by the current implementation.
 */
interface IERC1822ProxiableUpgradeable {
    /**
     * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
     * address.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy.
     */
    function proxiableUUID() external view returns (bytes32);
}

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

pragma solidity ^0.8.0;

/**
 * @dev Library for reading and writing primitive types to specific storage slots.
 *
 * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
 * This library helps with reading and writing to such slots without the need for inline assembly.
 *
 * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
 *
 * Example usage to set ERC1967 implementation slot:
 * ```
 * contract ERC1967 {
 *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
 *
 *     function _getImplementation() internal view returns (address) {
 *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
 *     }
 *
 *     function _setImplementation(address newImplementation) internal {
 *         require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 *
 * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
 */
library StorageSlotUpgradeable {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

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

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

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

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

File 20 of 20 : IBeaconUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)

pragma solidity ^0.8.0;

/**
 * @dev This is the interface that {BeaconProxy} expects of its beacon.
 */
interface IBeaconUpgradeable {
    /**
     * @dev Must return an address that can be used as a delegate call target.
     *
     * {BeaconProxy} will check that this address is a contract.
     */
    function implementation() external view returns (address);
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

API
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beacon","type":"address"}],"name":"BeaconUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"oldFee","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"newFee","type":"uint256"}],"name":"FeeChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"offerId","type":"uint256"},{"indexed":true,"internalType":"address","name":"seller","type":"address"},{"indexed":true,"internalType":"address","name":"buyer","type":"address"},{"indexed":false,"internalType":"address","name":"offerToken","type":"address"},{"indexed":false,"internalType":"address","name":"buyerToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"OfferAccepted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"offerToken","type":"address"},{"indexed":true,"internalType":"address","name":"buyerToken","type":"address"},{"indexed":false,"internalType":"address","name":"seller","type":"address"},{"indexed":false,"internalType":"address","name":"buyer","type":"address"},{"indexed":true,"internalType":"uint256","name":"offerId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"OfferCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"offerId","type":"uint256"}],"name":"OfferDeleted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"offerId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"oldPrice","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"newPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"oldAmount","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"newAmount","type":"uint256"}],"name":"OfferUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address[]","name":"tokens","type":"address[]"},{"indexed":true,"internalType":"enum IRealTokenYamUpgradeableV3.TokenType[]","name":"types","type":"uint8[]"}],"name":"TokenWhitelistWithTypeToggled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MODERATOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UPGRADER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"offerId","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"buy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_offerIds","type":"uint256[]"},{"internalType":"uint256[]","name":"_prices","type":"uint256[]"},{"internalType":"uint256[]","name":"_amounts","type":"uint256[]"}],"name":"buyOfferBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"offerId","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"buyWithPermit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"offerToken","type":"address"},{"internalType":"address","name":"buyerToken","type":"address"},{"internalType":"address","name":"buyer","type":"address"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"createOffer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_offerTokens","type":"address[]"},{"internalType":"address[]","name":"_buyerTokens","type":"address[]"},{"internalType":"address[]","name":"_buyers","type":"address[]"},{"internalType":"uint256[]","name":"_prices","type":"uint256[]"},{"internalType":"uint256[]","name":"_amounts","type":"uint256[]"}],"name":"createOfferBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"offerToken","type":"address"},{"internalType":"address","name":"buyerToken","type":"address"},{"internalType":"address","name":"buyer","type":"address"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"newAllowance","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"createOfferWithPermit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"offerId","type":"uint256"}],"name":"deleteOffer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"offerIds","type":"uint256[]"}],"name":"deleteOfferBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"offerIds","type":"uint256[]"}],"name":"deleteOfferByAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"fee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"offerId","type":"uint256"}],"name":"getInitialOffer","outputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOfferCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getTokenType","outputs":[{"internalType":"enum IRealTokenYamUpgradeableV3.TokenType","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"admin_","type":"address"},{"internalType":"address","name":"moderator_","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"offerId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"pricePreview","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"saveLostTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"fee_","type":"uint256"}],"name":"setFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"offerId","type":"uint256"}],"name":"showOffer","outputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"tokens_","type":"address[]"},{"internalType":"enum IRealTokenYamUpgradeableV3.TokenType[]","name":"types_","type":"uint8[]"}],"name":"toggleWhitelistWithType","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddr","type":"address"}],"name":"tokenInfo","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"string","name":"","type":"string"},{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"offerId","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"updateOffer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_offerIds","type":"uint256[]"},{"internalType":"uint256[]","name":"_prices","type":"uint256[]"},{"internalType":"uint256[]","name":"_amounts","type":"uint256[]"}],"name":"updateOfferBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"offerId","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"newAllowance","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"updateOfferWithPermit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"}]

60a06040523060601b6080523480156200001857600080fd5b506200002362000029565b620000eb565b600054610100900460ff1615620000965760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff9081161015620000e9576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b60805160601c613d2e6200012660003960008181611206015281816112460152818161151c0152818161155c01526115eb0152613d2e6000f3fe6080604052600436106102255760003560e01c806352d1902d11610123578063a217fddf116100ab578063dc3033fc1161006f578063dc3033fc146106b1578063ddca3f43146106d1578063f5050da0146106e8578063f5dab71114610760578063f72c0d8b1461078f57600080fd5b8063a217fddf14610626578063a55f1df01461063b578063b899266e1461065b578063d048db371461067b578063d547741f1461069157600080fd5b8063797669c9116100f2578063797669c9146105565780638456cb591461058a578063867a3db81461059f57806391d14854146105bf57806393272baf146105df57600080fd5b806352d1902d146104e95780635c975abb146104fe57806369fe0e2d1461051657806374268ff21461053657600080fd5b80632befd4ad116101b15780633f4ba83a116101755780633f4ba83a1461046157806340993b261461047657806342da1f5714610496578063485cc955146104b65780634f1ef286146104d657600080fd5b80632befd4ad146103c15780632df83c1e146103e15780632f2ff15d1461040157806336568abe146104215780633659cfe61461044157600080fd5b80631a2caf6f116101f85780631a2caf6f146103035780631bcae91614610323578063248a9ca314610343578063292d52f2146103815780632a3f700b146103a157600080fd5b8063017716dc1461022a57806301ffc9a7146102915780631032c610146102c157806314b2051f146102e3575b600080fd5b34801561023657600080fd5b5061024a610245366004613576565b6107c3565b604080516001600160a01b03978816815295871660208701529386169385019390935293166060830152608082019290925260a081019190915260c0015b60405180910390f35b34801561029d57600080fd5b506102b16102ac3660046135c8565b61098c565b6040519015158152602001610288565b3480156102cd57600080fd5b506102e16102dc366004613695565b6109c3565b005b3480156102ef57600080fd5b506102e16102fe3660046134a6565b6109db565b34801561030f57600080fd5b506102e161031e366004613312565b610ab9565b34801561032f57600080fd5b506102e161033e366004613725565b610c20565b34801561034f57600080fd5b5061037361035e366004613576565b60009081526097602052604090206001015490565b604051908152602001610288565b34801561038d57600080fd5b5061037361039c366004613674565b610e1f565b3480156103ad57600080fd5b506102e16103bc366004613158565b610ede565b3480156103cd57600080fd5b506102e16103dc3660046131a4565b61104a565b3480156103ed57600080fd5b506102e16103fc366004613466565b611102565b34801561040d57600080fd5b506102e161041c3660046135a6565b611158565b34801561042d57600080fd5b506102e161043c3660046135a6565b61117d565b34801561044d57600080fd5b506102e161045c366004613158565b6111fb565b34801561046d57600080fd5b506102e16112db565b34801561048257600080fd5b506102e1610491366004613695565b6112ee565b3480156104a257600080fd5b506102e16104b13660046136c0565b611301565b3480156104c257600080fd5b506102e16104d1366004613172565b611390565b6102e16104e4366004613287565b611511565b3480156104f557600080fd5b506103736115de565b34801561050a57600080fd5b5060335460ff166102b1565b34801561052257600080fd5b506102e1610531366004613576565b611691565b34801561054257600080fd5b506102e1610551366004613576565b6116d3565b34801561056257600080fd5b506103737f71f3d55856e4058ed06ee057d79ada615f65cdf5f9ee88181b914225088f834f81565b34801561059657600080fd5b506102e161174b565b3480156105ab57600080fd5b506102e16105ba3660046134a6565b61175e565b3480156105cb57600080fd5b506102b16105da3660046135a6565b611829565b3480156105eb57600080fd5b506106196105fa366004613158565b6001600160a01b03166000908152610165602052604090205460ff1690565b6040516102889190613913565b34801561063257600080fd5b50610373600081565b34801561064757600080fd5b506102e1610656366004613466565b611854565b34801561066757600080fd5b506102e16106763660046133fd565b6118ad565b34801561068757600080fd5b5061016654610373565b34801561069d57600080fd5b506102e16106ac3660046135a6565b611a31565b3480156106bd57600080fd5b506102e16106cc3660046131f8565b611a56565b3480156106dd57600080fd5b506103736101675481565b3480156106f457600080fd5b5061024a610703366004613576565b6000908152610161602090815260408083205461016283528184205461016384528285205461016485528386205461015f86528487205461016090965293909520546001600160a01b039283169691831695831694929093169290565b34801561076c57600080fd5b5061078061077b366004613158565b611b7d565b60405161028893929190613a40565b34801561079b57600080fd5b506103737f189ab7a9244df0848122154315af71fe140f3db0fe014031783b0946b8c9d2e381565b600081815261016160209081526040808320546101639092528083205490516370a0823160e01b81526001600160a01b0391821660048201528392839283928392839283929116906370a082319060240160206040518083038186803b15801561082c57600080fd5b505afa158015610840573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610864919061358e565b60008981526101616020908152604080832054610163909252808320549051636eb1769f60e11b81526001600160a01b039182166004820152306024820152939450919291169063dd62ed3e9060440160206040518083038186803b1580156108cc57600080fd5b505afa1580156108e0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610904919061358e565b60008a81526101606020526040902054909150808310156109225750815b8082101561092d5750805b6000998a5261016160209081526040808c20546101628352818d20546101638452828e20546101648552838f205461015f90955292909d20546001600160a01b039182169e9d82169d9282169c50921699509097509095509350505050565b60006001600160e01b03198216637965db0b60e01b14806109bd57506301ffc9a760e01b6001600160e01b03198316145b92915050565b6109cb611cf0565b6109d6838383611d38565b505050565b6109e3611cf0565b8483811480156109f257508181145b610a175760405162461bcd60e51b8152600401610a0e90613934565b60405180910390fd5b60005b81811015610aaf57610a9f888883818110610a4557634e487b7160e01b600052603260045260246000fd5b90506020020135878784818110610a6c57634e487b7160e01b600052603260045260246000fd5b90506020020135868685818110610a9357634e487b7160e01b600052603260045260246000fd5b90506020020135611e20565b610aa881613c6a565b9050610a1a565b5050505050505050565b610ac1611cf0565b888781148015610ad057508581145b8015610adb57508381145b8015610ae657508181145b610b025760405162461bcd60e51b8152600401610a0e90613934565b60005b81811015610c1257610c028c8c83818110610b3057634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610b459190613158565b8b8b84818110610b6557634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610b7a9190613158565b8a8a85818110610b9a57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610baf9190613158565b898986818110610bcf57634e487b7160e01b600052603260045260246000fd5b90506020020135888887818110610bf657634e487b7160e01b600052603260045260246000fd5b9050602002013561104a565b610c0b81613c6a565b9050610b05565b505050505050505050505050565b610c28611cf0565b6001600088815261016160209081526040808320546001600160a01b0316835261016590915290205460ff166003811115610c7357634e487b7160e01b600052602160045260246000fd5b1415610cf2576000878152610161602090815260408083205461016390925290912054610cae916001600160a01b0390811691163388612509565b610cf25760405162461bcd60e51b81526020600482015260156024820152741d1c985b9cd9995c881a5cc81b9bdd081d985b1a59605a1b6044820152606401610a0e565b60008781526101616020908152604080832054815163313ce56760e01b815291516001600160a01b039091169263313ce5679260048082019391829003018186803b158015610d4057600080fd5b505afa158015610d54573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d78919061358e565b610d8390600a613b49565b610d8d8789613bf1565b610d979190613ae6565b600089815261016260205260409081902054905163d505accf60e01b81529192506001600160a01b03169063d505accf90610de2903390309086908b908b908b908b906004016138d2565b600060405180830381600087803b158015610dfc57600080fd5b505af1158015610e10573d6000803e3d6000fd5b50505050610aaf888888611e20565b60008281526101616020908152604080832054815163313ce56760e01b815291516001600160a01b0390911692839263313ce5679260048083019392829003018186803b158015610e6f57600080fd5b505afa158015610e83573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ea7919061358e565b610eb290600a613b49565b600085815261015f6020526040902054610ecc9085613bf1565b610ed69190613ae6565b949350505050565b610f087f71f3d55856e4058ed06ee057d79ada615f65cdf5f9ee88181b914225088f834f33611829565b80610f195750610f19600033611829565b610f655760405162461bcd60e51b815260206004820181905260248201527f63616c6c6572206973206e6f74206d6f64657261746f72206f722061646d696e6044820152606401610a0e565b6040516370a0823160e01b815230600482015281906001600160a01b0382169063a9059cbb90339083906370a082319060240160206040518083038186803b158015610fb057600080fd5b505afa158015610fc4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fe8919061358e565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b15801561102e57600080fd5b505af1158015611042573d6000803e3d6000fd5b505050505050565b611052611cf0565b60016001600160a01b0386166000908152610165602052604090205460ff16600381111561109057634e487b7160e01b600052602160045260246000fd5b14156110ee576110a285333384612509565b6110ee5760405162461bcd60e51b815260206004820152601e60248201527f53656c6c65722063616e206e6f74207472616e7366657220746f6b656e7300006044820152606401610a0e565b6110fb85858585856125a3565b5050505050565b600061110d816127d1565b8160005b818110156110fb5761114885858381811061113c57634e487b7160e01b600052603260045260246000fd5b905060200201356127db565b61115181613c6a565b9050611111565b600082815260976020526040902060010154611173816127d1565b6109d68383612869565b6001600160a01b03811633146111ed5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610a0e565b6111f782826128ef565b5050565b306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614156112445760405162461bcd60e51b8152600401610a0e9061395d565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661128d600080516020613cb2833981519152546001600160a01b031690565b6001600160a01b0316146112b35760405162461bcd60e51b8152600401610a0e906139a9565b6112bc81612956565b604080516000808252602082019092526112d891839190612980565b50565b60006112e6816127d1565b6112d8612afa565b6112f6611cf0565b6109d6838383611e20565b611309611cf0565b600088815261016160205260409081902054905163d505accf60e01b81526001600160a01b039091169063d505accf9061135390339030908a908a908a908a908a906004016138d2565b600060405180830381600087803b15801561136d57600080fd5b505af1158015611381573d6000803e3d6000fd5b50505050610aaf888888611d38565b600054610100900460ff16158080156113b05750600054600160ff909116105b806113ca5750303b1580156113ca575060005460ff166001145b61142d5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610a0e565b6000805460ff191660011790558015611450576000805461ff0019166101001790555b611458612b4c565b611460612b4c565b61146b600084612869565b6114957f189ab7a9244df0848122154315af71fe140f3db0fe014031783b0946b8c9d2e384612869565b6114bf7f71f3d55856e4058ed06ee057d79ada615f65cdf5f9ee88181b914225088f834f83612869565b6114c7612b73565b80156109d6576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a1505050565b306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016141561155a5760405162461bcd60e51b8152600401610a0e9061395d565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166115a3600080516020613cb2833981519152546001600160a01b031690565b6001600160a01b0316146115c95760405162461bcd60e51b8152600401610a0e906139a9565b6115d282612956565b6111f782826001612980565b6000306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461167e5760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608401610a0e565b50600080516020613cb283398151915290565b600061169c816127d1565b610167546040518391907f5fc463da23c1b063e66f9e352006a7fbe8db7223c455dc429e881a2dfe2f94f190600090a35061016755565b6116db611cf0565b600081815261016360205260409020546001600160a01b031633146117425760405162461bcd60e51b815260206004820181905260248201527f6f6e6c79207468652073656c6c65722063616e2064656c657465206f666665726044820152606401610a0e565b6112d8816127db565b6000611756816127d1565b6112d8612ba2565b611766611cf0565b84838114801561177557508181145b6117915760405162461bcd60e51b8152600401610a0e90613934565b60005b81811015610aaf576118198888838181106117bf57634e487b7160e01b600052603260045260246000fd5b905060200201358787848181106117e657634e487b7160e01b600052603260045260246000fd5b9050602002013586868581811061180d57634e487b7160e01b600052603260045260246000fd5b90506020020135611d38565b61182281613c6a565b9050611794565b60009182526097602090815260408084206001600160a01b0393909316845291905290205460ff1690565b61185c611cf0565b8060005b818110156118a75761189784848381811061188b57634e487b7160e01b600052603260045260246000fd5b905060200201356116d3565b6118a081613c6a565b9050611860565b50505050565b60006118b8816127d1565b838281146119005760405162461bcd60e51b815260206004820152601560248201527413195b99dd1a1cc8185c99481b9bdd08195c5d585b605a1b6044820152606401610a0e565b60005b818110156119d05784848281811061192b57634e487b7160e01b600052603260045260246000fd5b905060200201602081019061194091906135f0565b610165600089898581811061196557634e487b7160e01b600052603260045260246000fd5b905060200201602081019061197a9190613158565b6001600160a01b031681526020810191909152604001600020805460ff191660018360038111156119bb57634e487b7160e01b600052602160045260246000fd5b02179055506119c981613c6a565b9050611903565b5083836040516119e192919061380e565b604051809103902086866040516119f99291906137ce565b604051908190038120907fde12227836ab32bab76c40e2745db367915d9d52b1c5f05df667b17df434593490600090a3505050505050565b600082815260976020526040902060010154611a4c816127d1565b6109d683836128ef565b611a5e611cf0565b60016001600160a01b038b166000908152610165602052604090205460ff166003811115611a9c57634e487b7160e01b600052602160045260246000fd5b1415611afa57611aae8a333389612509565b611afa5760405162461bcd60e51b815260206004820152601e60248201527f53656c6c65722063616e206e6f74207472616e7366657220746f6b656e7300006044820152606401610a0e565b611b078a8a8a8a8a6125a3565b60405163d505accf60e01b81526001600160a01b038b169063d505accf90611b3f90339030908a908a908a908a908a906004016138d2565b600060405180830381600087803b158015611b5957600080fd5b505af1158015611b6d573d6000803e3d6000fd5b5050505050505050505050505050565b60006060806000849050806001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015611bc057600080fd5b505afa158015611bd4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bf8919061358e565b816001600160a01b03166395d89b416040518163ffffffff1660e01b815260040160006040518083038186803b158015611c3157600080fd5b505afa158015611c45573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611c6d919081019061360a565b826001600160a01b03166306fdde036040518163ffffffff1660e01b815260040160006040518083038186803b158015611ca657600080fd5b505afa158015611cba573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611ce2919081019061360a565b935093509350509193909250565b60335460ff1615611d365760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610a0e565b565b600083815261016360205260409020546001600160a01b03163314611d9f5760405162461bcd60e51b815260206004820181905260248201527f6f6e6c79207468652073656c6c65722063616e206368616e6765206f666665726044820152606401610a0e565b600083815261015f6020908152604080832054610160909252918290205491518392859287927fc26a0a1f023ef119f120b3d9843d9e77dc8f66bbc0ea91d48d6dd39b8e35117892611df8928252602082015260400190565b60405180910390a4600092835261015f60209081526040808520939093556101609052912055565b600083815261016460205260409020546001600160a01b031615611e9557600083815261016460205260409020546001600160a01b03163314611e955760405162461bcd60e51b815260206004820152600d60248201526c383934bb30ba329037b33332b960991b6044820152606401610a0e565b6000838152610163602090815260408083205461016183528184205461016284528285205461016890945291909320546001600160a01b03938416939182169290911690829082904311611f435760405162461bcd60e51b815260206004820152602f60248201527f63616e206e6f742062757920696e207468652073616d6520626c6f636b20617360448201526e1037b33332b91031b932b0ba34b7b760891b6064820152608401610a0e565b600088815261015f60205260409020548714611f955760405162461bcd60e51b81526020600482015260116024820152706f666665722070726963652077726f6e6760781b6044820152606401610a0e565b60008881526101606020526040902054861115611fe65760405162461bcd60e51b815260206004820152600f60248201526e0c2dadeeadce840e8dede40d0d2ced608b1b6044820152606401610a0e565b816001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561201f57600080fd5b505afa158015612033573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612057919061358e565b61206290600a613b49565b61206c8888613bf1565b116120aa5760405162461bcd60e51b815260206004820152600e60248201526d616d6f756e7420746f6f206c6f7760901b6044820152606401610a0e565b6000826001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b1580156120e557600080fd5b505afa1580156120f9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061211d919061358e565b61212890600a613b49565b6121328989613bf1565b61213c9190613ae6565b6040516370a0823160e01b81523360048201529091506000906001600160a01b038416906370a082319060240160206040518083038186803b15801561218157600080fd5b505afa158015612195573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121b9919061358e565b6040516370a0823160e01b81526001600160a01b0389811660048301529192506000918616906370a082319060240160206040518083038186803b15801561220057600080fd5b505afa158015612214573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612238919061358e565b60008c81526101606020526040902054909150612256908a90613c10565b60008c815261016060205260409081902091909155516323b872dd60e01b81523360048201526001600160a01b038981166024830152604482018590528516906323b872dd90606401600060405180830381600087803b1580156122b957600080fd5b505af11580156122cd573d6000803e3d6000fd5b50506040516323b872dd60e01b81526001600160a01b038b81166004830152336024830152604482018d9052881692506323b872dd9150606401600060405180830381600087803b15801561232157600080fd5b505af1158015612335573d6000803e3d6000fd5b50506040516370a0823160e01b81523360048201526001600160a01b03871692506370a08231915060240160206040518083038186803b15801561237857600080fd5b505afa15801561238c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123b0919061358e565b82116123ec5760405162461bcd60e51b815260206004820152600b60248201526a313abcb2b91032b93937b960a91b6044820152606401610a0e565b6040516370a0823160e01b81526001600160a01b0389811660048301528616906370a082319060240160206040518083038186803b15801561242d57600080fd5b505afa158015612441573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612465919061358e565b81116124a25760405162461bcd60e51b815260206004820152600c60248201526b39b2b63632b91032b93937b960a11b6044820152606401610a0e565b604080516001600160a01b03898116825288811660208301529181018c9052606081018b905233918a16908d907f0fe687b89794caf9729d642df21576cbddc748b0c8c7a5e1ec39f3a46bd004109060800160405180910390a45050505050505050505050565b6040516372331c7360e11b81526001600160a01b038481166004830152838116602483015260448201839052600091829187169063e46638e69060640160606040518083038186803b15801561255e57600080fd5b505afa158015612572573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612596919061353c565b5090979650505050505050565b8460006001600160a01b0382166000908152610165602052604090205460ff1660038111156125e257634e487b7160e01b600052602160045260246000fd5b141561262b5760405162461bcd60e51b8152602060048201526018602482015277151bdad95b881a5cc81b9bdd081dda1a5d195b1a5cdd195960421b6044820152606401610a0e565b8460006001600160a01b0382166000908152610165602052604090205460ff16600381111561266a57634e487b7160e01b600052602160045260246000fd5b14156126b35760405162461bcd60e51b8152602060048201526018602482015277151bdad95b881a5cc81b9bdd081dda1a5d195b1a5cdd195960421b6044820152606401610a0e565b610166805490819060006126c683613c6a565b90915550506001600160a01b038616156127035760008181526101646020526040902080546001600160a01b0319166001600160a01b0388161790555b60008181526101636020908152604080832080546001600160a01b031990811633908117909255610161845282852080546001600160a01b038f81169184168217909255610162865284872080548f841694168417905561015f86528487208c905561016086528487208b905561016886529584902043905583519283528b1693820193909352908101889052606081018790528392907f9fa2d733a579251ad3a2286bebb5db74c062332de37e4904aa156729c4b38a659060800160405180910390a45050505050505050565b6112d88133612bdf565b60008181526101636020908152604080832080546001600160a01b03199081169091556101648352818420805482169055610161835281842080548216905561016283528184208054909116905561015f82528083208390556101609091528082208290555182917f88686b85d6f2c3ab9a04e4f15a22fcfa025ffd97226dcf0a67cdf682def5567691a250565b6128738282611829565b6111f75760008281526097602090815260408083206001600160a01b03851684529091529020805460ff191660011790556128ab3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6128f98282611829565b156111f75760008281526097602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b7f189ab7a9244df0848122154315af71fe140f3db0fe014031783b0946b8c9d2e36111f7816127d1565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff16156129b3576109d683612c43565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b815260040160206040518083038186803b1580156129ec57600080fd5b505afa925050508015612a1c575060408051601f3d908101601f19168201909252612a199181019061358e565b60015b612a7f5760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b6064820152608401610a0e565b600080516020613cb28339815191528114612aee5760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608401610a0e565b506109d6838383612cdf565b612b02612d04565b6033805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b600054610100900460ff16611d365760405162461bcd60e51b8152600401610a0e906139f5565b600054610100900460ff16612b9a5760405162461bcd60e51b8152600401610a0e906139f5565b611d36612d4d565b612baa611cf0565b6033805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612b2f3390565b612be98282611829565b6111f757612c01816001600160a01b03166014612d7c565b612c0c836020612d7c565b604051602001612c1d92919061385d565b60408051601f198184030181529082905262461bcd60e51b8252610a0e91600401613921565b6001600160a01b0381163b612cb05760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610a0e565b600080516020613cb283398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b612ce883612f65565b600082511180612cf55750805b156109d6576118a78383612fa5565b60335460ff16611d365760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610a0e565b600054610100900460ff16612d745760405162461bcd60e51b8152600401610a0e906139f5565b600161012d55565b60606000612d8b836002613bf1565b612d96906002613ace565b67ffffffffffffffff811115612dbc57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612de6576020820181803683370190505b509050600360fc1b81600081518110612e0f57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110612e4c57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053506000612e70846002613bf1565b612e7b906001613ace565b90505b6001811115612f0f576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110612ebd57634e487b7160e01b600052603260045260246000fd5b1a60f81b828281518110612ee157634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c93612f0881613c53565b9050612e7e565b508315612f5e5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610a0e565b9392505050565b612f6e81612c43565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606001600160a01b0383163b61300d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610a0e565b600080846001600160a01b0316846040516130289190613841565b600060405180830381855af49150503d8060008114613063576040519150601f19603f3d011682016040523d82523d6000602084013e613068565b606091505b50915091506130908282604051806060016040528060278152602001613cd260279139613099565b95945050505050565b606083156130a8575081612f5e565b8251156130b85782518084602001fd5b8160405162461bcd60e51b8152600401610a0e9190613921565b80356001600160a01b03811681146130e957600080fd5b919050565b60008083601f8401126130ff578081fd5b50813567ffffffffffffffff811115613116578182fd5b6020830191508360208260051b850101111561313157600080fd5b9250929050565b8035600481106130e957600080fd5b803560ff811681146130e957600080fd5b600060208284031215613169578081fd5b612f5e826130d2565b60008060408385031215613184578081fd5b61318d836130d2565b915061319b602084016130d2565b90509250929050565b600080600080600060a086880312156131bb578081fd5b6131c4866130d2565b94506131d2602087016130d2565b93506131e0604087016130d2565b94979396509394606081013594506080013592915050565b6000806000806000806000806000806101408b8d031215613217578485fd5b6132208b6130d2565b995061322e60208c016130d2565b985061323c60408c016130d2565b975060608b0135965060808b0135955060a08b0135945060c08b0135935061326660e08c01613147565b92506101008b013591506101208b013590509295989b9194979a5092959850565b60008060408385031215613299578182fd5b6132a2836130d2565b9150602083013567ffffffffffffffff8111156132bd578182fd5b8301601f810185136132cd578182fd5b80356132e06132db82613aa6565b613a75565b8181528660208385010111156132f4578384fd5b81602084016020830137908101602001929092525090939092509050565b60008060008060008060008060008060a08b8d031215613330578586fd5b8a3567ffffffffffffffff80821115613347578788fd5b6133538e838f016130ee565b909c509a5060208d013591508082111561336b578788fd5b6133778e838f016130ee565b909a50985060408d013591508082111561338f578788fd5b61339b8e838f016130ee565b909850965060608d01359150808211156133b3578586fd5b6133bf8e838f016130ee565b909650945060808d01359150808211156133d7578384fd5b506133e48d828e016130ee565b915080935050809150509295989b9194979a5092959850565b60008060008060408587031215613412578182fd5b843567ffffffffffffffff80821115613429578384fd5b613435888389016130ee565b9096509450602087013591508082111561344d578384fd5b5061345a878288016130ee565b95989497509550505050565b60008060208385031215613478578182fd5b823567ffffffffffffffff81111561348e578283fd5b61349a858286016130ee565b90969095509350505050565b600080600080600080606087890312156134be578384fd5b863567ffffffffffffffff808211156134d5578586fd5b6134e18a838b016130ee565b909850965060208901359150808211156134f9578586fd5b6135058a838b016130ee565b9096509450604089013591508082111561351d578384fd5b5061352a89828a016130ee565b979a9699509497509295939492505050565b600080600060608486031215613550578081fd5b8351801515811461355f578182fd5b602085015160409095015190969495509392505050565b600060208284031215613587578081fd5b5035919050565b60006020828403121561359f578081fd5b5051919050565b600080604083850312156135b8578182fd5b8235915061319b602084016130d2565b6000602082840312156135d9578081fd5b81356001600160e01b031981168114612f5e578182fd5b600060208284031215613601578081fd5b612f5e82613138565b60006020828403121561361b578081fd5b815167ffffffffffffffff811115613631578182fd5b8201601f81018413613641578182fd5b805161364f6132db82613aa6565b818152856020838501011115613663578384fd5b613090826020830160208601613c27565b60008060408385031215613686578182fd5b50508035926020909101359150565b6000806000606084860312156136a9578081fd5b505081359360208301359350604090920135919050565b600080600080600080600080610100898b0312156136dc578182fd5b883597506020890135965060408901359550606089013594506080890135935061370860a08a01613147565b925060c0890135915060e089013590509295985092959890939650565b600080600080600080600060e0888a03121561373f578081fd5b8735965060208801359550604088013594506060880135935061376460808901613147565b925060a0880135915060c0880135905092959891949750929550565b6004811061379e57634e487b7160e01b600052602160045260246000fd5b9052565b600081518084526137ba816020860160208601613c27565b601f01601f19169290920160200192915050565b60008184825b85811015613803576001600160a01b036137ed836130d2565b16835260209283019291909101906001016137d4565b509095945050505050565b60008184825b858110156138035761382e8361382984613138565b613780565b6020928301929190910190600101613814565b60008251613853818460208701613c27565b9190910192915050565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351613895816017850160208801613c27565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516138c6816028840160208801613c27565b01602801949350505050565b6001600160a01b0397881681529590961660208601526040850193909352606084019190915260ff16608083015260a082015260c081019190915260e00190565b602081016109bd8284613780565b602081526000612f5e60208301846137a2565b6020808252600f908201526e0d8cadccee8d040dad2e6dac2e8c6d608b1b604082015260600190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b838152606060208201526000613a5960608301856137a2565b8281036040840152613a6b81856137a2565b9695505050505050565b604051601f8201601f1916810167ffffffffffffffff81118282101715613a9e57613a9e613c9b565b604052919050565b600067ffffffffffffffff821115613ac057613ac0613c9b565b50601f01601f191660200190565b60008219821115613ae157613ae1613c85565b500190565b600082613b0157634e487b7160e01b81526012600452602481fd5b500490565b600181815b80851115613b41578160001904821115613b2757613b27613c85565b80851615613b3457918102915b93841c9390800290613b0b565b509250929050565b6000612f5e8383600082613b5f575060016109bd565b81613b6c575060006109bd565b8160018114613b825760028114613b8c57613ba8565b60019150506109bd565b60ff841115613b9d57613b9d613c85565b50506001821b6109bd565b5060208310610133831016604e8410600b8410161715613bcb575081810a6109bd565b613bd58383613b06565b8060001904821115613be957613be9613c85565b029392505050565b6000816000190483118215151615613c0b57613c0b613c85565b500290565b600082821015613c2257613c22613c85565b500390565b60005b83811015613c42578181015183820152602001613c2a565b838111156118a75750506000910152565b600081613c6257613c62613c85565b506000190190565b6000600019821415613c7e57613c7e613c85565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fdfe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122004fb417c80837d324c9c9f47f1b75089d71913499d13516263e1bc110dd5f82a64736f6c63430008040033

Deployed Bytecode

0x6080604052600436106102255760003560e01c806352d1902d11610123578063a217fddf116100ab578063dc3033fc1161006f578063dc3033fc146106b1578063ddca3f43146106d1578063f5050da0146106e8578063f5dab71114610760578063f72c0d8b1461078f57600080fd5b8063a217fddf14610626578063a55f1df01461063b578063b899266e1461065b578063d048db371461067b578063d547741f1461069157600080fd5b8063797669c9116100f2578063797669c9146105565780638456cb591461058a578063867a3db81461059f57806391d14854146105bf57806393272baf146105df57600080fd5b806352d1902d146104e95780635c975abb146104fe57806369fe0e2d1461051657806374268ff21461053657600080fd5b80632befd4ad116101b15780633f4ba83a116101755780633f4ba83a1461046157806340993b261461047657806342da1f5714610496578063485cc955146104b65780634f1ef286146104d657600080fd5b80632befd4ad146103c15780632df83c1e146103e15780632f2ff15d1461040157806336568abe146104215780633659cfe61461044157600080fd5b80631a2caf6f116101f85780631a2caf6f146103035780631bcae91614610323578063248a9ca314610343578063292d52f2146103815780632a3f700b146103a157600080fd5b8063017716dc1461022a57806301ffc9a7146102915780631032c610146102c157806314b2051f146102e3575b600080fd5b34801561023657600080fd5b5061024a610245366004613576565b6107c3565b604080516001600160a01b03978816815295871660208701529386169385019390935293166060830152608082019290925260a081019190915260c0015b60405180910390f35b34801561029d57600080fd5b506102b16102ac3660046135c8565b61098c565b6040519015158152602001610288565b3480156102cd57600080fd5b506102e16102dc366004613695565b6109c3565b005b3480156102ef57600080fd5b506102e16102fe3660046134a6565b6109db565b34801561030f57600080fd5b506102e161031e366004613312565b610ab9565b34801561032f57600080fd5b506102e161033e366004613725565b610c20565b34801561034f57600080fd5b5061037361035e366004613576565b60009081526097602052604090206001015490565b604051908152602001610288565b34801561038d57600080fd5b5061037361039c366004613674565b610e1f565b3480156103ad57600080fd5b506102e16103bc366004613158565b610ede565b3480156103cd57600080fd5b506102e16103dc3660046131a4565b61104a565b3480156103ed57600080fd5b506102e16103fc366004613466565b611102565b34801561040d57600080fd5b506102e161041c3660046135a6565b611158565b34801561042d57600080fd5b506102e161043c3660046135a6565b61117d565b34801561044d57600080fd5b506102e161045c366004613158565b6111fb565b34801561046d57600080fd5b506102e16112db565b34801561048257600080fd5b506102e1610491366004613695565b6112ee565b3480156104a257600080fd5b506102e16104b13660046136c0565b611301565b3480156104c257600080fd5b506102e16104d1366004613172565b611390565b6102e16104e4366004613287565b611511565b3480156104f557600080fd5b506103736115de565b34801561050a57600080fd5b5060335460ff166102b1565b34801561052257600080fd5b506102e1610531366004613576565b611691565b34801561054257600080fd5b506102e1610551366004613576565b6116d3565b34801561056257600080fd5b506103737f71f3d55856e4058ed06ee057d79ada615f65cdf5f9ee88181b914225088f834f81565b34801561059657600080fd5b506102e161174b565b3480156105ab57600080fd5b506102e16105ba3660046134a6565b61175e565b3480156105cb57600080fd5b506102b16105da3660046135a6565b611829565b3480156105eb57600080fd5b506106196105fa366004613158565b6001600160a01b03166000908152610165602052604090205460ff1690565b6040516102889190613913565b34801561063257600080fd5b50610373600081565b34801561064757600080fd5b506102e1610656366004613466565b611854565b34801561066757600080fd5b506102e16106763660046133fd565b6118ad565b34801561068757600080fd5b5061016654610373565b34801561069d57600080fd5b506102e16106ac3660046135a6565b611a31565b3480156106bd57600080fd5b506102e16106cc3660046131f8565b611a56565b3480156106dd57600080fd5b506103736101675481565b3480156106f457600080fd5b5061024a610703366004613576565b6000908152610161602090815260408083205461016283528184205461016384528285205461016485528386205461015f86528487205461016090965293909520546001600160a01b039283169691831695831694929093169290565b34801561076c57600080fd5b5061078061077b366004613158565b611b7d565b60405161028893929190613a40565b34801561079b57600080fd5b506103737f189ab7a9244df0848122154315af71fe140f3db0fe014031783b0946b8c9d2e381565b600081815261016160209081526040808320546101639092528083205490516370a0823160e01b81526001600160a01b0391821660048201528392839283928392839283929116906370a082319060240160206040518083038186803b15801561082c57600080fd5b505afa158015610840573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610864919061358e565b60008981526101616020908152604080832054610163909252808320549051636eb1769f60e11b81526001600160a01b039182166004820152306024820152939450919291169063dd62ed3e9060440160206040518083038186803b1580156108cc57600080fd5b505afa1580156108e0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610904919061358e565b60008a81526101606020526040902054909150808310156109225750815b8082101561092d5750805b6000998a5261016160209081526040808c20546101628352818d20546101638452828e20546101648552838f205461015f90955292909d20546001600160a01b039182169e9d82169d9282169c50921699509097509095509350505050565b60006001600160e01b03198216637965db0b60e01b14806109bd57506301ffc9a760e01b6001600160e01b03198316145b92915050565b6109cb611cf0565b6109d6838383611d38565b505050565b6109e3611cf0565b8483811480156109f257508181145b610a175760405162461bcd60e51b8152600401610a0e90613934565b60405180910390fd5b60005b81811015610aaf57610a9f888883818110610a4557634e487b7160e01b600052603260045260246000fd5b90506020020135878784818110610a6c57634e487b7160e01b600052603260045260246000fd5b90506020020135868685818110610a9357634e487b7160e01b600052603260045260246000fd5b90506020020135611e20565b610aa881613c6a565b9050610a1a565b5050505050505050565b610ac1611cf0565b888781148015610ad057508581145b8015610adb57508381145b8015610ae657508181145b610b025760405162461bcd60e51b8152600401610a0e90613934565b60005b81811015610c1257610c028c8c83818110610b3057634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610b459190613158565b8b8b84818110610b6557634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610b7a9190613158565b8a8a85818110610b9a57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610baf9190613158565b898986818110610bcf57634e487b7160e01b600052603260045260246000fd5b90506020020135888887818110610bf657634e487b7160e01b600052603260045260246000fd5b9050602002013561104a565b610c0b81613c6a565b9050610b05565b505050505050505050505050565b610c28611cf0565b6001600088815261016160209081526040808320546001600160a01b0316835261016590915290205460ff166003811115610c7357634e487b7160e01b600052602160045260246000fd5b1415610cf2576000878152610161602090815260408083205461016390925290912054610cae916001600160a01b0390811691163388612509565b610cf25760405162461bcd60e51b81526020600482015260156024820152741d1c985b9cd9995c881a5cc81b9bdd081d985b1a59605a1b6044820152606401610a0e565b60008781526101616020908152604080832054815163313ce56760e01b815291516001600160a01b039091169263313ce5679260048082019391829003018186803b158015610d4057600080fd5b505afa158015610d54573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d78919061358e565b610d8390600a613b49565b610d8d8789613bf1565b610d979190613ae6565b600089815261016260205260409081902054905163d505accf60e01b81529192506001600160a01b03169063d505accf90610de2903390309086908b908b908b908b906004016138d2565b600060405180830381600087803b158015610dfc57600080fd5b505af1158015610e10573d6000803e3d6000fd5b50505050610aaf888888611e20565b60008281526101616020908152604080832054815163313ce56760e01b815291516001600160a01b0390911692839263313ce5679260048083019392829003018186803b158015610e6f57600080fd5b505afa158015610e83573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ea7919061358e565b610eb290600a613b49565b600085815261015f6020526040902054610ecc9085613bf1565b610ed69190613ae6565b949350505050565b610f087f71f3d55856e4058ed06ee057d79ada615f65cdf5f9ee88181b914225088f834f33611829565b80610f195750610f19600033611829565b610f655760405162461bcd60e51b815260206004820181905260248201527f63616c6c6572206973206e6f74206d6f64657261746f72206f722061646d696e6044820152606401610a0e565b6040516370a0823160e01b815230600482015281906001600160a01b0382169063a9059cbb90339083906370a082319060240160206040518083038186803b158015610fb057600080fd5b505afa158015610fc4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fe8919061358e565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b15801561102e57600080fd5b505af1158015611042573d6000803e3d6000fd5b505050505050565b611052611cf0565b60016001600160a01b0386166000908152610165602052604090205460ff16600381111561109057634e487b7160e01b600052602160045260246000fd5b14156110ee576110a285333384612509565b6110ee5760405162461bcd60e51b815260206004820152601e60248201527f53656c6c65722063616e206e6f74207472616e7366657220746f6b656e7300006044820152606401610a0e565b6110fb85858585856125a3565b5050505050565b600061110d816127d1565b8160005b818110156110fb5761114885858381811061113c57634e487b7160e01b600052603260045260246000fd5b905060200201356127db565b61115181613c6a565b9050611111565b600082815260976020526040902060010154611173816127d1565b6109d68383612869565b6001600160a01b03811633146111ed5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610a0e565b6111f782826128ef565b5050565b306001600160a01b037f0000000000000000000000003b9543e2851accaef9b4f6fb42fcaea5e92315891614156112445760405162461bcd60e51b8152600401610a0e9061395d565b7f0000000000000000000000003b9543e2851accaef9b4f6fb42fcaea5e92315896001600160a01b031661128d600080516020613cb2833981519152546001600160a01b031690565b6001600160a01b0316146112b35760405162461bcd60e51b8152600401610a0e906139a9565b6112bc81612956565b604080516000808252602082019092526112d891839190612980565b50565b60006112e6816127d1565b6112d8612afa565b6112f6611cf0565b6109d6838383611e20565b611309611cf0565b600088815261016160205260409081902054905163d505accf60e01b81526001600160a01b039091169063d505accf9061135390339030908a908a908a908a908a906004016138d2565b600060405180830381600087803b15801561136d57600080fd5b505af1158015611381573d6000803e3d6000fd5b50505050610aaf888888611d38565b600054610100900460ff16158080156113b05750600054600160ff909116105b806113ca5750303b1580156113ca575060005460ff166001145b61142d5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610a0e565b6000805460ff191660011790558015611450576000805461ff0019166101001790555b611458612b4c565b611460612b4c565b61146b600084612869565b6114957f189ab7a9244df0848122154315af71fe140f3db0fe014031783b0946b8c9d2e384612869565b6114bf7f71f3d55856e4058ed06ee057d79ada615f65cdf5f9ee88181b914225088f834f83612869565b6114c7612b73565b80156109d6576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a1505050565b306001600160a01b037f0000000000000000000000003b9543e2851accaef9b4f6fb42fcaea5e923158916141561155a5760405162461bcd60e51b8152600401610a0e9061395d565b7f0000000000000000000000003b9543e2851accaef9b4f6fb42fcaea5e92315896001600160a01b03166115a3600080516020613cb2833981519152546001600160a01b031690565b6001600160a01b0316146115c95760405162461bcd60e51b8152600401610a0e906139a9565b6115d282612956565b6111f782826001612980565b6000306001600160a01b037f0000000000000000000000003b9543e2851accaef9b4f6fb42fcaea5e9231589161461167e5760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608401610a0e565b50600080516020613cb283398151915290565b600061169c816127d1565b610167546040518391907f5fc463da23c1b063e66f9e352006a7fbe8db7223c455dc429e881a2dfe2f94f190600090a35061016755565b6116db611cf0565b600081815261016360205260409020546001600160a01b031633146117425760405162461bcd60e51b815260206004820181905260248201527f6f6e6c79207468652073656c6c65722063616e2064656c657465206f666665726044820152606401610a0e565b6112d8816127db565b6000611756816127d1565b6112d8612ba2565b611766611cf0565b84838114801561177557508181145b6117915760405162461bcd60e51b8152600401610a0e90613934565b60005b81811015610aaf576118198888838181106117bf57634e487b7160e01b600052603260045260246000fd5b905060200201358787848181106117e657634e487b7160e01b600052603260045260246000fd5b9050602002013586868581811061180d57634e487b7160e01b600052603260045260246000fd5b90506020020135611d38565b61182281613c6a565b9050611794565b60009182526097602090815260408084206001600160a01b0393909316845291905290205460ff1690565b61185c611cf0565b8060005b818110156118a75761189784848381811061188b57634e487b7160e01b600052603260045260246000fd5b905060200201356116d3565b6118a081613c6a565b9050611860565b50505050565b60006118b8816127d1565b838281146119005760405162461bcd60e51b815260206004820152601560248201527413195b99dd1a1cc8185c99481b9bdd08195c5d585b605a1b6044820152606401610a0e565b60005b818110156119d05784848281811061192b57634e487b7160e01b600052603260045260246000fd5b905060200201602081019061194091906135f0565b610165600089898581811061196557634e487b7160e01b600052603260045260246000fd5b905060200201602081019061197a9190613158565b6001600160a01b031681526020810191909152604001600020805460ff191660018360038111156119bb57634e487b7160e01b600052602160045260246000fd5b02179055506119c981613c6a565b9050611903565b5083836040516119e192919061380e565b604051809103902086866040516119f99291906137ce565b604051908190038120907fde12227836ab32bab76c40e2745db367915d9d52b1c5f05df667b17df434593490600090a3505050505050565b600082815260976020526040902060010154611a4c816127d1565b6109d683836128ef565b611a5e611cf0565b60016001600160a01b038b166000908152610165602052604090205460ff166003811115611a9c57634e487b7160e01b600052602160045260246000fd5b1415611afa57611aae8a333389612509565b611afa5760405162461bcd60e51b815260206004820152601e60248201527f53656c6c65722063616e206e6f74207472616e7366657220746f6b656e7300006044820152606401610a0e565b611b078a8a8a8a8a6125a3565b60405163d505accf60e01b81526001600160a01b038b169063d505accf90611b3f90339030908a908a908a908a908a906004016138d2565b600060405180830381600087803b158015611b5957600080fd5b505af1158015611b6d573d6000803e3d6000fd5b5050505050505050505050505050565b60006060806000849050806001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015611bc057600080fd5b505afa158015611bd4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bf8919061358e565b816001600160a01b03166395d89b416040518163ffffffff1660e01b815260040160006040518083038186803b158015611c3157600080fd5b505afa158015611c45573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611c6d919081019061360a565b826001600160a01b03166306fdde036040518163ffffffff1660e01b815260040160006040518083038186803b158015611ca657600080fd5b505afa158015611cba573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611ce2919081019061360a565b935093509350509193909250565b60335460ff1615611d365760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610a0e565b565b600083815261016360205260409020546001600160a01b03163314611d9f5760405162461bcd60e51b815260206004820181905260248201527f6f6e6c79207468652073656c6c65722063616e206368616e6765206f666665726044820152606401610a0e565b600083815261015f6020908152604080832054610160909252918290205491518392859287927fc26a0a1f023ef119f120b3d9843d9e77dc8f66bbc0ea91d48d6dd39b8e35117892611df8928252602082015260400190565b60405180910390a4600092835261015f60209081526040808520939093556101609052912055565b600083815261016460205260409020546001600160a01b031615611e9557600083815261016460205260409020546001600160a01b03163314611e955760405162461bcd60e51b815260206004820152600d60248201526c383934bb30ba329037b33332b960991b6044820152606401610a0e565b6000838152610163602090815260408083205461016183528184205461016284528285205461016890945291909320546001600160a01b03938416939182169290911690829082904311611f435760405162461bcd60e51b815260206004820152602f60248201527f63616e206e6f742062757920696e207468652073616d6520626c6f636b20617360448201526e1037b33332b91031b932b0ba34b7b760891b6064820152608401610a0e565b600088815261015f60205260409020548714611f955760405162461bcd60e51b81526020600482015260116024820152706f666665722070726963652077726f6e6760781b6044820152606401610a0e565b60008881526101606020526040902054861115611fe65760405162461bcd60e51b815260206004820152600f60248201526e0c2dadeeadce840e8dede40d0d2ced608b1b6044820152606401610a0e565b816001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561201f57600080fd5b505afa158015612033573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612057919061358e565b61206290600a613b49565b61206c8888613bf1565b116120aa5760405162461bcd60e51b815260206004820152600e60248201526d616d6f756e7420746f6f206c6f7760901b6044820152606401610a0e565b6000826001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b1580156120e557600080fd5b505afa1580156120f9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061211d919061358e565b61212890600a613b49565b6121328989613bf1565b61213c9190613ae6565b6040516370a0823160e01b81523360048201529091506000906001600160a01b038416906370a082319060240160206040518083038186803b15801561218157600080fd5b505afa158015612195573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121b9919061358e565b6040516370a0823160e01b81526001600160a01b0389811660048301529192506000918616906370a082319060240160206040518083038186803b15801561220057600080fd5b505afa158015612214573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612238919061358e565b60008c81526101606020526040902054909150612256908a90613c10565b60008c815261016060205260409081902091909155516323b872dd60e01b81523360048201526001600160a01b038981166024830152604482018590528516906323b872dd90606401600060405180830381600087803b1580156122b957600080fd5b505af11580156122cd573d6000803e3d6000fd5b50506040516323b872dd60e01b81526001600160a01b038b81166004830152336024830152604482018d9052881692506323b872dd9150606401600060405180830381600087803b15801561232157600080fd5b505af1158015612335573d6000803e3d6000fd5b50506040516370a0823160e01b81523360048201526001600160a01b03871692506370a08231915060240160206040518083038186803b15801561237857600080fd5b505afa15801561238c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123b0919061358e565b82116123ec5760405162461bcd60e51b815260206004820152600b60248201526a313abcb2b91032b93937b960a91b6044820152606401610a0e565b6040516370a0823160e01b81526001600160a01b0389811660048301528616906370a082319060240160206040518083038186803b15801561242d57600080fd5b505afa158015612441573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612465919061358e565b81116124a25760405162461bcd60e51b815260206004820152600c60248201526b39b2b63632b91032b93937b960a11b6044820152606401610a0e565b604080516001600160a01b03898116825288811660208301529181018c9052606081018b905233918a16908d907f0fe687b89794caf9729d642df21576cbddc748b0c8c7a5e1ec39f3a46bd004109060800160405180910390a45050505050505050505050565b6040516372331c7360e11b81526001600160a01b038481166004830152838116602483015260448201839052600091829187169063e46638e69060640160606040518083038186803b15801561255e57600080fd5b505afa158015612572573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612596919061353c565b5090979650505050505050565b8460006001600160a01b0382166000908152610165602052604090205460ff1660038111156125e257634e487b7160e01b600052602160045260246000fd5b141561262b5760405162461bcd60e51b8152602060048201526018602482015277151bdad95b881a5cc81b9bdd081dda1a5d195b1a5cdd195960421b6044820152606401610a0e565b8460006001600160a01b0382166000908152610165602052604090205460ff16600381111561266a57634e487b7160e01b600052602160045260246000fd5b14156126b35760405162461bcd60e51b8152602060048201526018602482015277151bdad95b881a5cc81b9bdd081dda1a5d195b1a5cdd195960421b6044820152606401610a0e565b610166805490819060006126c683613c6a565b90915550506001600160a01b038616156127035760008181526101646020526040902080546001600160a01b0319166001600160a01b0388161790555b60008181526101636020908152604080832080546001600160a01b031990811633908117909255610161845282852080546001600160a01b038f81169184168217909255610162865284872080548f841694168417905561015f86528487208c905561016086528487208b905561016886529584902043905583519283528b1693820193909352908101889052606081018790528392907f9fa2d733a579251ad3a2286bebb5db74c062332de37e4904aa156729c4b38a659060800160405180910390a45050505050505050565b6112d88133612bdf565b60008181526101636020908152604080832080546001600160a01b03199081169091556101648352818420805482169055610161835281842080548216905561016283528184208054909116905561015f82528083208390556101609091528082208290555182917f88686b85d6f2c3ab9a04e4f15a22fcfa025ffd97226dcf0a67cdf682def5567691a250565b6128738282611829565b6111f75760008281526097602090815260408083206001600160a01b03851684529091529020805460ff191660011790556128ab3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6128f98282611829565b156111f75760008281526097602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b7f189ab7a9244df0848122154315af71fe140f3db0fe014031783b0946b8c9d2e36111f7816127d1565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff16156129b3576109d683612c43565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b815260040160206040518083038186803b1580156129ec57600080fd5b505afa925050508015612a1c575060408051601f3d908101601f19168201909252612a199181019061358e565b60015b612a7f5760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b6064820152608401610a0e565b600080516020613cb28339815191528114612aee5760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608401610a0e565b506109d6838383612cdf565b612b02612d04565b6033805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b600054610100900460ff16611d365760405162461bcd60e51b8152600401610a0e906139f5565b600054610100900460ff16612b9a5760405162461bcd60e51b8152600401610a0e906139f5565b611d36612d4d565b612baa611cf0565b6033805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612b2f3390565b612be98282611829565b6111f757612c01816001600160a01b03166014612d7c565b612c0c836020612d7c565b604051602001612c1d92919061385d565b60408051601f198184030181529082905262461bcd60e51b8252610a0e91600401613921565b6001600160a01b0381163b612cb05760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610a0e565b600080516020613cb283398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b612ce883612f65565b600082511180612cf55750805b156109d6576118a78383612fa5565b60335460ff16611d365760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610a0e565b600054610100900460ff16612d745760405162461bcd60e51b8152600401610a0e906139f5565b600161012d55565b60606000612d8b836002613bf1565b612d96906002613ace565b67ffffffffffffffff811115612dbc57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612de6576020820181803683370190505b509050600360fc1b81600081518110612e0f57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110612e4c57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053506000612e70846002613bf1565b612e7b906001613ace565b90505b6001811115612f0f576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110612ebd57634e487b7160e01b600052603260045260246000fd5b1a60f81b828281518110612ee157634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c93612f0881613c53565b9050612e7e565b508315612f5e5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610a0e565b9392505050565b612f6e81612c43565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606001600160a01b0383163b61300d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610a0e565b600080846001600160a01b0316846040516130289190613841565b600060405180830381855af49150503d8060008114613063576040519150601f19603f3d011682016040523d82523d6000602084013e613068565b606091505b50915091506130908282604051806060016040528060278152602001613cd260279139613099565b95945050505050565b606083156130a8575081612f5e565b8251156130b85782518084602001fd5b8160405162461bcd60e51b8152600401610a0e9190613921565b80356001600160a01b03811681146130e957600080fd5b919050565b60008083601f8401126130ff578081fd5b50813567ffffffffffffffff811115613116578182fd5b6020830191508360208260051b850101111561313157600080fd5b9250929050565b8035600481106130e957600080fd5b803560ff811681146130e957600080fd5b600060208284031215613169578081fd5b612f5e826130d2565b60008060408385031215613184578081fd5b61318d836130d2565b915061319b602084016130d2565b90509250929050565b600080600080600060a086880312156131bb578081fd5b6131c4866130d2565b94506131d2602087016130d2565b93506131e0604087016130d2565b94979396509394606081013594506080013592915050565b6000806000806000806000806000806101408b8d031215613217578485fd5b6132208b6130d2565b995061322e60208c016130d2565b985061323c60408c016130d2565b975060608b0135965060808b0135955060a08b0135945060c08b0135935061326660e08c01613147565b92506101008b013591506101208b013590509295989b9194979a5092959850565b60008060408385031215613299578182fd5b6132a2836130d2565b9150602083013567ffffffffffffffff8111156132bd578182fd5b8301601f810185136132cd578182fd5b80356132e06132db82613aa6565b613a75565b8181528660208385010111156132f4578384fd5b81602084016020830137908101602001929092525090939092509050565b60008060008060008060008060008060a08b8d031215613330578586fd5b8a3567ffffffffffffffff80821115613347578788fd5b6133538e838f016130ee565b909c509a5060208d013591508082111561336b578788fd5b6133778e838f016130ee565b909a50985060408d013591508082111561338f578788fd5b61339b8e838f016130ee565b909850965060608d01359150808211156133b3578586fd5b6133bf8e838f016130ee565b909650945060808d01359150808211156133d7578384fd5b506133e48d828e016130ee565b915080935050809150509295989b9194979a5092959850565b60008060008060408587031215613412578182fd5b843567ffffffffffffffff80821115613429578384fd5b613435888389016130ee565b9096509450602087013591508082111561344d578384fd5b5061345a878288016130ee565b95989497509550505050565b60008060208385031215613478578182fd5b823567ffffffffffffffff81111561348e578283fd5b61349a858286016130ee565b90969095509350505050565b600080600080600080606087890312156134be578384fd5b863567ffffffffffffffff808211156134d5578586fd5b6134e18a838b016130ee565b909850965060208901359150808211156134f9578586fd5b6135058a838b016130ee565b9096509450604089013591508082111561351d578384fd5b5061352a89828a016130ee565b979a9699509497509295939492505050565b600080600060608486031215613550578081fd5b8351801515811461355f578182fd5b602085015160409095015190969495509392505050565b600060208284031215613587578081fd5b5035919050565b60006020828403121561359f578081fd5b5051919050565b600080604083850312156135b8578182fd5b8235915061319b602084016130d2565b6000602082840312156135d9578081fd5b81356001600160e01b031981168114612f5e578182fd5b600060208284031215613601578081fd5b612f5e82613138565b60006020828403121561361b578081fd5b815167ffffffffffffffff811115613631578182fd5b8201601f81018413613641578182fd5b805161364f6132db82613aa6565b818152856020838501011115613663578384fd5b613090826020830160208601613c27565b60008060408385031215613686578182fd5b50508035926020909101359150565b6000806000606084860312156136a9578081fd5b505081359360208301359350604090920135919050565b600080600080600080600080610100898b0312156136dc578182fd5b883597506020890135965060408901359550606089013594506080890135935061370860a08a01613147565b925060c0890135915060e089013590509295985092959890939650565b600080600080600080600060e0888a03121561373f578081fd5b8735965060208801359550604088013594506060880135935061376460808901613147565b925060a0880135915060c0880135905092959891949750929550565b6004811061379e57634e487b7160e01b600052602160045260246000fd5b9052565b600081518084526137ba816020860160208601613c27565b601f01601f19169290920160200192915050565b60008184825b85811015613803576001600160a01b036137ed836130d2565b16835260209283019291909101906001016137d4565b509095945050505050565b60008184825b858110156138035761382e8361382984613138565b613780565b6020928301929190910190600101613814565b60008251613853818460208701613c27565b9190910192915050565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351613895816017850160208801613c27565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516138c6816028840160208801613c27565b01602801949350505050565b6001600160a01b0397881681529590961660208601526040850193909352606084019190915260ff16608083015260a082015260c081019190915260e00190565b602081016109bd8284613780565b602081526000612f5e60208301846137a2565b6020808252600f908201526e0d8cadccee8d040dad2e6dac2e8c6d608b1b604082015260600190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b838152606060208201526000613a5960608301856137a2565b8281036040840152613a6b81856137a2565b9695505050505050565b604051601f8201601f1916810167ffffffffffffffff81118282101715613a9e57613a9e613c9b565b604052919050565b600067ffffffffffffffff821115613ac057613ac0613c9b565b50601f01601f191660200190565b60008219821115613ae157613ae1613c85565b500190565b600082613b0157634e487b7160e01b81526012600452602481fd5b500490565b600181815b80851115613b41578160001904821115613b2757613b27613c85565b80851615613b3457918102915b93841c9390800290613b0b565b509250929050565b6000612f5e8383600082613b5f575060016109bd565b81613b6c575060006109bd565b8160018114613b825760028114613b8c57613ba8565b60019150506109bd565b60ff841115613b9d57613b9d613c85565b50506001821b6109bd565b5060208310610133831016604e8410600b8410161715613bcb575081810a6109bd565b613bd58383613b06565b8060001904821115613be957613be9613c85565b029392505050565b6000816000190483118215151615613c0b57613c0b613c85565b500290565b600082821015613c2257613c22613c85565b500390565b60005b83811015613c42578181015183820152602001613c2a565b838111156118a75750506000910152565b600081613c6257613c62613c85565b506000190190565b6000600019821415613c7e57613c7e613c85565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fdfe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122004fb417c80837d324c9c9f47f1b75089d71913499d13516263e1bc110dd5f82a64736f6c63430008040033

Block Transaction Gas Used Reward
view all blocks validated

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits

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