Rust SDK
Async, tonic-based Rust client for every service in sweetspot.api.v1. Quoting layer (OrderList, OracleOffset, LinearDistribution — all built using QuoteBuilder) behind the default quoting feature; turn it off for read-only consumers to drop the on-chain Solana SDK from your build.
Install
[dependencies]
sweetspot-api-client = { git = "https://github.com/superis-labs/sweetspot-maker-client", branch = "master" }
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }When the SDK is published to crates.io:
sweetspot-api-client = "0.1"Read-only (no quoting):
sweetspot-api-client = { version = "0.1", default-features = false, features = ["tls"] }Quickstart
The ergonomic entry point is Client — one handle that owns two tonic [Channel]s (one per server listener — see Onboarding), an optional AuthFlow, a ConfigCache, a ServerState, and resilient stream supervisors. Use the builder for everyday integrations; reach past it (client.public_channel(), client.auth_channel(), client.auth(), client.config_cache()) only when you need finer control.
use std::sync::Arc;
use solana_sdk::signature::Keypair;
use solana_sdk::signer::keypair::read_keypair_file;
use sweetspot_api_client::api::client::Client;
use sweetspot_api_client::api::proto::ListPairsRequest;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Public consumer — no wallet, no authed endpoint needed.
let client = Client::builder()
.public_endpoint("https://api.superis.exchange:443")
.build()
.await?;
let mut market = client.market_data();
let pairs = market.list_pairs(ListPairsRequest {}).await?.into_inner();
for pair in &pairs.pairs {
println!("{:?} / {:?}", pair.base, pair.quote);
}
// Maker — supply a wallet plus the authed endpoint, then authenticate
// once. Authenticated service clients pick up the cached bearer
// automatically and route to the authed listener.
let kp = read_keypair_file("/path/to/id.json").map_err(|e| anyhow::anyhow!("{e}"))?;
let client = Client::builder()
.public_endpoint("https://api.superis.exchange:443")
.auth_endpoint("https://auth.api.superis.exchange:443")
.wallet(Arc::new(kp))
.build()
.await?;
let session = client.authenticate().await?;
println!("authenticated as maker_id={}", session.maker_id);
let mut _maker = client.maker()?;
let mut _tx = client.tx()?;
Ok(())
}The bare building blocks remain available for callers who want to wire things up by hand. AuthFlow, MakerServiceClient, and TxServiceClient speak to the authed listener:
use std::sync::Arc;
use sweetspot_api_client::api::auth::AuthFlow;
use sweetspot_api_client::api::proto::maker_service_client::MakerServiceClient;
let auth_channel =
tonic::transport::Channel::from_static("https://auth.api.superis.exchange:443")
.connect()
.await?;
let auth = AuthFlow::new(auth_channel.clone(), Arc::new(my_keypair));
let session = auth.token().await?;
let mut maker = MakerServiceClient::with_interceptor(
auth_channel,
auth.interceptor(),
);
# let _ = (session, maker);MarketDataService, StatsService, and HistoricalService live on the public listener — pass client.public_channel() to their clients directly, no auth needed.
Where to go from here
| You want | Page |
|---|---|
| Boot a maker bot | Quoting |
| Stream books and fills | Market data |
| Pull historical trades / candles | Historical queries |
| Sign-in flow detail | Auth flow |
Decimal handling
Every wire numeric — book/fill prices and sizes, historical Trade/Candle OHLCV, and MakerBalanceEvent.balance — is wrapped as Decimal { value: String }. Parse with rust_decimal:
use rust_decimal::Decimal;
use std::str::FromStr;
let price = Decimal::from_str(&trade.price.as_ref().unwrap().value)?;
let size = Decimal::from_str(&trade.size.as_ref().unwrap().value)?;
let notional = price * size;Errors
The SDK surfaces gRPC tonic::Status directly. Branch on status.code() for retry decisions — see Errors.
Cargo features
| Feature | Default | What it adds |
|---|---|---|
tls | yes | HTTPS via rustls + native roots. |
quoting | yes | Quoting layer (QuoteBuilder for OrderList / OracleOffset / LinearDistribution, QuotingCore, Receipt, sequence trackers). Pulls in the on-chain Solana SDK. |
Source
- Crate:
rust/ - Examples:
examples/rust/
