Sonic Blaze Testnet

Contract

0x8f53ebd8d3c25a57B69F9E102524df8D53e88623

Overview

S Balance

Sonic Blaze LogoSonic Blaze LogoSonic Blaze Logo0 S

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

2 Internal Transactions found.

Latest 2 internal transactions

Parent Transaction Hash Block From To
229427222025-02-25 12:06:0914 days ago1740485169
0x8f53ebd8...D53e88623
0 S
229427222025-02-25 12:06:0914 days ago1740485169
0x8f53ebd8...D53e88623
0 S
Loading...
Loading

Similar Match Source Code
This contract matches the deployed Bytecode of the Source Code for Contract 0xB23463E2...5b7bdE503
The constructor portion of the code might be different and could alter the actual behaviour of the contract

Contract Name:
YieldTokenIncidents

Compiler Version
v0.8.18+commit.87f61d96

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 27 : YieldTokenIncidents.sol
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity ^0.8.18;

import "@openzeppelin/contracts-v4/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts-v4/token/ERC20/extensions/draft-IERC20Permit.sol";
import "@openzeppelin/contracts-v4/token/ERC20/utils/SafeERC20.sol";

import "../../abstract/MasterAwareV2.sol";
import "../../interfaces/IAssessment.sol";
import "../../interfaces/ICover.sol";
import "../../interfaces/ICoverNFT.sol";
import "../../interfaces/ICoverProducts.sol";
import "../../interfaces/ISAFURAToken.sol";
import "../../interfaces/IPool.sol";
import "../../interfaces/IYieldTokenIncidents.sol";
import "../../interfaces/IRamm.sol";
import "../../libraries/Math.sol";
import "../../libraries/SafeUintCast.sol";

/// Allows cover owners to redeem payouts from yield token depeg incidents. It is an entry point
/// to the assessment process where the members of the mutual decides the validity of the
/// submitted incident. At the moment incidents can only be submitted by the Advisory Board members
/// while all members are allowed to vote through Assessment.sol.
contract YieldTokenIncidents is IYieldTokenIncidents, MasterAwareV2 {

  // Ratios are defined between 0-10000 bps (i.e. double decimal precision percentage)
  uint internal constant REWARD_DENOMINATOR = 10000;
  uint internal constant INCIDENT_EXPECTED_PAYOUT_DENOMINATOR = 10000;
  uint internal constant INCIDENT_PAYOUT_DEDUCTIBLE_DENOMINATOR = 10000;

  // Used in operations involving NXM tokens and divisions
  uint internal constant PRECISION = 10 ** 18;

  ISAFURAToken public immutable nxm;

  ICoverNFT public immutable coverNFT;

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

  Configuration public override config;

  Incident[] public override incidents;

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

  address constant public ETH = 0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38; // 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
  uint constant public ETH_ASSET_ID = 0;

  /* ========== CONSTRUCTOR ========== */

  constructor(address nxmAddress, address coverNFTAddress) {
    nxm = ISAFURAToken(nxmAddress);
    coverNFT = ICoverNFT(coverNFTAddress);
  }

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

  /// @dev Returns the number of incidents.
  function getIncidentsCount() external override view returns (uint) {
    return incidents.length;
  }

  function getIncidentDisplay(uint id) internal view returns (IncidentDisplay memory) {
    Incident memory incident = incidents[id];
    (IAssessment.Poll memory poll,,) = assessment().assessments(incident.assessmentId);

    IncidentStatus incidentStatus;

    (,,uint payoutCooldownInDays,) = assessment().config();
    uint redeemableUntil = poll.end + (payoutCooldownInDays + config.payoutRedemptionPeriodInDays) * 1 days;

    // Determine the incidents status
    if (block.timestamp < poll.end) {
      incidentStatus = IncidentStatus.PENDING;
    } else if (poll.accepted > poll.denied) {
      if (block.timestamp > redeemableUntil) {
        incidentStatus = IncidentStatus.EXPIRED;
      } else {
        incidentStatus = IncidentStatus.ACCEPTED;
      }
    } else {
      incidentStatus = IncidentStatus.DENIED;
    }


    return IncidentDisplay(
      id,
      incident.productId,
      incident.priceBefore,
      incident.date,
      poll.start,
      poll.end,
      redeemableUntil,
      uint(incidentStatus)
    );
  }

  /// Returns an array of incidents aggregated in a human-friendly format.
  ///
  /// @dev This view is meant to be used in user interfaces to get incidents in a format suitable
  /// for displaying all relevant information in as few calls as possible. It can be used to
  /// paginate incidents by providing the following parameters:
  ///
  /// @param ids   Array of Incident ids which are returned as IncidentDisplay
  function getIncidentsToDisplay (uint104[] calldata ids)
  external view returns (IncidentDisplay[] memory) {
    IncidentDisplay[] memory incidentDisplays = new IncidentDisplay[](ids.length);
    for (uint i = 0; i < ids.length; i++) {
      uint104 id = ids[i];
      incidentDisplays[i] = getIncidentDisplay(id);
    }
    return incidentDisplays;
  }

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

  /// Submits an incident for assessment
  ///
  /// @param productId            Product identifier on which the incident occured
  /// @param priceBefore          The price of the token before the incident
  /// @param priceBefore          The price of the token before the incident
  /// @param date                 The date the incident occured
  /// @param expectedPayoutInNXM  The date the incident occured
  /// @param ipfsMetadata         An IPFS hash that stores metadata about the incident that is
  ///                             emitted as an event.
  function submitIncident(
    uint24 productId,
    uint96 priceBefore,
    uint32 date,
    uint expectedPayoutInNXM,
    string calldata ipfsMetadata
  ) external override onlyGovernance whenNotPaused {

    ICoverProducts coverProductsContract = coverProducts();
    (, ProductType memory productType) = coverProductsContract.getProductWithType(productId);

    require(
      productType.claimMethod == uint8(ClaimMethod.YieldTokenIncidents),
      "Invalid claim method for this product type"
    );

    // Determine the total rewards that should be minted for the assessors based on cover period
    uint totalReward = Math.min(
      uint(config.maxRewardInNXMWad) * PRECISION,
      expectedPayoutInNXM * uint(config.rewardRatio) / REWARD_DENOMINATOR
    );
    uint incidentId = incidents.length;
    uint80 assessmentId = SafeUintCast.toUint80(assessment().startAssessment(totalReward, 0));

    incidents.push(Incident(assessmentId, productId, date, priceBefore));

    if (bytes(ipfsMetadata).length > 0) {
      emit MetadataSubmitted(incidentId, ipfsMetadata);
    }

    emit IncidentSubmitted(msg.sender, incidentId, productId, expectedPayoutInNXM);
  }

  /// Redeems payouts for eligible covers matching an accepted incident
  ///
  /// @dev The function must be called during the redemption period.
  ///
  /// @param incidentId      Index of the incident
  /// @param coverId         Index of the cover to be redeemed
  /// @param segmentId       Index of the cover's segment that's elidgible for redemption
  /// @param depeggedTokens  The amount of depegged tokens to be swapped for the coverAsset
  /// @param payoutAddress   The addres where the payout must be sent to
  /// @param optionalParams  (Optional) Reserved for permit data which is still in draft phase.
  ///                        For tokens that already support it, use it by encoding the following
  ///                        values in this exact order: address owner, address spender,
  ///                        uint256 value, uint256 deadline, uint8 v , bytes32 r, bytes32 s
  function redeemPayout(
    uint104 incidentId,
    uint32 coverId,
    uint segmentId,
    uint depeggedTokens,
    address payable payoutAddress,
    bytes calldata optionalParams
  ) external override onlyMember whenNotPaused returns (uint, uint8) {
    require(
      coverNFT.isApprovedOrOwner(msg.sender, coverId),
      "Only the cover owner or approved addresses can redeem"
    );

    ICover coverContract = ICover(getInternalContractAddress(ID.CO));
    CoverData memory coverData = coverContract.coverData(coverId);
    Product memory product = coverProducts().getProduct(coverData.productId);

    uint payoutAmount;
    {
      CoverSegment memory coverSegment = coverContract.coverSegmentWithRemainingAmount(coverId, segmentId);

      require(
        coverSegment.start + coverSegment.period + coverSegment.gracePeriod >= block.timestamp,
        "Grace period has expired"
      );

      Incident memory incident =  incidents[incidentId];

      {
        IAssessment.Poll memory poll = assessment().getPoll(incident.assessmentId);

        require(
          poll.accepted > poll.denied,
          "The incident needs to be accepted"
        );

        (,,uint8 payoutCooldownInDays,) = assessment().config();
        require(
          block.timestamp >= poll.end + payoutCooldownInDays * 1 days,
          "The voting and cooldown periods must end"
        );

        require(
          block.timestamp < poll.end +
          payoutCooldownInDays * 1 days +
          config.payoutRedemptionPeriodInDays * 1 days,
          "The redemption period has expired"
        );
      }

      require(
        coverSegment.start + coverSegment.period >= incident.date,
        "Cover ended before the incident"
      );

      require(coverSegment.start < incident.date, "Cover started after the incident");

      require(coverData.productId == incident.productId, "Product id mismatch");

      require(block.timestamp > coverSegment.start, "Cannot buy cover and submit claim in the same block");

      // Calculate the payout amount
      {
        uint deductiblePriceBefore =
          uint(incident.priceBefore)
          * config.payoutDeductibleRatio
          / INCIDENT_PAYOUT_DEDUCTIBLE_DENOMINATOR;

        uint coverAssetDecimals;

        // ETH doesn't have a price feed oracle
        if (coverData.coverAsset == ETH_ASSET_ID) {
          coverAssetDecimals = 18;
        } else {
          IPool _pool = pool();
          address assetAddress = _pool.getAsset(coverData.coverAsset).assetAddress;
          (/* aggregator */, coverAssetDecimals) = _pool.priceFeedOracle().assets(assetAddress);
        }

        payoutAmount = depeggedTokens * deductiblePriceBefore / (10 ** coverAssetDecimals);
      }

      require(payoutAmount <= coverSegment.amount, "Payout exceeds covered amount");
    }

    ramm().updateTwap();
    coverContract.burnStake(coverId, segmentId, payoutAmount);

    if (optionalParams.length > 0) { // Skip the permit call when it is not provided
      (
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
      ) = abi.decode(optionalParams, (address, address, uint256, uint256, uint8, bytes32, bytes32));

      if (spender != address(0)) {
        IERC20Permit(product.yieldTokenAddress).permit(owner, spender, value, deadline, v, r, s);
      }
    }

    SafeERC20.safeTransferFrom(
      IERC20(product.yieldTokenAddress),
      msg.sender,
      address(this),
      depeggedTokens
    );

    IPool(internalContracts[uint(IMasterAwareV2.ID.P1)]).sendPayout(
      coverData.coverAsset,
      payoutAddress,
      payoutAmount,
      0 // deposit
    );

    emit IncidentPayoutRedeemed(msg.sender, payoutAmount, incidentId, coverId);

    return (payoutAmount, coverData.coverAsset);
  }

  /// Withdraws an amount of any asset held by this contract to a destination address.
  ///
  /// @param asset        The ERC20 address of the asset that needs to be withdrawn.
  /// @param destination  The address where the assets are transfered.
  /// @param amount       The amount of assets that are need to be transfered.
  function withdrawAsset(
    address asset,
    address destination,
    uint amount
  ) external onlyGovernance {
    IERC20 token = IERC20(asset);
    uint balance = token.balanceOf(address(this));
    uint transferAmount = amount > balance ? balance : amount;
    SafeERC20.safeTransfer(token, destination, transferAmount);
  }

  /// Updates configurable parameters through governance
  ///
  /// @param paramNames  An array of elements from UintParams enum
  /// @param values      An array of the new values, each one corresponding to the parameter
  ///                    from paramNames on the same position.
  function updateUintParameters(
    UintParams[] calldata paramNames,
    uint[] calldata values
  ) external override onlyGovernance {
    Configuration memory newConfig = config;
    for (uint i = 0; i < paramNames.length; i++) {
      if (paramNames[i] == UintParams.payoutRedemptionPeriodInDays) {
        newConfig.payoutRedemptionPeriodInDays = uint8(values[i]);
        continue;
      }
      if (paramNames[i] == UintParams.payoutDeductibleRatio) {
        newConfig.payoutDeductibleRatio = uint16(values[i]);
        continue;
      }
      if (paramNames[i] == UintParams.maxRewardInNXMWad) {
        newConfig.maxRewardInNXMWad = uint16(values[i]);
        continue;
      }
      if (paramNames[i] == UintParams.rewardRatio) {
        newConfig.rewardRatio = uint16(values[i]);
        continue;
      }
    }
    config = newConfig;
  }

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

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

  function coverProducts() internal view returns (ICoverProducts) {
    return ICoverProducts(internalContracts[uint(ID.CP)]);
  }

  function assessment() internal view returns (IAssessment) {
    return IAssessment(internalContracts[uint(ID.AS)]);
  }

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

  function ramm() internal view returns (IRamm) {
    return IRamm(internalContracts[uint(ID.RA)]);
  }

  /// @dev Updates internal contract addresses to the ones stored in master. This function is
  /// automatically called by the master contract when a contract is added or upgraded.
  function changeDependentContractAddress() external override {
    internalContracts[uint(ID.TC)] = master.getLatestAddress("TC");
    internalContracts[uint(ID.MR)] = master.getLatestAddress("MR");
    internalContracts[uint(ID.P1)] = master.getLatestAddress("P1");
    internalContracts[uint(ID.CO)] = master.getLatestAddress("CO");
    internalContracts[uint(ID.AS)] = master.getLatestAddress("AS");
    internalContracts[uint(ID.RA)] = master.getLatestAddress("RA");
    internalContracts[uint(ID.CP)] = master.getLatestAddress("CP");

    Configuration memory currentConfig = config;
    bool notInitialized = bytes32(
      abi.encodePacked(
        currentConfig.rewardRatio,
        currentConfig.payoutDeductibleRatio,
        currentConfig.payoutRedemptionPeriodInDays,
        currentConfig.maxRewardInNXMWad
      )
    ) == bytes32(0);

    if (notInitialized) {
      config.rewardRatio = 130; // 1.3%
      config.payoutDeductibleRatio = 9000; // 90%
      config.payoutRedemptionPeriodInDays = 30; // days to redeem the payout
      config.maxRewardInNXMWad = 50; // 50 NXM
    }
  }

}

