ETH Price: $3,395.02 (+5.05%)
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

1 Internal Transaction found.

Latest 1 internal transaction

Advanced mode:
Parent Transaction Hash Block
From
To
216231612025-01-14 13:55:479 days ago1736862947  Contract Creation0 ETH
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
CoverProducts

Compiler Version
v0.8.18+commit.87f61d96

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 24 : CoverProducts.sol
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity ^0.8.18;

import "@openzeppelin/contracts-v4/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts-v4/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts-v4/token/ERC20/utils/SafeERC20.sol";

import "../../abstract/MasterAwareV2.sol";
import "../../abstract/Multicall.sol";
import "../../interfaces/ICover.sol";
import "../../interfaces/ICoverProducts.sol";
import "../../interfaces/ILegacyCover.sol";
import "../../interfaces/IPool.sol";
import "../../interfaces/IStakingProducts.sol";

contract CoverProducts is ICoverProducts, MasterAwareV2, Multicall {

  /* ========== STATE VARIABLES ========== */

  Product[] internal _products;
  ProductType[] internal _productTypes;

  // productId => product name
  mapping(uint => string) internal productNames;
  // productTypeId => productType name
  mapping(uint => string) internal productTypeNames;
  // product id => allowed pool ids
  mapping(uint => uint[]) internal allowedPools;

  mapping(uint => Metadata[]) internal productMetadata;
  mapping(uint => Metadata[]) internal productTypeMetadata;

  /* ========== CONSTANTS ========== */

  uint private constant PRICE_DENOMINATOR = 10000;
  uint private constant CAPACITY_REDUCTION_DENOMINATOR = 10000;

  /* ========== VIEWS ========== */

  function getProductType(uint productTypeId) external view returns (ProductType memory) {
    return _productTypes[productTypeId];
  }

  function getProductTypeName(uint productTypeId) external view returns (string memory) {
    return productTypeNames[productTypeId];
  }

  function getProductTypeCount() external view returns (uint) {
    return _productTypes.length;
  }

  function getProductTypes() external view returns (ProductType[] memory) {
    return _productTypes;
  }

  function getProduct(uint productId) external view returns (Product memory) {
    return _products[productId];
  }

  function getProductName(uint productId) external view returns (string memory) {
    return productNames[productId];
  }

  function getProductCount() public view returns (uint) {
    return _products.length;
  }

  function getProducts() external view returns (Product[] memory) {
    return _products;
  }

  function getProductWithType(uint productId)  external override view returns (
    Product memory product,
    ProductType memory productType
  ) {
    product = _products[productId];
    productType = _productTypes[product.productType];
  }

  function getLatestProductMetadata(uint productId) external view returns (Metadata memory) {
    uint metadataLength = productMetadata[productId].length;
    return metadataLength > 0
      ? productMetadata[productId][metadataLength - 1]
      : Metadata("", 0);
  }

  function getLatestProductTypeMetadata(uint productTypeId) external view returns (Metadata memory) {
    uint metadataLength = productTypeMetadata[productTypeId].length;
    return metadataLength > 0
      ? productTypeMetadata[productTypeId][metadataLength - 1]
      : Metadata("", 0);
  }

  function getProductMetadata(uint productId) external view returns (Metadata[] memory) {
    return productMetadata[productId];
  }

  function getProductTypeMetadata(uint productTypeId) external view returns (Metadata[] memory) {
    return productTypeMetadata[productTypeId];
  }

  function getAllowedPools(uint productId) external view returns (uint[] memory _allowedPools) {

    uint allowedPoolCount = allowedPools[productId].length;
    _allowedPools = new uint[](allowedPoolCount);

    for (uint i = 0; i < allowedPoolCount; i++) {
      _allowedPools[i] = allowedPools[productId][i];
    }
  }

  function getAllowedPoolsCount(uint productId) external view returns (uint) {
    return allowedPools[productId].length;
  }

  function getInitialPrices(
    uint[] calldata productIds
  ) external view returns (uint[] memory initialPrices) {

    uint productCount = _products.length;
    initialPrices = new uint[](productIds.length);

    for (uint i = 0; i < productIds.length; i++) {
      uint productId = productIds[i];

      if (productId >= productCount) {
        revert ProductNotFound();
      }

      initialPrices[i] = _products[productId].initialPriceRatio;
    }
  }

  function getMinPrices(
    uint[] calldata productIds
  ) external view returns (uint[] memory minPrices) {
    uint productCount = _products.length;
    minPrices = new uint[](productIds.length);
    uint defaultMinPrice = cover().getDefaultMinPriceRatio();

    for (uint i = 0; i < productIds.length; i++) {
      uint productId = productIds[i];

      if (productId >= productCount) {
        revert ProductNotFound();
      }

      if (_products[productId].minPrice == 0) {
        minPrices[i] = defaultMinPrice;
      } else {
        minPrices[i] = _products[productId].minPrice;
      }
    }
  }

  function getCapacityReductionRatios(
    uint[] calldata productIds
  ) external view returns (uint[] memory capacityReductionRatios) {

    uint productCount = _products.length;
    capacityReductionRatios = new uint[](productIds.length);

    for (uint i = 0; i < productIds.length; i++) {
      uint productId = productIds[i];

      if (productId >= productCount) {
        revert ProductNotFound();
      }

      capacityReductionRatios[i] = _products[productId].capacityReductionRatio;
    }
  }

  function prepareStakingProductsParams(
    ProductInitializationParams[] calldata params
  ) external view returns (
    ProductInitializationParams[] memory validatedParams
  ) {

    uint productCount = _products.length;
    uint inputLength = params.length;
    validatedParams = new ProductInitializationParams[](inputLength);

    // override with initial price and check if pool is allowed
    for (uint i = 0; i < inputLength; i++) {

      uint productId = params[i].productId;

      if (productId >= productCount) {
        revert ProductNotFound();
      }

      // if there is a list of allowed pools for this product - the new pool didn't exist yet
      // so the product can't be in it
      if (allowedPools[productId].length > 0) {
        revert PoolNotAllowedForThisProduct(productId);
      }

      Product memory product = _products[productId];

      if (product.isDeprecated) {
        revert ProductDeprecated();
      }

      validatedParams[i] = params[i];
      validatedParams[i].initialPrice = product.initialPriceRatio;
    }
  }

  /* ========== PRODUCT CONFIGURATION ========== */

  function setProducts(ProductParam[] calldata productParams) external override onlyAdvisoryBoard {

    uint unsupportedCoverAssetsBitmap = type(uint).max;
    uint defaultMinPriceRatio = cover().getDefaultMinPriceRatio();

    uint poolCount = stakingProducts().getStakingPoolCount();
    Asset[] memory assets = pool().getAssets();
    uint assetsLength = assets.length;

    for (uint i = 0; i < assetsLength; i++) {
      if (assets[i].isCoverAsset && !assets[i].isAbandoned) {
        // clear the bit at index i
        unsupportedCoverAssetsBitmap ^= 1 << i;
      }
    }

    for (uint i = 0; i < productParams.length; i++) {

      ProductParam calldata param = productParams[i];
      Product calldata product = param.product;

      if (product.productType >= _productTypes.length) {
        revert ProductTypeNotFound();
      }

      if (unsupportedCoverAssetsBitmap & product.coverAssets != 0) {
        revert UnsupportedCoverAssets();
      }

      uint256 minPrice = product.minPrice == 0 ? defaultMinPriceRatio : product.minPrice;
      if (product.initialPriceRatio < minPrice) {
        revert InitialPriceRatioBelowMinPriceRatio();
      }

      if (product.initialPriceRatio > PRICE_DENOMINATOR) {
        revert InitialPriceRatioAbove100Percent();
      }

      if (product.capacityReductionRatio > CAPACITY_REDUCTION_DENOMINATOR) {
        revert CapacityReductionRatioAbove100Percent();
      }

      if (param.allowedPools.length > 0) {
        for (uint j = 0; j < param.allowedPools.length; j++) {
          if (param.allowedPools[j] > poolCount || param.allowedPools[j] == 0) {
            revert StakingPoolDoesNotExist();
          }
        }
      }

      // New product has id == uint256.max
      if (param.productId == type(uint256).max) {
        uint productId = _products.length;

        // the metadata is optional, do not push if empty
        if (bytes(param.ipfsMetadata).length > 0) {
          productMetadata[productId].push(Metadata(param.ipfsMetadata, block.timestamp));
        }

        productNames[productId] = param.productName;
        allowedPools[productId] = param.allowedPools;

        _products.push(product);
        emit ProductSet(productId);
        continue;
      }

      // Existing product
      if (param.productId >= _products.length) {
        revert ProductNotFound();
      }

      Product storage newProductValue = _products[param.productId];
      newProductValue.isDeprecated = product.isDeprecated;
      newProductValue.coverAssets = product.coverAssets;
      newProductValue.initialPriceRatio = product.initialPriceRatio;
      newProductValue.capacityReductionRatio = product.capacityReductionRatio;
      newProductValue.minPrice = product.minPrice;

      allowedPools[param.productId] = param.allowedPools;

      if (bytes(param.productName).length > 0) {
        productNames[param.productId] = param.productName;
      }

      if (bytes(param.ipfsMetadata).length > 0) {
        productMetadata[param.productId].push(Metadata(param.ipfsMetadata, block.timestamp));
      }

      emit ProductSet(param.productId);
    }
  }

  function setProductTypes(ProductTypeParam[] calldata productTypeParams) external onlyAdvisoryBoard {

    for (uint i = 0; i < productTypeParams.length; i++) {
      ProductTypeParam calldata param = productTypeParams[i];

      // New product has id == uint256.max
      if (param.productTypeId == type(uint256).max) {
        uint productTypeId = _productTypes.length;

        // the product type metadata is mandatory
        if (bytes(param.ipfsMetadata).length == 0) {
          revert MetadataRequired();
        }

        productTypeMetadata[productTypeId].push(Metadata(param.ipfsMetadata, block.timestamp));
        productTypeNames[productTypeId] = param.productTypeName;
        _productTypes.push(param.productType);

        emit ProductTypeSet(productTypeId);
        continue;
      }

      if (param.productTypeId >= _productTypes.length) {
        revert ProductTypeNotFound();
      }

      _productTypes[param.productTypeId].gracePeriod = param.productType.gracePeriod;

      if (bytes(param.productTypeName).length > 0) {
        productTypeNames[param.productTypeId] = param.productTypeName;
      }

      if (bytes(param.ipfsMetadata).length > 0) {
        productTypeMetadata[param.productTypeId].push(Metadata(param.ipfsMetadata, block.timestamp));
      }

      emit ProductTypeSet(param.productTypeId);
    }
  }

  function setProductsMetadata(
    uint[] calldata productIds,
    string[] calldata ipfsMetadata
  ) external onlyAdvisoryBoard {

    if (productIds.length != ipfsMetadata.length) {
      revert MismatchedArrayLengths();
    }

    uint productCount = _products.length;

    for (uint i = 0; i < productIds.length; i++) {
      uint productId = productIds[i];

      if (productId >= productCount) {
        revert ProductNotFound();
      }

      productMetadata[productId].push(Metadata(ipfsMetadata[i], block.timestamp));
    }
  }

  function setProductTypesMetadata(
    uint[] calldata productTypeIds,
    string[] calldata ipfsMetadata
  ) external onlyAdvisoryBoard {

    if (productTypeIds.length != ipfsMetadata.length) {
      revert MismatchedArrayLengths();
    }

    uint productTypeCount = _productTypes.length;

    for (uint i = 0; i < productTypeIds.length; i++) {
      uint productTypeId = productTypeIds[i];

      if (productTypeId >= productTypeCount) {
        revert ProductTypeNotFound();
      }

      if (bytes(ipfsMetadata[i]).length == 0) {
        revert MetadataRequired();
      }

      productTypeMetadata[productTypeId].push(Metadata(ipfsMetadata[i], block.timestamp));
    }
  }

  /* ========== COVER ASSETS HELPERS ========== */

  // Returns true if the product exists and the pool is authorized to have the product
  function isPoolAllowed(uint productId, uint poolId) public view returns (bool) {

    uint poolCount = allowedPools[productId].length;

    // If no pools are specified, every pool is allowed
    if (poolCount == 0) {
      return true;
    }

    for (uint i = 0; i < poolCount; i++) {
      if (allowedPools[productId][i] == poolId) {
        return true;
      }
    }

    // Product has allow list and pool is not in it
    return false;
  }

  function requirePoolIsAllowed(uint[] calldata productIds, uint poolId) external view {
    for (uint i = 0; i < productIds.length; i++) {
      if (!isPoolAllowed(productIds[i], poolId) ) {
        revert PoolNotAllowedForThisProduct(productIds[i]);
      }
    }
  }

  /* ========== DEPENDENCIES ========== */

  function migrateCoverProducts() external {
    require(_products.length == 0, "CoverProducts: _products already migrated");
    require(_productTypes.length == 0, "CoverProducts: _productTypes already migrated");

    ILegacyCover _cover = ILegacyCover(address(cover()));
    IStakingPoolFactory _stakingPoolFactory = IStakingPoolFactory(_cover.stakingPoolFactory());

    Product[] memory _productsToMigrate = _cover.getProducts();
    uint _productTypeCount = _cover.productTypesCount();
    uint stakingPoolCount = _stakingPoolFactory.stakingPoolCount();

    for (uint i = 0; i < _productsToMigrate.length; i++) {
      _products.push(_productsToMigrate[i]);
      productNames[i] = _cover.productNames(i);
      uint[] storage _allowedPools = allowedPools[i];

      if (!_productsToMigrate[i].useFixedPrice || _productsToMigrate[i].isDeprecated) {
        continue;
      }

      for (uint j = 0; j < stakingPoolCount; j++) {
        try _cover.allowedPools(i, j) returns (uint poolId) {
          _allowedPools.push(poolId);
        } catch {
          break;
        }
      }
    }

    for (uint i = 0; i < _productTypeCount; i++) {
      ProductType memory _productTypeToMigrate = _cover.productTypes(i);
      _productTypes.push(_productTypeToMigrate);
      productTypeNames[i] = _cover.productTypeNames(i);
    }
  }

  /* ========== DEPENDENCIES ========== */

  function pool() internal view returns (IPool) {
    return IPool(internalContracts[uint(ID.P1)]);
  }

  function cover() internal view returns (ICover) {
    return ICover(internalContracts[uint(ID.CO)]);
  }

  function stakingProducts() internal view returns (IStakingProducts) {
    return IStakingProducts(internalContracts[uint(ID.SP)]);
  }

  function changeDependentContractAddress() public {
    internalContracts[uint(ID.P1)] = master.getLatestAddress("P1");
    internalContracts[uint(ID.CO)] = master.getLatestAddress("CO");
    internalContracts[uint(ID.MR)] = master.getLatestAddress("MR");
    internalContracts[uint(ID.SP)] = master.getLatestAddress("SP");
  }

}

