💸Swap
In Enchanter Finance, users can swap tokens A by paying a transaction fee and providing tokens B of same value in exchange. By contrast, liquidity providers provide a pair of A and B tokens (again, equal in value) and earn a share of the transaction fees.
🪄Glossary
✨Automated Market Maker(AMM) is a protocol that runs on decentralized exchanges (Dex), where liquidity is provided by swapping and 'LP-ing'. It manages a liquidity pool made up of reserves of two ERC-20 tokens.
✨Enchanter's AMM protocol utilizes a constant function: x * y = k. It is used for calculating two tokens' relative prices to provide sustainability for the liquidity pool. In the formula, x and y are the amounts of the two tokens in a pool, and their product k is a constant. Any trade (swap) changes the amounts x and y, but k remains the same.
🪄AMM explained by example
Let’s say we fund a liquidity pool with 100 crystal balls and 100 magic books, which, according to our function, makes constant k = 10000. While their starting relative price is determined by the initial ratio of the two in market, let's assume that the exchange rate between magic books and crystal balls is exactly 1:1 for simplicity to start with.
So let’s say a customer named Harry comes to our liquidity pool to buy 1 book, we need to work out the number of magic balls to be treaded.
Buying a book leaves the pool with x' = 99. Solving for y' = k/x', we get 101.01. Hence he will need to add 1.01 crystal balls into the pool in exchange for one extra magic book. Hence the new price we have to quote him is 1.01 crystal ball/ magic book for 1 book.
(The liquidity curve above shows the change in price that results from each swap transaction.)
Due to the small exchange amount, the price slippage is quite small, changing from 1 crystal ball/ magic book to 1.01 crystal ball/ magic book. For a larger order, things would be quite different.
Say another customer named Voldemort comes to our liquidity pool to buy 90 books instead of Harry. Doing the maths all over again, we get:
Buying 90 book leaves the pool with x'' = 10. Solving for y'' = k/x'', we get 1000. Hence he will need to add 900 crystal balls into the pool in exchange for 90 extra magic books. Hence the new price we have to quote him is 10 crystal balls/ magic book for 1 book, which is 10 times the original price.
🔮Swapping on Enchanter Finance
1. Head to our main page and launch the Enchanter app here.

2. Make sure you have at least one Aptos-compatible wallet installed. Click the Connect Wallet in the top right-hand corner, and you're ready to swap!


3. While the default setting is APT, you can choose the token and enter the amount you want to swap from the dropdown menu. Make sure you have enough balance in your wallet - it is shown below the token dropdown menu.

4. Double check the details: there is a drop down bar for more information below if needed. Click the Swap button when you're ready.

5. A confirmation window will appear. When you are ready, click the Confirm Swap button and approve in your wallet. And... Done! You can click View on Explorer to see more.

⚠️ Decimals of stable pairs
To avoid rounding errors and loss of precision in liquidity operations, in Enchanter, we display the data to a maximum of 16-dp precision, while being quite sure that the norm of 8-dp is already enough for any coin on Aptos.
Last updated