Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 36 additions & 44 deletions contracts/interfaces/ICover.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,19 @@ import "./IStakingNFT.sol";
import "./IStakingPool.sol";
import "./ICompleteStakingPoolFactory.sol";

/* ========== DATA STRUCTURES ========== */
/* io structs */

enum ClaimMethod {
IndividualClaims,
YieldTokenIncidents
}

// Basically CoverStatus from QuotationData.sol but with the extra Migrated status to avoid
// polluting Cover.sol state layout with new status variables.
enum LegacyCoverStatus {
Active,
ClaimAccepted,
ClaimDenied,
CoverExpired,
ClaimSubmitted,
Requested,
Migrated
}

/* io structs */

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

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

struct BuyCoverParams {
uint coverId;
address owner;
Expand All @@ -57,6 +36,23 @@ struct BuyCoverParams {

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

struct PoolAllocation {
uint40 poolId;
uint96 coverAmountInNXM;
Expand All @@ -79,31 +75,27 @@ struct CoverSegment {
uint24 globalCapacityRatio;
}

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;
}
interface ICover {

struct ProductType {
uint8 claimMethod;
uint32 gracePeriod;
}
/* ========== DATA STRUCTURES ========== */

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

interface ICover {
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 ========== */

Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/ICoverBroker.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity ^0.8.18;
pragma solidity >=0.5.0;

import "@openzeppelin/contracts-v4/token/ERC20/IERC20.sol";

Expand Down
34 changes: 17 additions & 17 deletions contracts/interfaces/ICoverProducts.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,6 @@ pragma solidity >=0.5.0;

import "./ICover.sol";

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

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

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

struct ProductInitializationParams {
uint productId;
uint8 weight;
Expand All @@ -30,6 +13,23 @@ struct ProductInitializationParams {

interface ICoverProducts {

/* ========== IO STRUCTURES ========== */

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);
Expand Down
164 changes: 82 additions & 82 deletions contracts/interfaces/IIndividualClaims.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,90 +4,90 @@ pragma solidity >=0.5.0;

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

enum ClaimStatus { PENDING, ACCEPTED, DENIED }

enum PayoutStatus { PENDING, COMPLETE, UNCLAIMED, DENIED }

enum UintParams {
payoutRedemptionPeriodInDays,
minAssessmentDepositRatio,
maxRewardInNXMWad,
rewardRatio
}

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

// Ratio out of 1 ETH, used to calculate a flat ETH deposit required for claim submission.
// If the claim is accepted, the user will receive the deposit back when the payout is redeemed.
// (0-10000 bps i.e. double decimal precision)
uint16 minAssessmentDepositRatio;

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

// Holds the requested amount, NXM price, submission fee and other relevant details
// such as parts of the corresponding cover details and the payout status.
//
// This structure has snapshots of claim-time states that are considered moving targets
// but also parts of cover details that reduce the need of external calls. Everything is fitted
// in a single word that contains:
struct Claim {
// The index of the assessment, stored in Assessment.sol
uint80 assessmentId;

// The identifier of the cover on which this claim is submitted
uint32 coverId;

// The index of the cover segment on which this claim is submitted
uint16 segmentId;

// Amount requested as part of this claim up to the total cover amount
uint96 amount;

// The index of of the asset address stored at addressOfAsset which is expected at payout.
uint8 coverAsset;

// True if the payout is already redeemed. Prevents further payouts on the claim if it is
// accepted.
bool payoutRedeemed;
}

struct ClaimSubmission {
// The index of the claim, stored in Claims.sol
uint80 claimId;
// True when a previous submission exists
bool exists;
}

// Claim structure but in a human-friendly format.
//
// Contains aggregated values that give an overall view about the claim and other relevant
// pieces of information such as cover period, asset symbol etc. This structure is not used in
// any storage variables.
struct ClaimDisplay {
uint id;
uint productId;
uint coverId;
uint assessmentId;
uint amount;
string assetSymbol;
uint assetIndex;
uint coverStart;
uint coverEnd;
uint pollStart;
uint pollEnd;
uint claimStatus;
uint payoutStatus;
}

interface IIndividualClaims {

enum ClaimStatus { PENDING, ACCEPTED, DENIED }

enum PayoutStatus { PENDING, COMPLETE, UNCLAIMED, DENIED }

enum UintParams {
payoutRedemptionPeriodInDays,
minAssessmentDepositRatio,
maxRewardInNXMWad,
rewardRatio
}

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

// Ratio out of 1 ETH, used to calculate a flat ETH deposit required for claim submission.
// If the claim is accepted, the user will receive the deposit back when the payout is redeemed.
// (0-10000 bps i.e. double decimal precision)
uint16 minAssessmentDepositRatio;

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

// Holds the requested amount, NXM price, submission fee and other relevant details
// such as parts of the corresponding cover details and the payout status.
//
// This structure has snapshots of claim-time states that are considered moving targets
// but also parts of cover details that reduce the need of external calls. Everything is fitted
// in a single word that contains:
struct Claim {
// The index of the assessment, stored in Assessment.sol
uint80 assessmentId;

// The identifier of the cover on which this claim is submitted
uint32 coverId;

// The index of the cover segment on which this claim is submitted
uint16 segmentId;

// Amount requested as part of this claim up to the total cover amount
uint96 amount;

// The index of of the asset address stored at addressOfAsset which is expected at payout.
uint8 coverAsset;

// True if the payout is already redeemed. Prevents further payouts on the claim if it is
// accepted.
bool payoutRedeemed;
}

struct ClaimSubmission {
// The index of the claim, stored in Claims.sol
uint80 claimId;
// True when a previous submission exists
bool exists;
}

// Claim structure but in a human-friendly format.
//
// Contains aggregated values that give an overall view about the claim and other relevant
// pieces of information such as cover period, asset symbol etc. This structure is not used in
// any storage variables.
struct ClaimDisplay {
uint id;
uint productId;
uint coverId;
uint assessmentId;
uint amount;
string assetSymbol;
uint assetIndex;
uint coverStart;
uint coverEnd;
uint pollStart;
uint pollEnd;
uint claimStatus;
uint payoutStatus;
}

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

function claims(uint id) external view returns (
Expand Down
Loading