- Swap exact tokens for HBAR
- Swap tokens for exact HBAR
- Swap exact tokens supporting custom fees for HBAR
Contract ID: SaucerSwapV1RouterV3
The swapExactTokensForETH and swapTokensForExactETH function trades in HBAR but derives its name from Uniswap on Ethereum. This name was kept to simplify integration for developers versed in Uniswap tools.
Granting an spender allowance to the router contract is required when the input token is not native HBAR for security reasons enforced at the native code layer. Ensure that the allowance amount is in token’s smallest unit.
Consider the token’s decimal places when determining input amounts.The input values should be in the token’s smallest unit. For the SAUCE token, which has 6 decimal places, an input of 123.45 SAUCE should be entered as 123450000 (123.45 multiplied by 10^6).
Swap Exact Tokens for HBAR
Swap an exact amount of tokens for a minimum HBAR amount. Solidity function name: swapExactTokensForETH| Parameter Name | Description |
|---|---|
| uint amountIn | The input token amount in its smallest unit |
| uint amountOutMin | The minimum token amount to receive in its smallest unit |
| address[] calldata path | An ordered list of token EVM addresses |
| address to | EVM address for the token recipient |
| uint deadline | Deadline in Unix seconds |
Code Overview
- JavaScript SDK
Swap Tokens for Exact HBAR
Swap a maximum amount of tokens to receive an exact HBAR amount.| Parameter Name | Description |
|---|---|
| uint amountOut | The exact output HBAR amount to receive in its smallest unit |
| uint amountInMax | The maximum allowed input amount in its smallest unit |
| address[] calldata path | An ordered list of token EVM addresses |
| address to | EVM address for the token recipient |
| uint deadline | Deadline in Unix seconds |
Code Overview
- JavaScript SDK
Swap Exact Tokens Supporting Custom Fees for HBAR
Swap an exact amount of tokens, supporting HTS tokens with custom fees on token transfer, for a minimum HBAR amount. Solidity function name: swapExactTokensForETHSupportingFeeOnTransferTokens| Parameter Name | Description |
|---|---|
| uint amountIn | The input token amount in its smallest unit |
| uint amountOutMin | The minimum token amount to receive in its smallest unit |
| address[] calldata path | An ordered list of token EVM addresses |
| address to | EVM address for the token recipient |
| uint deadline | Deadline in Unix seconds |
Code Overview
- JavaScript SDK