File 2 of 27 : 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 3 of 27 : 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 4 of 27 : 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 5 of 27 : 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 6 of 27 : 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 7 of 27 : 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 8 of 27 : MasterAwareV2.sol
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity ^0.8.18;

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

abstract contract MasterAwareV2 is IMasterAwareV2 {

  ISAFURAMaster 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 = ISAFURAMaster(masterAddress);
  }

}

File 9 of 27 : IAssessment.sol
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity >=0.5.0;

interface IAssessment {

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

  enum UintParams {
    minVotingPeriodInDays,
    stakeLockupPeriodInDays,
    payoutCooldownInDays,
    silentEndingPeriodInDays
  }

  struct Configuration {
    // The minimum number of days the users can vote on polls
    uint8 minVotingPeriodInDays;

    // Number of days the users must wait from their last vote to withdraw their stake.
    uint8 stakeLockupPeriodInDays;

    // Number of days the users must wait after a poll closes to redeem payouts.
    uint8 payoutCooldownInDays;

    // Number of days representing the silence period. It is used to extend a poll's end date when
    // a vote is cast during the silence period before the end date.
    uint8 silentEndingPeriodInDays;
  }

  struct Stake {
    uint96 amount;
    uint104 rewardsWithdrawableFromIndex;
    uint16 fraudCount;
    /*uint32 unused,*/
  }

  // Holds data for a vote belonging to an assessor.
  //
  // The structure is used to keep track of user's votes. Each vote is used to determine
  // a user's share of rewards or to create a fraud resolution which excludes fraudulent votes
  // from the initial poll.
  struct Vote {
    // Identifier of the claim or incident
    uint80 assessmentId;

    // If the assessor votes to accept the event it's true otherwise it's false
    bool accepted;

    // Date and time when the vote was cast
    uint32 timestamp;

    // How many tokens were staked when the vote was cast
    uint96 stakedAmount;
  }

  // Holds poll results for an assessment.
  //
  // The structure is used to keep track of all votes on a given assessment such as how many NXM were
  // used to cast accept and deny votes as well as when the poll started and when it ends.
  struct Poll {
    // The amount of NXM from accept votes
    uint96 accepted;

    // The amount of NXM from deny votes
    uint96 denied;

    // Timestamp of when the poll started.
    uint32 start;

    // Timestamp of when the poll ends.
    uint32 end;
  }

  // Holds data for an assessment belonging to an assessable event (individual claims, yield token
  // incidents etc.).
  //
  // The structure is used to keep track of the total reward that should be distributed to
  // assessors, the assessment deposit the claimants made to start the assessment, and the poll
  // coresponding to this assessment.
  struct Assessment {
    // See Poll struct
    Poll poll;

    // The amount of NXM representing the assessment reward which is split among those who voted.
    uint128 totalRewardInNXM;

    // An amount of ETH which is sent back to the claimant when the poll result is positive,
    // otherwise it is kep it the pool to back the assessment rewards. This allows claimants to
    // open an unlimited amount of claims and prevents unbacked NXM to be minted through the
    // assessment process.
    uint128 assessmentDepositInETH;
  }

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

  function getAssessmentsCount() external view returns (uint);

  function assessments(uint id) external view
  returns (Poll memory poll, uint128 totalReward, uint128 assessmentDeposit);

  function getPoll(uint assessmentId) external view returns (Poll memory);

  function getRewards(address user) external view returns (
    uint totalPendingAmount,
    uint withdrawableAmount,
    uint withdrawableUntilIndex
  );

  function getVoteCountOfAssessor(address assessor) external view returns (uint);

  function votesOf(address user, uint id) external view
  returns (uint80 assessmentId, bool accepted, uint32 timestamp, uint96 stakedAmount);

  function stakeOf(address user) external view
  returns (uint96 amount, uint104 rewardsWithdrawableFromIndex, uint16 fraudCount);

  function config() external view returns (
    uint8 minVotingPeriodInDays,
    uint8 stakeLockupPeriodInDays,
    uint8 payoutCooldownInDays,
    uint8 silentEndingPeriodInDays
  );

  function hasAlreadyVotedOn(address voter, uint pollId) external view returns (bool);


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

  function stake(uint96 amount) external;

  function unstake(uint96 amount, address to) external;

  function withdrawRewards(
    address user,
    uint104 batchSize
  ) external returns (uint withdrawn, uint withdrawnUntilIndex);

  function withdrawRewardsTo(
    address destination,
    uint104 batchSize
  ) external returns (uint withdrawn, uint withdrawnUntilIndex);

  function startAssessment(uint totalReward, uint assessmentDeposit) external
  returns (uint);

