Expand description
§Lightcone Pinocchio Rust SDK
A Rust SDK for interacting with the Lightcone protocol.
§Modules
This SDK provides three main modules:
program: On-chain program interaction (smart contract)api: REST API client for market data, orders, and positionswebsocket: Real-time data streaming via WebSocket
Plus a shared module:
shared: Shared utilities, types, and constants
§Quick Start - REST API
ⓘ
use lightcone_sdk::api::LightconeApiClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create API client
let api = LightconeApiClient::new("https://api.lightcone.io");
// Get all markets
let markets = api.get_markets().await?;
println!("Found {} markets", markets.total);
// Get orderbook
let orderbook = api.get_orderbook("orderbook_id", Some(10)).await?;
println!("Best bid: {:?}", orderbook.best_bid);
Ok(())
}§Quick Start - On-Chain Program
ⓘ
use lightcone_sdk::program::LightconePinocchioClient;
use lightcone_sdk::shared::types::*;
use solana_sdk::pubkey::Pubkey;
#[tokio::main]
async fn main() {
// Create on-chain client
let client = LightconePinocchioClient::new("https://api.devnet.solana.com");
// Fetch exchange state
let exchange = client.get_exchange().await.unwrap();
println!("Market count: {}", exchange.market_count);
// Create an order
let order = client.create_bid_order(BidOrderParams {
nonce: 1,
maker: Pubkey::new_unique(),
market: Pubkey::new_unique(),
base_mint: Pubkey::new_unique(),
quote_mint: Pubkey::new_unique(),
maker_amount: 1000,
taker_amount: 500,
expiration: 0,
});
}Modules§
- api
- REST API client module for market data, orders, and positions. REST API client module for Lightcone.
- prelude
- Prelude module for convenient imports.
- program
- On-chain program interaction module. Contains the client and utilities for interacting with the Lightcone smart contract. On-chain program interaction module for Lightcone.
- shared
- Shared utilities, types, and constants. Used across all SDK modules. Shared utilities and types used across API and WebSocket modules.
- websocket
- WebSocket client module for real-time data streaming. WebSocket client module for Lightcone.