Build Plan - Fully Onchain Perps CLOB on Solana
Status: Active Company: Artifi Labs Audience: Internal team, grant reviewers, future contributors Related: milestones.md · risks-and-security.md · grant-application.md
Summary
Artifi Labs is building a fully onchain perpetual futures protocol, anchored by a central limit order book (CLOB) with isolated margin, USDC collateral, and SOL as the first market. Total grant ask: $65k (BSL 1.1 monorepo). Independent security audit funded separately by the Solana Foundation.
Locked Decisions
| # | Decision | Value |
|---|---|---|
| 1 | Architecture | Onchain CLOB, slab-based, price-time priority |
| 2 | Matching model | Fully onchain execution; no offchain sequencer or matching engine |
| 3 | Initial market | SOL-PERP (BTC-PERP and ETH-PERP optional, post-MVP) |
| 4 | Margin mode | Isolated margin only for MVP |
| 5 | Collateral | USDC only for MVP |
| 6 | License | BSL 1.1 (programs + SDK - source-available, prevents commercial closed-source forks) |
| 7 | Audit | Staged approach: targeted reviews during grant, full audit post-launch from protocol fees |
| 8 | Team | 6 people (5 engineers, 1 designer) |
| 9 | Funding ask | $65k (Milestone-based grant; audit funded by Solana Foundation) |
| 10 | Project name | [TBD - Artifi Labs is the company; project name to be finalized] |
| 11 | Revenue model | 5bps taker / 1bps maker rebate; 10% of protocol revenue routed to Solana public goods at protocol level |
Architecture (one-pager)
+----------------+ +-------------------+ +-------------------+
| Trader Web UI | <----> | TS SDK + Indexer | <----> | RPC / Stream |
+----------------+ +-------------------+ | Provider (gRPC) |
+-------------------+
|
v
+-----------------------------------------------------------------+
| SOLANA PROGRAMS |
| +----------+ +----------+ +----------+ +--------------+ |
| | CLOB | | Vault | | Risk / | | Keeper / | |
| | (slab) |<->| (coll.) |<->| Margin |<->| Liquidation | |
| +----------+ +----------+ +----------+ | Bot | |
| ^ ^ ^ +--------------+ |
| | | | |
| +-------------+-------------+--------------------------+
| | |
| +------+------+ |
| | Pyth Oracle | |
| +-------------+ |
+-----------------------------------------------------------------+
Core principles (mapped to Solana Foundation criteria)
- Fully onchain execution - every place, cancel, match, and settlement is a Solana transaction
- Real price discovery - slab-based CLOB, price-time priority; no AMM or pool-based pricing
- Solana-first - uses native SVM features (versioned transactions, priority fees, Pyth, SPL); no EVM bridges
- Open source - programs and SDK published under BSL 1.1; app includes proprietary components
- Isolated risk - each position carries its own collateral, so bad trades cannot socialize losses
Streaming Infrastructure (Staged)
Perps DEXes require sub-second data for liquidations, funding rate updates, and oracle price feeds. A dedicated Geyser node is overkill for the MVP. We follow a tiered approach:
Stage 1 - Devnet (Cost: 49/mo)
- Stream: Standard Solana WebSockets (
accountSubscribe,programSubscribe) - free and fast enough for bot logic testing - RPC: Helius or Chainstack devnet endpoints
- Oracle: Pyth Network devnet feeds (pull oracle architecture, sub-second updates)
- Transaction delivery: Standard tx submission; no Jito bundles needed yet
Stage 2 - Mainnet Alpha (Cost: 500/mo)
- Stream: Upgrade to a managed Yellowstone gRPC connection
- Providers: Chainstack Growth plan (~19-3k/mo hardware bill
- Oracle: Pyth mainnet pull oracle feeds
- Transaction delivery: Integrate Jito bundles for liquidation transactions - free off-chain revert if a liquidation would fail, saving tx fees
Stage 3 - Mature Mainnet (TVL >2k+/mo)
- Stream: Dedicated RPC node with Triton One Yellowstone gRPC
- Transaction delivery: Priority fee bidding + Jito bundles to guarantee liquidation txns land before toxic flow
Milestone Overview
See Milestones for the full breakdown.
| # | Focus | Budget |
|---|---|---|
| M1 | Research, architecture & visual prototype | $5,000 |
| M2 | Core on-chain programs & devnet integration | $15,000 |
| M3 | Complete on-chain programs | $12,000 |
| M4 | Off-chain infrastructure (indexer, keeper) | $10,000 |
| M5 | Full trading interface & monitoring | $8,000 |
| M6 | Security & mainnet | $10,000 |
| M7 | Developer SDK & ecosystem | $5,000 |
| Total | $65,000 |
Risks
See Risks & Security for the full risk register, threat model (top 10 attack surfaces), and incident response plan. Top three:
- Compute budget onchain - mitigated by batched matching and early CPI budget audit
- Oracle manipulation or staleness - mitigated by Pyth EMA + deviation circuit breaker + chaos tests
- Insufficient MM liquidity - mitigated by shipping a reference MM bot in M4 and seeding it ourselves
Audit Strategy
A full professional audit will be completed before mainnet deployment. Security is a prerequisite for launching any protocol that handles user funds. The independent security audit is funded separately by the Solana Foundation (see Grant Application - Support Beyond Funding).
| Phase | Security Activity |
|---|---|
| M1 | Threat model documented |
| M2 | Property-based tests for slab matching |
| M3 | Targeted external review of liquidation math + oracle guards |
| M4 | Friends-and-family test program; open-source release enables community review |
| M6 | Multi-sig governance, SEAL Framework certification, mainnet deployment |
Revenue Routing to Solana
Addressing the Foundation criterion that "application revenue should be structurally routed back to the chain, preferably set at protocol level from launch":
- 10% of net protocol revenue (retained protocol fees after maker rebates/payouts) hardcoded to a Solana public goods treasury
- Fee schedule: 5bps taker / 1bps maker rebate (net 4bps protocol revenue on taker flow)
- Governed by 3-of-5 multi-sig during MVP, transitioning to SPL Governance
- Hardcoded in the
riskprogram - no future governance vote required to maintain the Solana routing
Mapping to Solana Foundation Criteria
| Foundation criterion | Where in this plan |
|---|---|
| 1. Fully onchain execution | clob, vault, risk programs - all state and matching onchain |
| 2. Real price discovery | Slab CLOB with price-time priority; no pool/AMM pricing |
| 3. Solana-first | Pyth, SPL, versioned txs, priority fees, managed gRPC streams, Jito bundles for liquidations, + 10% protocol revenue routed to Solana chain |
| 4. Innovation | Isolated-margin CLOB with onchain insurance fund and explicit ADL fallback |
| 5. Experienced teams | 6-person Solana-native team |
| 6. Open source | Core protocol (programs + SDK) BSL 1.1 from day 1 |
Open Items
- Legal entity registration - working as Artifi Labs; welcome Solana Foundation assistance with establishing entities that control the protocol and token
- Market maker partnerships - identify 1-2 MMs willing to quote on mainnet before launch
- RPC/stream provider - Helius or Chainstack for managed Yellowstone gRPC during alpha; Triton One at scale
- Token launch - not in scope for this grant. The protocol will launch without a token, using a points-based incentive system for early trading activity. Token economics will be defined in a future phase. Protocol fee routing to Solana treasury is hardcoded in
riskprogram - Full professional audit - funded separately by the Solana Foundation; to be completed before mainnet deployment
- High-speed data infrastructure - the trading app requires sub-second data feeds; understanding Solana's event system (Geyser, program logs, account subscriptions) is critical for the indexer and real-time UI