Step 2: Quote Request
Required Parameters:
- Token contract addresses (EIP-55 checksummed format)
- Transaction amount in smallest denominated units (wei for 18-decimal tokens)
- Originating wallet address for gas estimation and routing
Implementation Example
const quote = await fetch(
"https://api.unikron.ch/api/v1/quote?" +
"sellToken=0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2&" + // WETH
"buyToken=0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48&" + // USDC
"sellAmount=1000000000000000000&" + // 1 WETH (18 decimals)
"user=0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb", // Your address
{ headers: { "X-API-Key": "YOUR_KEY" } }
);
const { data } = await quote.json();Response Structure
{
"source": "KyberSwap", // Optimal execution venue
"sellToken": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // Token being sold
"buyToken": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // Token being bought
"sellAmount": "1000000000000000000", // Input amount
"buyAmount": "3700000000", // Expected output amount (6 decimals for USDC)
"minBuyAmount": "3693000000", // Minimum acceptable output (includes slippage tolerance)
"estimatedGas": 250000, // Gas consumption estimate in units
"priceImpact": 0.12, // Price impact percentage
"dexRoute": {
"dex": "KyberSwap",
"target": "0x6131...", // Router contract address for token approval
"path": ["0xC02aa...", "0xA0b86..."], // Swap path
"data": "0xe21fd0e9..." // Encoded transaction calldata (immutable)
},
"scoring": {
"netValueUsd": 3700.0, // Net value after fees
"gasCostUsd": 8.5 // Estimated gas cost in USD
},
"alternatives": [
{
"source": "ParaSwap",
"buyAmount": "3695000000",
"netValueUsd": 3695.0
}
],
"mevAnalysis": {
"threatLevel": "MEDIUM", // LOW, MEDIUM, or HIGH
"estimatedProtectionUsd": 0.85 // Estimated MEV protection value
},
"mevProtection": {
"provider": "MEV Blocker",
"transactionParams": {
// Complete transaction object for signing
"to": "0x6131...", // Target contract address
"data": "0xe21fd0e9...", // Transaction data
"value": "0", // ETH value (0 for ERC-20 swaps)
"gasLimit": "375000", // Maximum gas limit
"maxFeePerGas": "3000000000", // Maximum fee per gas unit (wei)
"maxPriorityFeePerGas": "0", // Priority fee (tip to miners)
"nonce": 42, // Transaction nonce
"chainId": 1, // Ethereum mainnet
"type": 2 // EIP-1559 transaction type
}
}
}Important Considerations
Quote Validity & Best Practices:
- Quote validity: Approximately 30 seconds due to market volatility
- Slippage protection: Built-in 0.6% tolerance (60 basis points) in
minBuyAmount - Gas estimation: Include
estimatedGasin transaction cost calculations - Transaction integrity: Sign parameters without modification to ensure execution success
Previous: Step 1: API Authentication Next: Step 3: Token Approval
Last updated on