How to get a quote
In this section, you'll learn how to request quotes for swapping between tokens.
Prerequisites
None
You can choose either the explicit path or the protocol-agnostic (less explicit) path to get quotes.
A) Protocol-Specific Approach (Explicit)
Use this when you want to work with a specific DEX protocol.
Request Quote Fetch specific protocol information using:
Required Parameters:
ParameterDescriptionExamplechainId
Blockchain network ID
137
(Polygon)protocol
Protocol name
uniswap
fromToken
Token to swap from
ETH
toToken
Token to swap to
USDC
amountIn
Input amount
1000000000000000000
(1 ETH with decimals)amountOut
Output amount
1820450000
(1820.45 USDC with decimals)slippage
Maximum price slippage
0.5
(0.5% slippage tolerance)deadline
Transaction deadline
1800
(30 minutes in seconds)Example Request:
Response:
B) Protocol-Agnostic Approach (Less Explicit)
Let our system automatically select the optimal protocol for your needs.
Use the Generic Endpoint
Use the same parameters as above, excluding
protocol
.Example Request:
Response:
The response includes:
expectedOutput
: The amount of tokens you'll receiveestimatedGas
: Estimated gas cost for the swappriceImpact
: The effect your trade will have on the priceselectedProtocol
: (Only in protocol-agnostic response) The protocol selected for best execution
Next Steps
After getting a quote, you can:
Last updated