Appearance
Rust SDK
The Rust SDK is the flint-sdk crate (library flint_sdk). The spot DEX lives under flint_sdk::spot: an async, tonic-based client for every service in flint.spot.v1, the quoting layer (QuoteBuilder for OrderList, OracleOffset and LinearDistribution, committed through QuotingCore), the on-chain program helpers in spot::chain, and swap building for takers in spot::swap. Each part sits behind a Cargo feature, so a read-only consumer compiles none of the Solana program code.
Install
From the Kellnr registry (needs a registry token). Pick the feature for what you build:
toml
# Makers: clients, quoting, receipts
flint-sdk = { version = "12", registry = "kellnr", features = ["spot-quoting"] }toml
# Read-only consumers: public and authenticated clients, no quoting
flint-sdk = { version = "12", registry = "kellnr", features = ["spot"] }toml
# Takers: swap quoting and building (see Taking liquidity)
flint-sdk = { version = "12", registry = "kellnr", features = ["spot-swap"] }The same crate also holds the margin exchange's clients at the crate root; its default features build those and nothing from the spot DEX.
Registry token
Pulling from Kellnr requires a read-only registry token. Grab yours from the dashboard (Maker → Quoters → SDK access) — it is minted on first view, and the same token is shown on every visit.
Point Cargo at the registry in ~/.cargo/config.toml:
toml
[registries.kellnr]
index = "sparse+https://kellnr.xantasoft.com/api/v1/crates/"Then store the token with cargo login (paste it at the prompt):
sh
cargo login --registry kellnrOr skip the login and supply it via the environment (e.g. in CI):
sh
export CARGO_REGISTRIES_KELLNR_TOKEN=<token>Quickstart
There are two entry points in flint_sdk::spot. Client covers the public services and needs no credentials. Maker authenticates, owns the channels to both server listeners (see Endpoints) and the resilient streams, and exposes its public half as maker.client(). Reach for maker.raw() and client.raw() only when you need the generated clients.
rust
use std::sync::Arc;
use solana_sdk::signer::keypair::read_keypair_file;
use flint_sdk::Cluster;
use flint_sdk::spot::{Client, Maker};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Public consumer. Construction is synchronous and needs no credentials.
let client = Client::mainnet();
for listed in client.pairs().await? {
println!("{} / {}", listed.pair.base, listed.pair.quote);
}
// Maker — supply a wallet. `connect` authenticates before it returns, and
// every authenticated call picks up the cached bearer automatically.
let kp = read_keypair_file("/path/to/id.json").map_err(|e| anyhow::anyhow!("{e}"))?;
let maker = Maker::connect(Arc::new(kp), Cluster::mainnet()).await?;
let session = maker.session().await?;
println!("authenticated as maker_id={}", session.maker_id);
let balance = maker.balance(&[]).await?;
println!("{balance:?}");
Ok(())
}The generated tonic clients remain available for RPCs you want to call directly. maker.raw() hands out the ones that speak to the authed listener, with the bearer attached:
rust
let mut maker_rpc = maker.raw().maker();
let mut tx_rpc = maker.raw().tx()?;
let mut market_rpc = client.raw().market_data();
# let _ = (maker_rpc, tx_rpc, market_rpc);MarketDataService, StatsService, and HistoricalService live on the public listener — client.raw() hands out their clients, no auth needed.
Endpoint discovery
By default, Maker::builder().build() resolves every DNS record behind the public hostname, races a probe across the addresses (median of three NodeService.GetNodeInfo calls each), and pins both channels to the fastest healthy node — each deployment node serves api and makerapi from the same address, so the authed channel follows the public winner rather than running a weaker probe of its own. A background task re-probes every 10 s:
- If the pinned node stops answering (or reports degraded health), the channel switches to the best alternative immediately.
- A merely faster node must beat the pinned one by ≥10 % and ≥5 ms, in two consecutive rounds (so ~20 s), before a switch — a transient network blip never cuts live streams.
Every executed switch force-reconnects the client's resilient streams and session heartbeat onto the new node (swapping the channel's endpoint alone would only affect new RPCs — streams already in flight stay on the old connection otherwise). Switches and deferred candidates are logged at debug; anything that needs attention — a pinned node gone, a whole probe round failing — is warn.
rust
let maker = Maker::builder()
.cluster(Cluster::mainnet())
.wallet(wallet)
.endpoint_discovery(false) // opt out entirely, or
.discovery_interval(Duration::from_secs(60)) // slow the re-probe cadence
.build()
.await?;
// Observability: the node both channels are pinned to right now.
let pinned = maker.discovered_endpoint();
// Saw a disconnect yourself? Trigger a re-probe immediately.
maker.reprobe_endpoints();Discovery is skipped for IP-literal endpoints and pre-built channels (public_channel / auth_channel), which always connect directly.
The Python SDK has the same feature with the same thresholds — see Python: endpoint discovery. The browser TypeScript SDKs do not: gRPC-Web can't resolve DNS or pin TLS to a raw IP.
Where to go from here
| You want | Page |
|---|---|
| Boot a maker bot | Quoting |
| Shorten quote transaction lifetime | Quoting: controlling transaction lifetime |
| Widen spread ahead of risky slots | Quoting: SpreadProtect |
| Stream books and fills | Market data |
| Pull historical fills / candles | Historical queries |
| Sign-in flow detail | Auth flow |
Decimal handling
Every wire numeric — book/fill prices and sizes, historical SpotFill/Candle OHLCV, and MakerBalanceEvent.balance — is a decimal string on the wire. The models decode them into rust_decimal::Decimal, so there is nothing to unwrap or parse:
rust
let notional = trade.price * trade.size;flint_sdk::Decimal re-exports that type. A fill, maker fill, activity, quote update or decoded transaction whose wire signature is empty (the server sends one when the signature is invalid) decodes with signature: None instead of failing the stream.
When the quoting builders lower a price to oracle units, a bid (buy) price rounds down and an ask (sell) price rounds up: oracle fairs, linear fairs and order-list placements. Price offsets, spread backoff, maker-volume backoff and cross spreads keep their previous rounding.
Errors
Client calls return flint_sdk::Result<T>, whose error is flint_sdk::Error. Match on the variant: Error::Api carries the gRPC code (StatusCode), message, the method and the server's diagnostics; Error::Auth, Error::Transport, Error::Input and Error::Commit cover sign-in, connection, argument and quoting-receipt failures. Branch on ApiError::code for retry decisions, and on AuthError::code() (the server's StatusCode when it rejected the sign-in, None for a local failure); see Errors. Swap building returns spot::swap::SwapError and the aggregator clients AggregatorError; both convert into flint_sdk::Error.
Logging
The Rust SDK uses tracing. By default it logs connection, auth, and stream lifecycle events only if your application installs a tracing subscriber and enables debug or trace. At debug, client construction logs the SDK version, proto hash, and proto revision stamped on outbound requests.
To turn on full protobuf message payload logs for SDK-owned calls, enable it on the builder:
rust
let maker = Maker::builder()
.cluster(Cluster::mainnet())
.wallet(wallet)
.log_messages(true)
.message_log_limit(50_000)
.build()
.await?;Notes:
- Message payload logs are opt-in.
- Payload logging covers the SDK-managed auth flow, config refresh, and stream helpers.
- Payloads are emitted at
trace. message_log_limitcaps each payload in characters. Use0to disable truncation.- Auth fields such as
nonce,signature,code, andsession_tokenare redacted. - Bearer headers and API key headers are not logged.
Cargo features
| Feature | Default | What it adds |
|---|---|---|
tls | yes | HTTPS via rustls + native roots. |
spot | no | spot::Client, spot::Maker, auth, models, streams and proto::spot. No Solana program code. |
spot-quoting | no | spot::quoting (QuotingCore, Receipt, retries, failover) and spot::chain (program ids, PDAs, accounts, instructions, units, QuoteBuilder). Adds the Solana RPC client and private crates from Kellnr. |
spot-swap | no | spot::swap: market loading, exact-in/out quotes, direct swaps with the min-out guard, the Jupiter route, and the Jupiter and Titan clients. Implies spot-quoting. |
quic | no | Send quoting transactions straight to the leader's TPU over QUIC. |
full | no | Everything, margin and spot. |
The root features (client, maker, rpc, chain) are the margin exchange's and are documented on the margin docs site.