File 2 of 24 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

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

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

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

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

File 3 of 24 : draft-IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)

pragma solidity ^0.8.0;

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

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

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

File 4 of 24 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

File 5 of 24 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

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

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

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

    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

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

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

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

    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

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

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

File 6 of 24 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes calldata data
    ) external;

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

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

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

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

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

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

File 7 of 24 : Address.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 Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [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 Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

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

        (bool success, bytes memory returndata) = target.delegatecall(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 8 of 24 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

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

File 9 of 24 : MasterAwareV2.sol
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity ^0.8.18;

import "../interfaces/INXMMaster.sol";
import "../interfaces/IMasterAwareV2.sol";
import "../interfaces/IMemberRoles.sol";

abstract contract MasterAwareV2 is IMasterAwareV2 {

  INXMMaster public master;

  mapping(uint => address payable) public internalContracts;

  modifier onlyMember {
    require(
      IMemberRoles(internalContracts[uint(ID.MR)]).checkRole(
        msg.sender,
        uint(IMemberRoles.Role.Member)
      ),
      "Caller is not a member"
    );
    _;
  }

  modifier onlyAdvisoryBoard {
    require(
      IMemberRoles(internalContracts[uint(ID.MR)]).checkRole(
        msg.sender,
        uint(IMemberRoles.Role.AdvisoryBoard)
      ),
      "Caller is not an advisory board member"
    );
    _;
  }

  modifier onlyInternal {
    require(master.isInternal(msg.sender), "Caller is not an internal contract");
    _;
  }

  modifier onlyMaster {
    if (address(master) != address(0)) {
      require(address(master) == msg.sender, "Not master");
    }
    _;
  }

  modifier onlyGovernance {
    require(
      master.checkIsAuthToGoverned(msg.sender),
      "Caller is not authorized to govern"
    );
    _;
  }

  modifier onlyEmergencyAdmin {
    require(
      msg.sender == master.emergencyAdmin(),
      "Caller is not emergency admin"
    );
    _;
  }

  modifier whenPaused {
    require(master.isPause(), "System is not paused");
    _;
  }

  modifier whenNotPaused {
    require(!master.isPause(), "System is paused");
    _;
  }

  function getInternalContractAddress(ID id) internal view returns (address payable) {
    return internalContracts[uint(id)];
  }

  function changeMasterAddress(address masterAddress) public onlyMaster {
    master = INXMMaster(masterAddress);
  }

}

File 10 of 24 : Multicall.sol
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity ^0.8.18;

abstract contract Multicall {

  error RevertedWithoutReason(uint index);

  // WARNING: Do not set this function as payable
  function multicall(bytes[] calldata data) external returns (bytes[] memory results) {

    uint callCount = data.length;
    results = new bytes[](callCount);

    for (uint i = 0; i < callCount; i++) {
      (bool ok, bytes memory result) = address(this).delegatecall(data[i]);

      if (!ok) {

        uint length = result.length;

        // 0 length returned from empty revert() / require(false)
        if (length == 0) {
          revert RevertedWithoutReason(i);
        }

        assembly {
          revert(add(result, 0x20), length)
        }
      }

      results[i] = result;
    }
  }
}

File 11 of 24 : ICompleteStakingPoolFactory.sol
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity >=0.5.0;

import "./IStakingPoolFactory.sol";

/**
 * @dev IStakingPoolFactory is missing the changeOperator() and operator() functions.
 * @dev Any change to the original interface will affect staking pool addresses
 * @dev This interface is created to add the missing functions so it can be used in other contracts.
 */
interface ICompleteStakingPoolFactory is IStakingPoolFactory {

  function operator() external view returns (address);

  function changeOperator(address newOperator) external;
}

File 12 of 24 : ICover.sol
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity >=0.5.0;

import "./ICoverNFT.sol";
import "./IStakingNFT.sol";
import "./IStakingPool.sol";
import "./ICompleteStakingPoolFactory.sol";

/* io structs */

enum ClaimMethod {
  IndividualClaims,
  YieldTokenIncidents
}

struct PoolAllocationRequest {
  uint40 poolId;
  bool skip;
  uint coverAmountInAsset;
}

struct BuyCoverParams {
  uint coverId;
  address owner;
  uint24 productId;
  uint8 coverAsset;
  uint96 amount;
  uint32 period;
  uint maxPremiumInAsset;
  uint8 paymentAsset;
  uint16 commissionRatio;
  address commissionDestination;
  string ipfsData;
}

/* storage structs */

struct PoolAllocation {
  uint40 poolId;
  uint96 coverAmountInNXM;
  uint96 premiumInNXM;
  uint24 allocationId;
}

struct CoverData {
  uint24 productId;
  uint8 coverAsset;
  uint96 amountPaidOut;
}

struct CoverSegment {
  uint96 amount;
  uint32 start;
  uint32 period; // seconds
  uint32 gracePeriod; // seconds
  uint24 globalRewardsRatio;
  uint24 globalCapacityRatio;
}

interface ICover {

  /* ========== DATA STRUCTURES ========== */

  /* internal structs */

  struct RequestAllocationVariables {
    uint previousPoolAllocationsLength;
    uint previousPremiumInNXM;
    uint refund;
    uint coverAmountInNXM;
  }

  /* storage structs */

  struct ActiveCover {
    // Global active cover amount per asset.
    uint192 totalActiveCoverInAsset;
    // The last time activeCoverExpirationBuckets was updated
    uint64 lastBucketUpdateId;
  }

  /* ========== VIEWS ========== */

  function coverData(uint coverId) external view returns (CoverData memory);

  function coverDataCount() external view returns (uint);

  function coverSegmentsCount(uint coverId) external view returns (uint);

  function coverSegments(uint coverId) external view returns (CoverSegment[] memory);

  function coverSegmentWithRemainingAmount(
    uint coverId,
    uint segmentId
  ) external view returns (CoverSegment memory);

  function recalculateActiveCoverInAsset(uint coverAsset) external;

  function totalActiveCoverInAsset(uint coverAsset) external view returns (uint);

  function getGlobalCapacityRatio() external view returns (uint);

  function getGlobalRewardsRatio() external view returns (uint);

  function getDefaultMinPriceRatio() external pure returns (uint);

  function getGlobalCapacityAndPriceRatios() external view returns (
    uint _globalCapacityRatio,
    uint _defaultMinPriceRatio
  );

  function DEFAULT_MIN_PRICE_RATIO() external view returns (uint);

  /* === MUTATIVE FUNCTIONS ==== */

  function buyCover(
    BuyCoverParams calldata params,
    PoolAllocationRequest[] calldata coverChunkRequests
  ) external payable returns (uint coverId);

  function burnStake(
    uint coverId,
    uint segmentId,
    uint amount
  ) external returns (address coverOwner);

  function coverNFT() external returns (ICoverNFT);

  function stakingNFT() external returns (IStakingNFT);

  function stakingPoolFactory() external returns (ICompleteStakingPoolFactory);

  /* ========== EVENTS ========== */

  event CoverEdited(uint indexed coverId, uint indexed productId, uint indexed segmentId, address buyer, string ipfsMetadata);

  // Auth
  error OnlyOwnerOrApproved();

  // Cover details
  error CoverPeriodTooShort();
  error CoverPeriodTooLong();
  error CoverOutsideOfTheGracePeriod();
  error CoverAmountIsZero();

  // Products
  error ProductNotFound();
  error ProductDeprecated();
  error UnexpectedProductId();

  // Cover and payment assets
  error CoverAssetNotSupported();
  error InvalidPaymentAsset();
  error UnexpectedCoverAsset();
  error UnexpectedEthSent();
  error EditNotSupported();

  // Price & Commission
  error PriceExceedsMaxPremiumInAsset();
  error CommissionRateTooHigh();

  // ETH transfers
  error InsufficientEthSent();
  error SendingEthToPoolFailed();
  error SendingEthToCommissionDestinationFailed();
  error ReturningEthRemainderToSenderFailed();

  // Misc
  error ExpiredCoversCannotBeEdited();
  error CoverNotYetExpired(uint coverId);
  error InsufficientCoverAmountAllocated();
  error UnexpectedPoolId();

  // TODO: remove me after the rewards update
  error OnlySwapOperator();
}

File 13 of 24 : ICoverNFT.sol
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity >=0.5.0;

import "@openzeppelin/contracts-v4/token/ERC721/IERC721.sol";

interface ICoverNFT is IERC721 {

  function isApprovedOrOwner(address spender, uint tokenId) external returns (bool);

  function mint(address to) external returns (uint tokenId);

  function changeOperator(address newOperator) external;

  function changeNFTDescriptor(address newNFTDescriptor) external;

  function totalSupply() external view returns (uint);

  function name() external view returns (string memory);

  error NotOperator();
  error NotMinted();
  error WrongFrom();
  error InvalidRecipient();
  error InvalidNewOperatorAddress();
  error InvalidNewNFTDescriptorAddress();
  error NotAuthorized();
  error UnsafeRecipient();
  error AlreadyMinted();

}

File 14 of 24 : ICoverProducts.sol
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity >=0.5.0;

import "./ICover.sol";

/* io structs */

struct ProductInitializationParams {
  uint productId;
  uint8 weight;
  uint96 initialPrice;
  uint96 targetPrice;
}

/* storage structs */

struct Product {
  uint16 productType;
  uint16 minPrice;
  // leftover memory gap from the previously used address field yieldTokenAddress
  uint144 __gap;
  // cover assets bitmap. each bit represents whether the asset with
  // the index of that bit is enabled as a cover asset for this product
  uint32 coverAssets;
  uint16 initialPriceRatio;
  uint16 capacityReductionRatio;
  bool isDeprecated;
  bool useFixedPrice;
}

struct ProductType {
  uint8 claimMethod;
  uint32 gracePeriod;
}

interface ICoverProducts {

  /* storage structs */

  struct Metadata {
    string ipfsHash;
    uint timestamp;
  }

  /* io structs */

  struct ProductParam {
    string productName;
    uint productId;
    string ipfsMetadata;
    Product product;
    uint[] allowedPools;
  }

  struct ProductTypeParam {
    string productTypeName;
    uint productTypeId;
    string ipfsMetadata;
    ProductType productType;
  }

  /* ========== VIEWS ========== */

  function getProductType(uint productTypeId) external view returns (ProductType memory);

  function getProductTypeName(uint productTypeId) external view returns (string memory);

  function getProductTypeCount() external view returns (uint);

  function getProductTypes() external view returns (ProductType[] memory);

  function getProduct(uint productId) external view returns (Product memory);

  function getProductName(uint productTypeId) external view returns (string memory);

  function getProductCount() external view returns (uint);

  function getProducts() external view returns (Product[] memory);

  // add grace period function?
  function getProductWithType(uint productId) external view returns (Product memory, ProductType memory);

  function getLatestProductMetadata(uint productId) external view returns (Metadata memory);

  function getLatestProductTypeMetadata(uint productTypeId) external view returns (Metadata memory);

  function getProductMetadata(uint productId) external view returns (Metadata[] memory);

  function getProductTypeMetadata(uint productTypeId) external view returns (Metadata[] memory);

  function getAllowedPools(uint productId) external view returns (uint[] memory _allowedPools);

  function getAllowedPoolsCount(uint productId) external view returns (uint);

  function isPoolAllowed(uint productId, uint poolId) external view returns (bool);

  function requirePoolIsAllowed(uint[] calldata productIds, uint poolId) external view;

  function getCapacityReductionRatios(uint[] calldata productIds) external view returns (uint[] memory);

  function getInitialPrices(uint[] calldata productIds) external view returns (uint[] memory);

  function getMinPrices(uint[] calldata productIds) external view returns (uint[] memory);

  function prepareStakingProductsParams(
    ProductInitializationParams[] calldata params
  ) external returns (
    ProductInitializationParams[] memory validatedParams
  );

  /* === MUTATIVE FUNCTIONS ==== */

  function setProductTypes(ProductTypeParam[] calldata productTypes) external;

  function setProducts(ProductParam[] calldata params) external;

  /* ========== EVENTS ========== */

  event ProductSet(uint id);
  event ProductTypeSet(uint id);

  // Products and product types
  error ProductNotFound();
  error ProductTypeNotFound();
  error ProductDeprecated();
  error PoolNotAllowedForThisProduct(uint productId);
  error StakingPoolDoesNotExist();
  error MismatchedArrayLengths();
  error MetadataRequired();

  // Misc
  error UnsupportedCoverAssets();
  error InitialPriceRatioBelowMinPriceRatio();
  error InitialPriceRatioAbove100Percent();
  error CapacityReductionRatioAbove100Percent();

}

File 15 of 24 : ILegacyCover.sol
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity >=0.5.0;

import "./ICoverProducts.sol";

interface ILegacyCover {

  function stakingPoolFactory() external view returns (address);

  function getProducts() external view returns (Product[] memory);

  function productTypesCount() external view returns (uint);

  function productNames(uint productId) external view returns (string memory);

  function allowedPools(uint productId, uint index) external view returns (uint);

  function productTypes(uint id) external view returns (ProductType memory);

  function productTypeNames(uint id) external view returns (string memory);

}

File 16 of 24 : IMasterAwareV2.sol
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity >=0.5.0;

interface IMasterAwareV2 {

  // TODO: if you update this enum, update lib/constants.js as well
  enum ID {
    TC, // TokenController.sol
    P1, // Pool.sol
    MR, // MemberRoles.sol
    MC, // MCR.sol
    CO, // Cover.sol
    SP, // StakingProducts.sol
    PS, // LegacyPooledStaking.sol
    GV, // Governance.sol
    UNUSED_GW, // LegacyGateway.sol - removed
    UNUSED_CL, // CoverMigrator.sol - removed
    AS, // Assessment.sol
    CI, // IndividualClaims.sol - Claims for Individuals
    UNUSED_CG, // YieldTokenIncidents.sol - Claims for Groups -- removed
    RA, // Ramm.sol
    ST,  // SafeTracker.sol
    CP  // CoverProducts.sol
  }

  function changeMasterAddress(address masterAddress) external;

  function changeDependentContractAddress() external;

  function internalContracts(uint) external view returns (address payable);
}

File 17 of 24 : IMemberRoles.sol
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity >=0.5.0;

interface IMemberRoles {

  enum Role {Unassigned, AdvisoryBoard, Member, Owner}

  function join(address _userAddress, uint nonce, bytes calldata signature) external payable;

  function switchMembership(address _newAddress) external;

  function switchMembershipAndAssets(
    address newAddress,
    uint[] calldata coverIds,
    uint[] calldata stakingTokenIds
  ) external;

  function switchMembershipOf(address member, address _newAddress) external;

  function totalRoles() external view returns (uint256);

  function changeAuthorized(uint _roleId, address _newAuthorized) external;

  function setKycAuthAddress(address _add) external;

  function members(uint _memberRoleId) external view returns (uint, address[] memory memberArray);

  function numberOfMembers(uint _memberRoleId) external view returns (uint);

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

  function roles(address _memberAddress) external view returns (uint[] memory);

  function checkRole(address _memberAddress, uint _roleId) external view returns (bool);

  function getMemberLengthForAllRoles() external view returns (uint[] memory totalMembers);

  function memberAtIndex(uint _memberRoleId, uint index) external view returns (address, bool);

  function membersLength(uint _memberRoleId) external view returns (uint);

  event MemberRole(uint256 indexed roleId, bytes32 roleName, string roleDescription);

  event MemberJoined(address indexed newMember, uint indexed nonce);

  event switchedMembership(address indexed previousMember, address indexed newMember, uint timeStamp);
  
  event MembershipWithdrawn(address indexed member, uint timestamp);
}

File 18 of 24 : INXMMaster.sol
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity >=0.5.0;

interface INXMMaster {

  function tokenAddress() external view returns (address);

  function owner() external view returns (address);

  function emergencyAdmin() external view returns (address);

  function masterInitialized() external view returns (bool);

  function isInternal(address _add) external view returns (bool);

  function isPause() external view returns (bool check);

  function isMember(address _add) external view returns (bool);

  function checkIsAuthToGoverned(address _add) external view returns (bool);

  function getLatestAddress(bytes2 _contractName) external view returns (address payable contractAddress);

  function contractAddresses(bytes2 code) external view returns (address payable);

  function upgradeMultipleContracts(
    bytes2[] calldata _contractCodes,
    address payable[] calldata newAddresses
  ) external;

  function removeContracts(bytes2[] calldata contractCodesToRemove) external;

  function addNewInternalContracts(
    bytes2[] calldata _contractCodes,
    address payable[] calldata newAddresses,
    uint[] calldata _types
  ) external;

  function updateOwnerParameters(bytes8 code, address payable val) external;
}

File 19 of 24 : IPool.sol
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity >=0.5.0;

import "./IPriceFeedOracle.sol";

struct SwapDetails {
  uint104 minAmount;
  uint104 maxAmount;
  uint32 lastSwapTime;
  // 2 decimals of precision. 0.01% -> 0.0001 -> 1e14
  uint16 maxSlippageRatio;
}

struct Asset {
  address assetAddress;
  bool isCoverAsset;
  bool isAbandoned;
}

interface IPool {

  error RevertedWithoutReason(uint index);
  error AssetNotFound();
  error UnknownParameter();
  error OrderInProgress();

  function swapOperator() external view returns (address);

  function getAsset(uint assetId) external view returns (Asset memory);

  function getAssets() external view returns (Asset[] memory);

  function transferAssetToSwapOperator(address asset, uint amount) external;

  function setSwapDetailsLastSwapTime(address asset, uint32 lastSwapTime) external;

  function getAssetSwapDetails(address assetAddress) external view returns (SwapDetails memory);

  function sendPayout(uint assetIndex, address payable payoutAddress, uint amount, uint ethDepositAmount) external;

  function sendEth(address payoutAddress, uint amount) external;

  function upgradeCapitalPool(address payable newPoolAddress) external;

  function priceFeedOracle() external view returns (IPriceFeedOracle);

  function getPoolValueInEth() external view returns (uint);

  function calculateMCRRatio(uint totalAssetValue, uint mcrEth) external pure returns (uint);

  function getInternalTokenPriceInAsset(uint assetId) external view returns (uint tokenPrice);

  function getInternalTokenPriceInAssetAndUpdateTwap(uint assetId) external returns (uint tokenPrice);

  function getTokenPrice() external view returns (uint tokenPrice);

  function getMCRRatio() external view returns (uint);

  function setSwapAssetAmount(address assetAddress, uint value) external;
}

File 20 of 24 : IPriceFeedOracle.sol
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity >=0.5.0;

interface Aggregator {
  function decimals() external view returns (uint8);
  function latestAnswer() external view returns (int);
}

interface IPriceFeedOracle {

  enum AggregatorType { ETH, USD }

  struct AssetInfo {
    Aggregator aggregator;
    AggregatorType aggregatorType;
    uint8 decimals;
  }

  function ETH() external view returns (address);
  function assets(address) external view returns (Aggregator, uint8);
  function assetsMap(address) external view returns (Aggregator, AggregatorType, uint8);

  function getAssetToEthRate(address asset) external view returns (uint);
  function getAssetForEth(address asset, uint ethIn) external view returns (uint);
  function getEthForAsset(address asset, uint amount) external view returns (uint);

  /* ========== ERRORS ========== */

  error EmptyAssetAddresses();
  error ArgumentLengthMismatch(uint assetAddressesLength, uint aggregatorsLength, uint typesLength, uint decimalsLength);
  error ZeroAddress(string parameter);
  error ZeroDecimals(address asset);
  error IncompatibleAggregatorDecimals(address aggregator, uint8 aggregatorDecimals, uint8 expectedDecimals);
  error UnknownAggregatorType(uint8 aggregatorType);
  error EthUsdAggregatorNotSet();
  error InvalidEthAggregatorType(AggregatorType actual, AggregatorType expected);
  error UnknownAsset(address asset);
  error NonPositiveRate(address aggregator, int rate);
}

File 21 of 24 : IStakingNFT.sol
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity >=0.5.0;

import "@openzeppelin/contracts-v4/token/ERC721/IERC721.sol";

interface IStakingNFT is IERC721 {

  function isApprovedOrOwner(address spender, uint tokenId) external returns (bool);

  function mint(uint poolId, address to) external returns (uint tokenId);

  function changeOperator(address newOperator) external;

  function changeNFTDescriptor(address newNFTDescriptor) external;

  function totalSupply() external returns (uint);

  function tokenInfo(uint tokenId) external view returns (uint poolId, address owner);

  function stakingPoolOf(uint tokenId) external view returns (uint poolId);

  function stakingPoolFactory() external view returns (address);

  function name() external view returns (string memory);

  error NotOperator();
  error NotMinted();
  error WrongFrom();
  error InvalidRecipient();
  error InvalidNewOperatorAddress();
  error InvalidNewNFTDescriptorAddress();
  error NotAuthorized();
  error UnsafeRecipient();
  error AlreadyMinted();
  error NotStakingPool();

}

File 22 of 24 : IStakingPool.sol
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity >=0.5.0;

/* structs for io */

struct AllocationRequest {
  uint productId;
  uint coverId;
  uint allocationId;
  uint period;
  uint gracePeriod;
  bool useFixedPrice;
  uint previousStart;
  uint previousExpiration;
  uint previousRewardsRatio;
  uint globalCapacityRatio;
  uint capacityReductionRatio;
  uint rewardRatio;
  uint productMinPrice;
}

struct BurnStakeParams {
  uint allocationId;
  uint productId;
  uint start;
  uint period;
  uint deallocationAmount;
}

interface IStakingPool {

  /* structs for storage */

  // stakers are grouped in tranches based on the timelock expiration
  // tranche index is calculated based on the expiration date
  // the initial proposal is to have 4 tranches per year (1 tranche per quarter)
  struct Tranche {
    uint128 stakeShares;
    uint128 rewardsShares;
  }

  struct ExpiredTranche {
    uint96 accNxmPerRewardShareAtExpiry;
    uint96 stakeAmountAtExpiry; // nxm total supply is 6.7e24 and uint96.max is 7.9e28
    uint128 stakeSharesSupplyAtExpiry;
  }

  struct Deposit {
    uint96 lastAccNxmPerRewardShare;
    uint96 pendingRewards;
    uint128 stakeShares;
    uint128 rewardsShares;
  }

  struct WithdrawTrancheContext {
    uint _firstActiveTrancheId;
    uint _accNxmPerRewardsShare;
    uint managerLockedInGovernanceUntil;
    bool withdrawStake;
    bool withdrawRewards;
    address destination;
}

  function initialize(
    bool isPrivatePool,
    uint initialPoolFee,
    uint maxPoolFee,
    uint _poolId
  ) external;

  function processExpirations(bool updateUntilCurrentTimestamp) external;

  function requestAllocation(
    uint amount,
    uint previousPremium,
    AllocationRequest calldata request
  ) external returns (uint premium, uint allocationId);

  function burnStake(uint amount, BurnStakeParams calldata params) external;

  function depositTo(
    uint amount,
    uint trancheId,
    uint requestTokenId,
    address destination
  ) external returns (uint tokenId);

  function withdraw(
    uint tokenId,
    bool withdrawStake,
    bool withdrawRewards,
    uint[] memory trancheIds
  ) external returns (uint withdrawnStake, uint withdrawnRewards);

  function isPrivatePool() external view returns (bool);

  function isHalted() external view returns (bool);

  function manager() external view returns (address);

  function getPoolId() external view returns (uint);

  function getPoolFee() external view returns (uint);

  function getMaxPoolFee() external view returns (uint);

  function getActiveStake() external view returns (uint);

  function getStakeSharesSupply() external view returns (uint);

  function getRewardsSharesSupply() external view returns (uint);

  function getRewardPerSecond() external view returns (uint);

  function getAccNxmPerRewardsShare() external view returns (uint);

  function getLastAccNxmUpdate() external view returns (uint);

  function getFirstActiveTrancheId() external view returns (uint);

  function getFirstActiveBucketId() external view returns (uint);

  function getNextAllocationId() external view returns (uint);

  function getDeposit(uint tokenId, uint trancheId) external view returns (
    uint lastAccNxmPerRewardShare,
    uint pendingRewards,
    uint stakeShares,
    uint rewardsShares
  );

  function getTranche(uint trancheId) external view returns (
    uint stakeShares,
    uint rewardsShares
  );

  function getExpiredTranche(uint trancheId) external view returns (
    uint accNxmPerRewardShareAtExpiry,
    uint stakeAmountAtExpiry,
    uint stakeShareSupplyAtExpiry
  );

  function setPoolFee(uint newFee) external;

  function setPoolPrivacy(bool isPrivatePool) external;

  function getActiveAllocations(
    uint productId
  ) external view returns (uint[] memory trancheAllocations);

  function getTrancheCapacities(
    uint productId,
    uint firstTrancheId,
    uint trancheCount,
    uint capacityRatio,
    uint reductionRatio
  ) external view returns (uint[] memory trancheCapacities);

  /* ========== EVENTS ========== */

  event StakeDeposited(address indexed user, uint256 amount, uint256 trancheId, uint256 tokenId);

  event DepositExtended(address indexed user, uint256 tokenId, uint256 initialTrancheId, uint256 newTrancheId, uint256 topUpAmount);

  event PoolPrivacyChanged(address indexed manager, bool isPrivate);

  event PoolFeeChanged(address indexed manager, uint newFee);

  event Withdraw(address indexed user, uint indexed tokenId, uint tranche, uint amountStakeWithdrawn, uint amountRewardsWithdrawn);

  event StakeBurned(uint amount);

  event Deallocated(uint productId);

  event BucketExpired(uint bucketId);

  event TrancheExpired(uint trancheId);

  // Auth
  error OnlyCoverContract();
  error OnlyStakingProductsContract();
  error OnlyManager();
  error PrivatePool();
  error SystemPaused();
  error PoolHalted();

  // Fees
  error PoolFeeExceedsMax();
  error MaxPoolFeeAbove100();

  // Voting
  error NxmIsLockedForGovernanceVote();
  error ManagerNxmIsLockedForGovernanceVote();

  // Deposit
  error InsufficientDepositAmount();
  error RewardRatioTooHigh();

  // Staking NFTs
  error InvalidTokenId();
  error NotTokenOwnerOrApproved();
  error InvalidStakingPoolForToken();

  // Tranche & capacity
  error NewTrancheEndsBeforeInitialTranche();
  error RequestedTrancheIsNotYetActive();
  error RequestedTrancheIsExpired();
  error InsufficientCapacity();

  // Allocation
  error AlreadyDeallocated(uint allocationId);
}

File 23 of 24 : IStakingPoolFactory.sol
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity >=0.5.0;

interface IStakingPoolFactory {

  function stakingPoolCount() external view returns (uint);

  function beacon() external view returns (address);

  function create(address beacon) external returns (uint poolId, address stakingPoolAddress);

  event StakingPoolCreated(uint indexed poolId, address indexed stakingPoolAddress);
}

File 24 of 24 : IStakingProducts.sol
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity >=0.5.0;

import "./ICoverProducts.sol";
import "./IStakingPool.sol";

interface IStakingProducts {

  struct StakedProductParam {
    uint productId;
    bool recalculateEffectiveWeight;
    bool setTargetWeight;
    uint8 targetWeight;
    bool setTargetPrice;
    uint96 targetPrice;
  }

  struct Weights {
    uint32 totalEffectiveWeight;
    uint32 totalTargetWeight;
  }

  struct StakedProduct {
    uint16 lastEffectiveWeight;
    uint8 targetWeight;
    uint96 targetPrice;
    uint96 bumpedPrice;
    uint32 bumpedPriceUpdateTime;
  }

  /* ============= PRODUCT FUNCTIONS ============= */

  function setProducts(uint poolId, StakedProductParam[] memory params) external;

  function getProductTargetWeight(uint poolId, uint productId) external view returns (uint);

  function getTotalTargetWeight(uint poolId) external view returns (uint);

  function getTotalEffectiveWeight(uint poolId) external view returns (uint);

  function getProduct(uint poolId, uint productId) external view returns (
    uint lastEffectiveWeight,
    uint targetWeight,
    uint targetPrice,
    uint bumpedPrice,
    uint bumpedPriceUpdateTime
  );

  function getPoolManager(uint poolId) external view returns (address);

  /* ============= PRICING FUNCTIONS ============= */

  function getPremium(
    uint poolId,
    uint productId,
    uint period,
    uint coverAmount,
    uint totalCapacity,
    uint productMinPrice,
    bool useFixedPrice,
    uint nxmPerAllocationUnit
  ) external returns (uint premium);

  function calculateFixedPricePremium(
    uint coverAmount,
    uint period,
    uint fixedPrice,
    uint nxmPerAllocationUnit,
    uint targetPriceDenominator
  ) external pure returns (uint);


  function calculatePremium(
    StakedProduct memory product,
    uint period,
    uint coverAmount,
    uint totalCapacity,
    uint targetPrice,
    uint currentBlockTimestamp,
    uint nxmPerAllocationUnit,
    uint targetPriceDenominator
  ) external pure returns (uint premium, StakedProduct memory);

  /* ========== STAKING POOL CREATION ========== */

  function stakingPool(uint poolId) external view returns (IStakingPool);

  function getStakingPoolCount() external view returns (uint);

  function createStakingPool(
    bool isPrivatePool,
    uint initialPoolFee,
    uint maxPoolFee,
    ProductInitializationParams[] calldata productInitParams,
    string calldata ipfsDescriptionHash
  ) external returns (uint poolId, address stakingPoolAddress);

  function changeStakingPoolFactoryOperator(address newOperator) external;

  function setPoolMetadata(uint poolId, string memory ipfsHash) external;

  function getPoolMetadata(uint poolId) external view returns (string memory ipfsHash);

  function setInitialMetadata(string[] calldata ipfsHashes) external;

  /* ============= EVENTS ============= */

  event ProductUpdated(uint productId, uint8 targetWeight, uint96 targetPrice);

  /* ============= ERRORS ============= */

  // Auth
  error OnlyStakingPool();
  error OnlyCoverContract();
  error OnlyManager();

  // Products & weights
  error MustSetPriceForNewProducts();
  error MustSetWeightForNewProducts();
  error TargetPriceTooHigh();
  error TargetPriceBelowMin();
  error TargetWeightTooHigh();
  error MustRecalculateEffectiveWeight();
  error TotalTargetWeightExceeded();
  error TotalEffectiveWeightExceeded();

  // Staking Pool creation
  error ProductDoesntExistOrIsDeprecated();
  error InvalidProductType();
  error TargetPriceBelowMinPriceRatio();

  // IPFS
  error IpfsHashRequired();
}

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

Contract Security Audit

Contract ABI

[{"inputs":[],"name":"CapacityReductionRatioAbove100Percent","type":"error"},{"inputs":[],"name":"InitialPriceRatioAbove100Percent","type":"error"},{"inputs":[],"name":"InitialPriceRatioBelowMinPriceRatio","type":"error"},{"inputs":[],"name":"MetadataRequired","type":"error"},{"inputs":[],"name":"MismatchedArrayLengths","type":"error"},{"inputs":[{"internalType":"uint256","name":"productId","type":"uint256"}],"name":"PoolNotAllowedForThisProduct","type":"error"},{"inputs":[],"name":"ProductDeprecated","type":"error"},{"inputs":[],"name":"ProductNotFound","type":"error"},{"inputs":[],"name":"ProductTypeNotFound","type":"error"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"RevertedWithoutReason","type":"error"},{"inputs":[],"name":"StakingPoolDoesNotExist","type":"error"},{"inputs":[],"name":"UnsupportedCoverAssets","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"}],"name":"ProductSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"}],"name":"ProductTypeSet","type":"event"},{"inputs":[],"name":"changeDependentContractAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"masterAddress","type":"address"}],"name":"changeMasterAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"productId","type":"uint256"}],"name":"getAllowedPools","outputs":[{"internalType":"uint256[]","name":"_allowedPools","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"productId","type":"uint256"}],"name":"getAllowedPoolsCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"productIds","type":"uint256[]"}],"name":"getCapacityReductionRatios","outputs":[{"internalType":"uint256[]","name":"capacityReductionRatios","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"productIds","type":"uint256[]"}],"name":"getInitialPrices","outputs":[{"internalType":"uint256[]","name":"initialPrices","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"productId","type":"uint256"}],"name":"getLatestProductMetadata","outputs":[{"components":[{"internalType":"string","name":"ipfsHash","type":"string"},{"internalType":"uint256","name":"timestamp","type":"uint256"}],"internalType":"struct ICoverProducts.Metadata","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"productTypeId","type":"uint256"}],"name":"getLatestProductTypeMetadata","outputs":[{"components":[{"internalType":"string","name":"ipfsHash","type":"string"},{"internalType":"uint256","name":"timestamp","type":"uint256"}],"internalType":"struct ICoverProducts.Metadata","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"productIds","type":"uint256[]"}],"name":"getMinPrices","outputs":[{"internalType":"uint256[]","name":"minPrices","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"productId","type":"uint256"}],"name":"getProduct","outputs":[{"components":[{"internalType":"uint16","name":"productType","type":"uint16"},{"internalType":"uint16","name":"minPrice","type":"uint16"},{"internalType":"uint144","name":"__gap","type":"uint144"},{"internalType":"uint32","name":"coverAssets","type":"uint32"},{"internalType":"uint16","name":"initialPriceRatio","type":"uint16"},{"internalType":"uint16","name":"capacityReductionRatio","type":"uint16"},{"internalType":"bool","name":"isDeprecated","type":"bool"},{"internalType":"bool","name":"useFixedPrice","type":"bool"}],"internalType":"struct Product","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getProductCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"productId","type":"uint256"}],"name":"getProductMetadata","outputs":[{"components":[{"internalType":"string","name":"ipfsHash","type":"string"},{"internalType":"uint256","name":"timestamp","type":"uint256"}],"internalType":"struct ICoverProducts.Metadata[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"productId","type":"uint256"}],"name":"getProductName","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"productTypeId","type":"uint256"}],"name":"getProductType","outputs":[{"components":[{"internalType":"uint8","name":"claimMethod","type":"uint8"},{"internalType":"uint32","name":"gracePeriod","type":"uint32"}],"internalType":"struct ProductType","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getProductTypeCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"productTypeId","type":"uint256"}],"name":"getProductTypeMetadata","outputs":[{"components":[{"internalType":"string","name":"ipfsHash","type":"string"},{"internalType":"uint256","name":"timestamp","type":"uint256"}],"internalType":"struct ICoverProducts.Metadata[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"productTypeId","type":"uint256"}],"name":"getProductTypeName","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getProductTypes","outputs":[{"components":[{"internalType":"uint8","name":"claimMethod","type":"uint8"},{"internalType":"uint32","name":"gracePeriod","type":"uint32"}],"internalType":"struct ProductType[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"productId","type":"uint256"}],"name":"getProductWithType","outputs":[{"components":[{"internalType":"uint16","name":"productType","type":"uint16"},{"internalType":"uint16","name":"minPrice","type":"uint16"},{"internalType":"uint144","name":"__gap","type":"uint144"},{"internalType":"uint32","name":"coverAssets","type":"uint32"},{"internalType":"uint16","name":"initialPriceRatio","type":"uint16"},{"internalType":"uint16","name":"capacityReductionRatio","type":"uint16"},{"internalType":"bool","name":"isDeprecated","type":"bool"},{"internalType":"bool","name":"useFixedPrice","type":"bool"}],"internalType":"struct Product","name":"product","type":"tuple"},{"components":[{"internalType":"uint8","name":"claimMethod","type":"uint8"},{"internalType":"uint32","name":"gracePeriod","type":"uint32"}],"internalType":"struct ProductType","name":"productType","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getProducts","outputs":[{"components":[{"internalType":"uint16","name":"productType","type":"uint16"},{"internalType":"uint16","name":"minPrice","type":"uint16"},{"internalType":"uint144","name":"__gap","type":"uint144"},{"internalType":"uint32","name":"coverAssets","type":"uint32"},{"internalType":"uint16","name":"initialPriceRatio","type":"uint16"},{"internalType":"uint16","name":"capacityReductionRatio","type":"uint16"},{"internalType":"bool","name":"isDeprecated","type":"bool"},{"internalType":"bool","name":"useFixedPrice","type":"bool"}],"internalType":"struct Product[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"internalContracts","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"productId","type":"uint256"},{"internalType":"uint256","name":"poolId","type":"uint256"}],"name":"isPoolAllowed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"master","outputs":[{"internalType":"contract INXMMaster","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"migrateCoverProducts","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"multicall","outputs":[{"internalType":"bytes[]","name":"results","type":"bytes[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"productId","type":"uint256"},{"internalType":"uint8","name":"weight","type":"uint8"},{"internalType":"uint96","name":"initialPrice","type":"uint96"},{"internalType":"uint96","name":"targetPrice","type":"uint96"}],"internalType":"struct ProductInitializationParams[]","name":"params","type":"tuple[]"}],"name":"prepareStakingProductsParams","outputs":[{"components":[{"internalType":"uint256","name":"productId","type":"uint256"},{"internalType":"uint8","name":"weight","type":"uint8"},{"internalType":"uint96","name":"initialPrice","type":"uint96"},{"internalType":"uint96","name":"targetPrice","type":"uint96"}],"internalType":"struct ProductInitializationParams[]","name":"validatedParams","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"productIds","type":"uint256[]"},{"internalType":"uint256","name":"poolId","type":"uint256"}],"name":"requirePoolIsAllowed","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"string","name":"productTypeName","type":"string"},{"internalType":"uint256","name":"productTypeId","type":"uint256"},{"internalType":"string","name":"ipfsMetadata","type":"string"},{"components":[{"internalType":"uint8","name":"claimMethod","type":"uint8"},{"internalType":"uint32","name":"gracePeriod","type":"uint32"}],"internalType":"struct ProductType","name":"productType","type":"tuple"}],"internalType":"struct ICoverProducts.ProductTypeParam[]","name":"productTypeParams","type":"tuple[]"}],"name":"setProductTypes","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"productTypeIds","type":"uint256[]"},{"internalType":"string[]","name":"ipfsMetadata","type":"string[]"}],"name":"setProductTypesMetadata","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"string","name":"productName","type":"string"},{"internalType":"uint256","name":"productId","type":"uint256"},{"internalType":"string","name":"ipfsMetadata","type":"string"},{"components":[{"internalType":"uint16","name":"productType","type":"uint16"},{"internalType":"uint16","name":"minPrice","type":"uint16"},{"internalType":"uint144","name":"__gap","type":"uint144"},{"internalType":"uint32","name":"coverAssets","type":"uint32"},{"internalType":"uint16","name":"initialPriceRatio","type":"uint16"},{"internalType":"uint16","name":"capacityReductionRatio","type":"uint16"},{"internalType":"bool","name":"isDeprecated","type":"bool"},{"internalType":"bool","name":"useFixedPrice","type":"bool"}],"internalType":"struct Product","name":"product","type":"tuple"},{"internalType":"uint256[]","name":"allowedPools","type":"uint256[]"}],"internalType":"struct ICoverProducts.ProductParam[]","name":"productParams","type":"tuple[]"}],"name":"setProducts","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"productIds","type":"uint256[]"},{"internalType":"string[]","name":"ipfsMetadata","type":"string[]"}],"name":"setProductsMetadata","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b5061421f806100206000396000f3fe608060405234801561001057600080fd5b50600436106101e55760003560e01c80639e62e7951161010f578063d1f5e21f116100a2578063ee97f7f311610071578063ee97f7f31461047f578063fb9523a314610492578063fd32763e146104a5578063ff10ca34146104c557600080fd5b8063d1f5e21f14610405578063d4179cbd14610418578063d46655f41461042b578063eb9623601461043e57600080fd5b8063bfe94713116100de578063bfe94713146103c2578063c0c3a4a5146103d5578063c29b2f20146103e8578063c6a36630146103fd57600080fd5b80639e62e79514610341578063ac9650d814610361578063b6c700c014610381578063b9db15b4146103a257600080fd5b80633392473a116101875780636bcd0d0a116101565780636bcd0d0a146102db5780637f0f36e3146102ee57806394e5f369146103015780639d26bd1c1461032157600080fd5b80633392473a146102905780634a348da9146102a35780635c268eeb146102b55780636739d3d5146102c857600080fd5b806316076e76116101c357806316076e7614610225578063168d3dc41461023a57806319cc31c41461025a5780632c328aa61461026d57600080fd5b8063077fce96146101ea5780630ea9c984146101f457806314073e32146101fc575b600080fd5b6101f26104e5565b005b6101f2610b99565b61020f61020a366004613143565b610e50565b60405161021c91906131d5565b60405180910390f35b61022d610f80565b60405161021c91906131e8565b61024d610248366004613293565b610ff1565b60405161021c91906132d4565b61020f610268366004613143565b6110ee565b61028061027b366004613318565b611151565b604051901515815260200161021c565b6101f261029e366004613293565b6111d9565b6002545b60405190815260200161021c565b61024d6102c3366004613293565b611a97565b61024d6102d6366004613143565b611c56565b6101f26102e936600461333a565b611d18565b6101f26102fc36600461333a565b611f31565b61031461030f3660046133a5565b612104565b60405161021c9190613419565b61033461032f366004613143565b61235d565b60405161021c919061347f565b61035461034f366004613143565b61246b565b60405161021c91906134e1565b61037461036f366004613293565b61250d565b60405161021c91906134f4565b61039461038f366004613143565b61264a565b60405161021c9291906135c1565b6103b56103b0366004613143565b612764565b60405161021c91906135f1565b6103546103d0366004613143565b612820565b6101f26103e3366004613293565b61283d565b6103f0612c43565b60405161021c9190613600565b6003546102a7565b610334610413366004613143565b612d14565b6101f2610426366004613643565b612e17565b6101f26104393660046136a6565b612e95565b61046761044c366004613143565b6001602052600090815260409020546001600160a01b031681565b6040516001600160a01b03909116815260200161021c565b600054610467906001600160a01b031681565b61024d6104a0366004613293565b612f0f565b6102a76104b3366004613143565b60009081526006602052604090205490565b6104d86104d3366004613143565b613004565b60405161021c91906136c3565b6002541561054c5760405162461bcd60e51b815260206004820152602960248201527f436f76657250726f64756374733a205f70726f647563747320616c7265616479604482015268081b5a59dc985d195960ba1b60648201526084015b60405180910390fd5b600354156105b25760405162461bcd60e51b815260206004820152602d60248201527f436f76657250726f64756374733a205f70726f64756374547970657320616c7260448201526c1958591e481b5a59dc985d1959609a1b6064820152608401610543565b60006105bc613061565b90506000816001600160a01b031663a1b8adcb6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156105fe573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061062291906136e3565b90506000826001600160a01b031663c29b2f206040518163ffffffff1660e01b8152600401600060405180830381865afa158015610664573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261068c919081019061382a565b90506000836001600160a01b03166365e90a286040518163ffffffff1660e01b8152600401602060405180830381865afa1580156106ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106f2919061395d565b90506000836001600160a01b0316632dd96be96040518163ffffffff1660e01b8152600401602060405180830381865afa158015610734573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610758919061395d565b905060005b8351811015610a1c57600284828151811061077a5761077a613976565b6020908102919091018101518254600181018455600093845292829020815193018054928201516040808401516060850151608086015160a087015160c088015160e0909801511515600160f81b026001600160f81b03981515600160f01b02989098166001600160f01b0361ffff928316600160e01b0261ffff60e01b19948416600160d01b029490941663ffffffff60d01b1963ffffffff909616600160b01b0263ffffffff60b01b196001600160901b039098166401000000000297909716640100000000600160d01b0319998516620100000263ffffffff19909d1694909d16939093179a909a179690961699909917929092171696909617959095179390931692909217179055516372ca814160e11b8152600481018290526001600160a01b0387169063e595028290602401600060405180830381865afa1580156108c9573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526108f1919081019061398c565b60008281526004602052604090209061090a9082613a9f565b506000818152600660205260409020845185908390811061092d5761092d613976565b602002602001015160e00151158061095f575084828151811061095257610952613976565b602002602001015160c001515b1561096a5750610a0a565b60005b83811015610a075760405163e57315cb60e01b815260048101849052602481018290526001600160a01b0389169063e57315cb90604401602060405180830381865afa9250505080156109dd575060408051601f3d908101601f191682019092526109da9181019061395d565b60015b15610a075782546001810184556000848152602090200155806109ff81613b74565b91505061096d565b50505b80610a1481613b74565b91505061075d565b5060005b82811015610b9157604051637c09b0bb60e01b8152600481018290526000906001600160a01b03881690637c09b0bb906024016040805180830381865afa158015610a6f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a939190613b9c565b6003805460018101825560009190915281517fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b9091018054602084015163ffffffff166101000264ffffffffff1990911660ff909316929092179190911790556040516367b7397360e01b8152600481018490529091506001600160a01b038816906367b7397390602401600060405180830381865afa158015610b3b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610b63919081019061398c565b600083815260056020526040902090610b7c9082613a9f565b50508080610b8990613b74565b915050610a20565b505050505050565b6000546040516227050b60e31b815261503160f01b60048201526001600160a01b0390911690630138285890602401602060405180830381865afa158015610be5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c0991906136e3565b600160008181526020919091527fcc69885fda6bcc1a4ace058b4a62bf5e179ea78fd58a1ccd71c22cc9b688792f80546001600160a01b039384166001600160a01b0319909116179055546040516227050b60e31b815261434f60f01b6004820152911690630138285890602401602060405180830381865afa158015610c94573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cb891906136e3565b6004600081815260016020527fedc95719e9a3b28dd8e80877cb5880a9be7de1a13fc8b05e7999683b6b56764380546001600160a01b039485166001600160a01b0319909116179055546040516227050b60e31b81526126a960f11b9281019290925290911690630138285890602401602060405180830381865afa158015610d45573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d6991906136e3565b6002600090815260016020526000805160206141ca83398151915280546001600160a01b039384166001600160a01b0319909116179055546040516227050b60e31b815261053560f41b6004820152911690630138285890602401602060405180830381865afa158015610de1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e0591906136e3565b600560005260016020527fe2689cd4a84e23ad2f564004f1c9013e9589d260bde6380aba3ca7e09e4df40c80546001600160a01b0319166001600160a01b0392909216919091179055565b60408051808201909152606081526000602082015260008281526008602052604090205480610e9a5760408051606081018252600091810182815281526020810191909152610f79565b6000838152600860205260409020610eb3600183613bfa565b81548110610ec357610ec3613976565b9060005260206000209060020201604051806040016040529081600082018054610eec90613a1f565b80601f0160208091040260200160405190810160405280929190818152602001828054610f1890613a1f565b8015610f655780601f10610f3a57610100808354040283529160200191610f65565b820191906000526020600020905b815481529060010190602001808311610f4857829003601f168201915b505050505081526020016001820154815250505b9392505050565b60606003805480602002602001604051908101604052809291908181526020016000905b82821015610fe8576000848152602090819020604080518082019091529084015460ff81168252610100900463ffffffff1681830152825260019092019101610fa4565b50505050905090565b600254606090826001600160401b0381111561100f5761100f613700565b604051908082528060200260200182016040528015611038578160200160208202803683370190505b50915060005b838110156110e657600085858381811061105a5761105a613976565b905060200201359050828110611083576040516379de4af560e01b815260040160405180910390fd5b6002818154811061109657611096613976565b90600052602060002001600001601a9054906101000a900461ffff1661ffff168483815181106110c8576110c8613976565b602090810291909101015250806110de81613b74565b91505061103e565b505092915050565b604080518082019091526060815260006020820152600082815260076020526040902054806111385760408051606081018252600091810182815281526020810191909152610f79565b6000838152600760205260409020610eb3600183613bfa565b6000828152600660205260408120548082036111715760019150506111d3565b60005b818110156111cc57600085815260066020526040902080548591908390811061119f5761119f613976565b9060005260206000200154036111ba576001925050506111d3565b806111c481613b74565b915050611174565b5060009150505b92915050565b6002600052600160208190526000805160206141ca8339815191525460405163505ef22f60e01b815233600482015260248101929092526001600160a01b03169063505ef22f90604401602060405180830381865afa158015611240573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112649190613c0d565b6112805760405162461bcd60e51b815260040161054390613c2a565b600019600061128d613061565b6001600160a01b031663ef072e026040518163ffffffff1660e01b8152600401602060405180830381865afa1580156112ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112ee919061395d565b905060006112fa613088565b6001600160a01b0316639bf00f186040518163ffffffff1660e01b8152600401602060405180830381865afa158015611337573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061135b919061395d565b90506000611367613094565b6001600160a01b03166367e4ac2c6040518163ffffffff1660e01b8152600401600060405180830381865afa1580156113a4573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526113cc9190810190613c70565b805190915060005b81811015611442578281815181106113ee576113ee613976565b6020026020010151602001518015611421575082818151811061141357611413613976565b602002602001015160400151155b1561143057806001901b861895505b8061143a81613b74565b9150506113d4565b5060005b86811015611a8d573688888381811061146157611461613976565b90506020028101906114739190613d48565b600354909150606082019061148b6080840183613d69565b61ffff16106114ad5760405163c3af0fb960e01b815260040160405180910390fd5b6114bd6080820160608301613d86565b881663ffffffff16156114e357604051636a5b237960e11b815260040160405180910390fd5b60006114f56040830160208401613d69565b61ffff16156115175761150e6040830160208401613d69565b61ffff16611519565b875b90508061152c60a0840160808501613d69565b61ffff16101561154f5760405163f9c3cf0160e01b815260040160405180910390fd5b61271061156260a0840160808501613d69565b61ffff161115611585576040516306e1b30360e11b815260040160405180910390fd5b61271061159860c0840160a08501613d69565b61ffff1611156115bb5760405163267f61c960e21b815260040160405180910390fd5b60006115cb610160850185613da3565b905011156116755760005b6115e4610160850185613da3565b905081101561167357876115fc610160860186613da3565b8381811061160c5761160c613976565b9050602002013511806116435750611628610160850185613da3565b8281811061163857611638613976565b905060200201356000145b156116615760405163e050b05160e01b815260040160405180910390fd5b8061166b81613b74565b9150506115d6565b505b6000198360200135036117f85760025460006116946040860186613dec565b9050111561172f576000818152600760205260409081902081518083018352909181906116c390880188613dec565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052509385525050426020938401525083546001810185559381522081519192600202019081906117219082613a9f565b506020820151816001015550505b6117398480613dec565b600083815260046020526040902091611753919083613e32565b50611762610160850185613da3565b600083815260066020526040902061177b92909161309f565b506002805460018101825560009190915283907f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace016117ba8282613f26565b50506040518181527fe757b28b33896bc8918816faf8078f9ec27409af77ad80806d7196478897149b9060200160405180910390a150505050611a7b565b60025460208401351061181e576040516379de4af560e01b815260040160405180910390fd5b6000600284602001358154811061183757611837613976565b6000918252602090912001905061185460e0840160c085016140ae565b8154901515600160f01b0260ff60f01b1990911617815561187b6080840160608501613d86565b815463ffffffff91909116600160b01b0263ffffffff60b01b199091161781556118ab60a0840160808501613d69565b815461ffff91909116600160d01b0261ffff60d01b199091161781556118d760c0840160a08501613d69565b815461ffff91909116600160e01b0261ffff60e01b199091161781556119036040840160208501613d69565b815461ffff91909116620100000263ffff00001990911617815561192b610160850185613da3565b602080870135600090815260069091526040902061194a92909161309f565b5060006119578580613dec565b9050111561198b576119698480613dec565b602080870135600090815260049091526040902091611989919083613e32565b505b600061199a6040860186613dec565b90501115611a4057600760008560200135815260200190815260200160002060405180604001604052808680604001906119d49190613dec565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920182905250938552505042602093840152508354600181018555938152208151919260020201908190611a329082613a9f565b506020820151816001015550505b60405160208086013582527fe757b28b33896bc8918816faf8078f9ec27409af77ad80806d7196478897149b910160405180910390a1505050505b80611a8581613b74565b915050611446565b5050505050505050565b600254606090826001600160401b03811115611ab557611ab5613700565b604051908082528060200260200182016040528015611ade578160200160208202803683370190505b5091506000611aeb613061565b6001600160a01b031663ef072e026040518163ffffffff1660e01b8152600401602060405180830381865afa158015611b28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b4c919061395d565b905060005b84811015611c4d576000868683818110611b6d57611b6d613976565b905060200201359050838110611b96576040516379de4af560e01b815260040160405180910390fd5b60028181548110611ba957611ba9613976565b600091825260208220015462010000900461ffff169003611be85782858381518110611bd757611bd7613976565b602002602001018181525050611c3a565b60028181548110611bfb57611bfb613976565b9060005260206000200160000160029054906101000a900461ffff1661ffff16858381518110611c2d57611c2d613976565b6020026020010181815250505b5080611c4581613b74565b915050611b51565b50505092915050565b600081815260066020526040902054606090806001600160401b03811115611c8057611c80613700565b604051908082528060200260200182016040528015611ca9578160200160208202803683370190505b50915060005b81811015611d11576000848152600660205260409020805482908110611cd757611cd7613976565b9060005260206000200154838281518110611cf457611cf4613976565b602090810291909101015280611d0981613b74565b915050611caf565b5050919050565b6002600052600160208190526000805160206141ca8339815191525460405163505ef22f60e01b815233600482015260248101929092526001600160a01b03169063505ef22f90604401602060405180830381865afa158015611d7f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611da39190613c0d565b611dbf5760405162461bcd60e51b815260040161054390613c2a565b828114611ddf57604051632b477e7160e11b815260040160405180910390fd5b60035460005b84811015610b91576000868683818110611e0157611e01613976565b905060200201359050828110611e2a5760405163c3af0fb960e01b815260040160405180910390fd5b848483818110611e3c57611e3c613976565b9050602002810190611e4e9190613dec565b9050600003611e7057604051635c1cf85760e11b815260040160405180910390fd5b600860008281526020019081526020016000206040518060400160405280878786818110611ea057611ea0613976565b9050602002810190611eb29190613dec565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920182905250938552505042602093840152508354600181018555938152208151919260020201908190611f109082613a9f565b50602082015181600101555050508080611f2990613b74565b915050611de5565b6002600052600160208190526000805160206141ca8339815191525460405163505ef22f60e01b815233600482015260248101929092526001600160a01b03169063505ef22f90604401602060405180830381865afa158015611f98573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fbc9190613c0d565b611fd85760405162461bcd60e51b815260040161054390613c2a565b828114611ff857604051632b477e7160e11b815260040160405180910390fd5b60025460005b84811015610b9157600086868381811061201a5761201a613976565b905060200201359050828110612043576040516379de4af560e01b815260040160405180910390fd5b60076000828152602001908152602001600020604051806040016040528087878681811061207357612073613976565b90506020028101906120859190613dec565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052509385525050426020938401525083546001810185559381522081519192600202019081906120e39082613a9f565b506020820151816001015550505080806120fc90613b74565b915050611ffe565b60025460609082806001600160401b0381111561212357612123613700565b60405190808252806020026020018201604052801561217557816020015b6040805160808101825260008082526020808301829052928201819052606082015282526000199092019101816121415790505b50925060005b81811015611c4d57600086868381811061219757612197613976565b9050608002016000013590508381106121c3576040516379de4af560e01b815260040160405180910390fd5b600081815260066020526040902054156121f357604051635d46ff4160e01b815260048101829052602401610543565b60006002828154811061220857612208613976565b60009182526020918290206040805161010081018252919092015461ffff80821683526201000082048116948301949094526001600160901b036401000000008204169282019290925263ffffffff600160b01b8304166060820152600160d01b820483166080820152600160e01b820490921660a083015260ff600160f01b8204811615801560c0850152600160f81b90920416151560e08301529091506122c457604051631340cecb60e21b815260040160405180910390fd5b8787848181106122d6576122d6613976565b9050608002018036038101906122ec91906140e2565b8684815181106122fe576122fe613976565b6020026020010181905250806080015161ffff1686848151811061232457612324613976565b6020026020010151604001906001600160601b031690816001600160601b0316815250505050808061235590613b74565b91505061217b565b606060076000838152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b8282101561246057838290600052602060002090600202016040518060400160405290816000820180546123c590613a1f565b80601f01602080910402602001604051908101604052809291908181526020018280546123f190613a1f565b801561243e5780601f106124135761010080835404028352916020019161243e565b820191906000526020600020905b81548152906001019060200180831161242157829003601f168201915b5050505050815260200160018201548152505081526020019060010190612392565b505050509050919050565b600081815260046020526040902080546060919061248890613a1f565b80601f01602080910402602001604051908101604052809291908181526020018280546124b490613a1f565b80156125015780601f106124d657610100808354040283529160200191612501565b820191906000526020600020905b8154815290600101906020018083116124e457829003601f168201915b50505050509050919050565b606081806001600160401b0381111561252857612528613700565b60405190808252806020026020018201604052801561255b57816020015b60608152602001906001900390816125465790505b50915060005b818110156110e6576000803087878581811061257f5761257f613976565b90506020028101906125919190613dec565b60405161259f929190614159565b600060405180830381855af49150503d80600081146125da576040519150601f19603f3d011682016040523d82523d6000602084013e6125df565b606091505b50915091508161261757805160008190036126105760405163f1a8c42d60e01b815260048101859052602401610543565b8060208301fd5b8085848151811061262a5761262a613976565b60200260200101819052505050808061264290613b74565b915050612561565b6126526130ea565b60408051808201909152600080825260208201526002838154811061267957612679613976565b60009182526020918290206040805161010081018252929091015461ffff8082168085526201000083048216958501959095526001600160901b036401000000008304169284019290925263ffffffff600160b01b8204166060840152600160d01b810482166080840152600160e01b810490911660a083015260ff600160f01b82048116151560c0840152600160f81b90910416151560e0820152600380549194509190811061272c5761272c613976565b60009182526020918290206040805180820190915291015460ff81168252610100900463ffffffff1691810191909152919391925050565b61276c6130ea565b6002828154811061277f5761277f613976565b60009182526020918290206040805161010081018252919092015461ffff80821683526201000082048116948301949094526001600160901b036401000000008204169282019290925263ffffffff600160b01b8304166060820152600160d01b820483166080820152600160e01b820490921660a083015260ff600160f01b82048116151560c0840152600160f81b90910416151560e082015292915050565b600081815260056020526040902080546060919061248890613a1f565b6002600052600160208190526000805160206141ca8339815191525460405163505ef22f60e01b815233600482015260248101929092526001600160a01b03169063505ef22f90604401602060405180830381865afa1580156128a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128c89190613c0d565b6128e45760405162461bcd60e51b815260040161054390613c2a565b60005b81811015612c3e573683838381811061290257612902613976565b90506020028101906129149190614169565b9050600019816020013503612a8a576003546129336040830183613dec565b905060000361295557604051635c1cf85760e11b815260040160405180910390fd5b60008181526008602052604090819020815180830183529091819061297c90860186613dec565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052509385525050426020938401525083546001810185559381522081519192600202019081906129da9082613a9f565b50602091909101516001909101556129f28280613dec565b600083815260056020526040902091612a0c919083613e32565b506003805460018101825560009190915260608301907fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b01612a4e828261417f565b50506040518181527fd88b8450ea1e752935616a2e6cb78fbb30e68c5fb6859a9edcb110a95e5f882a9060200160405180910390a15050612c2c565b600354602082013510612ab05760405163c3af0fb960e01b815260040160405180910390fd5b612ac060a0820160808301613d86565b6003826020013581548110612ad757612ad7613976565b60009182526020822001805463ffffffff939093166101000264ffffffff001990931692909217909155612b0b8280613dec565b90501115612b3f57612b1d8180613dec565b602080840135600090815260059091526040902091612b3d919083613e32565b505b6000612b4e6040830183613dec565b90501115612bf45760086000826020013581526020019081526020016000206040518060400160405280838060400190612b889190613dec565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920182905250938552505042602093840152508354600181018555938152208151919260020201908190612be69082613a9f565b506020820151816001015550505b60405160208083013582527fd88b8450ea1e752935616a2e6cb78fbb30e68c5fb6859a9edcb110a95e5f882a910160405180910390a1505b80612c3681613b74565b9150506128e7565b505050565b60606002805480602002602001604051908101604052809291908181526020016000905b82821015610fe857600084815260209081902060408051610100810182529185015461ffff80821684526201000082048116848601526001600160901b036401000000008304169284019290925263ffffffff600160b01b8204166060840152600160d01b810482166080840152600160e01b810490911660a083015260ff600160f01b82048116151560c0840152600160f81b90910416151560e0820152825260019092019101612c67565b606060086000838152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b828210156124605783829060005260206000209060020201604051806040016040529081600082018054612d7c90613a1f565b80601f0160208091040260200160405190810160405280929190818152602001828054612da890613a1f565b8015612df55780601f10612dca57610100808354040283529160200191612df5565b820191906000526020600020905b815481529060010190602001808311612dd857829003601f168201915b5050505050815260200160018201548152505081526020019060010190612d49565b60005b82811015612e8f57612e44848483818110612e3757612e37613976565b9050602002013583611151565b612e7d57838382818110612e5a57612e5a613976565b90506020020135604051635d46ff4160e01b815260040161054391815260200190565b80612e8781613b74565b915050612e1a565b50505050565b6000546001600160a01b031615612eed576000546001600160a01b03163314612eed5760405162461bcd60e51b815260206004820152600a6024820152692737ba1036b0b9ba32b960b11b6044820152606401610543565b600080546001600160a01b0319166001600160a01b0392909216919091179055565b600254606090826001600160401b03811115612f2d57612f2d613700565b604051908082528060200260200182016040528015612f56578160200160208202803683370190505b50915060005b838110156110e6576000858583818110612f7857612f78613976565b905060200201359050828110612fa1576040516379de4af560e01b815260040160405180910390fd5b60028181548110612fb457612fb4613976565b90600052602060002001600001601c9054906101000a900461ffff1661ffff16848381518110612fe657612fe6613976565b60209081029190910101525080612ffc81613b74565b915050612f5c565b60408051808201909152600080825260208201526003828154811061302b5761302b613976565b60009182526020918290206040805180820190915291015460ff81168252610100900463ffffffff169181019190915292915050565b600060018160045b81526020810191909152604001600020546001600160a01b0316919050565b60006001816005613069565b600060018181613069565b8280548282559060005260206000209081019282156130da579160200282015b828111156130da5782358255916020019190600101906130bf565b506130e692915061312e565b5090565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e081019190915290565b5b808211156130e6576000815560010161312f565b60006020828403121561315557600080fd5b5035919050565b60005b8381101561317757818101518382015260200161315f565b50506000910152565b6000815180845261319881602086016020860161315c565b601f01601f19169290920160200192915050565b60008151604084526131c16040850182613180565b602093840151949093019390935250919050565b602081526000610f7960208301846131ac565b602080825282518282018190526000919060409081850190868401855b8281101561323b5761322b848351805160ff16825260209081015163ffffffff16910152565b9284019290850190600101613205565b5091979650505050505050565b60008083601f84011261325a57600080fd5b5081356001600160401b0381111561327157600080fd5b6020830191508360208260051b850101111561328c57600080fd5b9250929050565b600080602083850312156132a657600080fd5b82356001600160401b038111156132bc57600080fd5b6132c885828601613248565b90969095509350505050565b6020808252825182820181905260009190848201906040850190845b8181101561330c578351835292840192918401916001016132f0565b50909695505050505050565b6000806040838503121561332b57600080fd5b50508035926020909101359150565b6000806000806040858703121561335057600080fd5b84356001600160401b038082111561336757600080fd5b61337388838901613248565b9096509450602087013591508082111561338c57600080fd5b5061339987828801613248565b95989497509550505050565b600080602083850312156133b857600080fd5b82356001600160401b03808211156133cf57600080fd5b818501915085601f8301126133e357600080fd5b8135818111156133f257600080fd5b8660208260071b850101111561340757600080fd5b60209290920196919550909350505050565b602080825282518282018190526000919060409081850190868401855b8281101561323b578151805185528681015160ff1687860152858101516001600160601b0390811687870152606091820151169085015260809093019290850190600101613436565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b828110156134d457603f198886030184526134c28583516131ac565b945092850192908501906001016134a6565b5092979650505050505050565b602081526000610f796020830184613180565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b828110156134d457603f19888603018452613537858351613180565b9450928501929085019060010161351b565b61ffff8082511683528060208301511660208401526001600160901b03604083015116604084015263ffffffff60608301511660608401528060808301511660808401528060a08301511660a08401525060c08101516135ad60c084018215159052565b5060e0810151612c3e60e084018215159052565b61014081016135d08285613549565b825160ff16610100830152602083015163ffffffff16610120830152610f79565b61010081016111d38284613549565b6020808252825182820181905260009190848201906040850190845b8181101561330c5761362f838551613549565b92840192610100929092019160010161361c565b60008060006040848603121561365857600080fd5b83356001600160401b0381111561366e57600080fd5b61367a86828701613248565b909790965060209590950135949350505050565b6001600160a01b03811681146136a357600080fd5b50565b6000602082840312156136b857600080fd5b8135610f798161368e565b815160ff16815260208083015163ffffffff1690820152604081016111d3565b6000602082840312156136f557600080fd5b8151610f798161368e565b634e487b7160e01b600052604160045260246000fd5b60405161010081016001600160401b038111828210171561373957613739613700565b60405290565b604051606081016001600160401b038111828210171561373957613739613700565b604051601f8201601f191681016001600160401b038111828210171561378957613789613700565b604052919050565b60006001600160401b038211156137aa576137aa613700565b5060051b60200190565b61ffff811681146136a357600080fd5b80516137cf816137b4565b919050565b6001600160901b03811681146136a357600080fd5b80516137cf816137d4565b63ffffffff811681146136a357600080fd5b80516137cf816137f4565b80151581146136a357600080fd5b80516137cf81613811565b6000602080838503121561383d57600080fd5b82516001600160401b0381111561385357600080fd5b8301601f8101851361386457600080fd5b805161387761387282613791565b613761565b81815260089190911b8201830190838101908783111561389657600080fd5b928401925b828410156139525761010084890312156138b55760008081fd5b6138bd613716565b84516138c8816137b4565b81526138d58587016137c4565b8682015260406138e68187016137e9565b9082015260606138f7868201613806565b9082015260806139088682016137c4565b9082015260a06139198682016137c4565b9082015260c061392a86820161381f565b9082015260e061393b86820161381f565b90820152825261010093909301929084019061389b565b979650505050505050565b60006020828403121561396f57600080fd5b5051919050565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561399e57600080fd5b81516001600160401b03808211156139b557600080fd5b818401915084601f8301126139c957600080fd5b8151818111156139db576139db613700565b6139ee601f8201601f1916602001613761565b9150808252856020828501011115613a0557600080fd5b613a1681602084016020860161315c565b50949350505050565b600181811c90821680613a3357607f821691505b602082108103613a5357634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115612c3e57600081815260208120601f850160051c81016020861015613a805750805b601f850160051c820191505b81811015610b9157828155600101613a8c565b81516001600160401b03811115613ab857613ab8613700565b613acc81613ac68454613a1f565b84613a59565b602080601f831160018114613b015760008415613ae95750858301515b600019600386901b1c1916600185901b178555610b91565b600085815260208120601f198616915b82811015613b3057888601518255948401946001909101908401613b11565b5085821015613b4e5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052601160045260246000fd5b600060018201613b8657613b86613b5e565b5060010190565b60ff811681146136a357600080fd5b600060408284031215613bae57600080fd5b604051604081018181106001600160401b0382111715613bd057613bd0613700565b6040528251613bde81613b8d565b81526020830151613bee816137f4565b60208201529392505050565b818103818111156111d3576111d3613b5e565b600060208284031215613c1f57600080fd5b8151610f7981613811565b60208082526026908201527f43616c6c6572206973206e6f7420616e2061647669736f727920626f6172642060408201526536b2b6b132b960d11b606082015260800190565b60006020808385031215613c8357600080fd5b82516001600160401b03811115613c9957600080fd5b8301601f81018513613caa57600080fd5b8051613cb861387282613791565b81815260609182028301840191848201919088841115613cd757600080fd5b938501935b83851015613d3c5780858a031215613cf45760008081fd5b613cfc61373f565b8551613d078161368e565b815285870151613d1681613811565b81880152604086810151613d2981613811565b9082015283529384019391850191613cdc565b50979650505050505050565b6000823561017e19833603018112613d5f57600080fd5b9190910192915050565b600060208284031215613d7b57600080fd5b8135610f79816137b4565b600060208284031215613d9857600080fd5b8135610f79816137f4565b6000808335601e19843603018112613dba57600080fd5b8301803591506001600160401b03821115613dd457600080fd5b6020019150600581901b360382131561328c57600080fd5b6000808335601e19843603018112613e0357600080fd5b8301803591506001600160401b03821115613e1d57600080fd5b60200191503681900382131561328c57600080fd5b6001600160401b03831115613e4957613e49613700565b613e5d83613e578354613a1f565b83613a59565b6000601f841160018114613e915760008515613e795750838201355b600019600387901b1c1916600186901b178355613eeb565b600083815260209020601f19861690835b82811015613ec25786850135825560209485019460019092019101613ea2565b5086821015613edf5760001960f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b600081356111d3816137b4565b600081356111d3816137d4565b600081356111d3816137f4565b600081356111d381613811565b8135613f31816137b4565b61ffff8116905081548161ffff1982161783556020840135613f52816137b4565b63ffff00008160101b168363ffffffff19841617178455505050613fb9613f7b60408401613eff565b825475ffffffffffffffffffffffffffffffffffff00000000191660209190911b75ffffffffffffffffffffffffffffffffffff0000000016178255565b613fec613fc860608401613f0c565b82805463ffffffff60b01b191660b09290921b63ffffffff60b01b16919091179055565b61401b613ffb60808401613ef2565b82805461ffff60d01b191660d09290921b61ffff60d01b16919091179055565b61404a61402a60a08401613ef2565b82805461ffff60e01b191660e09290921b61ffff60e01b16919091179055565b61407761405960c08401613f19565b82805460ff60f01b191691151560f01b60ff60f01b16919091179055565b6140aa61408660e08401613f19565b8280546001600160f81b031691151560f81b6001600160f81b031916919091179055565b5050565b6000602082840312156140c057600080fd5b8135610f7981613811565b80356001600160601b03811681146137cf57600080fd5b6000608082840312156140f457600080fd5b604051608081018181106001600160401b038211171561411657614116613700565b60405282358152602083013561412b81613b8d565b602082015261413c604084016140cb565b604082015261414d606084016140cb565b60608201529392505050565b8183823760009101908152919050565b60008235609e19833603018112613d5f57600080fd5b813561418a81613b8d565b60ff8116905081548160ff19821617835560208401356141a9816137f4565b64ffffffff008160081b168364ffffffffff19841617178455505050505056fed9d16d34ffb15ba3a3d852f0d403e2ce1d691fb54de27ac87cd2f993f3ec330fa2646970667358221220058d0cc82abfff733d233a23d27fc86e6d499fd40e56ecdab2d4b2e6a28eac3b64736f6c63430008120033

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101e55760003560e01c80639e62e7951161010f578063d1f5e21f116100a2578063ee97f7f311610071578063ee97f7f31461047f578063fb9523a314610492578063fd32763e146104a5578063ff10ca34146104c557600080fd5b8063d1f5e21f14610405578063d4179cbd14610418578063d46655f41461042b578063eb9623601461043e57600080fd5b8063bfe94713116100de578063bfe94713146103c2578063c0c3a4a5146103d5578063c29b2f20146103e8578063c6a36630146103fd57600080fd5b80639e62e79514610341578063ac9650d814610361578063b6c700c014610381578063b9db15b4146103a257600080fd5b80633392473a116101875780636bcd0d0a116101565780636bcd0d0a146102db5780637f0f36e3146102ee57806394e5f369146103015780639d26bd1c1461032157600080fd5b80633392473a146102905780634a348da9146102a35780635c268eeb146102b55780636739d3d5146102c857600080fd5b806316076e76116101c357806316076e7614610225578063168d3dc41461023a57806319cc31c41461025a5780632c328aa61461026d57600080fd5b8063077fce96146101ea5780630ea9c984146101f457806314073e32146101fc575b600080fd5b6101f26104e5565b005b6101f2610b99565b61020f61020a366004613143565b610e50565b60405161021c91906131d5565b60405180910390f35b61022d610f80565b60405161021c91906131e8565b61024d610248366004613293565b610ff1565b60405161021c91906132d4565b61020f610268366004613143565b6110ee565b61028061027b366004613318565b611151565b604051901515815260200161021c565b6101f261029e366004613293565b6111d9565b6002545b60405190815260200161021c565b61024d6102c3366004613293565b611a97565b61024d6102d6366004613143565b611c56565b6101f26102e936600461333a565b611d18565b6101f26102fc36600461333a565b611f31565b61031461030f3660046133a5565b612104565b60405161021c9190613419565b61033461032f366004613143565b61235d565b60405161021c919061347f565b61035461034f366004613143565b61246b565b60405161021c91906134e1565b61037461036f366004613293565b61250d565b60405161021c91906134f4565b61039461038f366004613143565b61264a565b60405161021c9291906135c1565b6103b56103b0366004613143565b612764565b60405161021c91906135f1565b6103546103d0366004613143565b612820565b6101f26103e3366004613293565b61283d565b6103f0612c43565b60405161021c9190613600565b6003546102a7565b610334610413366004613143565b612d14565b6101f2610426366004613643565b612e17565b6101f26104393660046136a6565b612e95565b61046761044c366004613143565b6001602052600090815260409020546001600160a01b031681565b6040516001600160a01b03909116815260200161021c565b600054610467906001600160a01b031681565b61024d6104a0366004613293565b612f0f565b6102a76104b3366004613143565b60009081526006602052604090205490565b6104d86104d3366004613143565b613004565b60405161021c91906136c3565b6002541561054c5760405162461bcd60e51b815260206004820152602960248201527f436f76657250726f64756374733a205f70726f647563747320616c7265616479604482015268081b5a59dc985d195960ba1b60648201526084015b60405180910390fd5b600354156105b25760405162461bcd60e51b815260206004820152602d60248201527f436f76657250726f64756374733a205f70726f64756374547970657320616c7260448201526c1958591e481b5a59dc985d1959609a1b6064820152608401610543565b60006105bc613061565b90506000816001600160a01b031663a1b8adcb6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156105fe573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061062291906136e3565b90506000826001600160a01b031663c29b2f206040518163ffffffff1660e01b8152600401600060405180830381865afa158015610664573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261068c919081019061382a565b90506000836001600160a01b03166365e90a286040518163ffffffff1660e01b8152600401602060405180830381865afa1580156106ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106f2919061395d565b90506000836001600160a01b0316632dd96be96040518163ffffffff1660e01b8152600401602060405180830381865afa158015610734573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610758919061395d565b905060005b8351811015610a1c57600284828151811061077a5761077a613976565b6020908102919091018101518254600181018455600093845292829020815193018054928201516040808401516060850151608086015160a087015160c088015160e0909801511515600160f81b026001600160f81b03981515600160f01b02989098166001600160f01b0361ffff928316600160e01b0261ffff60e01b19948416600160d01b029490941663ffffffff60d01b1963ffffffff909616600160b01b0263ffffffff60b01b196001600160901b039098166401000000000297909716640100000000600160d01b0319998516620100000263ffffffff19909d1694909d16939093179a909a179690961699909917929092171696909617959095179390931692909217179055516372ca814160e11b8152600481018290526001600160a01b0387169063e595028290602401600060405180830381865afa1580156108c9573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526108f1919081019061398c565b60008281526004602052604090209061090a9082613a9f565b506000818152600660205260409020845185908390811061092d5761092d613976565b602002602001015160e00151158061095f575084828151811061095257610952613976565b602002602001015160c001515b1561096a5750610a0a565b60005b83811015610a075760405163e57315cb60e01b815260048101849052602481018290526001600160a01b0389169063e57315cb90604401602060405180830381865afa9250505080156109dd575060408051601f3d908101601f191682019092526109da9181019061395d565b60015b15610a075782546001810184556000848152602090200155806109ff81613b74565b91505061096d565b50505b80610a1481613b74565b91505061075d565b5060005b82811015610b9157604051637c09b0bb60e01b8152600481018290526000906001600160a01b03881690637c09b0bb906024016040805180830381865afa158015610a6f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a939190613b9c565b6003805460018101825560009190915281517fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b9091018054602084015163ffffffff166101000264ffffffffff1990911660ff909316929092179190911790556040516367b7397360e01b8152600481018490529091506001600160a01b038816906367b7397390602401600060405180830381865afa158015610b3b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610b63919081019061398c565b600083815260056020526040902090610b7c9082613a9f565b50508080610b8990613b74565b915050610a20565b505050505050565b6000546040516227050b60e31b815261503160f01b60048201526001600160a01b0390911690630138285890602401602060405180830381865afa158015610be5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c0991906136e3565b600160008181526020919091527fcc69885fda6bcc1a4ace058b4a62bf5e179ea78fd58a1ccd71c22cc9b688792f80546001600160a01b039384166001600160a01b0319909116179055546040516227050b60e31b815261434f60f01b6004820152911690630138285890602401602060405180830381865afa158015610c94573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cb891906136e3565b6004600081815260016020527fedc95719e9a3b28dd8e80877cb5880a9be7de1a13fc8b05e7999683b6b56764380546001600160a01b039485166001600160a01b0319909116179055546040516227050b60e31b81526126a960f11b9281019290925290911690630138285890602401602060405180830381865afa158015610d45573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d6991906136e3565b6002600090815260016020526000805160206141ca83398151915280546001600160a01b039384166001600160a01b0319909116179055546040516227050b60e31b815261053560f41b6004820152911690630138285890602401602060405180830381865afa158015610de1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e0591906136e3565b600560005260016020527fe2689cd4a84e23ad2f564004f1c9013e9589d260bde6380aba3ca7e09e4df40c80546001600160a01b0319166001600160a01b0392909216919091179055565b60408051808201909152606081526000602082015260008281526008602052604090205480610e9a5760408051606081018252600091810182815281526020810191909152610f79565b6000838152600860205260409020610eb3600183613bfa565b81548110610ec357610ec3613976565b9060005260206000209060020201604051806040016040529081600082018054610eec90613a1f565b80601f0160208091040260200160405190810160405280929190818152602001828054610f1890613a1f565b8015610f655780601f10610f3a57610100808354040283529160200191610f65565b820191906000526020600020905b815481529060010190602001808311610f4857829003601f168201915b505050505081526020016001820154815250505b9392505050565b60606003805480602002602001604051908101604052809291908181526020016000905b82821015610fe8576000848152602090819020604080518082019091529084015460ff81168252610100900463ffffffff1681830152825260019092019101610fa4565b50505050905090565b600254606090826001600160401b0381111561100f5761100f613700565b604051908082528060200260200182016040528015611038578160200160208202803683370190505b50915060005b838110156110e657600085858381811061105a5761105a613976565b905060200201359050828110611083576040516379de4af560e01b815260040160405180910390fd5b6002818154811061109657611096613976565b90600052602060002001600001601a9054906101000a900461ffff1661ffff168483815181106110c8576110c8613976565b602090810291909101015250806110de81613b74565b91505061103e565b505092915050565b604080518082019091526060815260006020820152600082815260076020526040902054806111385760408051606081018252600091810182815281526020810191909152610f79565b6000838152600760205260409020610eb3600183613bfa565b6000828152600660205260408120548082036111715760019150506111d3565b60005b818110156111cc57600085815260066020526040902080548591908390811061119f5761119f613976565b9060005260206000200154036111ba576001925050506111d3565b806111c481613b74565b915050611174565b5060009150505b92915050565b6002600052600160208190526000805160206141ca8339815191525460405163505ef22f60e01b815233600482015260248101929092526001600160a01b03169063505ef22f90604401602060405180830381865afa158015611240573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112649190613c0d565b6112805760405162461bcd60e51b815260040161054390613c2a565b600019600061128d613061565b6001600160a01b031663ef072e026040518163ffffffff1660e01b8152600401602060405180830381865afa1580156112ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112ee919061395d565b905060006112fa613088565b6001600160a01b0316639bf00f186040518163ffffffff1660e01b8152600401602060405180830381865afa158015611337573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061135b919061395d565b90506000611367613094565b6001600160a01b03166367e4ac2c6040518163ffffffff1660e01b8152600401600060405180830381865afa1580156113a4573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526113cc9190810190613c70565b805190915060005b81811015611442578281815181106113ee576113ee613976565b6020026020010151602001518015611421575082818151811061141357611413613976565b602002602001015160400151155b1561143057806001901b861895505b8061143a81613b74565b9150506113d4565b5060005b86811015611a8d573688888381811061146157611461613976565b90506020028101906114739190613d48565b600354909150606082019061148b6080840183613d69565b61ffff16106114ad5760405163c3af0fb960e01b815260040160405180910390fd5b6114bd6080820160608301613d86565b881663ffffffff16156114e357604051636a5b237960e11b815260040160405180910390fd5b60006114f56040830160208401613d69565b61ffff16156115175761150e6040830160208401613d69565b61ffff16611519565b875b90508061152c60a0840160808501613d69565b61ffff16101561154f5760405163f9c3cf0160e01b815260040160405180910390fd5b61271061156260a0840160808501613d69565b61ffff161115611585576040516306e1b30360e11b815260040160405180910390fd5b61271061159860c0840160a08501613d69565b61ffff1611156115bb5760405163267f61c960e21b815260040160405180910390fd5b60006115cb610160850185613da3565b905011156116755760005b6115e4610160850185613da3565b905081101561167357876115fc610160860186613da3565b8381811061160c5761160c613976565b9050602002013511806116435750611628610160850185613da3565b8281811061163857611638613976565b905060200201356000145b156116615760405163e050b05160e01b815260040160405180910390fd5b8061166b81613b74565b9150506115d6565b505b6000198360200135036117f85760025460006116946040860186613dec565b9050111561172f576000818152600760205260409081902081518083018352909181906116c390880188613dec565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052509385525050426020938401525083546001810185559381522081519192600202019081906117219082613a9f565b506020820151816001015550505b6117398480613dec565b600083815260046020526040902091611753919083613e32565b50611762610160850185613da3565b600083815260066020526040902061177b92909161309f565b506002805460018101825560009190915283907f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace016117ba8282613f26565b50506040518181527fe757b28b33896bc8918816faf8078f9ec27409af77ad80806d7196478897149b9060200160405180910390a150505050611a7b565b60025460208401351061181e576040516379de4af560e01b815260040160405180910390fd5b6000600284602001358154811061183757611837613976565b6000918252602090912001905061185460e0840160c085016140ae565b8154901515600160f01b0260ff60f01b1990911617815561187b6080840160608501613d86565b815463ffffffff91909116600160b01b0263ffffffff60b01b199091161781556118ab60a0840160808501613d69565b815461ffff91909116600160d01b0261ffff60d01b199091161781556118d760c0840160a08501613d69565b815461ffff91909116600160e01b0261ffff60e01b199091161781556119036040840160208501613d69565b815461ffff91909116620100000263ffff00001990911617815561192b610160850185613da3565b602080870135600090815260069091526040902061194a92909161309f565b5060006119578580613dec565b9050111561198b576119698480613dec565b602080870135600090815260049091526040902091611989919083613e32565b505b600061199a6040860186613dec565b90501115611a4057600760008560200135815260200190815260200160002060405180604001604052808680604001906119d49190613dec565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920182905250938552505042602093840152508354600181018555938152208151919260020201908190611a329082613a9f565b506020820151816001015550505b60405160208086013582527fe757b28b33896bc8918816faf8078f9ec27409af77ad80806d7196478897149b910160405180910390a1505050505b80611a8581613b74565b915050611446565b5050505050505050565b600254606090826001600160401b03811115611ab557611ab5613700565b604051908082528060200260200182016040528015611ade578160200160208202803683370190505b5091506000611aeb613061565b6001600160a01b031663ef072e026040518163ffffffff1660e01b8152600401602060405180830381865afa158015611b28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b4c919061395d565b905060005b84811015611c4d576000868683818110611b6d57611b6d613976565b905060200201359050838110611b96576040516379de4af560e01b815260040160405180910390fd5b60028181548110611ba957611ba9613976565b600091825260208220015462010000900461ffff169003611be85782858381518110611bd757611bd7613976565b602002602001018181525050611c3a565b60028181548110611bfb57611bfb613976565b9060005260206000200160000160029054906101000a900461ffff1661ffff16858381518110611c2d57611c2d613976565b6020026020010181815250505b5080611c4581613b74565b915050611b51565b50505092915050565b600081815260066020526040902054606090806001600160401b03811115611c8057611c80613700565b604051908082528060200260200182016040528015611ca9578160200160208202803683370190505b50915060005b81811015611d11576000848152600660205260409020805482908110611cd757611cd7613976565b9060005260206000200154838281518110611cf457611cf4613976565b602090810291909101015280611d0981613b74565b915050611caf565b5050919050565b6002600052600160208190526000805160206141ca8339815191525460405163505ef22f60e01b815233600482015260248101929092526001600160a01b03169063505ef22f90604401602060405180830381865afa158015611d7f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611da39190613c0d565b611dbf5760405162461bcd60e51b815260040161054390613c2a565b828114611ddf57604051632b477e7160e11b815260040160405180910390fd5b60035460005b84811015610b91576000868683818110611e0157611e01613976565b905060200201359050828110611e2a5760405163c3af0fb960e01b815260040160405180910390fd5b848483818110611e3c57611e3c613976565b9050602002810190611e4e9190613dec565b9050600003611e7057604051635c1cf85760e11b815260040160405180910390fd5b600860008281526020019081526020016000206040518060400160405280878786818110611ea057611ea0613976565b9050602002810190611eb29190613dec565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920182905250938552505042602093840152508354600181018555938152208151919260020201908190611f109082613a9f565b50602082015181600101555050508080611f2990613b74565b915050611de5565b6002600052600160208190526000805160206141ca8339815191525460405163505ef22f60e01b815233600482015260248101929092526001600160a01b03169063505ef22f90604401602060405180830381865afa158015611f98573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fbc9190613c0d565b611fd85760405162461bcd60e51b815260040161054390613c2a565b828114611ff857604051632b477e7160e11b815260040160405180910390fd5b60025460005b84811015610b9157600086868381811061201a5761201a613976565b905060200201359050828110612043576040516379de4af560e01b815260040160405180910390fd5b60076000828152602001908152602001600020604051806040016040528087878681811061207357612073613976565b90506020028101906120859190613dec565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052509385525050426020938401525083546001810185559381522081519192600202019081906120e39082613a9f565b506020820151816001015550505080806120fc90613b74565b915050611ffe565b60025460609082806001600160401b0381111561212357612123613700565b60405190808252806020026020018201604052801561217557816020015b6040805160808101825260008082526020808301829052928201819052606082015282526000199092019101816121415790505b50925060005b81811015611c4d57600086868381811061219757612197613976565b9050608002016000013590508381106121c3576040516379de4af560e01b815260040160405180910390fd5b600081815260066020526040902054156121f357604051635d46ff4160e01b815260048101829052602401610543565b60006002828154811061220857612208613976565b60009182526020918290206040805161010081018252919092015461ffff80821683526201000082048116948301949094526001600160901b036401000000008204169282019290925263ffffffff600160b01b8304166060820152600160d01b820483166080820152600160e01b820490921660a083015260ff600160f01b8204811615801560c0850152600160f81b90920416151560e08301529091506122c457604051631340cecb60e21b815260040160405180910390fd5b8787848181106122d6576122d6613976565b9050608002018036038101906122ec91906140e2565b8684815181106122fe576122fe613976565b6020026020010181905250806080015161ffff1686848151811061232457612324613976565b6020026020010151604001906001600160601b031690816001600160601b0316815250505050808061235590613b74565b91505061217b565b606060076000838152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b8282101561246057838290600052602060002090600202016040518060400160405290816000820180546123c590613a1f565b80601f01602080910402602001604051908101604052809291908181526020018280546123f190613a1f565b801561243e5780601f106124135761010080835404028352916020019161243e565b820191906000526020600020905b81548152906001019060200180831161242157829003601f168201915b5050505050815260200160018201548152505081526020019060010190612392565b505050509050919050565b600081815260046020526040902080546060919061248890613a1f565b80601f01602080910402602001604051908101604052809291908181526020018280546124b490613a1f565b80156125015780601f106124d657610100808354040283529160200191612501565b820191906000526020600020905b8154815290600101906020018083116124e457829003601f168201915b50505050509050919050565b606081806001600160401b0381111561252857612528613700565b60405190808252806020026020018201604052801561255b57816020015b60608152602001906001900390816125465790505b50915060005b818110156110e6576000803087878581811061257f5761257f613976565b90506020028101906125919190613dec565b60405161259f929190614159565b600060405180830381855af49150503d80600081146125da576040519150601f19603f3d011682016040523d82523d6000602084013e6125df565b606091505b50915091508161261757805160008190036126105760405163f1a8c42d60e01b815260048101859052602401610543565b8060208301fd5b8085848151811061262a5761262a613976565b60200260200101819052505050808061264290613b74565b915050612561565b6126526130ea565b60408051808201909152600080825260208201526002838154811061267957612679613976565b60009182526020918290206040805161010081018252929091015461ffff8082168085526201000083048216958501959095526001600160901b036401000000008304169284019290925263ffffffff600160b01b8204166060840152600160d01b810482166080840152600160e01b810490911660a083015260ff600160f01b82048116151560c0840152600160f81b90910416151560e0820152600380549194509190811061272c5761272c613976565b60009182526020918290206040805180820190915291015460ff81168252610100900463ffffffff1691810191909152919391925050565b61276c6130ea565b6002828154811061277f5761277f613976565b60009182526020918290206040805161010081018252919092015461ffff80821683526201000082048116948301949094526001600160901b036401000000008204169282019290925263ffffffff600160b01b8304166060820152600160d01b820483166080820152600160e01b820490921660a083015260ff600160f01b82048116151560c0840152600160f81b90910416151560e082015292915050565b600081815260056020526040902080546060919061248890613a1f565b6002600052600160208190526000805160206141ca8339815191525460405163505ef22f60e01b815233600482015260248101929092526001600160a01b03169063505ef22f90604401602060405180830381865afa1580156128a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128c89190613c0d565b6128e45760405162461bcd60e51b815260040161054390613c2a565b60005b81811015612c3e573683838381811061290257612902613976565b90506020028101906129149190614169565b9050600019816020013503612a8a576003546129336040830183613dec565b905060000361295557604051635c1cf85760e11b815260040160405180910390fd5b60008181526008602052604090819020815180830183529091819061297c90860186613dec565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052509385525050426020938401525083546001810185559381522081519192600202019081906129da9082613a9f565b50602091909101516001909101556129f28280613dec565b600083815260056020526040902091612a0c919083613e32565b506003805460018101825560009190915260608301907fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b01612a4e828261417f565b50506040518181527fd88b8450ea1e752935616a2e6cb78fbb30e68c5fb6859a9edcb110a95e5f882a9060200160405180910390a15050612c2c565b600354602082013510612ab05760405163c3af0fb960e01b815260040160405180910390fd5b612ac060a0820160808301613d86565b6003826020013581548110612ad757612ad7613976565b60009182526020822001805463ffffffff939093166101000264ffffffff001990931692909217909155612b0b8280613dec565b90501115612b3f57612b1d8180613dec565b602080840135600090815260059091526040902091612b3d919083613e32565b505b6000612b4e6040830183613dec565b90501115612bf45760086000826020013581526020019081526020016000206040518060400160405280838060400190612b889190613dec565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920182905250938552505042602093840152508354600181018555938152208151919260020201908190612be69082613a9f565b506020820151816001015550505b60405160208083013582527fd88b8450ea1e752935616a2e6cb78fbb30e68c5fb6859a9edcb110a95e5f882a910160405180910390a1505b80612c3681613b74565b9150506128e7565b505050565b60606002805480602002602001604051908101604052809291908181526020016000905b82821015610fe857600084815260209081902060408051610100810182529185015461ffff80821684526201000082048116848601526001600160901b036401000000008304169284019290925263ffffffff600160b01b8204166060840152600160d01b810482166080840152600160e01b810490911660a083015260ff600160f01b82048116151560c0840152600160f81b90910416151560e0820152825260019092019101612c67565b606060086000838152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b828210156124605783829060005260206000209060020201604051806040016040529081600082018054612d7c90613a1f565b80601f0160208091040260200160405190810160405280929190818152602001828054612da890613a1f565b8015612df55780601f10612dca57610100808354040283529160200191612df5565b820191906000526020600020905b815481529060010190602001808311612dd857829003601f168201915b5050505050815260200160018201548152505081526020019060010190612d49565b60005b82811015612e8f57612e44848483818110612e3757612e37613976565b9050602002013583611151565b612e7d57838382818110612e5a57612e5a613976565b90506020020135604051635d46ff4160e01b815260040161054391815260200190565b80612e8781613b74565b915050612e1a565b50505050565b6000546001600160a01b031615612eed576000546001600160a01b03163314612eed5760405162461bcd60e51b815260206004820152600a6024820152692737ba1036b0b9ba32b960b11b6044820152606401610543565b600080546001600160a01b0319166001600160a01b0392909216919091179055565b600254606090826001600160401b03811115612f2d57612f2d613700565b604051908082528060200260200182016040528015612f56578160200160208202803683370190505b50915060005b838110156110e6576000858583818110612f7857612f78613976565b905060200201359050828110612fa1576040516379de4af560e01b815260040160405180910390fd5b60028181548110612fb457612fb4613976565b90600052602060002001600001601c9054906101000a900461ffff1661ffff16848381518110612fe657612fe6613976565b60209081029190910101525080612ffc81613b74565b915050612f5c565b60408051808201909152600080825260208201526003828154811061302b5761302b613976565b60009182526020918290206040805180820190915291015460ff81168252610100900463ffffffff169181019190915292915050565b600060018160045b81526020810191909152604001600020546001600160a01b0316919050565b60006001816005613069565b600060018181613069565b8280548282559060005260206000209081019282156130da579160200282015b828111156130da5782358255916020019190600101906130bf565b506130e692915061312e565b5090565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e081019190915290565b5b808211156130e6576000815560010161312f565b60006020828403121561315557600080fd5b5035919050565b60005b8381101561317757818101518382015260200161315f565b50506000910152565b6000815180845261319881602086016020860161315c565b601f01601f19169290920160200192915050565b60008151604084526131c16040850182613180565b602093840151949093019390935250919050565b602081526000610f7960208301846131ac565b602080825282518282018190526000919060409081850190868401855b8281101561323b5761322b848351805160ff16825260209081015163ffffffff16910152565b9284019290850190600101613205565b5091979650505050505050565b60008083601f84011261325a57600080fd5b5081356001600160401b0381111561327157600080fd5b6020830191508360208260051b850101111561328c57600080fd5b9250929050565b600080602083850312156132a657600080fd5b82356001600160401b038111156132bc57600080fd5b6132c885828601613248565b90969095509350505050565b6020808252825182820181905260009190848201906040850190845b8181101561330c578351835292840192918401916001016132f0565b50909695505050505050565b6000806040838503121561332b57600080fd5b50508035926020909101359150565b6000806000806040858703121561335057600080fd5b84356001600160401b038082111561336757600080fd5b61337388838901613248565b9096509450602087013591508082111561338c57600080fd5b5061339987828801613248565b95989497509550505050565b600080602083850312156133b857600080fd5b82356001600160401b03808211156133cf57600080fd5b818501915085601f8301126133e357600080fd5b8135818111156133f257600080fd5b8660208260071b850101111561340757600080fd5b60209290920196919550909350505050565b602080825282518282018190526000919060409081850190868401855b8281101561323b578151805185528681015160ff1687860152858101516001600160601b0390811687870152606091820151169085015260809093019290850190600101613436565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b828110156134d457603f198886030184526134c28583516131ac565b945092850192908501906001016134a6565b5092979650505050505050565b602081526000610f796020830184613180565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b828110156134d457603f19888603018452613537858351613180565b9450928501929085019060010161351b565b61ffff8082511683528060208301511660208401526001600160901b03604083015116604084015263ffffffff60608301511660608401528060808301511660808401528060a08301511660a08401525060c08101516135ad60c084018215159052565b5060e0810151612c3e60e084018215159052565b61014081016135d08285613549565b825160ff16610100830152602083015163ffffffff16610120830152610f79565b61010081016111d38284613549565b6020808252825182820181905260009190848201906040850190845b8181101561330c5761362f838551613549565b92840192610100929092019160010161361c565b60008060006040848603121561365857600080fd5b83356001600160401b0381111561366e57600080fd5b61367a86828701613248565b909790965060209590950135949350505050565b6001600160a01b03811681146136a357600080fd5b50565b6000602082840312156136b857600080fd5b8135610f798161368e565b815160ff16815260208083015163ffffffff1690820152604081016111d3565b6000602082840312156136f557600080fd5b8151610f798161368e565b634e487b7160e01b600052604160045260246000fd5b60405161010081016001600160401b038111828210171561373957613739613700565b60405290565b604051606081016001600160401b038111828210171561373957613739613700565b604051601f8201601f191681016001600160401b038111828210171561378957613789613700565b604052919050565b60006001600160401b038211156137aa576137aa613700565b5060051b60200190565b61ffff811681146136a357600080fd5b80516137cf816137b4565b919050565b6001600160901b03811681146136a357600080fd5b80516137cf816137d4565b63ffffffff811681146136a357600080fd5b80516137cf816137f4565b80151581146136a357600080fd5b80516137cf81613811565b6000602080838503121561383d57600080fd5b82516001600160401b0381111561385357600080fd5b8301601f8101851361386457600080fd5b805161387761387282613791565b613761565b81815260089190911b8201830190838101908783111561389657600080fd5b928401925b828410156139525761010084890312156138b55760008081fd5b6138bd613716565b84516138c8816137b4565b81526138d58587016137c4565b8682015260406138e68187016137e9565b9082015260606138f7868201613806565b9082015260806139088682016137c4565b9082015260a06139198682016137c4565b9082015260c061392a86820161381f565b9082015260e061393b86820161381f565b90820152825261010093909301929084019061389b565b979650505050505050565b60006020828403121561396f57600080fd5b5051919050565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561399e57600080fd5b81516001600160401b03808211156139b557600080fd5b818401915084601f8301126139c957600080fd5b8151818111156139db576139db613700565b6139ee601f8201601f1916602001613761565b9150808252856020828501011115613a0557600080fd5b613a1681602084016020860161315c565b50949350505050565b600181811c90821680613a3357607f821691505b602082108103613a5357634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115612c3e57600081815260208120601f850160051c81016020861015613a805750805b601f850160051c820191505b81811015610b9157828155600101613a8c565b81516001600160401b03811115613ab857613ab8613700565b613acc81613ac68454613a1f565b84613a59565b602080601f831160018114613b015760008415613ae95750858301515b600019600386901b1c1916600185901b178555610b91565b600085815260208120601f198616915b82811015613b3057888601518255948401946001909101908401613b11565b5085821015613b4e5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052601160045260246000fd5b600060018201613b8657613b86613b5e565b5060010190565b60ff811681146136a357600080fd5b600060408284031215613bae57600080fd5b604051604081018181106001600160401b0382111715613bd057613bd0613700565b6040528251613bde81613b8d565b81526020830151613bee816137f4565b60208201529392505050565b818103818111156111d3576111d3613b5e565b600060208284031215613c1f57600080fd5b8151610f7981613811565b60208082526026908201527f43616c6c6572206973206e6f7420616e2061647669736f727920626f6172642060408201526536b2b6b132b960d11b606082015260800190565b60006020808385031215613c8357600080fd5b82516001600160401b03811115613c9957600080fd5b8301601f81018513613caa57600080fd5b8051613cb861387282613791565b81815260609182028301840191848201919088841115613cd757600080fd5b938501935b83851015613d3c5780858a031215613cf45760008081fd5b613cfc61373f565b8551613d078161368e565b815285870151613d1681613811565b81880152604086810151613d2981613811565b9082015283529384019391850191613cdc565b50979650505050505050565b6000823561017e19833603018112613d5f57600080fd5b9190910192915050565b600060208284031215613d7b57600080fd5b8135610f79816137b4565b600060208284031215613d9857600080fd5b8135610f79816137f4565b6000808335601e19843603018112613dba57600080fd5b8301803591506001600160401b03821115613dd457600080fd5b6020019150600581901b360382131561328c57600080fd5b6000808335601e19843603018112613e0357600080fd5b8301803591506001600160401b03821115613e1d57600080fd5b60200191503681900382131561328c57600080fd5b6001600160401b03831115613e4957613e49613700565b613e5d83613e578354613a1f565b83613a59565b6000601f841160018114613e915760008515613e795750838201355b600019600387901b1c1916600186901b178355613eeb565b600083815260209020601f19861690835b82811015613ec25786850135825560209485019460019092019101613ea2565b5086821015613edf5760001960f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b600081356111d3816137b4565b600081356111d3816137d4565b600081356111d3816137f4565b600081356111d381613811565b8135613f31816137b4565b61ffff8116905081548161ffff1982161783556020840135613f52816137b4565b63ffff00008160101b168363ffffffff19841617178455505050613fb9613f7b60408401613eff565b825475ffffffffffffffffffffffffffffffffffff00000000191660209190911b75ffffffffffffffffffffffffffffffffffff0000000016178255565b613fec613fc860608401613f0c565b82805463ffffffff60b01b191660b09290921b63ffffffff60b01b16919091179055565b61401b613ffb60808401613ef2565b82805461ffff60d01b191660d09290921b61ffff60d01b16919091179055565b61404a61402a60a08401613ef2565b82805461ffff60e01b191660e09290921b61ffff60e01b16919091179055565b61407761405960c08401613f19565b82805460ff60f01b191691151560f01b60ff60f01b16919091179055565b6140aa61408660e08401613f19565b8280546001600160f81b031691151560f81b6001600160f81b031916919091179055565b5050565b6000602082840312156140c057600080fd5b8135610f7981613811565b80356001600160601b03811681146137cf57600080fd5b6000608082840312156140f457600080fd5b604051608081018181106001600160401b038211171561411657614116613700565b60405282358152602083013561412b81613b8d565b602082015261413c604084016140cb565b604082015261414d606084016140cb565b60608201529392505050565b8183823760009101908152919050565b60008235609e19833603018112613d5f57600080fd5b813561418a81613b8d565b60ff8116905081548160ff19821617835560208401356141a9816137f4565b64ffffffff008160081b168364ffffffffff19841617178455505050505056fed9d16d34ffb15ba3a3d852f0d403e2ce1d691fb54de27ac87cd2f993f3ec330fa2646970667358221220058d0cc82abfff733d233a23d27fc86e6d499fd40e56ecdab2d4b2e6a28eac3b64736f6c63430008120033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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.