Qiguard API docs

Contracts and fees

Every Qiguard trade runs through the settlement contract of its chain. The settlement contracts are upgradeable proxies, shared with CEXORDEX. The API reads their live state (paused(), fee recipient, head block) and shows it in GET /status.

BSC (56)

ContractAddress
Settlement (transaction.to, allowanceTarget, gasless spender)0x79A76e54f354AC7567f97d979EC1b785c15e37d8
USDT (the fee token of USDT-input trades)0x55d398326f99059fF775485246999027B3197955
Wrapped native0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c
PancakeSwap_V2 adapter0xD81F42bc939b078684e209CD94f8700F16943622
PancakeSwap_V2 router0x10ED43C718714eb63d5aA57B78B54704E256024E
PancakeSwap_V3 adapter0xb8dfc084c3912B71662044092722fdDA40b15Ab3
PancakeSwap_V3 router0x1b81D678ffb9C0263b24A97847620C99d213eB14
PancakeSwap_V3 quoter0xB048Bbc1Ee6b733FFfCFb9e9CeF7375518e25997

Ethereum (1)

ContractAddress
Settlement (transaction.to, allowanceTarget, gasless spender)0x67433187Db1e57f66E88880b6Be833f6759362b1
USDT (the fee token of USDT-input trades)0xdAC17F958D2ee523a2206206994597C13D831ec7
Wrapped native0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
Uniswap_V2 adapter0xD4Ca0A78528391728De85C4FFE5db4FF86cC7043
Uniswap_V2 router0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D
Uniswap_V3 adapter0xBA521B205AB809086B78Ee0B878d1C541F34aA1a
Uniswap_V3 router0xE592427A0AEce92De3Edee1F18E0157C05861564
Uniswap_V3 quoter0x61fFE014bA17989E743c5F6cB21bF9697530B21e

Base (8453)

ContractAddress
Settlement (transaction.to, allowanceTarget, gasless spender)0x67433187Db1e57f66E88880b6Be833f6759362b1
USDT (the fee token of USDT-input trades)0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2
Wrapped native0x4200000000000000000000000000000000000006
Uniswap_V2 adapter0xD4Ca0A78528391728De85C4FFE5db4FF86cC7043
Uniswap_V2 router0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24
Uniswap_V3 adapter0xB47011d787B432ccF7A53284a74432a0De4397a3
Uniswap_V3 router0x2626664c2603336E57B271c5C0b26F421741e481
Uniswap_V3 quoter0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a

Polygon (137)

ContractAddress
Settlement (transaction.to, allowanceTarget, gasless spender)0xe9280cE8F0990c35c9CA183A7Fb942d57620C5a2
USDT (the fee token of USDT-input trades)0xc2132D05D31c914a87C6611C10748AEb04B58e8F
Wrapped native0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270
QuickSwap_V2 adapter0x7723B258DB19dB594dfe99D5AFf90c9799ae6e9e
QuickSwap_V2 router0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff
Uniswap_V3 adapter0x8Ba540B7C41278dB99467046f35C10A57526b83E
Uniswap_V3 router0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45
Uniswap_V3 quoter0x61fFE014bA17989E743c5F6cB21bF9697530B21e

All chains

ContractAddress
Permit20x000000000022D473030F116dDEE9F6B43aC78BA3
Multicall30xcA11bde05977b3631167028862bE2a173976CA11
Native coin placeholder0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE

GET /status returns the settlement address, paused, priceBandEnforced, feeRecipient and the head block of every chain, read live and cached for 15 seconds.

Functions the API calls

SelectorFunctionUsed by
0xb5019436marketSwap(address,address,uint256,uint256,address,bytes,uint256)swap, token to token
0x6f1190c5marketSwapNativeToToken(address,uint256,address,bytes,uint256) (payable)swap, selling the native coin
0x1f60a2c7marketSwapTokenToNative(address,uint256,uint256,address,bytes,uint256)swap, buying the native coin
0x1701c80dfillOrderWithPermit2((address,address,uint256,address,uint256,address,bytes,uint256,uint256,bytes))gasless, sent by the Qiguard relayer

routerData (the route inside the adapter) is abi.encode(address[] path, uint256 deadline) for V2 sources and abi.encode(bytes packedPath, uint256 deadline) for V3 sources, where the packed path is token (20 bytes), fee (3 bytes), token, and so on.

Fee rule

The fee is 0.50% (50 bps), or the lower on-chain rate of the taker wallet (getFeeBps(taker)). The contract takes it in the same transaction and pays it to its fee recipient:

The full table is on Swap. Gas for gasless trades is sponsored by Qiguard in v1 (Gasless).

Calldata tag

Swap calldata ends with an 18-byte tag: 0x71673031 ("qg01") + the first 8 bytes of sha256(app id) + the first 6 bytes of the response zid. Example: 0x716730313eb3ac763a2a9d9c5f1c9a7e2b44. The contract ignores bytes after the call arguments; the tag only attributes the trade to the app.

Revert reasons

For integrators who send the swap transaction themselves, and for detail of a failed gasless trade.

SelectorErrorMeaningWhat to do
0xbff79e2fInsufficientNetReceived(uint256,uint256)The price moved beyond the slippageQuote again
0xc56873baOrderExpired()The deadline passedQuote again and send sooner
0x7b9d05edRouterAdapterNotAllowed()The adapter is no longer allowedQuote again
0x9bfa3c17FeeOnTransferNotSupported()The token takes a transfer taxThe token is not supported
0xd93c0665EnforcedPause()The settlement contract is pausedWait; see GET /status
0x8686656dInvalidTokenPair()For example native coin and its wrapped tokenUse another pair
0x2c5211c6InvalidAmount()Zero amountSend a positive amount
0x756688fePermit2 InvalidNonce()The Permit2 nonce is used or invalidatedQuote and sign again
0xcd21db4fPermit2 SignatureExpired(uint256)The signed deadline passedQuote and sign again
0x815e1d64Permit2 InvalidSigner()The signer is not the takerSign with the taker wallet
0x8baa579fPermit2 InvalidSignature()The signature does not matchSign trade.eip712 again
string TRANSFER_FROM_FAILEDPermit2 token pullThe allowance or balance is goneTop up or approve again