Smart Contracts

Solana smart contract managing options, collateral, and settlement


📦 Program Info

Property
Value

Network

Solana (Devnet & Mainnet)

Language

Rust

Framework

Anchor


🗂️ Key Accounts

Config

Purpose: Global protocol settings

Stores:

  • Admin public key

  • Protocol fee parameters

  • Authorized creators


Option Type

Purpose: Defines tradable asset pairs

Examples:

  • SOL-CALL - Right to buy SOL

  • SOL-PUT - Right to sell SOL

  • WBTC-CALL - Right to buy WBTC

  • WBTC-PUT - Right to sell WBTC


Seller Vault

Purpose: Market maker collateral storage

Tracks:

  • Owner & attestation keys

  • Total balances (SOL, WBTC, USDC)

  • Available vs locked amounts

Functions:

  • deposit → Add collateral

  • withdraw → Remove available collateral

  • Auto-locks when options created


Option Contract

Purpose: Individual option instance

Stores:

  • Buyer, seller, option type

  • Strike, amount, expiry

  • Premium paid

  • Exercise status

Lifecycle:

  1. Created when buyer accepts quote

  2. Active until exercised/expired

  3. Collateral released after settlement


Seller Quote Index (BRP)

Purpose: Prevent quote replay attacks

Structure:

  • 20 index accounts per MM

  • 100 slots each (2,000 total)

  • Monotonically increasing counters

How it works:

Quote says: "Slot 42, expect value 10"
Contract checks: slot[42] == 9 ✓
Contract updates: slot[42] = 10
Future replay fails: value already 10 ✗

Buyer Options Index

Purpose: Track buyer's option count

Stores:

  • Buyer public key

  • Total options created

Generates unique addresses for each option


⚙️ Core Operations

Create Option

1. Verify Ed25519 signature
2. Validate quote (not expired, BRP valid)
3. Lock collateral (vault → option contract)
4. Transfer premium (buyer → seller)
5. Create option account
6. Increment counters

Exercise Option

1. Verify not exercised, not expired
2. Execute settlement:
   CALL: Strike USDC → Seller, Asset → Buyer
   PUT: Asset → Seller, Strike USDC → Buyer
3. Mark as exercised

Withdraw Expired

1. Verify expired & not exercised
2. Return collateral to seller vault
3. Mark as expired

🔒 Security Features

Feature
Purpose

Ed25519 Signatures

Cryptographic proof quotes are authentic

BRP (Replay Protection)

Prevents reuse of old quotes

PDAs

Only program can modify account data

Collateral Locking

Cannot withdraw while options active


📐 Technical Specs

Decimals

Asset
Decimals
Unit Name

SOL

9

Lamports

WBTC

8

Satoshis

USDC

6

Micro-dollars

Time Units

  • Expiry stored as Solana slots

  • ~400ms per slot

  • 1 day ≈ 216,000 slots

  • 7 days ≈ 1,512,000 slots

Fees

  • Transaction fee: ~0.000005 SOL

  • Protocol fee: Configurable (TBD)


🔗 Account Addresses (PDAs)

All accounts use deterministic addresses:

Seller Vault:
  PDA(["seller_vault", owner_pubkey])

Option Contract:
  PDA(["option_contract", buyer_pubkey, option_index])

Seller Quote Index:
  PDA(["seller_quote_index", vault_pubkey, index_number])

Buyer Options Index:
  PDA(["buyer_options_index", buyer_pubkey])

Ensures:

  • Unique addresses

  • No collisions

  • Easy lookup


👨‍💻 For Developers

Full Documentation:

For Market Makers:


📚 Learn More

Last updated