Skip to content
Stablecoin API

LCX Liberty. American DeFi. Your keys. Your assets. Your control.

Stablecoin API

Stablecoin API

Stablecoin-to-stablecoin conversion on the swap engine, with rules: a fair-price anchor, your tolerance enforced on chain, and off-peg coins refused.

What it is

The Stablecoin API converts one stablecoin into another on the same chain. It runs the same engine as /v1/quote and /v1/swap, the same routes and the same router, on the same host with the same key, and puts a rule set for stablecoins around it. Three endpoints:

EndpointPurpose
GET /v1/stablecoins/coinsEvery stablecoin the API quotes, by chain, with its currency.
POST /v1/stablecoins/quoteA conversion, measured against its anchor, or refused.
POST /v1/stablecoins/swapThe same quote and a transaction to sign, its minimum output set from your tolerance.

For any other token, or for a conversion without these rules, use /v1/quote and /v1/swap as before.

The rules

  • Both sides are registered stablecoins. Each must be in the registry for that chain (not_a_stablecoin otherwise), and neither may be on our exclusion list (excluded_coin).
  • Every quote is measured against a fair price. Par within one currency, a reference rate across two. The distance is parDeviationBps.
  • Your tolerance is enforced. A quote further below the anchor than maxParDeviationBps is refused, and the swap's minimum output is set from it, so the transaction reverts on chain rather than paying less.
  • Off-peg coins are refused by default. Buying a coin that trades away from its peg needs allowOffPeg.
  • Non-custodial. The API returns a transaction; you or your client sign and send it. We never hold funds.

Anchors

Every coin in the registry carries a currency: USD, EUR or CHF. The pair's two currencies decide what the quote is measured against, and stablecoin.anchor says which.

PairanchorMeasured as
Two coins of one currency"USD par"The output against the input, each in whole coins. 250,022.5 USDT for 250,000 USDC is +0.9 bps.
Two currencies"USD/EUR reference rate"The USD value of the output against the USD value of the input, from our oracle. Without a rate the quote is refused with no_reference_rate.

parDeviationBps is positive when the output is worth more than the anchor and negative when it is worth less. It is rounded to two decimals, and 0 is a measurement like any other.

Tolerance and the floor

Two numbers bound a conversion, and the tighter one wins. maxParDeviationBps (default 50) is how far below the anchor you accept. slippageBps (default 30) is how far below the quote itself the fill may land, as on any swap.

stablecoin.minOut is the result, in base units of tokenOut: the least the swap may deliver. A quote at par with a 50 bps tolerance and 30 bps slippage has its floor 30 bps under the quote. A quote already 20 bps below par, with the same two, has room for 30 bps before it reaches the tolerance, so the same 30 bps applies. With a 10 bps tolerance instead, a quote at par has its floor 10 bps under the quote: the tolerance is the tighter of the two. Either way the floor never sits further below the anchor than your tolerance.

stablecoin.slippageBps is that floor as a slippage figure. /v1/stablecoins/swap builds with it. To build a stablecoin quote's quoteId through /v1/build yourself, send that slippageBps, or the floor is the plain slippage bound and not your tolerance.

quote.output.minimumAmount is what /v1/quote would hold the swap to, from slippageBps alone. On this API read stablecoin.minOut.

A quote that is already past the tolerance, or so close to it that no room is left, is refused with below_tolerance. The refusal carries the quote's parDeviationBps, so a caller can see how far it was.

Off-peg coins

Buying a coin that trades more than 1% away from its peg is refused with off_peg. Either of two signals is enough: our oracle's price of the coin (for a dollar coin), or a quote that pays more than 1% above par for it, which is the market saying it is cheap. USDC, USDT and each chain's own dollar hub are anchored at one dollar by the engine and are not judged by price.

Set allowOffPeg: true to buy one anyway. The tolerance still applies, and stablecoin.offPegChecked comes back false so your records show the check was skipped on purpose. Selling an off-peg coin is never refused for it.

Custody and pricing

The API returns calldata for the taker to sign. We hold no funds, and there is nothing to deposit first. Approvals work as on the swap API: approve quote.spender, and check /v1/allowance before sending.

The Stablecoin API is included in every plan, from Free to Enterprise, and its calls count against your plan like the rest of the API. We take no fee on the output. A fee you registered for your integration is taken through integrator, exactly as on /v1/quote. See pricing.

A first call

bash
curl -X POST https://swap-api.lcx.com/v1/stablecoins/quote \
  -H "Authorization: Bearer YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "chainId": 1,
    "tokenIn":  "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
    "tokenOut": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
    "amount": "250000",
    "maxParDeviationBps": 10
  }'

Next: the quote's fields, and what each refusal means.