Lightcone Rust SDK
Rust SDK for the Lightcone protocol on Solana.
Installation (TBC)
[]
= "0.1.0"
Modules
| Module | Description |
|---|---|
program |
On-chain Solana program interaction (accounts, transactions, orders, Ed25519 verification) |
api |
REST API client for market data and order management |
websocket |
Real-time data streaming via WebSocket |
shared |
Shared utilities (Resolution, decimal helpers) |
Quick Start
use *;
REST API
Query markets, submit orders, and manage positions via the REST API.
use LightconeApiClient;
async
On-Chain Program
Build transactions for on-chain operations: minting positions, matching orders, redeeming winnings.
use LightconePinocchioClient;
async
WebSocket
Stream real-time orderbook updates, trades, and user events.
use *;
use StreamExt;
async
Module Overview
Program Module
Direct interaction with the Lightcone Solana program:
- Account Types: Exchange, Market, Position, OrderStatus, UserNonce
- Transaction Builders: All 14 instructions (mint, merge, match, settle, etc.)
- PDA Derivation: 8 PDA functions with seeds
- Order Types: FullOrder (225 bytes), CompactOrder (65 bytes)
- Ed25519 Verification: Three strategies (individual, batch, cross-reference)
use *;
// Create and sign an order
let mut order = new_bid;
order.sign;
let hash = order.hash;
API Module
REST API client with typed requests and responses:
- Markets: get_markets, get_market, get_market_by_slug
- Orderbooks: get_orderbook with depth parameter
- Orders: submit_order, cancel_order, cancel_all_orders
- Positions: get_user_positions, get_user_market_positions
- Trades: get_trades with filters
- Price History: get_price_history with OHLCV
use *;
let response = client.submit_order.await?;
WebSocket Module
Real-time streaming with automatic state management:
- Subscriptions: book_updates, trades, user, price_history, market
- State Management: LocalOrderbook, UserState, PriceHistory
- Authentication: Ed25519 sign-in for user streams
- Auto-Reconnect: Configurable reconnection with exponential backoff
use *;
// Authenticated connection for user streams
let client = connect_authenticated.await?;
client.subscribe_user.await?;
// Access maintained state
if let Some = client.get_user_state
Shared Module
Common utilities used across modules:
- Resolution: Candle intervals (1m, 5m, 15m, 1h, 4h, 1d)
- Decimal Helpers: parse_decimal, format_decimal for string price handling
use ;
let res = OneHour; // "1h"
let price = parse_decimal?; // 0.5
Features
default- Standard featureslive_tests- Enable live integration tests
Program ID
Mainnet/Devnet: EfRvELrn4b5aJRwddD1VUrqzsfm1pewBLPebq3iMPDp2
License
MIT