Skip to content

Contracts overview

Technical reference for every smart contract in Kairence. For high-level user flow see How it works; for token-level descriptions see Tokens.

Contract map

USER ENTRY POINTS
  Locker            User → lock DIEM, get PT20/PT721 + DD
  Redeemer          User → redeem PT20/PT721, request unstake
  DailyAuction      User → bid for inference, claim refund

STATE ANCHORS
  VeniceStakingVault    Custodies DIEM, calls Venice stake/unstake
  kDIEM                 Internal escrow token (1:1 with staked DIEM)
  PT20 (one per maturity) ERC-5095 principal claim for monthly maturities
  PT721                 ERC-721 principal claim for arbitrary maturities
  DailyUnstakeQueue     Batches user unstakes into Venice cooldown windows

POLICY MODULES
  DDMinter              Computes DD issuance, mints DD on lock
  PT20Factory             CREATE2-deploys monthly PT20 contracts

UNIVERSAL TOKENS
  DD                    ERC-20 Burnable inference credit (1 DD = $1 inference)
  KAI                   ERC-20 Votes fixed-supply governance + auction premium

Wiring graph

                    ┌──────────────┐
                    │   Locker     │
                    └──────┬───────┘
        ┌──────────┬───────┼─────────┬──────────┐
        ▼          ▼       ▼         ▼          ▼
   ┌────────┐ ┌─────────┐ ┌──┐  ┌────────┐ ┌────────┐
   │ Vault  │ │ kDIEM   │ │DD│  │PT20Factory│ │ PT721  │
   └───┬────┘ │ Minter  │ │  │  └───┬────┘ └────────┘
       │      └─────────┘ └──┘      │
       │                            ▼
       │                       ┌────────┐
       │                       │   PT20   │ (one per maturity)
       │                       └────────┘


  ┌─────────┐
  │  Queue  │ ← Redeemer (writes)
  └─────────┘   PT20/PT721 (source of redeem)

                    ┌──────────────┐
                    │ DailyAuction │ ← reads Vault.dailyCap()
                    └──────────────┘

Per-contract pages

Standards used

OpenZeppelin moduleWhere
ERC20DD, KAI, kDIEM, PT20
ERC20BurnableDD, KAI
ERC20PermitDD, KAI
ERC20VotesKAI
ERC721PT721
Ownable2StepEvery admin contract
PausableDD, Locker, Redeemer
ReentrancyGuardLocker, Redeemer, Vault, Queue, Auction
SafeERC20All token interactions

Solidity version

All contracts compile with Solidity 0.8.28 under via-IR, evm_version = "cancun", optimizer_runs = 200.

Deploy script

script/Deploy.s.sol performs the full wire-up in the right order:

  1. Deploy 11 contracts.
  2. Call every setXxxInitial / addXxxInitial in the right order.
  3. auction.registerPlatform(vault).
  4. _verifyWiring() reads back every slot and reverts if any drift.

Run with:

sh
forge script script/Deploy.s.sol --rpc-url $BASE_RPC_URL \
  --account kairence-deployer \
  --sender 0x95EE9AFc670C4c9973b1768c72Ab03546993dadb \
  --broadcast

Post-deploy: forge script script/VerifyKAI.s.sol --rpc-url $BASE_RPC_URL to verify the four KAI tranches distributed correctly.

Released under the MIT License.