Qiguard API docs

Swap

Allowance-holder swaps on BSC (56), Ethereum (1), Base (8453) and Polygon (137). The taker approves the settlement contract for the exact amount and sends the transaction from the quote.

EndpointUse
GET /swap/allowance-holder/priceIndicative price, no transaction. taker is optional.
GET /swap/allowance-holder/quoteFirm quote with transaction. taker is required.

Parameters

ParameterRule
chainIdRequired. 56, 1, 8453 or 137. Other values: 400 CHAIN_NOT_SUPPORTED.
sellToken, buyTokenRequired. Addresses in any letter case. The native coin is 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE.
sellAmountRequired. Base units, decimal string, above 0.
takerRequired on quote, optional on price. With a taker, issues are filled and the wallet's on-chain fee rate is used.
recipientAbsent, or equal to taker. Another address gives 400 RECIPIENT_NOT_SUPPORTED: the contract pays the sender.
slippageBpsDefault 100, allowed 10 to 1000.
slippagePpm1,000 to 100,000, rounded down to whole bps (warning slippage_ppm_rounded when not a multiple of 100). Not together with slippageBps.
deadlineSecondsSeconds until the transaction deadline (expiresAt). Default 120, allowed 30 to 600.
excludedSourcesComma-separated names from GET /sources. Unknown names are listed in issues.invalidSourcesPassed.
gasPriceGas price in wei for the estimate. Default: the chain's current price.

Integrator fee: swapFeeRecipient (one wallet, or up to 3 separated by commas) and swapFeeBps (one value per wallet, 300 in total), optionally swapFeeToken (sellToken or buyToken, default buyToken); the router pays each wallet in the same transaction and the answer lists them in fees.integratorFees. tradeSurplus*, txOrigin, sellEntireBalance and wrapUnwrapMode are accepted and ignored; buyAmount (exact-out) is not supported in v1. Unknown parameters are ignored; a repeated parameter gives 400 INPUT_INVALID.

Pairs

Each pair needs an anchor on at least one side. The other side is an anchor or a token listed by GET /tokens?chainId=.

ChainAnchors
BSC (56)BNB, WBNB, USDT, USDC
Ethereum (1)ETH, WETH, USDT, USDC
Base (8453)ETH, WETH, USDT, USDC
Polygon (137)POL, WPOL, USDT, USDC
PairAnswer
Same token on both sides400 TOKEN_PAIR_NOT_SUPPORTED
A token not in GET /tokens400 TOKEN_NOT_SUPPORTED with data.token
No anchor on either side400 TOKEN_PAIR_NOT_SUPPORTED, data.reason no_anchor
Native coin and its wrapped token400 TOKEN_PAIR_NOT_SUPPORTED, data.reason wrap_unwrap
A token with a transfer tax400 TOKEN_NOT_SUPPORTED, data.reason transfer_tax (found by the quote simulation)

Fee

The on-chain fee is fees.qiguardFee: 0.50% (50 bps) of the trade, or the lower on-chain rate of the taker wallet when it has one. It is charged by the settlement contract in the same transaction.

SellBuyFee taken fromFee token
USDTany tokenthe sell amount, before the swapUSDT
USDTnative cointhe sell amountUSDT
any tokenUSDTthe gross outputUSDT
native coinUSDTthe gross outputUSDT
token X (USDC and wrapped native included)token Y (not USDT)the gross outputY
token (not USDT)native cointhe gross outputnative coin
native cointoken (not USDT)the gross outputthat token

buyAmount and minBuyAmount are net: what the taker receives after the fee. The contract checks minBuyAmount against the net amount.

minBuyAmount = floor(buyAmount * (10000 - slippageBps) / 10000)

A minBuyAmount of 0 gives 400 SELL_AMOUNT_TOO_SMALL.

Approvals

The transaction

The quote returns transaction = { to, data, value, gas, gasPrice }. Send it unchanged; use gas as the gas limit.

FieldMeaning
transaction.toThe settlement contract.
transaction.datamarketSwap, marketSwapNativeToToken (selling the native coin) or marketSwapTokenToNative (buying the native coin), then the 18-byte Qiguard tag.
transaction.valuesellAmount when selling the native coin, else 0.
expiresAtThe deadline inside transaction.data (Unix seconds). The contract refuses the transaction after it.
qiguardfunction, selector, adapter, deadline and tag of the call.
totalNetworkFeegas x gasPrice, plus the L1 data fee on Base.

The price endpoint returns the same object without transaction, qiguard and expiresAt, and with top-level gas and gasPrice. When no route exists, both endpoints answer 200 with only { "liquidityAvailable": false, "zid": "..." }.

Quote checks

Calldata tag

transaction.data ends with 18 bytes: 0x71673031 ("qg01"), the first 8 bytes of sha256 of the app id, and the first 6 bytes of the response zid. The contract ignores bytes after the call arguments. The tag attributes the trade to the app; an app can switch it off in the dashboard (app settings).

Warnings

warnings[] lists accepted parameters that changed nothing: trade_surplus_ignored, tx_origin_ignored, wrap_unwrap_mode_ignored, slippage_ppm_rounded, and secret_key_origin_header (a secret key arrived with an Origin header; send it from a server without browser headers).