Appearance
Prices, sizes, and units
Every numeric field that represents a human price, size, balance, or volume is a decimal string on the wire — books, fills, candles, trades, and maker balances all share the same Decimal { value } message, and the SDKs hand it to you as rust_decimal::Decimaldecimal.Decimal. This is the load-bearing contract: get it right and everything downstream works.
Why strings
Floating-point arithmetic loses precision for large notionals. Decimal strings preserve the exact representation. Parse with whatever fixed-precision type your language offers:
| Language | Library |
|---|---|
| Rust | rust_decimal::Decimal |
| Python | decimal.Decimal |
| TypeScript | bignumber.js or decimal.js |
Conventions on the wire
| Field | Example | Meaning |
|---|---|---|
price | "155.14" | Quote per base, human-readable |
size | "10.0" | Base token units (e.g. SOL) |
volume | "42.137" | Candle base-asset volume |
open / high / low / close | "154.97" | Candle OHLC |
balance | "1.5" | Maker balance in token units (server scales by SpotMetadata.decimals) |
best_bid / best_ask / mid | strings | Optional, omitted on empty side |
You will never see on the wire:
- Lot multiples.
- Oracle units.
MakerService reports balances in human token units — the server applies SpotMetadata.decimals for you, so a 1.5-SOL balance arrives as a decimal string value of "1.5", not 1_500_000_000 atoms.
The SDK's quoting layer converts the human values you pass to the on-chain integer forms exactly once, at the point of building the instruction. The integer forms are documented in How Flint works for completeness — most integrators never have to think about them.
Pricing helpers
For when you need the conversion outside a QuoteBuildercore.builder() call:
rust
use flint_sdk::spot::chain::units::{human_size_to_lots, human_to_oracle, oracle_to_human};
use rust_decimal::Decimal;
let markets = client.markets().await?;
let market = markets
.iter()
.find(|m| m.name == "SOL/USDC")
.ok_or_else(|| anyhow::anyhow!("SOL/USDC is not listed"))?;
let units = market.units();
let oracle = human_to_oracle("155.14".parse()?, &units)?; // → 155_140
let back = oracle_to_human(oracle, &units)?; // → 155.14
let lots = human_size_to_lots(Decimal::from(10), &units)?; // → 10_000python
from decimal import Decimal
from flint.spot.chain.units import human_size_to_lots, human_to_oracle, oracle_to_human
markets = await client.markets()
market = next(m for m in markets if m.name == "SOL/USDC")
oracle = human_to_oracle(Decimal("155.14"), market.units)
back = oracle_to_human(oracle, market.units)
lots = human_size_to_lots("10.0", market.units)The conversions take rust_decimal::Decimal and return a Result; edge cases are documented in the Rust function-level docs.Human money inputs must be decimal.Decimal, decimal strings, or integers. Floats, NaN/Infinity, negatives, overflows, fractional atoms, and non-lot-aligned sizes raise instead of being rounded into quote bytes.
Timestamps
Timestamp { micros }— Unix microseconds since epoch. Used on trades, candles, stream events, and range bounds. The SDKs convert it tochrono::DateTime<Utc>datetime.datetime.slot— Solana slot number. Useful for cross-referencing on-chain data.- Historical
startis inclusive. Historicalendis exclusive and defaults to server time when unset (micros = 0on the wire,Nonein the SDKs).
Enums on the wire
Wire/proto enum names use these variant names:
| Field | Examples |
|---|---|
interval | "CANDLE_INTERVAL_5M", "CANDLE_INTERVAL_1H", "CANDLE_INTERVAL_1D" |
side | "SIDE_BUY", "SIDE_SELL" |
state | "HEALTH_STATE_HEALTHY", "HEALTH_STATE_DEGRADED" |
The SDKs expose typed enum forms or generated constants, so you don't have to hardcode raw numbers.
