Generate a Quote
The first step to execute a zap using the Odos SOR API is generating a quote.
Send a POST request to the /sor/quote/v3/zap endpoint using the same request body structure as /sor/quote/v3.
It is recommended to start with one of the example request bodies and customize as needed.
- Python
- JavaScript
import json
import requests
quote_url = "https://api.odos.xyz/sor/quote/v2/zap"
quote_request_body = {
"chainId": 1,
"inputTokens": [
{
"tokenAddress": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", # WETH token address
"amount": "1000000000000000000" # 1 WETH for zap-in
}
],
"outputTokens": [
{
"tokenAddress": "0xB4e16d0168e52d35CaCD2c6185b44281Ec28C9Dc", # Uniswap V2 pool address to zap into
"proportion": 1
}
],
"slippageLimitPercent": 0.3, # 0.3% slippage tolerance
"userAddr": "0x...", # checksummed user address
"referralCode": 0, # referral code (recommended)
"compact": True
}
response = requests.post(
quote_url,
headers={"Content-Type": "application/json"},
json=quote_request_body
)
if response.status_code == 200:
quote = response.json()
print(json.dumps(quote, indent=2))
else:
print(f"Error: {response.status_code} - {response.text}")
const quoteUrl = 'https://api.odos.xyz/sor/quote/v2/zap';
const quoteRequestBody = {
chainId: 1,
inputTokens: [
{
tokenAddress: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', // WETH token address
amount: '1000000000000000000' // 1 WETH for zap-in
}
],
outputTokens: [
{
tokenAddress: '0xB4e16d0168e52d35CaCD2c6185b44281Ec28C9Dc', // Uniswap V2 pool address to zap into
proportion: 1
}
],
userAddr: '0x...', // checksummed user address
slippageLimitPercent: 0.3, // 0.3% slippage tolerance
referralCode: 0, // referral code (recommended)
compact: true,
};
const response = await fetch(quoteUrl, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(quoteRequestBody),
});
if (response.ok) {
const quote = await response.json();
console.log(JSON.stringify(quote, null, 2));
} else {
console.error('Quote error:', response.statusText);
}
Replace the placeholder values with actual addresses and token details for your intended zap.
The userAddr field should be the checksummed address of the user who may later assemble and execute the transaction.
The response will include full quote details including pathId, which is required for the next step (assembling the transaction).
Quotes are valid for 60 seconds — if expired, request a new quote.