Skip to content

How it works

The short version: you lock DIEM, you get two things — a principal claim (PT20 or PT721) and DD (inference credits). DD pays for inference through a daily auction. PT20 gets you your DIEM back at maturity.

Here is the full lifecycle, end to end.

1. Lock

You decide:

  • How much DIEM to lock (any amount above 0.01 DIEM).
  • Maturity date — when you want your DIEM back.

You have two paths:

PathMaturityWhat you get
Monthly PT201st of any month, up to 13 months outFungible ERC-20 with shared DEX liquidity
PT721Any day, up to 400 days outNon-fungible position, unique per lock

You call Locker.lockPT20(amount, maturity, recipient) (PT20 path) or Locker.lockPT721(amount, maturity, recipient) (PT721 path). Under the hood:

  1. Your DIEM is transferred into the protocol's vault.
  2. The vault stakes it on Venice — from this point Venice credits your locked DIEM toward the protocol's daily inference allowance.
  3. You receive DD = amount × days_until_maturity (floor, minimum 1 day). At 1 DD = $1 of inference, this is the headline asset — your share of the inference that your locked DIEM will generate between now and maturity, paid to you upfront and immediately spendable or tradeable.
  4. You receive a principal token that gets you your DIEM back at maturity:
    • PT20 — fungible, you can sell it on a DEX.
    • PT721 — non-fungible, each token represents one specific (principal, maturity) position.

You can lock as many times as you want, each into a different maturity.

Detailed lock mechanics →

2. Hold, trade, or both

DD and PT20 are both transferable from the moment they're minted.

  • DD you can keep to bid for your own inference, or sell on a DEX to people who want inference and don't want to lock DIEM.
  • PT20 you can hold until maturity, or sell on a DEX at a discount to people who want exposure to DIEM pricing without locking.

PT721 is also transferable but, being non-fungible, lives on NFT marketplaces rather than DEX pools.

3. Bid for inference (daily auction)

Every day, the DailyAuction sells the protocol's total inference capacity for the next UTC day.

  • You call bid(platform, ddAmount, kaiBid) between 00:00 and 23:59 UTC for inference on the following day.
  • ddAmount is the dollar amount of inference you want (1 DD = $1).
  • kaiBid is your KAI premium — minimum 0.01 KAI per bid, higher bids win priority if the auction is oversubscribed.

At 00:00 UTC the next day, anyone can call settle():

  • Bids are sorted by kaiBid (highest first), ties broken by who bid first.
  • The auction is all-or-nothing: if your bid doesn't fit the remaining capacity, it's skipped, the next-best bid is tried. You either get the full ddAmount you asked for, or you get a full refund — never a partial fill of a half-useful key.
  • Winners pay a uniform clearing price (everyone pays the lowest winning KAI bid). Excess KAI you bid above clearing is refundable.
  • DD of winners is burned at face value. Clearing KAI × winner count is also burned (KAI is deflationary).

Detailed auction mechanics →

4. Get your Venice API key

If you won the auction:

  1. You call requestKey(platform, day, bidIndex) — emits an event the backend watches.
  2. The backend calls Venice's REST API to create a sub-API-key scoped to your ddAmount and expiring at end of day.
  3. Backend calls markKeyIssued(...) on-chain so you can verify, and exposes the key string through its REST endpoint.
  4. You use the key for inference through Venice's API for that day.

If you didn't win — call claimRefund(...) to get your DD and KAI back.

5. Mature & redeem

Once your lock reaches its maturity date:

  1. Whoever holds the PT20 (or PT721) calls Redeemer.redeemAndRequestUnstake(pt, amount, beneficiary).
  2. The PT20 is burned and an unstake request for amount DIEM is queued in DailyUnstakeQueue.
  3. After Venice's 1-day cooldown, anyone can call sync() (backend does it automatically), which:
    • Drains the matured unstake from Venice.
    • Marks your request day Claimable.
  4. You (or anyone, on your behalf) calls claim(day, beneficiary) — DIEM is transferred to the beneficiary.

Detailed unstake mechanics →

Visual flow

Day 0
  Alice has 10 DIEM, wants out by Jul 1.

  Locker.lockPT20(10 DIEM, Jul 1, alice)

    ├──→ DIEM transferred → Vault → Venice (staked)
    ├──→ DD minted directly to Alice    [10 × 45 days = 450 DD]
    └──→ PT20-JUL26 minted to Alice [10 PT20]

Day 1..44
  Alice can do any combination:
    • Sell PT20 on DEX (e.g. SushiSwap pool PT20-JUL26/USDC)
    • Sell DD on DEX (DD/USDC pool)
    • Hold both and bid for her own inference days through DailyAuction
    • Lend PT20 as collateral on Aave/Morpho once those integrations land

  Meanwhile every day:
    • DailyAuction sells the next day's total capacity
    • Bidders pay DD + KAI premium
    • Winners get a Venice API key for that day

Day 45 (Jul 1, maturity)
  PT20-JUL26 is now redeemable. Anyone holding it can:

  Redeemer.redeemAndRequestUnstake(PT20-JUL26, 10, alice)

    ├──→ 10 PT20 burned
    └──→ Queue records: "alice gets 10 DIEM, request day = Jul 1"

Day 46
  Backend (or anyone) calls Queue.sync():
    • Vault.initiateUnstake(10 DIEM) — Venice cooldown starts

Day 47
  Backend (or anyone) calls Queue.sync() again:
    • Vault.claimUnstake() — DIEM is back in vault
    • Request day Jul 1 marked Claimable

Day 47+
  Anyone calls Queue.claim(Jul 1, alice):
    • 10 DIEM transferred to alice
    • Lock is fully closed.

That's it. No operator approval, no early-withdrawal fee for reaching maturity, no off-chain custody.

What can break?

  • The protocol's owner can rotate roles (e.g. swap to a new Locker contract) but only through a 7-day timelock with full on-chain visibility, giving you time to exit.
  • The backend can be down — settle is permissionless so anyone can call it. If your bid is never settled and 7 days pass, you can claimRefund unconditionally (escape hatch).
  • An emergency drain by the owner exists, but with a 7-day arm window during which you can fully exit through the normal queue.

Full safety model: Safety & owner model →.

Released under the MIT License.