getTradeQuotes
.
How to Request Trade Quotes
To get started, here is a simple example of how to request quotes to bridge and swap 1 USDC on Arbitrum to ETH on Base.buildTradeTransaction
.
Trade Quotes Request Parameters
ThegetTradeQuotes
function expects a TradeQuotesRequest
object, which specifies a desired trade and includes all the information needed to calculate the most efficient routes.
Request Parameters
Parameter | Type | Required | Description |
---|---|---|---|
integratorId | string | yes | Your unique integrator identifier (e.g. “dzap”) |
fromChain | number | yes | The ID of the source chain (e.g., Ethereum mainnet is 1) |
data | TradeQuotesRequestData[] | yes | Array of trade request data objects |
account | string | no | User’s wallet address for the trade (optional) |
filter | QuoteFilter | no | Filter type for quote results (default is “all”) |
allowedSources | string[] | no | List of allowed providers for the trade (optional) |
TradeQuotesRequestData Parameters
Parameter | Type | Required | Description |
---|---|---|---|
amount | string | yes | The amount to be transferred from the source chain, specified in the smallest unit of the token |
srcToken | string | yes | The contract address of the token on the source chain |
destToken | string | yes | The contract address of the token on the destination chain |
toChain | number | yes | The ID of the destination chain |
slippage | number | yes | The slippage tolerance as a percentage (e.g., 1 for 1%) |
Quote Filter Options
You can filter quotes based on different criteria:all
- Returns all available quotes. This is the default option and provides the fastest response time.best
- Return only the best quotefastest
- Return the fastest execution time quote (for bridge operations)
Advanced Quote Configuration
For applications requiring fine-tuned control over quote optimization, the SDK provides advanced configuration options:Advanced Parameters
Parameter | Type | Required | Description |
---|---|---|---|
timingStrategy | TimingStrategy | no | Fine-tune quote optimization timing behavior |
disablePricing | boolean | no | Skip pricing calculations for faster response times |
TimingStrategy Configuration
ThetimingStrategy
parameter allows fine-grained control over how the SDK optimizes quote collection:
minWaitTimeMs
Property | Type | Default | Description |
---|---|---|---|
minWaitTimeMs | number | 1000 | Minimum wait time before returning results. Sets the floor for how long the SDK will wait before returning quotes, ensuring adequate time for providers to respond. Useful when you want to guarantee a minimum collection time for better quote diversity. |
maxWaitTimeMs
Property | Type | Default | Description |
---|---|---|---|
maxWaitTimeMs | number | 5000 | Maximum wait time for quote optimization. Sets the ceiling for quote collection time. The SDK will stop waiting for additional quotes after this duration, even if more providers might respond. Helps balance quote quality with response time requirements. |
subsequentDelayMs
Property | Type | Default | Description |
---|---|---|---|
subsequentDelayMs | number | 500 | Delay between subsequent quote requests. Controls the interval between batched quote requests to providers. Lower values may overwhelm providers, while higher values may slow down quote collection. Optimize based on provider response patterns. |
preferredResultCount
Property | Type | Default | Description |
---|---|---|---|
preferredResultCount | number | 3 | Target number of quote results to collect. The SDK will attempt to gather this many quotes before potentially stopping early (if within timing constraints). Higher values provide more options but may increase response time. |
disablePricing Configuration
Property | Type | Default | Description |
---|---|---|---|
disablePricing | boolean | false | Skip pricing calculations for faster response times. When enabled, the SDK will skip detailed price impact calculations and USD value conversions, significantly reducing response time. Ideal for high-frequency applications where speed is prioritized over detailed pricing data. |
Advanced Configuration Example
TypeScript Type Definition
Key Response Fields
pair
- Unique identifier for the trade pair (e.g.,42161_0xaf88d065e77c8cC2239327C5EDb3A432268e5831_8453_0x42000000000000000000000000000000000000006
). Can be generated usinggetTokensPairKey
.recommendedSource
- The provider ID of the recommended routequoteRates
- Object containing detailed quotes for each providertokensWithoutPrice
- Tokens that don’t have price data available
Working with Quote Results
Next Steps
Once you have received quotes, you can proceed to:- Execute the transaction on the blockchain
- Track the status of your trade
Before executing trades, tokens typically require approval to allow the DZap
contracts to spend them on your behalf. Learn more about gas-optimized
approval mechanisms in the Approval Mechanisms
section.