  function castVotes(
    uint[] calldata assessmentIds,
    bool[] calldata votes,
    string[] calldata ipfsAssessmentDataHashes,
    uint96 stakeIncrease
  ) external;

  function submitFraud(bytes32 root) external;

  function processFraud(
    uint256 rootIndex,
    bytes32[] calldata proof,
    address assessor,
    uint256 lastFraudulentVoteIndex,
    uint96 burnAmount,
    uint16 fraudCount,
    uint256 voteBatchSize
  ) external;

  function updateUintParameters(UintParams[] calldata paramNames, uint[] calldata values) external;

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

  event StakeDeposited(address user, uint104 amount);
  event StakeWithdrawn(address indexed user, address to, uint96 amount);
  event VoteCast(address indexed user, uint256 assessmentId, uint96 stakedAmount, bool accepted, string ipfsAssessmentDataHash);
  event RewardWithdrawn(address user, address to, uint256 amount);
  event FraudProcessed(uint assessmentId, address assessor, Poll poll);
  event FraudSubmitted(bytes32 root);

}

File 10 of 27 : 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 11 of 27 : 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 getGlobalMinPriceRatio() external pure returns (uint);

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

  function GLOBAL_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 changeStakingPoolFactoryOperator() external;

  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();
}

File 12 of 27 : 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 13 of 27 : 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;
  address yieldTokenAddress;
  // 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 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 InitialPriceRatioBelowGlobalMinPriceRatio();
  error InitialPriceRatioAbove100Percent();
  error CapacityReductionRatioAbove100Percent();

}

File 14 of 27 : 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
    GW, // LegacyGateway.sol - removed
    CL, // CoverMigrator.sol - removed
    AS, // Assessment.sol
    CI, // IndividualClaims.sol - Claims for Individuals
    CG, // YieldTokenIncidents.sol - Claims for Groups
    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 15 of 27 : IMemberRoles.sol
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity >=0.5.0;

interface IMemberRoles {

  enum Role {Unassigned, AdvisoryBoard, Member, Owner, Auditor}

  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 16 of 27 : 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 {

  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 setSwapValue(uint value) external;
}

File 17 of 27 : 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 {

  struct OracleAsset {
    Aggregator aggregator;
    uint8 decimals;
  }

  function ETH() external view returns (address);
  function assets(address) external view returns (Aggregator, 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);

}

File 18 of 27 : IRamm.sol
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity >=0.5.0;

import "./IPool.sol";
import "./ISAFURAToken.sol";
import "./ITokenController.sol";

interface IRamm {

  // storage structs

  struct Slot0 {
    uint128 nxmReserveA;
    uint128 nxmReserveB;
  }

  struct Slot1 {
    uint128 ethReserve;
    uint88 budget;
    uint32 updatedAt;
    bool swapPaused; // emergency pause
  }

  struct Observation {
    uint32 timestamp;
    uint112 priceCumulativeAbove;
    uint112 priceCumulativeBelow;
  }

  // memory structs

  struct State {
    uint nxmA;
    uint nxmB;
    uint eth;
    uint budget;
    uint ratchetSpeedB;
    uint timestamp;
  }

  struct Context {
    uint capital;
    uint supply;
    uint mcr;
  }

  struct CumulativePriceCalculationProps {
    uint previousEthReserve;
    uint currentEthReserve;
    uint previousNxmA;
    uint currentNxmA;
    uint previousNxmB;
    uint currentNxmB;
    uint previousTimestamp;
    uint observationTimestamp;
  }

  struct CumulativePriceCalculationTimes {
    uint secondsUntilBVAbove;
    uint secondsUntilBVBelow;
    uint timeElapsed;
    uint bvTimeBelow;
    uint bvTimeAbove;
    uint ratchetTimeAbove;
    uint ratchetTimeBelow;
  }

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

  function getReserves() external view returns (
    uint ethReserve,
    uint nxmA,
    uint nxmB,
    uint remainingBudget
  );

  function getSpotPrices() external view returns (uint spotPriceA, uint spotPriceB);

  function getBookValue() external view returns (uint bookValue);

  function getInternalPrice() external view returns (uint internalPrice);

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

  function updateTwap() external;

  function getInternalPriceAndUpdateTwap() external returns (uint internalPrice);

  function swap(uint nxmIn, uint minAmountOut, uint deadline) external payable returns (uint amountOut);

  function removeBudget() external;

  function setEmergencySwapPause(bool _swapPaused) external;

  /* ========== EVENTS AND ERRORS ========== */

  event EthSwappedForNxm(address indexed member, uint ethIn, uint nxmOut);
  event NxmSwappedForEth(address indexed member, uint nxmIn, uint ethOut);
  event ObservationUpdated(uint32 timestamp, uint112 priceCumulativeAbove, uint112 priceCumulativeBelow);
  event BudgetRemoved();
  event SwapPauseConfigured(bool paused);
  event EthInjected(uint value);
  event EthExtracted(uint value);

  // Pause
  error SystemPaused();
  error SwapPaused();

  // Input
  error OneInputOnly();
  error OneInputRequired();

  // Expiry
  error SwapExpired(uint deadline, uint blockTimestamp);

  // Insufficient amount out
  error InsufficientAmountOut(uint amountOut, uint minAmountOut);

  // Buffer Zone
  error NoSwapsInBufferZone();

  // ETH Transfer
  error EthTransferFailed();

  // Circuit breakers
  error EthCircuitBreakerHit();
  error NxmCircuitBreakerHit();
}

File 19 of 27 : ISAFURAMaster.sol
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity >=0.5.0;

interface ISAFURAMaster {

  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 20 of 27 : ISAFURAToken.sol
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity >=0.5.0;

interface ISAFURAToken {

  function burn(uint256 amount) external returns (bool);

  function burnFrom(address from, uint256 value) external returns (bool);

  function operatorTransfer(address from, uint256 value) external returns (bool);

  function mint(address account, uint256 amount) external;

  function isLockedForMV(address member) external view returns (uint);

  function whiteListed(address member) external view returns (bool);

  function addToWhiteList(address _member) external returns (bool);

  function removeFromWhiteList(address _member) external returns (bool);

  function changeOperator(address _newOperator) external returns (bool);

  function lockForMemberVote(address _of, uint _days) external;

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

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

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

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

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

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

  /**
   * @dev Emitted when `value` tokens are moved from one account (`from`) to
   * another (`to`).
   *
   * Note that `value` may be zero.
   */
  event Transfer(address indexed from, address indexed to, uint256 value);

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

File 21 of 27 : 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 27 : 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 globalMinPrice;
}

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;
  }

  function initialize(
    bool isPrivatePool,
    uint initialPoolFee,
    uint maxPoolFee,
    uint _poolId,
    string memory ipfsDescriptionHash
  ) 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 PoolDescriptionSet(string ipfsDescriptionHash);

  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 27 : 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 27 : ITokenController.sol
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity >=0.5.0;

import "./ISAFURAToken.sol";

interface ITokenController {

  struct StakingPoolNXMBalances {
    uint128 rewards;
    uint128 deposits;
  }

  struct CoverInfo {
    uint16 claimCount;
    bool hasOpenClaim;
    bool hasAcceptedClaim;
    uint96 requestedPayoutAmount;
    // note: still 128 bits available here, can be used later
  }

  struct StakingPoolOwnershipOffer {
    address proposedManager;
    uint96 deadline;
  }

  function coverInfo(uint id) external view returns (
    uint16 claimCount,
    bool hasOpenClaim,
    bool hasAcceptedClaim,
    uint96 requestedPayoutAmount
  );

  function withdrawCoverNote(
    address _of,
    uint[] calldata _coverIds,
    uint[] calldata _indexes
  ) external;

  function changeOperator(address _newOperator) external;

  function operatorTransfer(address _from, address _to, uint _value) external returns (bool);

  function burnFrom(address _of, uint amount) external returns (bool);

  function addToWhitelist(address _member) external;

  function removeFromWhitelist(address _member) external;

  function mint(address _member, uint _amount) external;

  function lockForMemberVote(address _of, uint _days) external;

  function withdrawClaimAssessmentTokens(address[] calldata users) external;

  function getLockReasons(address _of) external view returns (bytes32[] memory reasons);

  function totalSupply() external view returns (uint);

  function totalBalanceOf(address _of) external view returns (uint amount);

  function totalBalanceOfWithoutDelegations(address _of) external view returns (uint amount);

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

  function token() external view returns (ISAFURAToken);

  function getStakingPoolManager(uint poolId) external view returns (address manager);

  function getManagerStakingPools(address manager) external view returns (uint[] memory poolIds);

  function isStakingPoolManager(address member) external view returns (bool);

  function getStakingPoolOwnershipOffer(uint poolId) external view returns (address proposedManager, uint deadline);

  function transferStakingPoolsOwnership(address from, address to) external;

  function assignStakingPoolManager(uint poolId, address manager) external;

  function createStakingPoolOwnershipOffer(uint poolId, address proposedManager, uint deadline) external;

  function acceptStakingPoolOwnershipOffer(uint poolId) external;

  function cancelStakingPoolOwnershipOffer(uint poolId) external;

  function mintStakingPoolNXMRewards(uint amount, uint poolId) external;

  function burnStakingPoolNXMRewards(uint amount, uint poolId) external;

  function depositStakedNXM(address from, uint amount, uint poolId) external;

  function withdrawNXMStakeAndRewards(address to, uint stakeToWithdraw, uint rewardsToWithdraw, uint poolId) external;

  function burnStakedNXM(uint amount, uint poolId) external;

