get_gasless_price
Calculate indicative prices for token swaps without gas fees by specifying chain, tokens, and amounts to enable cost-efficient DeFi trading.
Instructions
Get indicative price for a gasless token swap (no gas fees required)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chainId | Yes | Blockchain ID (e.g., 8453 for Base) | |
| buyToken | Yes | Contract address of token to buy | |
| sellToken | Yes | Contract address of token to sell | |
| sellAmount | Yes | Amount of sellToken in base units | |
| taker | No | Address executing the trade (optional) | |
| slippageBps | No | Maximum acceptable slippage in basis points (optional, min: 30) |
Implementation Reference
- src/services/agService.js:118-137 (helper)Supporting helper method in AgService that makes the actual API call to the aggregator's gasless price endpoint.
async getGaslessPrice(params) { try { const queryParams = new URLSearchParams(params); const response = await fetch(`${this.baseUrl}/api/swap/gasless/price?${queryParams}`); if (!response.ok) { throw new Error(`HTTP ${response.status}: ${response.statusText}`); } const data = await response.json(); if (!data.success) { throw new Error(data.error || 'Gasless price request failed'); } return data.data; } catch (error) { throw new Error(`Failed to get gasless price: ${error.message}`); } }