## Quote API

*served on the RPC endpoint*

Estimated prices across 17 Solana pool families, on the [RPC](https://carbium.sh/docs/rpc.md) endpoint and key. POST `quote` to `https://services.carbium.sh`, then `swap` for an unsigned transaction. Bought per account; the plan's rate is shared by its keys.

```
# Quote
curl https://services.carbium.sh \
  -H 'content-type: application/json' -H 'x-api-key: <YOUR_KEY>' \
  -d '{"jsonrpc":"2.0","id":1,"method":"quote","params":[{
        "src_mint":"So11111111111111111111111111111111111111112",
        "dst_mint":"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
        "amount_in":"1000000000","slippage_bps":50}]}'
# -> {"jsonrpc":"2.0","result":{
#     "srcAmountIn":"1000000000","destAmountOut":"109583697","minAmountOut":"109035778",
#     "slippageBps":50,"swapMode":"BaseIn",
#     "inputMint":"So11111111111111111111111111111111111111112",
#     "outputMint":"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
#     "routePlan":[{"hop":0,"percent":"100","swapInfo":{
#       "ammKey":"DJNtGuBGEQiUCWE8F981M2C3ZghZt2XLD8f2sQdZ6rsZ","label":"pancakeswap-v3",
#       "inputMint":"So11111111111111111111111111111111111111112",
#       "outputMint":"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
#       "inAmount":"999500000","outAmount":"109583697"}}],
#     "quoteId":"65a5c08fd08b79ea9ffd4290a229a5fb",
#     "platformFee":{"amount":"500000","feeBps":5,"mint":"So11111111111111111111111111111111111111112"}},"id":1}
# Pin venues with "dex":"o-whirlpool" or "dex":["o-whirlpool","r-clmm"].
```

### request and result

| field | type | meaning |
|---|---|---|
| **params · required, positional [{...}] or by name** |  |  |
| src_mint | base58 | input mint |
| dst_mint | base58 | output mint; not src_mint |
| amount_in | u64, number or string | input amount, base units; a string keeps precision past 2^53 |
| slippage_bps | 0 to 5000 | sets minAmountOut: 50 is 0.5% |
| **params · optional** |  |  |
| dex | label, or array of labels | only these families (table below), one hop src_mint to dst_mint, may split across their pools; no such route: -32051 no_route_in_pinned_dex, never another venue's route. Omit to search every family, multi-hop and split |
| txVersion | number, optional | 0 (default): v0 with address lookup tables, at most 1,232 B. 1: v1 with every address inline, at most 4,096 B, for routes v0 cannot fit. Over 64 accounts is refused in both |
| swapTag | number, optional | 0 (default): the router picks the form. 1: the plain form: data starts with tag 0x01, no middle block, each middle token account made by its own idempotent instruction, paid and owned by your wallet, left open; same route, price, fee and floor. v0 only: with txVersion 1, -32602 (the quote upstream refused the request) with error.data.code swap_tag_format |
| maxAccounts | number, optional | the most accounts the swap instruction may carry, 1 to 64, repeats counted. Omitted: no cap, except 64 with swapTag 1. No route within it: -32055; out of range: -32602 (the quote upstream refused the request) with error.data.code bad_max_accounts |
| **result** |  |  |
| srcAmountIn | string | input amount, base units |
| destAmountOut | string | expected output, base units, net of platformFee and any Token-2022 transfer fee on the route's mints; do not take them off again |
| minAmountOut | string | the exact floor swap sets, rounded down; the transaction never fills below it. Fee off the output (SOL out, or USDC or USDT out with no SOL in): G = floor(gross × (10000 − slippageBps) / 10000), then G − floor(G × feeBps / 10000), gross being destAmountOut plus platformFee.amount. Otherwise: floor(destAmountOut × (10000 − slippageBps) / 10000) |
| slippageBps, swapMode | number, string | your slippage; always BaseIn |
| inputMint, outputMint | base58 | the pair |
| routePlan[] | array | legs: hop (depth), percent (share of the hop's input), swapInfo {ammKey, label, inputMint, outputMint, inAmount, outAmount} |
| quoteId | 32 hex | for swap; valid 30 s |
| platformFee | object, when charged | {amount, feeBps, mint}: router fee, rounded down. Mint: SOL when SOL is at either end, else USDC or USDT when that is the output, else the input token. Taken off the input before the route, except on SOL out, or USDC or USDT out with no SOL in, where destAmountOut and minAmountOut are net of it. Absent when it rounds to 0 (a base under 2,000 atoms), or on an input-token route whose input is a Token-2022 mint with a transfer hook program set (an empty hook still pays), frozen by default or non-transferable |
| txVersion | number; v1 only | 1 when asked; its swap is v1. Absent on v0 |
| swapTag | number; tagged only | 1 when asked; its swap is the plain form. Absent otherwise |
| partial, requestedAmountIn | boolean, string; partial only | only part of amount_in can fill: past what its one pool pays out (any family; that bound less 3%), or a SOL-input route that cannot fill it whole (why first_hop_unfilled; halved up to 6 times, down to 1/64, the first part that fills served). srcAmountIn is the part, requestedAmountIn your ask; swap builds the part |

### venues

| dex label | venue |
|---|---|
| r-amm | Raydium AMM v4 |
| r-cpmm | Raydium CPMM |
| r-clmm | Raydium CLMM |
| r-lpad | Raydium LaunchLab |
| o-whirlpool | Orca Whirlpool |
| o-orca-v1 | Orca legacy pools (token-swap v1) |
| o-orca-v2 | Orca legacy pools (token-swap v2) |
| m-dlmm | Meteora DLMM |
| m-damm | Meteora DAMM v1 |
| m-damm-v2 | Meteora DAMM v2 |
| m-dbc | Meteora Dynamic Bonding Curve |
| m-dbc-hook | Meteora DBC, Token-2022 transfer-hook mints |
| pump-curve | pump.fun bonding curve |
| pump-amm | PumpSwap |
| manifest | Manifest |
| pancakeswap-v3 | PancakeSwap v3 |
| byreal | Byreal CLMM |

> Bonding curves: `quote` quotes a token on its curve, then on its pool once it migrates (`pump-curve`, then `pump-amm`), with no extra parameter. Just after a migration it waits for the new pool: 250 ms on `pump-curve`, 600 ms on `r-lpad` and `m-dbc`. A `dex` pin to `pump-curve` on a migrated token answers `-32051` `no_route_in_pinned_dex`: drop the pin or pin `pump-amm`. Chained pump hops (a PumpSwap pool or SOL curve, then curves quoted in each other) land as one pump multi_hop_swap step; `routePlan` lists each hop with one-step amounts. The protocol fee is only on the SOL-end hop, and the curves in between pay none. The creator fee is on the hop farthest from SOL (the last when SOL is the input, the first when SOL is the output), plus the LP fee when that hop is a `pump-amm` pool.

### errors

| http | code | message | what to do |
|---|---|---|---|
| 400 | -32602 | params accepts only … / params must carry … / … must be … | the four params plus optional dex, txVersion, swapTag, maxAccounts; amount_in non-zero, base units; slippage_bps 0 to 5000; two different valid mints |
| 400 | -32602 | txVersion must be 0 or 1 | 0, 1 or omit |
| 400 | -32602 | swapTag must be 0 or 1 | 0, 1 or omit |
| 400 | -32602 | maxAccounts must be a whole number | 1 to 64, or omit |
| 400 | -32602 | dex must name venue families: … / dex must be a venue-family label … | a venue table label, or an array |
| 400 | -32602 | the quote upstream refused the request | error.data.code says why; dust_amount: send amount_in of at least error.data.min_amount_in; bad_max_accounts: maxAccounts 1 to 64. Change the request before sending it again |
| 400 | -32052 | dex names a venue family the quote upstream does not have | family unavailable now: pin another or omit dex |
| 400 | -32600 | quote is not batchable | one quote per request |
| 401 | -32001 | unknown api key / api key is not enabled for quote | send the whole key; give it the QUOTE scope |
| 403 | -32050 | module not enabled for this account | the account needs the quote module |
| 429 | -32005 | rate limit exceeded / quote lane capacity exceeded / free quote plan at capacity / free tier limit for your network reached | already waited up to 1 s (rate) and 3 s (lane permit): retry after Retry-After; upgrade from free for your own budget |
| 200 | -32051 | no route | no path for this pair and size; error.data.message, when sent, gives the reason. error.data.why hook_launch_window: the transfer hook admits only allowlisted wallets, retry later; hook_market_closed: retry when its transfer schedule allows; hook_sells_only: routes only as the input; no_route_in_pinned_dex: drop the pin or pin others; dust_gate: every pool holds under 0.001 SOL on its SOL side (direct_why names the pool and reserve), stop until it refills |
| 200 | -32053 | sell exceeds what the curve can pay | input exceeds one pool's payout in any family, and the payable part (error.data.max_amount_in less 3%) failed too. max_out: the most it pays at max_amount_in. why partial_below_fee: that part pays less than the swap costs, stop. max_amount_in 0: nothing pays, stop. No why: the part did not route or the bound moved; quote well under max_amount_in, or stop |
| 200 | -32054 | token has no live pool | stop until it lists again |
| 200 | -32055 | no route fits the account cap | the cap (maxAccounts, or 64 with swapTag 1) left no route: raise maxAccounts (at most 64), lower amount_in, or quote with neither |
| 503 | -32011 | quote upstream stale | price feed reloading: retry after Retry-After. error.data.why graduating: a migrated curve's new pool is not serving yet, retry after about 3 s |
| 503 | -32011 | quote upstream … | retry with backoff, after Retry-After when sent |

> Branch on `error`: `-32051`, `-32053`, `-32054` and `-32055` come back `200`. A `429` comes before any params check.

### plans

| plan | price | quotes / account |
|---|---|---|
| FREE | $0 | 10 / s |
| STARTER | $7 | 50 / s |
| PRO | $28 | 150 / s |
| ELITE | $104 | 500 / s |

> A swap counts as one quote. Keys need the QUOTE scope, set at issue or on the dashboard. Router fee (`platformFee`): 5 bps (0.05%), charged on chain in the transaction.

### methods

#### quote

0 credits

| param | type |   |   |
|---|---|---|---|
| src_mint | pubkey | req |  |
| dst_mint | pubkey | req | must differ from src_mint |
| amount_in | u64, number or decimal string | req | non zero, in base units |
| slippage_bps | u64 | req | 0 to 5000 |
| dex | r-amm \| r-cpmm \| r-clmm \| r-lpad \| o-whirlpool \| o-orca-v1 \| o-orca-v2 \| m-dlmm \| m-damm \| m-damm-v2 \| m-dbc \| m-dbc-hook \| pump-amm \| pump-curve \| pancakeswap-v3 \| manifest \| byreal, or an array of them | opt | send only one of dex and dexes |
| dexes | array of the dex labels | opt |  |
| txVersion | 0 \| 1 | opt | 1 builds a v1 swap |
| swapTag | 0 \| 1 | opt |  |
| maxAccounts | 1 to 64 | opt | the most accounts the swap instruction may carry; 64 with swapTag 1 when omitted |

```
{"jsonrpc":"2.0","id":1,"method":"quote","params":[{"src_mint":"So11111111111111111111111111111111111111112","dst_mint":"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v","amount_in":"1000000000","slippage_bps":50}]}
```

**answer**: {srcAmountIn, destAmountOut, minAmountOut, slippageBps, swapMode, inputMint, outputMint, routePlan: [{hop, percent, swapInfo}], quoteId?, partial?, requestedAmountIn?, platformFee?, txVersion?, swapTag?}

**refuses**: 403 -32050 the account lacks the quote module; 401 -32001 the key lacks the quote scope; 400 -32602 a param missing, unknown or out of range; 200 -32051 no route; 400 -32052 dex names a family the router lacks; 200 -32053 sell exceeds what the curve can pay; 200 -32054 token has no live pool; 200 -32055 no route fits the account cap; 400 -32600 sent in a batch

#### GET /cq1/quote

0 credits

| param | type |   |   |
|---|---|---|---|
| src_mint | pubkey | req | query string |
| dst_mint | pubkey | req | query string |
| amount_in | u64 | req | query string |
| slippage_bps | u64 | req | query string |

```
curl 'https://services.carbium.sh/cq1/quote?src_mint=So11111111111111111111111111111111111111112&dst_mint=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v&amount_in=10000000000&slippage_bps=50' -H 'x-api-key: <YOUR_KEY>'
```

**answer**: {srcAmountIn, destAmountOut, destAmountOutMin, swapMode, slippage, priceImpactPct, routePlan, feeMint, feeBps, signatureFeeLamports, prioritizationFeeLamports, rentFeeLamports, inputMint, outputMint, swapType, router, requestId, priceImpact}

**refuses**: 403 -32050 the account lacks the quote module; 401 -32001 the key lacks the quote scope
