Swaps
The core functionality of BeraSwap is to allow users to exchange one type of token for another. If liquidity exists for a given pair in the DEX contract, users will be able to swap between tokens. The BeraSwap web app provides an interface for general-purpose swaps.
Single-Hop and Multi-Hop Swaps
If adequate liquidity exists in a given pair, a swap will most likely be executed 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), BeraSwap 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 BeraSwap are never transferred because settlement occurs based on the net debit against the entire BeraSwap protocol.
You can see an example of a multi-hop swap here in this screenshot(circled in red):
Swap Parameters
When initiating a swap, users 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 the user is willing to accept. If the actual price impact exceeds this threshold, the swap transaction will revert. Slippage can be specified by selecting the gear icon on the swap page: