Cover
Overview
The Cover contract manages the purchase and management of coverage within the protocol. It allows users to buy coverage for specific products and handles the allocation of coverage across various staking pools. The contract keeps track of cover segments, allocations, and active covers, ensuring that coverage is properly managed over time.
Key Concepts
Cover Data Structures
CoverData
Represents the basic information about a cover.
struct CoverData {
uint productId;
uint coverAsset;
uint96 amountPaidOut;
}
Parameter | Description |
---|---|
productId | The ID of the product being covered. |
coverAsset | The asset ID used for coverage (e.g., ETH). |
amountPaidOut | Total amount paid out for claims on this cover. |
CoverSegment
Each cover can have multiple segments representing different periods or modifications to the coverage.
struct CoverSegment {
uint96 amount;
uint32 start;
uint32 period;
uint32 gracePeriod;
uint24 globalRewardsRatio;
uint24 globalCapacityRatio;
}
Parameter | Description |
---|---|
amount | Coverage amount in cover asset. |
start | Start timestamp of the cover segment. |
period | Duration of the cover segment in seconds. |
gracePeriod | Additional time after expiration for claim submissions. |
globalRewardsRatio | Global rewards ratio applicable to the cover. |
globalCapacityRatio | Global capacity ratio applicable to the cover. |
PoolAllocation
Represents the allocation of coverage to a specific staking pool.
struct PoolAllocation {
uint poolId;
uint96 coverAmountInNXM;
uint96 premiumInNXM;
uint24 allocationId;
}
Parameter | Description |
---|---|
poolId | ID of the staking pool. |
coverAmountInNXM | Cover amount allocated to the pool in NXM tokens. |
premiumInNXM | Premium paid for the allocation in NXM tokens. |
allocationId | Unique identifier for the allocation within the pool. |
Active Cover and Expiration Buckets
- ActiveCover: Tracks the total active cover in an asset and the last bucket update ID.
- Expiration Buckets: Cover amounts are tracked in weekly buckets (BUCKET_SIZE is 7 days). As covers expire, the amounts are deducted from the active cover.
Constants
- Commission and Ratios:
uint private constant COMMISSION_DENOMINATOR = 10000;
uint public constant MAX_COMMISSION_RATIO = 3000; // 30%
uint public constant GLOBAL_CAPACITY_RATIO = 20000; // 2x
uint public constant GLOBAL_REWARDS_RATIO = 5000; // 50%
uint public constant GLOBAL_MIN_PRICE_RATIO = 100; // 1%
- Cover Periods:
uint private constant MAX_COVER_PERIOD = 365 days;
uint private constant MIN_COVER_PERIOD = 28 days;
uint private constant BUCKET_SIZE = 7 days;
Allocation Units
- Allocation Units per NXM:
uint private constant ALLOCATION_UNITS_PER_NXM = 100;
uint public constant NXM_PER_ALLOCATION_UNIT = ONE_NXM / ALLOCATION_UNITS_PER_NXM;