
Single-hop and multi-hop swaps
If adequate liquidity exists in a given pair, BEX most likely executes the swap as a single hop. Single-hop swaps incur less exchange and gas fees, making them the preferred method. However, when a trade between the input and output token does not provide the best overall price (or the trading pair does not exist as a single pool), BEX can perform a multi-hop swap. Multi-hop swaps involve chaining swaps across multiple pools to find the best overall price. The process of finding a cost-efficient multi-hop path is called routing.Intermediate tokens
In a multi-hop swap, intermediate tokens are the tokens held temporarily when swapping through a sequence of pairs. Intermediate tokens in BEX are never transferred because settlement occurs based on the net debit against the entire BEX protocol.
Swap parameters
When initiating a swap, you can define the following parameters:- Quantity: The amount of tokens to swap, which can be specified as either a fixed input quantity or a fixed output quantity.
- Slippage: The maximum acceptable difference between the expected and actual price of the trade. Slippage is expressed as a percentage and represents the worst-case price impact you are willing to accept. If the actual price impact exceeds this threshold, the swap transaction will revert.
