On-Chain Program
Program ID: EmM2mjKXruMuSHWJmRiFZed9vypWn7oxL1CzgBws3Rhp
Accounts
Trade PDA
Seeds: ["trade", maker, seed_u64_le]. Holds asset manifests, status, expiry, escrowed SOL, optional private taker and counter-offer linkage. Up to 16 assets per side.
Config PDA
Seeds: ["config"]. Protocol fee (max 5%), treasury, pause flag, authority. Never touches escrow.
Asset types
- SOL — escrowed on trade PDA lamports
- SPL — trade-owned vault ATAs; Token-2022 with safe extensions only
- NFT — supply 1, decimals 0; same vault mechanism
Instructions
| Instruction | Who | What |
|---|---|---|
create_trade | Maker | Init trade with manifests |
deposit_sol | Maker | Escrow SOL leg |
deposit_token | Maker | Escrow SPL/NFT into vault |
activate_trade | Maker | Verify full escrow → Active |
accept_trade | Taker | Atomic settlement |
cancel_trade | Maker | Cancel + SOL refund |
expire_trade | Anyone | Enforce deadline |
reclaim_token | Maker | Recover token after cancel/expire |
close_trade | Maker | Close account, recover rent |
State machine
Initialized → Active → Completed | Cancelled | Expired
Security
- Token-2022 extension gating (rejects transfer hooks, fees, permanent delegates)
- NFT validation (supply 1, decimals 0)
- Status guards prevent double-settlement and replay
- On-chain expiry enforced at accept time
- Fee capped at 5% hardcoded; treasury must match config
- 17 dedicated tests in
tests/bazaarfi.test.ts
Full instruction reference: docs/on-chain-program.md