Appearance
Errors
Every authenticated RPC can fail. Most failures fall into a handful of codes; the SDKs raise them as ApiError, carrying the gRPC status as code, the server's reason string as message, and the server's build details as server.
Codes you'll see
| gRPC code | When | Retry? |
|---|---|---|
UNAUTHENTICATED | Session token missing / expired / revoked. Pubkey not registered as a quoting authority. | Refresh the session and retry once. |
INVALID_ARGUMENT | Bad pair name, malformed pubkey, out-of-range limit, unsupported interval. | No — fix the input. |
RESOURCE_EXHAUSTED | Per-IP rate-limit bucket empty. | Yes, with exponential backoff. The bucket replenishes. |
FAILED_PRECONDITION | Historical query when the historical archive is disabled on this deployment. Or your SDK is older than the minimum the server supports; the message says which version to upgrade to. | No — enable the feature or upgrade the SDK. |
NOT_FOUND | Pair not in catalog, maker_id has no balances. | No — fix the input. |
UNAVAILABLE | The server (or a proxy in front of it) answered that it can't serve the call right now, for example while restarting. | Yes, with backoff. The Subscription every watch method returns reconnects automatically; for unary calls you decide the policy. |
INTERNAL | A bug. Report it. | Capped retry (1–3 attempts) before surfacing. |
When nothing answers at all (connection refused, DNS, TLS, a timeout with nothing received), the SDKs raise TransportError instead, with kindCONNECT, TLS or TIMEOUT and the endpoint. Retry it with backoff like UNAVAILABLE.
The SDKs don't retry unary calls. Pick your policy explicitly.
Minimum SDK version
A server can advertise the oldest SDK it supports in the x-flint-sdk-minimum response header. When yours is older, the SDK logs a warning once, the first time it sees the header, so you can upgrade before the server starts refusing that version with FAILED_PRECONDITION. Node discovery and health checks stay reachable either way, and clients that don't identify themselves with x-flint-sdk are never refused.
Reading errors
rust
use flint_sdk::{Error, StatusCode};
match maker.balance(&[]).await {
Ok(res) => /* ... */,
Err(Error::Api(e)) if e.code == StatusCode::Unauthenticated => {
maker.session().await?;
}
Err(Error::Api(e)) if e.code == StatusCode::ResourceExhausted => sleep_then_retry().await,
Err(e) => return Err(e.into()),
}python
from flint import ApiError, StatusCode
try:
await client.pairs()
except ApiError as exc:
if exc.code == StatusCode.RESOURCE_EXHAUSTED:
await sleep_then_retry()
if exc.code == StatusCode.UNAVAILABLE:
await sleep_then_retry()ts
import { ApiError, StatusCode } from "@superis-labs/flint";
try {
await client.pairs();
} catch (err) {
if (err instanceof ApiError) {
if (err.code === StatusCode.ResourceExhausted) await sleep(backoff);
if (err.code === StatusCode.Unavailable) await sleep(backoff);
}
}Auth-flow specific failures
AuthService.Authenticate returns UNAUTHENTICATED for any of:
- The pubkey has no outstanding nonce (you didn't call
Challengefirst). - The nonce expired (TTL exceeded between
ChallengeandAuthenticate). - The signature doesn't cover
b"SWEETSPOT-AUTH-V1:" || nonce. - The pubkey isn't registered as a quoting authority for any maker.
Refreshing the session always runs Challenge → sign → Authenticate from scratch, so you don't need to think about nonce expiry yourself.
On-chain failures (quoting)
When you submit a tx via the quoting layer, the on-chain program may revert. The SDK surfaces this through Receipt:
rust
use flint_sdk::CommitError;
match receipt.landed().await {
Ok(()) => /* landed */,
Err(CommitError::Failed { signature, reason }) => {
// Reason is whatever the on-chain program returned.
// Common: "OracleFairSequenceNotMonotonic", "InsufficientBalance".
}
Err(CommitError::Timeout) => /* didn't land in time */,
Err(CommitError::Disconnected) => /* status stream dropped */,
Err(CommitError::NotSubmitted { count, reason }) => /* `count` transactions never left */,
Err(e) => /* `Lagged`, `StrategySwitch`, or a variant added later */,
}python
from flint import CommitDisconnected, CommitFailed, CommitNotSubmitted, CommitTimeout
try:
await receipt.landed()
except CommitFailed as exc:
reason = exc.reason
except CommitNotSubmitted as exc:
unsent = exc.count
except CommitTimeout:
pass
except CommitDisconnected:
passThe most common on-chain reverts and what to do about them:
| Reason | Cause | Fix |
|---|---|---|
OracleFairSequenceNotMonotonic | Two clients sharing a maker_id, or a clock-skew restart. | Don't share maker_ids; the SDK's nanosecond seed handles restarts. |
OrderSequenceNotMonotonic | Same as above for UpdateQuotingParams. | Same fix. |
OracleFairTooStale | current_slot - last_oracle_slot > order.staleness. | Increase staleness or flush more often. |
InsufficientBalance | One of the legs the matcher budgets against — your micro-book or the counterparty — has zero deposited inventory or zero soft_max_balance headroom. | See Budgets per leg. |
landed() returns the first on-chain failure and stops. When a single quote commit updates several markets, some can land while others revert. To get the full split — which of your updates landed and which failed — use receipt.settled() instead of landed(). It reports landed_intents and failed_intents as flat indices over the (market, kind) intents you submitted, without short-circuiting on the first failure; resolve an index to its market and operation with receipt.intents(). See Receipts.