  function stakingPoolNXMBalances(uint poolId) external view returns(uint128 rewards, uint128 deposits);

  function tokensLocked(address _of, bytes32 _reason) external view returns (uint256 amount);

  function getWithdrawableCoverNotes(
    address coverOwner
  ) external view returns (
    uint[] memory coverIds,
    bytes32[] memory lockReasons,
    uint withdrawableAmount
  );

  function getPendingRewards(address member) external view returns (uint);
}

File 25 of 27 : IYieldTokenIncidents.sol
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity >=0.5.0;

interface IYieldTokenIncidents {

  enum IncidentStatus { PENDING, ACCEPTED, DENIED, EXPIRED }

  enum UintParams {
    payoutRedemptionPeriodInDays,
    expectedPayoutRatio,
    payoutDeductibleRatio,
    maxRewardInNXMWad,
    rewardRatio
  }

  struct Configuration {
    // Number of days in which payouts can be redeemed
    uint8 payoutRedemptionPeriodInDays;

    // Ratio used to calculate potential payout of an incident
    // (0-10000 bps i.e. double decimal precision)
    uint16 expectedPayoutRatio;

    // Ratio used to determine the deductible payout (0-10000 bps i.e. double decimal precision)
    uint16 payoutDeductibleRatio;

    // An amount of NXM representing the maximum reward amount given for any claim assessment.
    uint16 maxRewardInNXMWad;

    // Ratio used to calculate assessment rewards (0-10000 i.e. double decimal precision)
    uint16 rewardRatio;
  }

  struct Incident {
    uint80 assessmentId;

    // Product identifier
    uint24 productId;

    // Timestamp marking the date of the incident used to verify the user's eligibility for a claim
    // according to their cover period.
    uint32 date;

    // The price of the depegged token before the incident that resulted in the depeg.
    uint96 priceBefore;
  }

  struct IncidentDisplay {
    uint id;
    uint productId;
    uint priceBefore;
    uint incidentDate;
    uint pollStart;
    uint pollEnd;
    uint redeemableUntil;
    uint status;
  }

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

  function config() external view returns (
    uint8 payoutRedemptionPeriodInDays,
    uint16 expectedPayoutRatio,
    uint16 payoutDeductibleRatio,
    uint16 maxRewardInNXMWad,
    uint16 rewardRatio
  );

  function incidents(uint id) external view
  returns (uint80 assessmentId, uint24 productId, uint32 date, uint96 priceBefore);

  function getIncidentsCount() external view returns (uint);

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

  function submitIncident(
    uint24 productId,
    uint96 priceBefore,
    uint32 date,
    uint expectedPayoutInNXM,
    string calldata ipfsMetadata
  ) external;

  function redeemPayout(
    uint104 incidentId,
    uint32 coverId,
    uint segmentId,
    uint depeggedTokens,
    address payable payoutAddress,
    bytes calldata optionalParams
  ) external returns (uint payoutAmount, uint8 coverAsset);

  function updateUintParameters(UintParams[] calldata paramNames, uint[] calldata values) external;

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

  event IncidentSubmitted(address user, uint incidentId, uint productId, uint expectedPayoutInNXM);
  event MetadataSubmitted(uint indexed incidentId, string ipfsMetadata);
  event IncidentPayoutRedeemed(address indexed user, uint amount, uint incidentId, uint coverId);

}

File 26 of 27 : Math.sol
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity ^0.8.18;

/**
 * @dev Simple library that defines min, max and babylonian sqrt functions
 */
library Math {

  function min(uint a, uint b) internal pure returns (uint) {
    return a < b ? a : b;
  }

  function max(uint a, uint b) internal pure returns (uint) {
    return a > b ? a : b;
  }

  function sum(uint[] memory items) internal pure returns (uint) {
    uint count = items.length;
    uint total;

    for (uint i = 0; i < count; i++) {
      total += items[i];
    }

    return total;
  }

  function divRound(uint a, uint b) internal pure returns (uint) {
    return (a + b / 2) / b;
  }

  function divCeil(uint a, uint b) internal pure returns (uint) {
    return (a + b - 1) / b;
  }

  function roundUp(uint a, uint b) internal pure returns (uint) {
    return divCeil(a, b) * b;
  }

  // babylonian method
  function sqrt(uint y) internal pure returns (uint) {

    if (y > 3) {
      uint z = y;
      uint x = y / 2 + 1;
      while (x < z) {
        z = x;
        x = (y / x + x) / 2;
      }
      return z;
    }

    if (y != 0) {
      return 1;
    }

    return 0;
  }

}

File 27 of 27 : SafeUintCast.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.18;

/**
 * @dev Wrappers over Solidity's uintXX casting operators with added overflow
 * checks.
 *
 * Downcasting from uint256 in Solidity does not revert on overflow. This can
 * easily result in undesired exploitation or bugs, since developers usually
 * assume that overflows raise errors. `SafeCast` restores this intuition by
 * reverting the transaction when such an operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeUintCast {
  /**
   * @dev Returns the downcasted uint248 from uint256, reverting on
   * overflow (when the input is greater than largest uint248).
   *
   * Counterpart to Solidity's `uint248` operator.
   *
   * Requirements:
   *
   * - input must fit into 248 bits
   */
  function toUint248(uint256 value) internal pure returns (uint248) {
    require(value < 2**248, "SafeCast: value doesn\'t fit in 248 bits");
    return uint248(value);
  }

  /**
   * @dev Returns the downcasted uint240 from uint256, reverting on
   * overflow (when the input is greater than largest uint240).
   *
   * Counterpart to Solidity's `uint240` operator.
   *
   * Requirements:
   *
   * - input must fit into 240 bits
   */
  function toUint240(uint256 value) internal pure returns (uint240) {
    require(value < 2**240, "SafeCast: value doesn\'t fit in 240 bits");
    return uint240(value);
  }

  /**
   * @dev Returns the downcasted uint232 from uint256, reverting on
   * overflow (when the input is greater than largest uint232).
   *
   * Counterpart to Solidity's `uint232` operator.
   *
   * Requirements:
   *
   * - input must fit into 232 bits
   */
  function toUint232(uint256 value) internal pure returns (uint232) {
    require(value < 2**232, "SafeCast: value doesn\'t fit in 232 bits");
    return uint232(value);
  }

  /**
   * @dev Returns the downcasted uint224 from uint256, reverting on
   * overflow (when the input is greater than largest uint224).
   *
   * Counterpart to Solidity's `uint224` operator.
   *
   * Requirements:
   *
   * - input must fit into 224 bits
   */
  function toUint224(uint256 value) internal pure returns (uint224) {
    require(value < 2**224, "SafeCast: value doesn\'t fit in 224 bits");
    return uint224(value);
  }

  /**
   * @dev Returns the downcasted uint216 from uint256, reverting on
   * overflow (when the input is greater than largest uint216).
   *
   * Counterpart to Solidity's `uint216` operator.
   *
   * Requirements:
   *
   * - input must fit into 216 bits
   */
  function toUint216(uint256 value) internal pure returns (uint216) {
    require(value < 2**216, "SafeCast: value doesn\'t fit in 216 bits");
    return uint216(value);
  }

  /**
   * @dev Returns the downcasted uint208 from uint256, reverting on
   * overflow (when the input is greater than largest uint208).
   *
   * Counterpart to Solidity's `uint208` operator.
   *
   * Requirements:
   *
   * - input must fit into 208 bits
   */
  function toUint208(uint256 value) internal pure returns (uint208) {
    require(value < 2**208, "SafeCast: value doesn\'t fit in 208 bits");
    return uint208(value);
  }

  /**
   * @dev Returns the downcasted uint200 from uint256, reverting on
   * overflow (when the input is greater than largest uint200).
   *
   * Counterpart to Solidity's `uint200` operator.
   *
   * Requirements:
   *
   * - input must fit into 200 bits
   */
  function toUint200(uint256 value) internal pure returns (uint200) {
    require(value < 2**200, "SafeCast: value doesn\'t fit in 200 bits");
    return uint200(value);
  }

  /**
   * @dev Returns the downcasted uint192 from uint256, reverting on
   * overflow (when the input is greater than largest uint192).
   *
   * Counterpart to Solidity's `uint192` operator.
   *
   * Requirements:
   *
   * - input must fit into 192 bits
   */
  function toUint192(uint256 value) internal pure returns (uint192) {
    require(value < 2**192, "SafeCast: value doesn\'t fit in 192 bits");
    return uint192(value);
  }

  /**
   * @dev Returns the downcasted uint184 from uint256, reverting on
   * overflow (when the input is greater than largest uint184).
   *
   * Counterpart to Solidity's `uint184` operator.
   *
   * Requirements:
   *
   * - input must fit into 184 bits
   */
  function toUint184(uint256 value) internal pure returns (uint184) {
    require(value < 2**184, "SafeCast: value doesn\'t fit in 184 bits");
    return uint184(value);
  }

  /**
   * @dev Returns the downcasted uint176 from uint256, reverting on
   * overflow (when the input is greater than largest uint176).
   *
   * Counterpart to Solidity's `uint176` operator.
   *
   * Requirements:
   *
   * - input must fit into 176 bits
   */
  function toUint176(uint256 value) internal pure returns (uint176) {
    require(value < 2**176, "SafeCast: value doesn\'t fit in 176 bits");
    return uint176(value);
  }

  /**
   * @dev Returns the downcasted uint168 from uint256, reverting on
   * overflow (when the input is greater than largest uint168).
   *
   * Counterpart to Solidity's `uint168` operator.
   *
   * Requirements:
   *
   * - input must fit into 168 bits
   */
  function toUint168(uint256 value) internal pure returns (uint168) {
    require(value < 2**168, "SafeCast: value doesn\'t fit in 168 bits");
    return uint168(value);
  }

