Swap Quote
Get a token swap quote based on an input or output value
Below are the two methods to get a quote for a swap from a given route:
Contract ID: SaucerSwapV2QuoterV2
When providing HBAR in the path array, use the wrapped HBAR token ID (WHBAR).
For production environments, itโs highly recommended to use a paid Mirror Node provider for commercial and high-traffic purposes. While Hederaโs public mirror node offers free REST API and JSON API endpoints, they have global rate limits. These are best suited for development or low rate usage scenarios.
Get Output Quote from Exact Input Amount
Get the output amount from a given exact input amount and a swap route.
Function name: quoteExactInput โฝ No gas cost
Parameter Name | Description |
---|---|
bytes path | Route path containing pair swap fees |
uint256 amountIn | Exact input amount in tokenโs smallest unit |
The data passed to the โpathโ parameter follows this format: [token, fee, token, fee, token, โฆ], with each โtokenโ in the route being 20 bytes long and each โfeeโ being 3 bytes long. Example, 0x0001F4 for a 0.05% fee.
Code Overview
Get Input Quote from Exact Output Amount
Get the input amount from a given exact output amount and a swap route.
Function name: quoteExactOutput โฝ No gas cost
Parameter Name | Description |
---|---|
bytes path | Route path containing pair swap fees, reversed |
uint256 amountOut | Exact output amount in tokenโs smallest unit |
The data passed to the โpathโ parameter follows this format: [token, fee, token, fee, token, โฆ], but reversed (i.e. the first token in the array should be output token), with each โtokenโ in the route being 20 bytes long and each โfeeโ being 3 bytes long. Example, 0x000BB8
for a 0.30% fee.