Phoenix
Phoenix Overview¶
Phoenix is the first fully on-chain Central Limit Order Book (CLOB) DEX in the Solana ecosystem, providing professional traders with a trading experience comparable to centralized exchanges. Unlike traditional AMMs, Phoenix uses an order book model supporting limit orders, market orders, and other order types, offering precise price control and deep liquidity. Through Solana's high performance and low latency advantages, Phoenix achieves fully on-chain order matching without relying on centralized servers, truly delivering decentralization, transparency, and self-custody.
Website: https://phoenix.trade/
Core Features¶
1. Central Limit Order Book (CLOB)¶
Professional trading mechanism:
- Price Priority: Best price executes first
- Time Priority: Same price fills in chronological order
- Precise Control: Set exact buy/sell prices
- Depth Display: Complete order book depth visualization
- Order Types: Limit, Market, IOC, POST_ONLY, and more
2. Fully On-Chain¶
True decentralization:
- On-Chain Matching: Order matching occurs on-chain
- No Intermediaries: No need to custody funds on centralized servers
- Transparent and Auditable: All orders and trades are verifiable on-chain
- Censorship Resistant: Cannot be shut down or frozen
- Self-Custody: Users maintain complete control of their assets
3. High-Performance Optimization¶
Fully leveraging Solana's advantages:
- Low Latency: Order submission and execution < 1 second
- High Throughput: Supports thousands of transactions per second
- Low Cost: Transaction fees < $0.01 per trade
- Instant Settlement: No block confirmation wait required
- Batch Processing: Supports batch order placement and cancellation
How It Works¶
1. Order Book Structure¶
Order Book Data Structure:
Asks (Sell Orders) - Sorted by price from low to high
+-----------------------------+
| Price Quantity Cumulative|
| $25.10 100 100 | <- Lowest ask price (Best Ask)
| $25.12 200 300 |
| $25.15 500 800 |
+-----------------------------+
Current Market Price: $25.08
+-----------------------------+
| Price Quantity Cumulative|
| $25.05 300 300 | <- Highest bid price (Best Bid)
| $25.03 150 450 |
| $25.00 250 700 |
+-----------------------------+
Bids (Buy Orders) - Sorted by price from high to low
2. Order Matching Flow¶
User submits order → Phoenix Program
↓
Verify order validity
↓
Calculate fillable quantity
↓
Match against order book counterparties
↓
Execute trade, update balances
↓
Unfilled portion placed on order book
↓
Emit trade event
3. Maker-Taker Model¶
Fee incentive mechanism:
Maker (Order Placer):
- Submits limit orders, adds order book depth
- Fee: -0.02% (receives rebate)
- Example: Place buy order for 100 SOL, receive 0.02 SOL rebate
Taker (Order Taker):
- Submits market orders, consumes order book liquidity
- Fee: 0.05%
- Example: Market buy 100 SOL, pay 0.05 SOL fee
Net Effect: Maker rebate = 40% of Taker fee
Practical Applications¶
1. Basic Trading¶
Trading with the Phoenix SDK:
import { PhoenixClient } from '@ellipsis-labs/phoenix-sdk'
import { Connection, Keypair, PublicKey } from '@solana/web3.js'
const connection = new Connection('https://api.mainnet-beta.solana.com')
const wallet = Keypair.fromSecretKey(/* your secret key */)
// Initialize Phoenix client
const phoenixClient = await PhoenixClient.create({
connection,
wallet,
})
// Get SOL/USDC market
const marketPubkey = new PublicKey('4DoNfFBfF7UokCC2FQzriy7yHK6DY6NVdYpuekQ5pRgg')
const market = await phoenixClient.getMarket(marketPubkey)
console.log('Market Info:', market.marketConfig)
// Limit buy order: Buy 10 SOL at $25.00
const limitBuyOrder = await phoenixClient.placeLimitOrder({
market: marketPubkey,
side: 'Bid', // Buy
price: 25.0,
size: 10.0,
orderType: 'Limit',
})
console.log('Limit buy order submitted:', limitBuyOrder.signature)
// Market sell order: Immediately sell 5 SOL
const marketSellOrder = await phoenixClient.placeMarketOrder({
market: marketPubkey,
side: 'Ask', // Sell
size: 5.0,
})
console.log('Market sell order executed:', marketSellOrder.signature)
2. Advanced Order Types¶
Using different order strategies:
import { PhoenixClient, OrderType } from '@ellipsis-labs/phoenix-sdk'
const phoenixClient = await PhoenixClient.create({ connection, wallet })
const market = new PublicKey('4DoNfFBfF7UokCC2FQzriy7yHK6DY6NVdYpuekQ5pRgg')
// 1. POST_ONLY order (Maker only)
// Cancels if it would execute immediately, ensures Maker rebate
const postOnlyOrder = await phoenixClient.placeLimitOrder({
market,
side: 'Bid',
price: 25.0,
size: 10.0,
orderType: 'PostOnly', // Will not take
})
// 2. IOC order (Immediate Or Cancel)
// Fills immediately, unfilled portion cancelled (no resting order)
const iocOrder = await phoenixClient.placeLimitOrder({
market,
side: 'Ask',
price: 25.1,
size: 10.0,
orderType: 'ImmediateOrCancel', // No resting order
})
// 3. FOK order (Fill Or Kill)
// Fill entirely or cancel entirely
const fokOrder = await phoenixClient.placeLimitOrder({
market,
side: 'Bid',
price: 25.0,
size: 100.0,
orderType: 'FillOrKill', // All or nothing
})
console.log('Advanced orders submitted')
3. Querying Order Book and Depth¶
Getting market data:
import { PhoenixClient } from '@ellipsis-labs/phoenix-sdk'
const phoenixClient = await PhoenixClient.create({ connection, wallet })
const marketPubkey = new PublicKey('4DoNfFBfF7UokCC2FQzriy7yHK6DY6NVdYpuekQ5pRgg')
// Get order book
const orderbook = await phoenixClient.getOrderbook(marketPubkey)
console.log('Order Book Depth:')
console.log('Asks:')
orderbook.asks.forEach((level, index) => {
if (index < 5) { // Show top 5 levels
console.log(` Price: ${level.price}, Quantity: ${level.size}`)
}
})
console.log('Bids:')
orderbook.bids.forEach((level, index) => {
if (index < 5) {
console.log(` Price: ${level.price}, Quantity: ${level.size}`)
}
})
// Get best bid/ask
const bestBid = orderbook.bids[0]?.price || 0
const bestAsk = orderbook.asks[0]?.price || 0
const spread = bestAsk - bestBid
const spreadBps = (spread / bestBid) * 10000
console.log('Market Stats:')
console.log('Best Bid:', bestBid)
console.log('Best Ask:', bestAsk)
console.log('Bid-Ask Spread:', spread, `(${spreadBps.toFixed(2)} bps)`)
// Get market depth
const depth = {
bids: orderbook.bids.slice(0, 10).reduce((sum, level) => sum + level.size, 0),
asks: orderbook.asks.slice(0, 10).reduce((sum, level) => sum + level.size, 0),
}
console.log('Top 10 Levels Depth:')
console.log('Total Bid Volume:', depth.bids, 'SOL')
console.log('Total Ask Volume:', depth.asks, 'SOL')
4. Market Making Strategy¶
Implementing a simple market-making bot:
import { PhoenixClient } from '@ellipsis-labs/phoenix-sdk'
const phoenixClient = await PhoenixClient.create({ connection, wallet })
const market = new PublicKey('4DoNfFBfF7UokCC2FQzriy7yHK6DY6NVdYpuekQ5pRgg')
// Market making configuration
const config = {
spread: 0.1, // 0.1% spread
orderSize: 5.0, // 5 SOL per order
levels: 3, // 3 levels of orders
tickSize: 0.01, // Price tick size
}
// Get current mid-price
const orderbook = await phoenixClient.getOrderbook(market)
const midPrice = (orderbook.bids[0].price + orderbook.asks[0].price) / 2
// Cancel existing orders
const openOrders = await phoenixClient.getOpenOrders(market)
for (const order of openOrders) {
await phoenixClient.cancelOrder({ market, orderId: order.orderId })
}
// Place two-sided orders
const orders = []
for (let i = 0; i < config.levels; i++) {
// Bid prices decreasing
const bidPrice = midPrice * (1 - config.spread / 100) - i * config.tickSize
const bidOrder = phoenixClient.placeLimitOrder({
market,
side: 'Bid',
price: bidPrice,
size: config.orderSize,
orderType: 'PostOnly',
})
orders.push(bidOrder)
// Ask prices increasing
const askPrice = midPrice * (1 + config.spread / 100) + i * config.tickSize
const askOrder = phoenixClient.placeLimitOrder({
market,
side: 'Ask',
price: askPrice,
size: config.orderSize,
orderType: 'PostOnly',
})
orders.push(askOrder)
}
await Promise.all(orders)
console.log('Market making orders placed:', orders.length)
// Periodically update orders (every 30 seconds)
setInterval(async () => {
// Recalculate prices and update orders...
}, 30000)
Phoenix vs Other DEXes¶
| Feature | Phoenix | Raydium (AMM) | OpenBook (CLOB) |
|---|---|---|---|
| Mechanism | Order Book | AMM Pool | Order Book |
| Price Control | Precise | Slippage | Precise |
| Liquidity Depth | Visible | Pool Depth | Visible |
| Maker Rebate | -0.02% | None | -0.03% |
| Order Types | Diverse | Market only | Diverse |
| Fully On-Chain | Yes | Yes | Yes |
| Best For | Pro trading | Retail trading | All scenarios |
Ecosystem Integration¶
1. DEX Aggregators¶
Phoenix liquidity aggregation:
- Jupiter: Aggregates Phoenix order book liquidity
- Mango Markets: Integrates Phoenix spot markets
- 1inch: Cross-chain aggregation of Phoenix liquidity
2. Trading Tools¶
Professional trading interfaces:
- TradingView Integration: Charts and technical analysis
- API Interface: REST and WebSocket APIs
- Trading Bots: Supports strategy trading and market making
- Mobile: iOS/Android apps
3. Wallet Support¶
Mainstream wallet integration:
- Phantom: Browser extension wallet
- Backpack: Integrated Phoenix trading interface
- Solflare: Supports Phoenix order management
Related Concepts and Technologies¶
- Solana: High-performance blockchain
- CLOB: Central Limit Order Book
- OpenBook: Serum's successor
- Jupiter: DEX aggregator
- Market Maker: Traders who provide liquidity
Summary¶
Phoenix, as the first fully on-chain CLOB DEX in the Solana ecosystem, delivers a trading experience comparable to centralized exchanges for professional traders. Through its order book mechanism, Phoenix provides precise price control, deep liquidity visualization, and diverse order types, meeting professional needs for high-frequency trading and market making. Compared to the AMM model, Phoenix's order book design eliminates slippage issues and incentivizes liquidity providers through Maker rebates. Leveraging Solana's high performance and low cost, Phoenix achieves true fully on-chain matching without relying on centralized servers, guaranteeing decentralization, transparency, and self-custody. For users seeking precise price control and professional trading tools, Phoenix provides an ideal on-chain trading solution. With the launch of perpetual contracts, options, and other derivatives, Phoenix will continue to enrich the Solana DeFi ecosystem and set new benchmarks for decentralized trading.