  /**
   * @dev Returns the downcasted uint160 from uint256, reverting on
   * overflow (when the input is greater than largest uint160).
   *
   * Counterpart to Solidity's `uint160` operator.
   *
   * Requirements:
   *
   * - input must fit into 160 bits
   */
  function toUint160(uint256 value) internal pure returns (uint160) {
    require(value < 2**160, "SafeCast: value doesn\'t fit in 160 bits");
    return uint160(value);
  }

  /**
   * @dev Returns the downcasted uint152 from uint256, reverting on
   * overflow (when the input is greater than largest uint152).
   *
   * Counterpart to Solidity's `uint152` operator.
   *
   * Requirements:
   *
   * - input must fit into 152 bits
   */
  function toUint152(uint256 value) internal pure returns (uint152) {
    require(value < 2**152, "SafeCast: value doesn\'t fit in 152 bits");
    return uint152(value);
  }

  /**
   * @dev Returns the downcasted uint144 from uint256, reverting on
   * overflow (when the input is greater than largest uint144).
   *
   * Counterpart to Solidity's `uint144` operator.
   *
   * Requirements:
   *
   * - input must fit into 144 bits
   */
  function toUint144(uint256 value) internal pure returns (uint144) {
    require(value < 2**144, "SafeCast: value doesn\'t fit in 144 bits");
    return uint144(value);
  }

  /**
   * @dev Returns the downcasted uint136 from uint256, reverting on
   * overflow (when the input is greater than largest uint136).
   *
   * Counterpart to Solidity's `uint136` operator.
   *
   * Requirements:
   *
   * - input must fit into 136 bits
   */
  function toUint136(uint256 value) internal pure returns (uint136) {
    require(value < 2**136, "SafeCast: value doesn\'t fit in 136 bits");
    return uint136(value);
  }

  /**
   * @dev Returns the downcasted uint128 from uint256, reverting on
   * overflow (when the input is greater than largest uint128).
   *
   * Counterpart to Solidity's `uint128` operator.
   *
   * Requirements:
   *
   * - input must fit into 128 bits
   */
  function toUint128(uint256 value) internal pure returns (uint128) {
    require(value < 2**128, "SafeCast: value doesn\'t fit in 128 bits");
    return uint128(value);
  }

  /**
   * @dev Returns the downcasted uint120 from uint256, reverting on
   * overflow (when the input is greater than largest uint120).
   *
   * Counterpart to Solidity's `uint120` operator.
   *
   * Requirements:
   *
   * - input must fit into 120 bits
   */
  function toUint120(uint256 value) internal pure returns (uint120) {
    require(value < 2**120, "SafeCast: value doesn\'t fit in 120 bits");
    return uint120(value);
  }

  /**
   * @dev Returns the downcasted uint112 from uint256, reverting on
   * overflow (when the input is greater than largest uint112).
   *
   * Counterpart to Solidity's `uint112` operator.
   *
   * Requirements:
   *
   * - input must fit into 112 bits
   */
  function toUint112(uint256 value) internal pure returns (uint112) {
    require(value < 2**112, "SafeCast: value doesn\'t fit in 112 bits");
    return uint112(value);
  }

  /**
   * @dev Returns the downcasted uint104 from uint256, reverting on
   * overflow (when the input is greater than largest uint104).
   *
   * Counterpart to Solidity's `uint104` operator.
   *
   * Requirements:
   *
   * - input must fit into 104 bits
   */
  function toUint104(uint256 value) internal pure returns (uint104) {
    require(value < 2**104, "SafeCast: value doesn\'t fit in 104 bits");
    return uint104(value);
  }

  /**
   * @dev Returns the downcasted uint96 from uint256, reverting on
   * overflow (when the input is greater than largest uint96).
   *
   * Counterpart to Solidity's `uint104` operator.
   *
   * Requirements:
   *
   * - input must fit into 96 bits
   */
  function toUint96(uint256 value) internal pure returns (uint96) {
    require(value < 2**96, "SafeCast: value doesn\'t fit in 96 bits");
    return uint96(value);
  }

  /**
   * @dev Returns the downcasted uint88 from uint256, reverting on
   * overflow (when the input is greater than largest uint88).
   *
   * Counterpart to Solidity's `uint104` operator.
   *
   * Requirements:
   *
   * - input must fit into 88 bits
   */
  function toUint88(uint256 value) internal pure returns (uint88) {
    require(value < 2**88, "SafeCast: value doesn\'t fit in 88 bits");
    return uint88(value);
  }

  /**
   * @dev Returns the downcasted uint80 from uint256, reverting on
   * overflow (when the input is greater than largest uint80).
   *
   * Counterpart to Solidity's `uint104` operator.
   *
   * Requirements:
   *
   * - input must fit into 80 bits
   */
  function toUint80(uint256 value) internal pure returns (uint80) {
    require(value < 2**80, "SafeCast: value doesn\'t fit in 80 bits");
    return uint80(value);
  }

  /**
   * @dev Returns the downcasted uint64 from uint256, reverting on
   * overflow (when the input is greater than largest uint64).
   *
   * Counterpart to Solidity's `uint64` operator.
   *
   * Requirements:
   *
   * - input must fit into 64 bits
   */
  function toUint64(uint256 value) internal pure returns (uint64) {
    require(value < 2**64, "SafeCast: value doesn\'t fit in 64 bits");
    return uint64(value);
  }

  /**
   * @dev Returns the downcasted uint56 from uint256, reverting on
   * overflow (when the input is greater than largest uint56).
   *
   * Counterpart to Solidity's `uint56` operator.
   *
   * Requirements:
   *
   * - input must fit into 56 bits
   */
  function toUint56(uint256 value) internal pure returns (uint56) {
    require(value < 2**56, "SafeCast: value doesn\'t fit in 56 bits");
    return uint56(value);
  }

  /**
   * @dev Returns the downcasted uint48 from uint256, reverting on
   * overflow (when the input is greater than largest uint48).
   *
   * Counterpart to Solidity's `uint48` operator.
   *
   * Requirements:
   *
   * - input must fit into 48 bits
   */
  function toUint48(uint256 value) internal pure returns (uint48) {
    require(value < 2**48, "SafeCast: value doesn\'t fit in 48 bits");
    return uint48(value);
  }

  /**
   * @dev Returns the downcasted uint40 from uint256, reverting on
   * overflow (when the input is greater than largest uint40).
   *
   * Counterpart to Solidity's `uint40` operator.
   *
   * Requirements:
   *
   * - input must fit into 40 bits
   */
  function toUint40(uint256 value) internal pure returns (uint40) {
    require(value < 2**40, "SafeCast: value doesn\'t fit in 40 bits");
    return uint40(value);
  }

  /**
   * @dev Returns the downcasted uint32 from uint256, reverting on
   * overflow (when the input is greater than largest uint32).
   *
   * Counterpart to Solidity's `uint32` operator.
   *
   * Requirements:
   *
   * - input must fit into 32 bits
   */
  function toUint32(uint256 value) internal pure returns (uint32) {
    require(value < 2**32, "SafeCast: value doesn\'t fit in 32 bits");
    return uint32(value);
  }

  /**
   * @dev Returns the downcasted uint24 from uint256, reverting on
   * overflow (when the input is greater than largest uint24).
   *
   * Counterpart to Solidity's `uint24` operator.
   *
   * Requirements:
   *
   * - input must fit into 24 bits
   */
  function toUint24(uint256 value) internal pure returns (uint24) {
    require(value < 2**24, "SafeCast: value doesn\'t fit in 24 bits");
    return uint24(value);
  }

  /**
   * @dev Returns the downcasted uint16 from uint256, reverting on
   * overflow (when the input is greater than largest uint16).
   *
   * Counterpart to Solidity's `uint16` operator.
   *
   * Requirements:
   *
   * - input must fit into 16 bits
   */
  function toUint16(uint256 value) internal pure returns (uint16) {
    require(value < 2**16, "SafeCast: value doesn\'t fit in 16 bits");
    return uint16(value);
  }

  /**
   * @dev Returns the downcasted uint8 from uint256, reverting on
   * overflow (when the input is greater than largest uint8).
   *
   * Counterpart to Solidity's `uint8` operator.
   *
   * Requirements:
   *
   * - input must fit into 8 bits.
   */
  function toUint8(uint256 value) internal pure returns (uint8) {
    require(value < 2**8, "SafeCast: value doesn\'t fit in 8 bits");
    return uint8(value);
  }
}

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

Contract ABI

