Getting Started
Flow
Quote-to-execution
1. Get price estimates (OPTIONAL)
Use the RFQ API’s /prices
endpoint to get informative prices and liquidity information for each supported pair.
2. Get a signed quote
Use the RFQ API’s /quote
endpoint to get a signed message ready to be settled on-chain.
3. Execute the transaction
Follow the steps described in the Smart Contract > Functions > Settlement
section
Listed Pairs
Use the RFQ API’s /pairs
endpoint to get listed pairs and their associated liquidity.
Listed Tokens
Use the RFQ API’s /tokens
endpoint to get listed tokens.
Docs
RFQ API
Authentication
Each request should use the following header to authenticate:
"x-api-key: $API_KEY" # given by the Swaap Labs team
Routes
/status
GET https://api.swaap.finance/status
Response:
{
"code": 200,
"message": "OK"
}
/v1/rfq/prices
Request:
GET https://api.swaap.finance/v1/rfq/prices
?network_id=$NETWORK_ID # e.g. 1 for Ethereum, 137 for Polygon
Response:
{
"levels": {
# base / quote token addresses
"0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48": {
"bids": [
{
"level": 5.21486e-05,
"price": 29274.258
},
{
"level": 0.000521486,
"price": 29274.232
},
{
"level": 0.0052148597,
"price": 29273.998
},
...
],
"asks": [
{
"level": 5.21486e-05,
"price": 29561.406
},
{
"level": 0.000521486,
"price": 29561.406
},
{
"level": 0.0052148597,
"price": 29561.406
},
...
]
}
},
"success": true
}
NB:
To compute the estimated price for a given amount from the price levels you can follow the computeLevelsQuote implementation here:
https://github.com/paraswap/paraswap-dex-lib/blob/master/src/dex/swaap-v2/swaap-v2.ts
/v1/rfq/quote
Request:
POST https://api.swaap.finance/v1/rfq/quote
body: {
"origin": $TRADER, # address of the end trader
"sender": $CALLER, # address calling the Swaap vault
"recipient": $RECIPIENT, # address receiving the funds
"timestamp": 1681730800, # timestamp of the request (in sec)
"order_type": 1, # order type enum: 1 for SELL, 2 for BUY
"token_in": "0x0000000000000000000000000000000000000000", # address of the input token
"token_out": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", # address of the output token
"amount": "nn", # input amount if SELL, output amount if BUY. fixed-point format
"tolerance": 0.03, # price tolerance. should be > 0 or will be mapped to 0.01618034 (1.618034%)
"network_id": 1, # e.g. 1 for Ethereum, 137 for Polygon
"referral_fees": 0.0001, # e.g. 0.0001 for 1bps
"authorizer": $INTENT_USER, # NB: Only for solvers
}
Response:
{
"id": "0xa900...", # id of the transaction
"recipient": "0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57", # address receiving the funds
"expiration": 1686060161, # expiration timestamp
"amount": "338442", # quote amount
"expected_price": 25500.31, # will be met or revert
"guaranteed_price": 25532.43, # will be met or revert
"success": true,
"calldata": "0x...", # calldata to execute onchain. see "Settlement" section
"router": "0x..." # Swaap router address
}
/v1/rfq/pairs
Request:
GET https://api.swaap.finance/v1/rfq/pairs
?network_id=$NETWORK_ID # e.g. 1 for Ethereum, 137 for Polygon
Response:
{
"pairs": {
# base / quote token addresses
"0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48": {
"base": "WBTC",
"quote": "USDC",
"liquidityUSD": 24742709.6
}
},
"success": true
}
/v1/rfq/tokens
Request:
GET https://api.swaap.finance/v1/rfq/tokens
?network_id=$NETWORK_ID # e.g. 1 for Ethereum, 137 for Polygon
Response
{
"tokens": {
"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48": {
"symbol": "USDC",
"address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"decimals": 6
},
"0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599": {
"symbol": "BTC",
"address": "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
"decimals": 8
}
},
"success": true
}
Smart Contract
NB:
The ABI can be found here:
https://etherscan.io/address/0xd315a9c38ec871068fec378e4ce78af528c76293#code
Functions
Settlement
address(quote.router).call{...}(quote.calldata)