Appearance
Taking liquidity (swaps)
This page is for takers: wallets, routers and bots that swap against the Flint spot DEX. Makers who quote into the book want Quoting instead.
A Flint swap is one instruction on the spot program. It fills against every maker's on-chain quotes at the slot it lands in, so the SDK can quote it offline: it loads the market accounts once, then runs the same matching engine the program runs. There are three ways to send the swap:
| Route | What you build | Price protection | Extra fee |
|---|---|---|---|
| Direct swap | The spot program's own swap instruction | A Lighthouse balance assertion after the swap (the min-out guard) | The direct-caller surcharge once it ships |
| Jupiter program route | A Jupiter route instruction that calls Flint, built locally | Jupiter's slippage check | None |
| Aggregator APIs | A transaction from the Jupiter Swap API or Titan, restricted to Flint | The aggregator's own minimum out | None |
All three live in the swap module of each SDK:
| SDK | Module | Install |
|---|---|---|
| Rust | flint_sdk::spot::swap | flint-sdk = { version = "12", registry = "kellnr", features = ["spot-swap"] } |
| Python | flint.spot.swap | flint-sdk (see Python SDK) |
| TypeScript | @superis-labs/flint/spot/swap | @superis-labs/flint with the @solana/kit 8 peer |
The Rust spot-swap feature pulls private crates from the Kellnr registry, so it needs the same registry token as quoting.
Units
Swap amounts are raw token atoms (u64), never human decimals: 1 SOL is 1_000_000_000 atoms of the native mint and 1 USDC is 1_000_000. Fees are in hbps, millionths of the amount: 1_000_000 hbps is 100%, 100 hbps is one basis point. A market's fee is capped at MAX_FEE_HBPS (10_000, 1%).
Every market trades a token against the exchange's quote token (USDC on mainnet). A swap is one of three sides:
| Side | Input | Output |
|---|---|---|
buy | quote token | base token |
sell | base token | quote token |
cross | base token | another base token, through both markets in one instruction |
swap_side / swapSide tells you which one a mint pair is. You never pick it; the builders do.
Load markets and quote
load_markets reads the global market, the spot market of each non-quote mint, both mints and the epoch in one getMultipleAccounts call, at one slot. Pass a Cluster with an RPC URL (or a Solana RPC client); the program id comes from the cluster unless you pass one. A cluster without an RPC URL raises an input error naming rpc_url before any request is made.
Quotes are pure functions of that snapshot. quote_exact_in returns what a fixed input buys; quote_exact_out searches for the smallest input whose output reaches a target. Both take extra_fee_hbps (TypeScript { extraFeeHbps }) with no default: the surcharge your venue adds on top of the market fee, 0 when it adds none (see the direct-caller surcharge).
rust
use flint_sdk::Cluster;
use flint_sdk::spot::swap::{self, NATIVE_MINT};
use solana_sdk::pubkey::Pubkey;
let usdc = Pubkey::from_str_const("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
let cluster = Cluster::mainnet().with_rpc_url(std::env::var("FLINT_RPC_URL")?);
let markets = swap::load_markets(&cluster, &NATIVE_MINT, &usdc, None).await?;
let quote = swap::quote_exact_in(&markets, &NATIVE_MINT, &usdc, 100_000_000, 0, None)?;
println!("0.1 SOL buys {} USDC atoms at slot {}", quote.amount_out, quote.slot);
let needed = swap::quote_exact_out(&markets, &NATIVE_MINT, &usdc, 10_000_000, 0, None)?;
println!("10 USDC costs {} SOL atoms", needed.amount_in);python
import os
from solders.pubkey import Pubkey
from flint import Cluster
from flint.spot import swap
USDC = Pubkey.from_string("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v")
cluster = Cluster.mainnet().with_rpc_url(os.environ["FLINT_RPC_URL"])
markets = await swap.load_markets(cluster, swap.NATIVE_MINT, USDC)
quote = swap.quote_exact_in(markets, swap.NATIVE_MINT, USDC, 100_000_000, 0)
print(f"0.1 SOL buys {quote.amount_out} USDC atoms at slot {quote.slot}")
needed = swap.quote_exact_out(markets, swap.NATIVE_MINT, USDC, 10_000_000, 0)
print(f"10 USDC costs {needed.amount_in} SOL atoms")ts
import { Cluster } from "@superis-labs/flint";
import { NATIVE_MINT, loadMarkets, quoteExactIn, quoteExactOut } from "@superis-labs/flint/spot/swap";
import { address } from "@solana/kit";
const USDC = address("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
const cluster = Cluster.mainnet().withRpcUrl(process.env.FLINT_RPC_URL!);
const markets = await loadMarkets(cluster, NATIVE_MINT, USDC);
const quote = quoteExactIn(markets, NATIVE_MINT, USDC, 100_000_000n, { extraFeeHbps: 0n });
console.log(`0.1 SOL buys ${quote.amountOut} USDC atoms at slot ${quote.slot}`);
const needed = quoteExactOut(markets, NATIVE_MINT, USDC, 10_000_000n, { extraFeeHbps: 0n });
console.log(`10 USDC costs ${needed.amountIn} SOL atoms`);A SwapQuote accounts for every atom of the input: amount_in = input_transfer_fee + atoms_in + fee_in_atoms, and amount_out = atoms_out - output_transfer_fee. The transfer-fee fields are non-zero only for Token-2022 mints with a transfer fee; the quote applies the fee schedule of the snapshot's epoch, as the token program will. fee_hbps is the rate charged, including any extra fee you passed.
Maker quotes decay with slot age (see how Flint works), so a quote is only good for the slot it was taken at. Pass slot to evaluate the same snapshot at a later slot, and reload the markets before you build a transaction you mean to send. When the book cannot fill the input, quoting raises ExhaustedLiquidity; an input too small to fill one lot raises ZeroFillAmount; a paused market raises TradingNotAllowed.
Direct swaps
build_direct_swap returns the instructions for one transaction: optional compute-budget instructions, wrapping native SOL when the input is SOL, creating the output token account if needed, the swap, the min-out guard, and closing the wrapped SOL accounts afterwards. You sign and send them.
The min-out guard
The spot program's swap instruction has no minimum-output argument: it fills whatever the book gives at the landing slot. The SDK adds the protection around the swap with Lighthouse, in the same transaction:
MemoryWritecopies the output token account's balance into a Lighthouse memory account (["memory", taker, LIGHTHOUSE_MEMORY_ID], paid by the taker and created on the fly);- the swap;
AssertAccountDeltarequires the balance to have grown by at leastmin_amount_out;MemoryClosereturns the memory account's rent to the taker.
If the swap delivered less, the assertion fails (Lighthouse error 6001) and the whole transaction reverts, so the input never leaves the wallet. Because the guard measures a delta inside the transaction, a transfer into the output account before the swap does not count toward it, and you do not read the balance first. Wrapped SOL is unwrapped only after the guard. The guard adds about 12,000 compute units and 70 bytes; leave room if you set a compute-unit limit. min_out_guard returns the same three instructions (memory_write, assert_delta, memory_close) to put around your own swap instruction.
Pick min_amount_out from a fresh quote and your slippage tolerance. It must be positive: 0 (or less) raises an input error naming min_amount_out, unless you opt out explicitly with allow_unbounded (Rust params.allow_unbounded = true, Python allow_unbounded=True, TypeScript { allowUnbounded: true }), which sends without a guard.
rust
use flint_sdk::Cluster;
use flint_sdk::spot::swap::{self, DirectSwapParams, NATIVE_MINT};
use solana_sdk::pubkey::Pubkey;
let usdc = Pubkey::from_str_const("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
let cluster = Cluster::mainnet().with_rpc_url(std::env::var("FLINT_RPC_URL")?);
let taker = keypair.pubkey();
let amount_in = 100_000_000;
let markets = swap::load_markets(&cluster, &NATIVE_MINT, &usdc, None).await?;
if swap::market_rejects_direct(&markets, &NATIVE_MINT, &usdc)? {
anyhow::bail!("this market only accepts routed swaps");
}
let quote = swap::quote_exact_in(&markets, &NATIVE_MINT, &usdc, amount_in, 0, None)?;
let min_out = quote.amount_out * 995 / 1000;
let mut params = DirectSwapParams::new(&markets, taker, NATIVE_MINT, usdc, amount_in, min_out);
params.compute_unit_price = Some(10_000);
let direct = swap::build_direct_swap(¶ms)?;
println!("guard: output grows by at least {:?}", direct.min_amount_out);python
import os
from solders.pubkey import Pubkey
from flint import Cluster
from flint.spot import swap
USDC = Pubkey.from_string("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v")
cluster = Cluster.mainnet().with_rpc_url(os.environ["FLINT_RPC_URL"])
taker = taker_keypair.pubkey()
amount_in = 100_000_000
markets = await swap.load_markets(cluster, swap.NATIVE_MINT, USDC)
if swap.market_rejects_direct(markets, swap.NATIVE_MINT, USDC):
raise SystemExit("this market only accepts routed swaps")
quote = swap.quote_exact_in(markets, swap.NATIVE_MINT, USDC, amount_in, 0)
min_out = quote.amount_out * 995 // 1000
direct = swap.build_direct_swap(
markets,
taker,
swap.NATIVE_MINT,
USDC,
amount_in,
min_out,
compute_unit_price=10_000,
)
print("guard: output grows by at least", direct.min_amount_out)ts
import { Cluster } from "@superis-labs/flint";
import {
NATIVE_MINT,
buildDirectSwap,
loadMarkets,
marketRejectsDirect,
quoteExactIn,
} from "@superis-labs/flint/spot/swap";
import { address, type KeyPairSigner } from "@solana/kit";
declare const taker: KeyPairSigner;
const USDC = address("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
const cluster = Cluster.mainnet().withRpcUrl(process.env.FLINT_RPC_URL!);
const amountIn = 100_000_000n;
const markets = await loadMarkets(cluster, NATIVE_MINT, USDC);
if (marketRejectsDirect(markets, NATIVE_MINT, USDC)) {
throw new Error("this market only accepts routed swaps");
}
const quote = quoteExactIn(markets, NATIVE_MINT, USDC, amountIn, { extraFeeHbps: 0n });
const minOut = (quote.amountOut * 995n) / 1000n;
const direct = buildDirectSwap(markets, taker.address, NATIVE_MINT, USDC, amountIn, minOut, {
computeUnitPrice: 10_000n,
});
console.log(`guard: output grows by at least ${direct.minAmountOut}`);Other things the builder does for you:
- Native SOL. With
wrap_unwrap_solon (the default), a SOL input is wrapped into a temporary wSOL account and a SOL output is unwrapped, and both wSOL accounts are closed at the end. Turn it off to trade an existing wSOL balance. - Token-2022. Mints owned by Token-2022 work, including transfer fees. Mints with an active transfer hook are refused with
TransferHookUnsupported. - Markets that only accept routers. A market can set the
REVERT_UNRECOGNIZED_CALLERstatus flag, which makes the program reject any swap that does not come through a recognized router (program errorUnrecognizedCaller, 31).market_rejects_directreads that flag from the snapshot; when it is set, use the Jupiter route or an aggregator.
The direct-caller surcharge
Extra fee for direct swaps after the next program redeploy
The spot program deployed today charges direct callers the market fee only. The next redeploy adds a surcharge for swaps that call the program directly rather than through a recognized router: DIRECT_CALLER_SURCHARGE_HBPS (5_000 hbps, 0.5%) on top of the market fee, with the total still capped at MAX_FEE_HBPS. Routed swaps (the Jupiter route and the aggregators) do not pay it.
Once that redeploy is live, quote direct swaps with the surcharge, or the quote will overstate the output and a tight min-out guard will revert:
python
quote = swap.quote_exact_in(
markets,
swap.NATIVE_MINT,
USDC,
amount_in,
extra_fee_hbps=swap.DIRECT_CALLER_SURCHARGE_HBPS,
)Rust passes DIRECT_CALLER_SURCHARGE_HBPS as the extra_fee_hbps argument and TypeScript as { extraFeeHbps: DIRECT_CALLER_SURCHARGE_HBPS }. The SDK cannot tell which program version is deployed, so the extra fee is a required argument in all three languages: pass 0 until the redeploy ships, and this page will say when it has.
Send the transaction
The SDK builds instructions; signing and sending are yours. Any Solana client works. In Python, the root flint.Client can sign, simulate for a compute limit, send and confirm any instructions; it needs no Flint account for this.
rust
use flint_sdk::spot::swap::DirectSwap;
use solana_rpc_client::nonblocking::rpc_client::RpcClient;
use solana_sdk::signature::{Keypair, Signature, Signer};
use solana_sdk::transaction::Transaction;
async fn send(rpc_url: &str, taker: &Keypair, direct: &DirectSwap) -> anyhow::Result<Signature> {
let rpc = RpcClient::new(rpc_url.to_owned());
let blockhash = rpc.get_latest_blockhash().await?;
let transaction = Transaction::new_signed_with_payer(
&direct.instructions,
Some(&taker.pubkey()),
&[taker],
blockhash,
);
Ok(rpc.send_and_confirm_transaction(&transaction).await?)
}python
from flint import Client
sender = Client(cluster, signer=taker_keypair)
result = await sender.send(direct.instructions)
if result.error is not None:
raise SystemExit(f"swap reverted: {result.error.name}")
print("swapped:", result.signature)
await sender.close()ts
import {
appendTransactionMessageInstructions,
createSolanaRpc,
createTransactionMessage,
getBase64EncodedWireTransaction,
pipe,
setTransactionMessageFeePayerSigner,
setTransactionMessageLifetimeUsingBlockhash,
signTransactionMessageWithSigners,
type KeyPairSigner,
} from "@solana/kit";
import type { DirectSwap } from "@superis-labs/flint/spot/swap";
declare const taker: KeyPairSigner;
declare const direct: DirectSwap;
const rpc = createSolanaRpc(process.env.FLINT_RPC_URL!);
const { value: latest } = await rpc.getLatestBlockhash().send();
const message = pipe(
createTransactionMessage({ version: 0 }),
(m) => setTransactionMessageFeePayerSigner(taker, m),
(m) => setTransactionMessageLifetimeUsingBlockhash(latest, m),
(m) => appendTransactionMessageInstructions(direct.instructions, m),
);
const signed = await signTransactionMessageWithSigners(message);
const signature = await rpc
.sendTransaction(getBase64EncodedWireTransaction(signed), { encoding: "base64" })
.send();
console.log(`swapped: ${signature}`);A swap that reverts on the guard costs only the transaction fee. Reload the markets, re-quote and try again; do not widen the guard to force a fill.
Jupiter program route
build_jupiter_route_swap builds a Jupiter v6 route instruction whose single step is the Flint swap, so the trade goes through Jupiter's on-chain program without calling Jupiter's API. Jupiter is a recognized router: markets that reject direct callers accept it, and no direct-caller surcharge applies, so the SDK quotes it with no extra fee.
You give it a slippage in basis points. The builder quotes the output (or takes expected_amount_out if you quoted yourself), subtracts the optional platform fee, and encodes the result as Jupiter's quoted amount. Jupiter then reverts the transaction unless the output after its fee is at least quoted_amount_out - floor(quoted_amount_out * slippage_bps / 10_000); that bound is returned as min_amount_out.
rust
use flint_sdk::spot::swap::{self, JupiterRouteSwapParams, NATIVE_MINT};
use solana_sdk::pubkey::Pubkey;
let usdc = Pubkey::from_str_const("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
let cluster = flint_sdk::Cluster::mainnet().with_rpc_url(std::env::var("FLINT_RPC_URL")?);
let markets = swap::load_markets(&cluster, &NATIVE_MINT, &usdc, None).await?;
let params =
JupiterRouteSwapParams::new(&markets, keypair.pubkey(), NATIVE_MINT, usdc, 100_000_000, 50);
let routed = swap::build_jupiter_route_swap(¶ms)?;
println!(
"quoted {} atoms, reverts below {}",
routed.quoted_amount_out, routed.min_amount_out
);python
import os
from solders.pubkey import Pubkey
from flint import Cluster
from flint.spot import swap
USDC = Pubkey.from_string("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v")
cluster = Cluster.mainnet().with_rpc_url(os.environ["FLINT_RPC_URL"])
markets = await swap.load_markets(cluster, swap.NATIVE_MINT, USDC)
routed = swap.build_jupiter_route_swap(
markets, taker_keypair.pubkey(), swap.NATIVE_MINT, USDC, 100_000_000, slippage_bps=50
)
print(f"quoted {routed.quoted_amount_out} atoms, reverts below {routed.min_amount_out}")ts
import { Cluster } from "@superis-labs/flint";
import { NATIVE_MINT, buildJupiterRouteSwap, loadMarkets } from "@superis-labs/flint/spot/swap";
import { address, type KeyPairSigner } from "@solana/kit";
declare const taker: KeyPairSigner;
const USDC = address("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
const cluster = Cluster.mainnet().withRpcUrl(process.env.FLINT_RPC_URL!);
const markets = await loadMarkets(cluster, NATIVE_MINT, USDC);
const routed = buildJupiterRouteSwap(markets, taker.address, NATIVE_MINT, USDC, 100_000_000n, 50);
console.log(`quoted ${routed.quotedAmountOut} atoms, reverts below ${routed.minAmountOut}`);routed.instructions include the same SOL wrapping, output-account creation and compute-budget options as a direct swap; send them the same way. slippage_bps is at most JUPITER_MAX_SLIPPAGE_BPS (10_000).
A platform fee (platform_fee_bps up to 255, with platform_fee_account, a token account for the output mint) is taken by Jupiter from the output as floor(out * bps / 10_000). It is refused for Token-2022 output mints (PlatformFeeToken2022Unsupported), because the route instruction transfers the fee with a single token program.
Aggregator APIs: Jupiter and Titan
JupiterClient (Jupiter Swap API v2, /build) and TitanClient (Titan's /quote/swap) ask the aggregator for a ready transaction and return an AggregatorSwap: its instructions, address lookup tables, amounts, route labels and, when the aggregator sends one, a recent blockhash. compile_aggregator_swap turns it into a v0 message for the taker to sign.
Both requests are restricted to Flint by default: Jupiter's dexes is ["Flint"] (JUPITER_FLINT_LABEL) and Titan's is ["SweetSpot"] (TITAN_FLINT_DEX, the name Titan lists the Flint venue under), and require_flint_route is on. With it on, the client raises NoFlintRoute when the aggregator has no route or returns one that never touches the Flint program, and NonFlintLeg when any leg uses another venue. Turn it off and clear dexes to let the aggregator route anywhere; uses_flint(route) and flint_only(route) then tell you what you got. Either way the client refuses a transaction that asks for any signer other than the taker (UnexpectedSigner).
The clients do not trust the aggregator's transaction. Parsing checks every instruction against an allowlist (compute budget, associated token, Token, Token-2022, System, Lighthouse, that aggregator's own program and the Flint spot programs; DisallowedProgram) and per-program rules: System only wraps the taker's own SOL, Token only syncs and closes the taker's accounts back to the taker, so approvals, authority changes and transfers to anyone else are DisallowedInstruction. It then compares the response with your request (mints, input amount, mode, slippage and a minimum output consistent with it; RequestMismatch). verify_aggregator_swap (called by build_swap and quote_swap, which is why they take an RPC) loads the output mint and every lookup table from chain, replaces the aggregator's table contents with the on-chain ones, and wraps the swap in the same Lighthouse min-out guard as a direct swap. compile_aggregator_swap refuses a swap that was not verified.
Titan needs an API key; TitanClient.from_env() reads TITAN_API_KEY. The Jupiter key is optional.
rust
use flint_sdk::spot::swap::{
self, JupiterClient, JupiterSwapRequest, NATIVE_MINT, TitanClient, TitanSwapRequest,
};
use solana_rpc_client::nonblocking::rpc_client::RpcClient;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::transaction::VersionedTransaction;
let usdc = Pubkey::from_str_const("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
let taker = keypair.pubkey();
let rpc = RpcClient::new(std::env::var("FLINT_RPC_URL")?);
let titan = TitanClient::from_env()?;
let route = titan
.quote_swap(&rpc, &TitanSwapRequest::new(NATIVE_MINT, usdc, 100_000_000, taker))
.await?;
println!("Titan: {} out via {:?}", route.out_amount, route.route_labels);
let jupiter = JupiterClient::new();
let mut request = JupiterSwapRequest::new(NATIVE_MINT, usdc, 100_000_000, taker);
request.slippage_bps = 30;
let route = jupiter.build_swap(&rpc, &request).await?;
let blockhash = rpc.get_latest_blockhash().await?;
let message = swap::compile_aggregator_swap(&route, &taker, Some(blockhash))?;
let transaction = VersionedTransaction::try_new(message, &[keypair.as_ref()])?;
let signature = rpc.send_and_confirm_transaction(&transaction).await?;python
from solders.pubkey import Pubkey
from solders.transaction import VersionedTransaction
import os
from flint import Cluster
from flint.spot import swap
USDC = Pubkey.from_string("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v")
taker = taker_keypair.pubkey()
rpc = Cluster.mainnet().with_rpc_url(os.environ["FLINT_RPC_URL"])
async with swap.TitanClient.from_env() as titan:
route = await titan.quote_swap(
rpc, swap.TitanSwapRequest(swap.NATIVE_MINT, USDC, 100_000_000, user_public_key=taker)
)
print("Titan:", route.out_amount, "out via", route.route_labels)
async with swap.JupiterClient() as jupiter:
route = await jupiter.build_swap(
rpc, swap.JupiterSwapRequest(swap.NATIVE_MINT, USDC, 100_000_000, taker, slippage_bps=30)
)
message = swap.compile_aggregator_swap(route, taker)
transaction = VersionedTransaction(message, [taker_keypair])ts
import {
JupiterClient,
NATIVE_MINT,
TitanClient,
compileAggregatorSwap,
} from "@superis-labs/flint/spot/swap";
import {
address,
compileTransaction,
createSolanaRpc,
getBase64EncodedWireTransaction,
signTransaction,
type KeyPairSigner,
} from "@solana/kit";
declare const taker: KeyPairSigner;
const USDC = address("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
const rpc = createSolanaRpc(process.env.FLINT_RPC_URL!);
const titan = TitanClient.fromEnv();
const titanRoute = await titan.quoteSwap(rpc, {
inputMint: NATIVE_MINT,
outputMint: USDC,
amount: 100_000_000n,
userPublicKey: taker.address,
});
console.log(`Titan: ${titanRoute.outAmount} out via ${titanRoute.routeLabels.join(", ")}`);
const jupiter = new JupiterClient();
const route = await jupiter.buildSwap(rpc, {
inputMint: NATIVE_MINT,
outputMint: USDC,
amount: 100_000_000n,
taker: taker.address,
slippageBps: 30,
});
const { value: latest } = await rpc.getLatestBlockhash().send();
const message = compileAggregatorSwap(route, taker.address, latest.blockhash, latest.lastValidBlockHeight);
const signed = await signTransaction([taker.keyPair], compileTransaction(message));
await rpc.sendTransaction(getBase64EncodedWireTransaction(signed), { encoding: "base64" }).send();compile_aggregator_swap uses the blockhash you pass, or the one the aggregator returned. Titan's responses include the lookup-table contents (includeAltContents=true), so compiling needs no extra RPC call. If you only need the unsigned transaction (for a wallet adapter, say), compile_unsigned_wire_transaction returns it base64-encoded with empty signature slots.
The SDK's own quote is a good cross-check for an aggregator route: evaluated at the route's context_slot with extra_fee_hbps = 0, quote_exact_in should match a Flint-only route's out_amount. When the book is empty between maker refreshes, Titan answers with no route and the SDK quote raises ExhaustedLiquidity at the same slot.
Errors
| Error | Raised by | Meaning |
|---|---|---|
ExhaustedLiquidity | quoting | The book at that slot cannot fill the input. |
ZeroFillAmount | quoting | The input is too small to fill one lot. |
TradingNotAllowed | quoting | The market's status disallows trading. |
UnknownMint / MissingMint | quoting, builders | No spot market for that mint, or the mint account was not loaded. |
SameMint | quoting, builders | Input and output are the same mint. |
TransferHookUnsupported | builders | A mint has an active transfer hook. |
InputError (Rust SwapError::Input), field min_amount_out | build_direct_swap | min_amount_out is not positive and allow_unbounded is off. |
InvalidAccount | load_output_balance, loading | An account has the wrong owner or size, or the token-program override disagrees with the mint. |
InvalidArgument | Jupiter route | Slippage, platform fee or amount out of range. |
PlatformFeeToken2022Unsupported | Jupiter route | Platform fee on a Token-2022 output mint. |
NoFlintRoute / NoRoute | aggregators | No route (restricted to Flint or not). |
NonFlintLeg | aggregators | A Flint-only request got a route with another venue. |
UnexpectedSigner | aggregators | The route asks for a signer other than the taker. |
DisallowedProgram / DisallowedInstruction | aggregators | The transaction calls a program outside the allowlist, or an allowed program in a way the rules forbid. |
RequestMismatch | aggregators | The response's mints, amounts, mode, slippage or minimum output differ from the request (field names which). |
Unverified | aggregators | A lookup table or the output mint does not match chain, or compile_aggregator_swap got a swap verify_aggregator_swap never checked. |
MissingApiKey / InvalidApiKey / RateLimited | aggregators | Titan key absent or rejected; HTTP 429. |
Python raises one class per case (all SwapError or AggregatorError subclasses), Rust returns SwapError / AggregatorError variants, and TypeScript throws SwapError / AggregatorError with a code. On chain, a direct swap that misses its guard fails with Lighthouse error 6001 (swap.LIGHTHOUSE_ASSERTION_FAILED), and one sent to a router-only market fails with the spot program's UnrecognizedCaller (see Errors). spot.chain.errors.program_error(err, logs) (Rust spot::chain::errors::program_error, TypeScript errors.programError from /spot/chain) decodes a failed transaction's error against the spot program's table, the way chain.errors.program_error does for the margin program.