API
[{"inputs":[{"internalType":"address","name":"nxmAddress","type":"address"},{"internalType":"address","name":"coverNFTAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"incidentId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"coverId","type":"uint256"}],"name":"IncidentPayoutRedeemed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"incidentId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"productId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"expectedPayoutInNXM","type":"uint256"}],"name":"IncidentSubmitted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"incidentId","type":"uint256"},{"indexed":false,"internalType":"string","name":"ipfsMetadata","type":"string"}],"name":"MetadataSubmitted","type":"event"},{"inputs":[],"name":"ETH","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ETH_ASSET_ID","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"changeDependentContractAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"masterAddress","type":"address"}],"name":"changeMasterAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"config","outputs":[{"internalType":"uint8","name":"payoutRedemptionPeriodInDays","type":"uint8"},{"internalType":"uint16","name":"expectedPayoutRatio","type":"uint16"},{"internalType":"uint16","name":"payoutDeductibleRatio","type":"uint16"},{"internalType":"uint16","name":"maxRewardInNXMWad","type":"uint16"},{"internalType":"uint16","name":"rewardRatio","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"coverNFT","outputs":[{"internalType":"contract ICoverNFT","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getIncidentsCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint104[]","name":"ids","type":"uint104[]"}],"name":"getIncidentsToDisplay","outputs":[{"components":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"productId","type":"uint256"},{"internalType":"uint256","name":"priceBefore","type":"uint256"},{"internalType":"uint256","name":"incidentDate","type":"uint256"},{"internalType":"uint256","name":"pollStart","type":"uint256"},{"internalType":"uint256","name":"pollEnd","type":"uint256"},{"internalType":"uint256","name":"redeemableUntil","type":"uint256"},{"internalType":"uint256","name":"status","type":"uint256"}],"internalType":"struct IYieldTokenIncidents.IncidentDisplay[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"incidents","outputs":[{"internalType":"uint80","name":"assessmentId","type":"uint80"},{"internalType":"uint24","name":"productId","type":"uint24"},{"internalType":"uint32","name":"date","type":"uint32"},{"internalType":"uint96","name":"priceBefore","type":"uint96"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"internalContracts","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"master","outputs":[{"internalType":"contract ISAFURAMaster","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nxm","outputs":[{"internalType":"contract ISAFURAToken","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint104","name":"incidentId","type":"uint104"},{"internalType":"uint32","name":"coverId","type":"uint32"},{"internalType":"uint256","name":"segmentId","type":"uint256"},{"internalType":"uint256","name":"depeggedTokens","type":"uint256"},{"internalType":"address payable","name":"payoutAddress","type":"address"},{"internalType":"bytes","name":"optionalParams","type":"bytes"}],"name":"redeemPayout","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint24","name":"productId","type":"uint24"},{"internalType":"uint96","name":"priceBefore","type":"uint96"},{"internalType":"uint32","name":"date","type":"uint32"},{"internalType":"uint256","name":"expectedPayoutInNXM","type":"uint256"},{"internalType":"string","name":"ipfsMetadata","type":"string"}],"name":"submitIncident","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum IYieldTokenIncidents.UintParams[]","name":"paramNames","type":"uint8[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"updateUintParameters","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"address","name":"destination","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawAsset","outputs":[],"stateMutability":"nonpayable","type":"function"}]

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101005760003560e01c806376fe675411610097578063d46655f411610066578063d46655f4146102d2578063eb962360146102e5578063ee97f7f31461030e578063fc1520fb1461032157600080fd5b806376fe6754146101e457806379502c55146101f75780638322fff214610262578063a6c6a8f31461027d57600080fd5b806342e53fcf116100d357806342e53fcf1461017857806348d3303d1461019f5780634fcd182a146101c9578063722c498b146101dc57600080fd5b8063092ae4dc1461010557806309b4c1361461011a5780630ea9c9841461013157806330e45f0514610139575b600080fd5b6101186101133660046128d6565b610341565b005b6003545b6040519081526020015b60405180910390f35b610118610467565b6101607f000000000000000000000000cb3c294cf415632b87d29cea59d8d12fca54fd2381565b6040516001600160a01b039091168152602001610128565b6101607f000000000000000000000000b2e56a3fdde232b9fa12289279a9d46197e219fb81565b6101b26101ad36600461298e565b610a16565b6040805192835260ff909116602083015201610128565b6101186101d7366004612a41565b611878565b61011e600081565b6101186101f2366004612b0b565b611d2c565b60025461022d9060ff81169061ffff610100820481169163010000008104821691600160281b8204811691600160381b90041685565b6040805160ff909616865261ffff9485166020870152928416928501929092528216606084015216608082015260a001610128565b61016073039e2fb66102314ce7b64ce5ce3e5183bc94ad3881565b61029061028b366004612b77565b612043565b604080516001600160501b03909516855262ffffff909316602085015263ffffffff909116918301919091526001600160601b03166060820152608001610128565b6101186102e0366004612b90565b612099565b6101606102f3366004612b77565b6001602052600090815260409020546001600160a01b031681565b600054610160906001600160a01b031681565b61033461032f366004612bad565b612113565b6040516101289190612bef565b600054604051632c1a733d60e11b81523360048201526001600160a01b0390911690635834e67a90602401602060405180830381865afa158015610389573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103ad9190612c8c565b6103d25760405162461bcd60e51b81526004016103c990612ca7565b60405180910390fd5b6040516370a0823160e01b815230600482015283906000906001600160a01b038316906370a0823190602401602060405180830381865afa15801561041b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061043f9190612ce9565b905060008184116104505783610452565b815b905061045f8386836121ef565b505050505050565b6000546040516227050b60e31b815261544360f01b60048201526001600160a01b0390911690630138285890602401602060405180830381865afa1580156104b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104d79190612d02565b600080805260016020527fa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb4980546001600160a01b039384166001600160a01b0319909116179055546040516227050b60e31b81526126a960f11b6004820152911690630138285890602401602060405180830381865afa15801561055f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105839190612d02565b6002600090815260016020527fd9d16d34ffb15ba3a3d852f0d403e2ce1d691fb54de27ac87cd2f993f3ec330f80546001600160a01b039384166001600160a01b0319909116179055546040516227050b60e31b815261503160f01b6004820152911690630138285890602401602060405180830381865afa15801561060d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106319190612d02565b600160008181526020919091527fcc69885fda6bcc1a4ace058b4a62bf5e179ea78fd58a1ccd71c22cc9b688792f80546001600160a01b039384166001600160a01b0319909116179055546040516227050b60e31b815261434f60f01b6004820152911690630138285890602401602060405180830381865afa1580156106bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106e09190612d02565b6004600081815260016020527fedc95719e9a3b28dd8e80877cb5880a9be7de1a13fc8b05e7999683b6b56764380546001600160a01b039485166001600160a01b0319909116179055546040516227050b60e31b815261415360f01b9281019290925290911690630138285890602401602060405180830381865afa15801561076d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107919190612d02565b600a600090815260016020527f2a32391a76c35a36352b711f9152c0d0a340cd686850c8ef25fbb11c71b89e7b80546001600160a01b039384166001600160a01b0319909116179055546040516227050b60e31b815261524160f01b6004820152911690630138285890602401602060405180830381865afa15801561081b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061083f9190612d02565b600d600090815260016020527f86b3fa87ee245373978e0d2d334dbde866c9b8b039036b87c5eb2fd89bcb6bab80546001600160a01b039384166001600160a01b0319909116179055546040516227050b60e31b815261043560f41b6004820152911690630138285890602401602060405180830381865afa1580156108c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108ed9190612d02565b600f6000908152600160209081527f12bd632ff333b55931f9f8bda8b4ed27e86687f88c95871969d72474fb428c1480546001600160a01b03949094166001600160a01b0319909416939093179092556040805160a08101825260025460ff8116825261ffff61010082048116838701526301000000820480821684860152600160281b83048083166060860152600160381b84049283166080860152945160f092831b6001600160f01b03199081169882019890985290821b8716602282015260f89290921b6001600160f81b03191660248301529290921b909316602582015281906027016040516020818303038152906040526109ec90612d35565b1490508015610a12576002805468ffffffffffff0000ff191667820032232800001e1790555b5050565b6002600081815260016020527fd9d16d34ffb15ba3a3d852f0d403e2ce1d691fb54de27ac87cd2f993f3ec330f5460405163505ef22f60e01b81523360048201526024810193909352909182916001600160a01b03169063505ef22f90604401602060405180830381865afa158015610a93573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ab79190612c8c565b610afc5760405162461bcd60e51b815260206004820152601660248201527521b0b63632b91034b9903737ba10309036b2b6b132b960511b60448201526064016103c9565b60008054906101000a90046001600160a01b03166001600160a01b031663ff0938a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b4d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b719190612c8c565b15610bb15760405162461bcd60e51b815260206004820152601060248201526f14de5cdd195b481a5cc81c185d5cd95960821b60448201526064016103c9565b60405163430c208160e01b815233600482015263ffffffff891660248201527f000000000000000000000000b2e56a3fdde232b9fa12289279a9d46197e219fb6001600160a01b03169063430c2081906044016020604051808303816000875af1158015610c23573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c479190612c8c565b610cb15760405162461bcd60e51b815260206004820152603560248201527f4f6e6c792074686520636f766572206f776e6572206f7220617070726f766564604482015274206164647265737365732063616e2072656465656d60581b60648201526084016103c9565b6000610cbd6004612257565b60405163bce2a88360e01b815263ffffffff8b1660048201529091506000906001600160a01b0383169063bce2a88390602401606060405180830381865afa158015610d0d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d319190612db8565b90506000610d3d61228f565b8251604051632e76c56d60e21b815262ffffff90911660048201526001600160a01b03919091169063b9db15b49060240160e060405180830381865afa158015610d8b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610daf9190612ee3565b60405163ccfa4b7960e01b815263ffffffff8d166004820152602481018c905290915060009081906001600160a01b0386169063ccfa4b799060440160c060405180830381865afa158015610e08573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e2c9190612eff565b905042816060015182604001518360200151610e489190612fce565b610e529190612fce565b63ffffffff161015610ea65760405162461bcd60e51b815260206004820152601860248201527f477261636520706572696f64206861732065787069726564000000000000000060448201526064016103c9565b600060038f6001600160681b031681548110610ec457610ec4612ff2565b600091825260208083206040805160808101825293909101546001600160501b0381168452600160501b810462ffffff1692840192909252600160681b820463ffffffff1690830152600160881b90046001600160601b031660608201529150610f2c6122b6565b8251604051630d465e5560e11b81526001600160501b0390911660048201526001600160a01b039190911690631a8cbcaa90602401608060405180830381865afa158015610f7e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fa291906130a1565b905080602001516001600160601b031681600001516001600160601b0316116110175760405162461bcd60e51b815260206004820152602160248201527f54686520696e636964656e74206e6565647320746f20626520616363657074656044820152601960fa1b60648201526084016103c9565b60006110216122b6565b6001600160a01b03166379502c556040518163ffffffff1660e01b8152600401608060405180830381865afa15801561105e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061108291906130bd565b50925061109891505060ff82166201518061311c565b62ffffff1682606001516110ac9190612fce565b63ffffffff164210156111125760405162461bcd60e51b815260206004820152602860248201527f54686520766f74696e6720616e6420636f6f6c646f776e20706572696f6473206044820152671b5d5cdd08195b9960c21b60648201526084016103c9565b6002546111259060ff166201518061311c565b62ffffff1661113a60ff83166201518061311c565b62ffffff16836060015161114e9190612fce565b6111589190612fce565b63ffffffff1642106111b65760405162461bcd60e51b815260206004820152602160248201527f54686520726564656d7074696f6e20706572696f6420686173206578706972656044820152601960fa1b60648201526084016103c9565b5050806040015163ffffffff16826040015183602001516111d79190612fce565b63ffffffff16101561122b5760405162461bcd60e51b815260206004820152601f60248201527f436f76657220656e646564206265666f72652074686520696e636964656e740060448201526064016103c9565b806040015163ffffffff16826020015163ffffffff161061128e5760405162461bcd60e51b815260206004820181905260248201527f436f76657220737461727465642061667465722074686520696e636964656e7460448201526064016103c9565b806020015162ffffff16856000015162ffffff16146112e55760405162461bcd60e51b81526020600482015260136024820152720a0e4dec8eac6e840d2c840dad2e6dac2e8c6d606b1b60448201526064016103c9565b816020015163ffffffff16421161135a5760405162461bcd60e51b815260206004820152603360248201527f43616e6e6f742062757920636f76657220616e64207375626d697420636c61696044820152726d20696e207468652073616d6520626c6f636b60681b60648201526084016103c9565b600254606082015160009161271091611387916301000000900461ffff16906001600160601b0316613143565b611391919061315a565b9050600080876020015160ff16036113ab57506012611508565b60006113b56122c2565b6020890151604051631d591eb760e31b815260ff90911660048201529091506000906001600160a01b0383169063eac8f5b890602401606060405180830381865afa158015611408573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061142c919061317c565b600001519050816001600160a01b031663b9ab99276040518163ffffffff1660e01b8152600401602060405180830381865afa158015611470573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114949190612d02565b604051631e23703160e31b81526001600160a01b038381166004830152919091169063f11b8188906024016040805180830381865afa1580156114db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114ff91906131c0565b60ff1693505050505b61151381600a6132de565b828f61151f9190613143565b611529919061315a565b9450505081600001516001600160601b031683111561158a5760405162461bcd60e51b815260206004820152601d60248201527f5061796f7574206578636565647320636f766572656420616d6f756e7400000060448201526064016103c9565b50506115946122cd565b6001600160a01b0316638516e6dc6040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156115ce57600080fd5b505af11580156115e2573d6000803e3d6000fd5b5050604051636d18082f60e11b815263ffffffff8f166004820152602481018e9052604481018490526001600160a01b038716925063da30105e91506064016020604051808303816000875af1158015611640573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116649190612d02565b5086156117445760008060008060008060008e8e81019061168591906132ea565b965096509650965096509650965060006001600160a01b0316866001600160a01b03161461173c57602089015160405163d505accf60e01b81526001600160a01b0389811660048301528881166024830152604482018890526064820187905260ff8616608483015260a4820185905260c482018490529091169063d505accf9060e401600060405180830381600087803b15801561172357600080fd5b505af1158015611737573d6000803e3d6000fd5b505050505b505050505050505b611754826020015133308d6122d9565b6001600081815260209182527fcc69885fda6bcc1a4ace058b4a62bf5e179ea78fd58a1ccd71c22cc9b688792f549185015160405163a278bd4d60e01b815260ff90911660048201526001600160a01b038c8116602483015260448201859052606482019290925291169063a278bd4d90608401600060405180830381600087803b1580156117e257600080fd5b505af11580156117f6573d6000803e3d6000fd5b50505050336001600160a01b03167f5b196da3d959f0378549a182f7a16b76de62686df4e0dbd608381e94cae35271828f8f604051611857939291909283526001600160681b0391909116602083015263ffffffff16604082015260600190565b60405180910390a2602090920151919c919b50909950505050505050505050565b600054604051632c1a733d60e11b81523360048201526001600160a01b0390911690635834e67a90602401602060405180830381865afa1580156118c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118e49190612c8c565b6119005760405162461bcd60e51b81526004016103c990612ca7565b60008054906101000a90046001600160a01b03166001600160a01b031663ff0938a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015611951573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119759190612c8c565b156119b55760405162461bcd60e51b815260206004820152601060248201526f14de5cdd195b481a5cc81c185d5cd95960821b60448201526064016103c9565b60006119bf61228f565b6040516302db1c0360e61b815262ffffff891660048201529091506000906001600160a01b0383169063b6c700c09060240161012060405180830381865afa158015611a0f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a33919061335b565b805190925060ff166001149050611a9f5760405162461bcd60e51b815260206004820152602a60248201527f496e76616c696420636c61696d206d6574686f6420666f7220746869732070726044820152696f64756374207479706560b01b60648201526084016103c9565b600254600090611af290611ac790670de0b6b3a764000090600160281b900461ffff16613143565b60025461271090611ae390600160381b900461ffff168a613143565b611aed919061315a565b612317565b6003549091506000611b7e611b056122b6565b60405163f6e0f60b60e01b815260048101869052600060248201526001600160a01b03919091169063f6e0f60b906044016020604051808303816000875af1158015611b55573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b799190612ce9565b61232f565b905060036040518060800160405280836001600160501b031681526020018d62ffffff1681526020018b63ffffffff1681526020018c6001600160601b03168152509080600181540180825580915050600190039060005260206000200160009091909190915060008201518160000160006101000a8154816001600160501b0302191690836001600160501b03160217905550602082015181600001600a6101000a81548162ffffff021916908362ffffff160217905550604082015181600001600d6101000a81548163ffffffff021916908363ffffffff16021790555060608201518160000160116101000a8154816001600160601b0302191690836001600160601b0316021790555050506000878790501115611cd457817f0713a463db90dc47d4ffff96cdf194d43d0d76e0ef6ff8334ad14505f1a4df068888604051611ccb9291906133f2565b60405180910390a25b604080513381526020810184905262ffffff8d1681830152606081018a905290517f2d8ec83f719ed0c382705899c2194ba00cd730638736bd1d7046699520aa0f809181900360800190a15050505050505050505050565b600054604051632c1a733d60e11b81523360048201526001600160a01b0390911690635834e67a90602401602060405180830381865afa158015611d74573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d989190612c8c565b611db45760405162461bcd60e51b81526004016103c990612ca7565b6040805160a08101825260025460ff8116825261ffff61010082048116602084015263010000008204811693830193909352600160281b810483166060830152600160381b9004909116608082015260005b84811015611fb8576000868683818110611e2257611e22612ff2565b9050602002016020810190611e379190613421565b6004811115611e4857611e48612d1f565b03611e7257838382818110611e5f57611e5f612ff2565b602002919091013560ff16835250611fa6565b6002868683818110611e8657611e86612ff2565b9050602002016020810190611e9b9190613421565b6004811115611eac57611eac612d1f565b03611eda57838382818110611ec357611ec3612ff2565b602002919091013561ffff16604084015250611fa6565b6003868683818110611eee57611eee612ff2565b9050602002016020810190611f039190613421565b6004811115611f1457611f14612d1f565b03611f4257838382818110611f2b57611f2b612ff2565b602002919091013561ffff16606084015250611fa6565b6004868683818110611f5657611f56612ff2565b9050602002016020810190611f6b9190613421565b6004811115611f7c57611f7c612d1f565b03611fa657838382818110611f9357611f93612ff2565b602002919091013561ffff166080840152505b80611fb081613442565b915050611e06565b5080516002805460208401516040850151606086015160809096015161ffff908116600160381b0268ffff0000000000000019978216600160281b0266ffff0000000000199383166301000000029390931666ffffffff00000019929094166101000262ffffff1990951660ff90971696909617939093179290921617179290921617905550505050565b6003818154811061205357600080fd5b6000918252602090912001546001600160501b0381169150600160501b810462ffffff1690600160681b810463ffffffff1690600160881b90046001600160601b031684565b6000546001600160a01b0316156120f1576000546001600160a01b031633146120f15760405162461bcd60e51b815260206004820152600a6024820152692737ba1036b0b9ba32b960b11b60448201526064016103c9565b600080546001600160a01b0319166001600160a01b0392909216919091179055565b606060008267ffffffffffffffff81111561213057612130612d5c565b60405190808252806020026020018201604052801561216957816020015b612156612879565b81526020019060019003908161214e5790505b50905060005b838110156121e557600085858381811061218b5761218b612ff2565b90506020020160208101906121a0919061345b565b90506121b4816001600160681b0316612397565b8383815181106121c6576121c6612ff2565b60200260200101819052505080806121dd90613442565b91505061216f565b5090505b92915050565b6040516001600160a01b03831660248201526044810182905261225290849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612626565b505050565b60006001600083600f81111561226f5761226f612d1f565b81526020810191909152604001600020546001600160a01b031692915050565b6000600181600f5b81526020810191909152604001600020546001600160a01b0316919050565b6000600181600a612297565b600060018181612297565b6000600181600d612297565b6040516001600160a01b03808516602483015283166044820152606481018290526123119085906323b872dd60e01b9060840161221b565b50505050565b60008183106123265781612328565b825b9392505050565b6000600160501b82106123935760405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203860448201526530206269747360d01b60648201526084016103c9565b5090565b61239f612879565b6000600383815481106123b4576123b4612ff2565b600091825260208083206040805160808101825293909101546001600160501b0381168452600160501b810462ffffff1692840192909252600160681b820463ffffffff1690830152600160881b90046001600160601b03166060820152915061241c6122b6565b825160405163275b51d960e11b81526001600160501b0390911660048201526001600160a01b039190911690634eb6a3b29060240160c060405180830381865afa15801561246e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124929190613496565b505090506000806124a16122b6565b6001600160a01b03166379502c556040518163ffffffff1660e01b8152600401608060405180830381865afa1580156124de573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061250291906130bd565b5060025460ff91821694506000935061251d925016836134da565b61252a9062015180613143565b846060015163ffffffff1661253f91906134da565b9050836060015163ffffffff1642101561255c576000925061259d565b83602001516001600160601b031684600001516001600160601b03161115612598578042111561258f576003925061259d565b6001925061259d565b600292505b604051806101000160405280888152602001866020015162ffffff16815260200186606001516001600160601b03168152602001866040015163ffffffff168152602001856040015163ffffffff168152602001856060015163ffffffff16815260200182815260200184600381111561261957612619612d1f565b9052979650505050505050565b600061267b826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166126f89092919063ffffffff16565b80519091501561225257808060200190518101906126999190612c8c565b6122525760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016103c9565b6060612707848460008561270f565b949350505050565b6060824710156127705760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016103c9565b6001600160a01b0385163b6127c75760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016103c9565b600080866001600160a01b031685876040516127e39190613511565b60006040518083038185875af1925050503d8060008114612820576040519150601f19603f3d011682016040523d82523d6000602084013e612825565b606091505b5091509150612835828286612840565b979650505050505050565b6060831561284f575081612328565b82511561285f5782518084602001fd5b8160405162461bcd60e51b81526004016103c9919061352d565b60405180610100016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b03811681146128d357600080fd5b50565b6000806000606084860312156128eb57600080fd5b83356128f6816128be565b92506020840135612906816128be565b929592945050506040919091013590565b80356001600160681b038116811461292e57600080fd5b919050565b63ffffffff811681146128d357600080fd5b60008083601f84011261295757600080fd5b50813567ffffffffffffffff81111561296f57600080fd5b60208301915083602082850101111561298757600080fd5b9250929050565b600080600080600080600060c0888a0312156129a957600080fd5b6129b288612917565b965060208801356129c281612933565b9550604088013594506060880135935060808801356129e0816128be565b925060a088013567ffffffffffffffff8111156129fc57600080fd5b612a088a828b01612945565b989b979a50959850939692959293505050565b62ffffff811681146128d357600080fd5b6001600160601b03811681146128d357600080fd5b60008060008060008060a08789031215612a5a57600080fd5b8635612a6581612a1b565b95506020870135612a7581612a2c565b94506040870135612a8581612933565b935060608701359250608087013567ffffffffffffffff811115612aa857600080fd5b612ab489828a01612945565b979a9699509497509295939492505050565b60008083601f840112612ad857600080fd5b50813567ffffffffffffffff811115612af057600080fd5b6020830191508360208260051b850101111561298757600080fd5b60008060008060408587031215612b2157600080fd5b843567ffffffffffffffff80821115612b3957600080fd5b612b4588838901612ac6565b90965094506020870135915080821115612b5e57600080fd5b50612b6b87828801612ac6565b95989497509550505050565b600060208284031215612b8957600080fd5b5035919050565b600060208284031215612ba257600080fd5b8135612328816128be565b60008060208385031215612bc057600080fd5b823567ffffffffffffffff811115612bd757600080fd5b612be385828601612ac6565b90969095509350505050565b602080825282518282018190526000919060409081850190868401855b82811015612c6f5781518051855286810151878601528581015186860152606080820151908601526080808201519086015260a0808201519086015260c0808201519086015260e090810151908501526101009093019290850190600101612c0c565b5091979650505050505050565b8051801515811461292e57600080fd5b600060208284031215612c9e57600080fd5b61232882612c7c565b60208082526022908201527f43616c6c6572206973206e6f7420617574686f72697a656420746f20676f7665604082015261393760f11b606082015260800190565b600060208284031215612cfb57600080fd5b5051919050565b600060208284031215612d1457600080fd5b8151612328816128be565b634e487b7160e01b600052602160045260246000fd5b80516020808301519190811015612d56576000198160200360031b1b821691505b50919050565b634e487b7160e01b600052604160045260246000fd5b6040516060810167ffffffffffffffff81118282101715612da357634e487b7160e01b600052604160045260246000fd5b60405290565b60ff811681146128d357600080fd5b600060608284031215612dca57600080fd5b612dd2612d72565b8251612ddd81612a1b565b81526020830151612ded81612da9565b60208201526040830151612e0081612a2c565b60408201529392505050565b805161ffff8116811461292e57600080fd5b600060e08284031215612e3057600080fd5b60405160e0810181811067ffffffffffffffff82111715612e6157634e487b7160e01b600052604160045260246000fd5b604052905080612e7083612e0c565b81526020830151612e80816128be565b60208201526040830151612e9381612933565b6040820152612ea460608401612e0c565b6060820152612eb560808401612e0c565b6080820152612ec660a08401612c7c565b60a0820152612ed760c08401612c7c565b60c08201525092915050565b600060e08284031215612ef557600080fd5b6123288383612e1e565b600060c08284031215612f1157600080fd5b60405160c0810181811067ffffffffffffffff82111715612f4257634e487b7160e01b600052604160045260246000fd5b6040528251612f5081612a2c565b81526020830151612f6081612933565b60208201526040830151612f7381612933565b60408201526060830151612f8681612933565b60608201526080830151612f9981612a1b565b608082015260a0830151612fac81612a1b565b60a08201529392505050565b634e487b7160e01b600052601160045260246000fd5b63ffffffff818116838216019080821115612feb57612feb612fb8565b5092915050565b634e487b7160e01b600052603260045260246000fd5b60006080828403121561301a57600080fd5b6040516080810181811067ffffffffffffffff8211171561304b57634e487b7160e01b600052604160045260246000fd5b8060405250809150825161305e81612a2c565b8152602083015161306e81612a2c565b6020820152604083015161308181612933565b6040820152606083015161309481612933565b6060919091015292915050565b6000608082840312156130b357600080fd5b6123288383613008565b600080600080608085870312156130d357600080fd5b84516130de81612da9565b60208601519094506130ef81612da9565b604086015190935061310081612da9565b606086015190925061311181612da9565b939692955090935050565b62ffffff81811683821602808216919082811461313b5761313b612fb8565b505092915050565b80820281158282048414176121e9576121e9612fb8565b60008261317757634e487b7160e01b600052601260045260246000fd5b500490565b60006060828403121561318e57600080fd5b613196612d72565b82516131a1816128be565b81526131af60208401612c7c565b6020820152612e0060408401612c7c565b600080604083850312156131d357600080fd5b82516131de816128be565b60208401519092506131ef81612da9565b809150509250929050565b600181815b8085111561323557816000190482111561321b5761321b612fb8565b8085161561322857918102915b93841c93908002906131ff565b509250929050565b60008261324c575060016121e9565b81613259575060006121e9565b816001811461326f576002811461327957613295565b60019150506121e9565b60ff84111561328a5761328a612fb8565b50506001821b6121e9565b5060208310610133831016604e8410600b84101617156132b8575081810a6121e9565b6132c283836131fa565b80600019048211156132d6576132d6612fb8565b029392505050565b6000612328838361323d565b600080600080600080600060e0888a03121561330557600080fd5b8735613310816128be565b96506020880135613320816128be565b95506040880135945060608801359350608088013561333e81612da9565b9699959850939692959460a0840135945060c09093013592915050565b60008082840361012081121561337057600080fd5b61337a8585612e1e565b9250604060df198201121561338e57600080fd5b506040516040810181811067ffffffffffffffff821117156133c057634e487b7160e01b600052604160045260246000fd5b60405260e08401516133d181612da9565b81526101008401516133e281612933565b6020820152919491935090915050565b60208152816020820152818360408301376000818301604090810191909152601f909201601f19160101919050565b60006020828403121561343357600080fd5b81356005811061232857600080fd5b60006001820161345457613454612fb8565b5060010190565b60006020828403121561346d57600080fd5b61232882612917565b80516fffffffffffffffffffffffffffffffff8116811461292e57600080fd5b600080600060c084860312156134ab57600080fd5b6134b58585613008565b92506134c360808501613476565b91506134d160a08501613476565b90509250925092565b808201808211156121e9576121e9612fb8565b60005b838110156135085781810151838201526020016134f0565b50506000910152565b600082516135238184602087016134ed565b9190910192915050565b602081526000825180602084015261354c8160408501602087016134ed565b601f01601f1916919091016040019291505056fea26469706673582212204b8726a1c977fff823de32fd75b0bfedae7be4ea1a93ca61914c9022f6d9289c64736f6c63430008120033

Block Transaction 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
[ 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.