Skip to content
PlutusShield
Live on Cardano Preview testnet

How cover works

A policy is two tokens and a datum on Cardano, plus a private record on Midnight. Here is the full lifecycle and every rule the validator checks.

← Back to site
DocsHow cover works

One validator, two roles#

All Cardano logic lives in one parameterised Plutus V3 multi-validator, cover(params). Its script hash is both the minting policy of every PlutusShield token and the payment credential that locks the pool and every policy reference UTxO. There is no admin key: the accepted currencies, product terms, oracle allowlist, quorum and claim grace period are fixed in CoverParams when the script is deployed.

PlutusShield tokens
TokenAsset nameLives atMeaning
Pool NFTpoolScript addressMarks the one genuine pool UTxO. Minted once by consuming params.seed.
LP sharelp ‖ tranche byteLP walletsFungible, pro-rata claim on one currency tranche (6c7000 = ADA, 6c7001 = USDC).
Policy reference token000643b0 ‖ id[0..28]Script address, with PolicyDatumLive policy state (CIP-67 label 100).
Policy user token000de140 ‖ id[0..28]Buyer's walletBearer right to claim (CIP-67 label 222). Burning it is how you claim.

Every LP or policy action spends the pool UTxO, and the pool spend checks the transaction's exact mint and burn, the capital change in the one tranche it touches, that every other tranche is untouched, and the next pool datum. The mint handler's ViaPool redeemer only requires that the pool UTxO is an input. A policy UTxO can be spent only if its reference token is burned in the same transaction, which only the pool's Settle and Expire paths allow.

Lifecycle#

  1. 01

    InitPoolCardano

    Mints the pool NFT exactly once by spending params.seed. The pool starts with one empty tranche per accepted currency, and the params are sanity-checked. For example, there must be 1 to 256 distinct assets, quorum must be between 1 and the number of feeds, and the single-policy cap must not exceed the utilization cap.
  2. 02

    Deposit / WithdrawCardano

    Underwriters add capital to one currency tranche for that tranche's LP shares, and redeem shares for capital in the same asset, subject to the capital lock. See Underwriting pool.
  3. 03

    BuyCardano

    The buyer picks a currency (ADA or USDC) and pays the premium in it, into that tranche. The transaction mints one reference token, locked at the script with a PolicyDatum, and one user token for the buyer. That tranche's active_cover grows by the coverage amount. The buy must reference a fresh healthy-peg reading from every oracle feed, and cover starts only after the waiting period. The buyer's browser also makes a private Midnight policy key and writes only its commitment into the datum. See the purchase rules.
  4. 04

    registerPolicyMidnight

    After the Cardano mint confirms, the issuer mirrors the policy into the private registry, keyed by the same 32-byte policy id. The record holds a holder commitment and a coverage commitment, and the circuit refuses any pair that doesn't open the datum's commitment. See Privacy.
  5. 05

    Settle (claim)Cardano

    If a quorum of allowlisted oracle feeds attests the trigger inside the cover period, the holder burns both policy tokens, and the policy's tranche pays exactly coverage in the policy's asset. The claim must land before expiry + claim_grace_ms. See Settlement.
  6. 06

    ExpireCardano

    Once the validity range starts after expiry + claim_grace_ms, anyone can burn the reference token to retire the policy. Capital stays in the pool, and the tranche's active_cover drops by the coverage, which frees capacity. The reference UTxO's min-ada deposit must go back to the buyer's refund_to address, whoever submits. The user token can be burned in the same transaction or later with BurnUserTokens.
Redeemers (types.ak)
MintAction = InitPool | ViaPool | BurnUserTokens
PoolAction = Deposit { tranche } | Withdraw { tranche, shares } | Buy | Settle | Expire

What a purchase must satisfy#

validate_buy accepts a Buy only if all of these hold. Product terms are fixed by the deployment. The buyer can't choose them.

  • Exactly one reference token and one user token are minted for the derived policy id. The reference output sits at the script and holds only that token plus ada.
  • policy_id equals blake2b_256(cbor(pool OutputReference spent)). Each pool UTxO is spent once, so ids are unique.
  • product_id and trigger equal the product's, so a buyer can't pick a looser threshold.
  • asset is one of the accepted currencies. It selects the tranche. Premium, capacity, the premium floor (with that asset's min_premium), and the active-cover update all use that tranche only. Every other tranche's capital is unchanged.
  • midnight_commitment is exactly 32 bytes.
  • coverage > 0. The term is a whole number of days between min_days and max_days.
  • Waiting period. The transaction's validity upper bound plus sale_guard.waiting_period_ms must be ≤ start. That rules out backdating, and a depeg that begins during the wait is never covered, because trigger windows must start at or after start.
  • Circuit-breaker. Every allowlisted oracle feed, passed as a reference input, reports the covered asset at or above the trigger threshold, with a window_end no older than sale_guard.max_price_age_ms. All feeds, not a quorum: the buyer picks the reference inputs, so a quorum rule would let them leave out the feed that already shows a depeg. If any feed is depegged, stale, or missing, nothing can be sold.
  • The capacity caps hold against the tranche's pre-purchase capital, and the premium paid (the tranche's capital increase) is at least the integer floor. See Pricing.
  • The tranche's next ledger is exactly active_cover + coverage, with shares unchanged.

The policy datum#

PolicyDatum (types.ak)
PolicyDatum {
  policy_id:           ByteArray  -- 32 bytes, blake2b_256(cbor(pool OutputReference))
  product_id:          ByteArray  -- "depeg"
  asset:               AssetClass -- currency of coverage, premium and payout; picks the tranche
  coverage:            Int        -- base units of that asset
  premium:             Int
  start, expiry:       Int        -- POSIX ms, expiry = start + days * 86_400_000
  trigger:             Trigger    -- { covered_asset, threshold_bps, window_ms }
  midnight_commitment: ByteArray  -- 32-byte Midnight coverage commitment
  refund_to:           Address    -- gets the reference UTxO's min-ada back on Expire
}

packages/sdk builds this datum (buildPolicyDatum), derives ids and token names, and encodes Plutus Data byte-for-byte as the validator does. Golden vectors are checked on both sides.

Products#

The quote engine prices three product lines. One deployment of cover serves one product with one trigger, and can accept several currencies (ADA and USDC by default). The cover products catalog shows each line's status, premium currencies, claim model and deployed parameters.

Product lines
ProductSettlementStatus
Stablecoin depegParametric. Oracle TWAP below 0.95 of peg for 24h (threshold_bps 9_500, window 86_400_000 ms)Implemented in the Cardano validator (MVP)
Smart-contract exploitAssessed. Evidence commitment on Midnight plus an assessor decision; the Cardano payout needs 2 of 3 assessor-committee signaturesLive on Preview: Midnight Preprod claim flow plus a Cardano exploit-cover pool that pays on a 2-of-3 committee Settle
Protocol SLAParametric. Uptime oracle below an SLA thresholdPriced in SDK. Oracle and deployment planned