client.balances reads ledger balances. Unlike Python/Go convenience signatures, list takes a
proto GetBalancesRequest.
Balance fields are already scaled integer decimal strings on the wire (ledger u128 at the
assetโs ledger scale, typically 18). Decode once: pass the string into format_ledger_u128 for
display. Do not multiply by 1e18 again. Use format_ledger_u128 for the full wire range; format_ledger_u64 remains available for values already known to fit in u64.
Spot orders spend trading balance
An external deposit can stop in funding or continue to trading, depending on its route. Spot orders and holds use trading balance.
Funding to trading is on-chain / wallet-driven, not a ConnectRPC balance write.
Methods
| Method | Summary |
|---|---|
list | GetBalancesRequest โ BalancesList |
get_balance_history | GetBalanceHistoryRequest |
get_equity_history | GetEquityHistorySeriesRequest |
list_holds | ListHoldsRequest |
list_transfers | ListTransfersRequest (also on balances in Rust) |
subscribe | Private balance stream (recv_result) |
List
use polyester::proto::ledger::read::v1::GetBalancesRequest;
let list = client.balances.list(GetBalancesRequest::default()).await?;
for b in list.balances {
println!(
"{} trading={} available={}",
b.asset_id,
polyester::codecs::scalars::format_ledger_u128(&b.trading, 18)?,
polyester::codecs::scalars::format_ledger_u128(&b.available, 18)?,
);
}
let scoped = client.balances.list(GetBalancesRequest {
subaccount_id: Some(123),
..Default::default()
}).await?;AssetBalance: asset_id, trading, funding, reserved, available, trading_revision, funding_revision.
Balance and hold history
use polyester::proto::ledger::read::v1::{
GetBalanceHistoryRequest, GetEquityHistorySeriesRequest, ListHoldsRequest,
};
let hist = client.balances.get_balance_history(GetBalanceHistoryRequest {
// set range / ledger / account_codes as needed
..Default::default()
}).await?;
// Each series exposes balance_q as Vec<u64> and account_code as raw i32,
// preserving the complete wire values, including unknown future enum codes.
let equity = client.balances.get_equity_history(GetEquityHistorySeriesRequest {
..Default::default()
}).await?;
let holds = client.balances.list_holds(ListHoldsRequest {
limit: 50,
..Default::default()
}).await?;Hold-route availability is host-specific
The typed
list_holds wrapper can be present in the SDK while the target host does not mount its
RPC. In particular, api-devnet may return Error::RouteNotFound. That result describes host
capability/deployment configuration, not an SDK implementation failure; use the method only
against an environment that exposes the route.Subscribe
let mut sub = client
.balances
.subscribe(client.default_account_id.as_deref())
.await?;
while let Some(b) = sub.recv_result().await? {
println!(
"{} available={}",
b.asset_id,
polyester::codecs::scalars::format_ledger_u128(&b.available, 18)?,
);
break;
}Streamed balance components use the same raw ledger u128 representation as snapshots.
Related
Related Topics
Address book Saved destinations and whitelist views. API keys List, get, subscribe, and generate local API key material (no create on API-key SDKs). Auth Auth service helpers including nested profile access. Candles Read and stream public spot OHLCV candles via market_data. Catalog Spot/Zipper catalog hydration with hydrate_catalogs and wait_for_catalogs. Chain helpers On-chain Funding โ Trading and Funding withdraw helpers. Chain analytics Chain analytics read APIs. Client configuration Config fields, URLs, catalogs, wire format, and from_env behavior. Deposit Create and list per-account chain deposit addresses for funding your Polyester account. Errors Rust Error enum variants, MFA auth codes, and queue overflow. Guard signer Guard signer approval helpers. Heatmap L2 order book heatmap reads. Internal transfers Move trading balances between Polyester accounts without touching a chain. Layout Layout collaboration APIs (reference-only). Lifecycle Deposit/withdraw lifecycle flows and subscribe. Market overview List and subscribe to per-market stats with optional snapshot-then-stream merge. Order book Depth snapshots and a stateful live order book that reconstructs the book for you. Orders Place, modify, cancel, batch, and stream spot orders with the Rust OrdersService. Policies Realtime API-key and subaccount-policy updates. Polychart Polychart collaboration APIs (reference-only). Profile Profile identity reads and subscribe helpers. Public trades Public trade tape reads and subscribe via market_data. Realtime Shared Centrifugo client, observable failures, handshake-before-return, and fail-closed overflow. Social verification Social verification APIs (reference-only). Subaccounts Subaccount reads, members, invites, activity. User trades List and stream your private spot fills (not the public tape). Transfers Transfer history reads. Triggers Create, manage, pause/resume, and stream standalone triggers with the Rust TriggersService. Whiteboard Whiteboard collaboration APIs (reference-only). Withdrawals Trading withdraw intents to funding or external chain destinations (signed payload). Zipper Deposit/withdraw config and related Zipper reads.