PancakeswapV3 Toaster
A router that makes the Pancakeswap V3 an easy investment. It calculates the correct amount of token swaps for your investment and uses PancakeswapV3Toaster.
Last updated
A router that makes the Pancakeswap V3 an easy investment. It calculates the correct amount of token swaps for your investment and uses PancakeswapV3Toaster.
Last updated
If you decide on a price range, the current price will determine the ratio of the amount of tokens 0 and 1. If the user wants to provide liquidity of $1000, it will be very cumbersome to manually invest exactly $1000, and of course they will not be able to invest the amount they want.
Even if you know the amount of tokens to swap in advance, there is a problem: the moment you swap the tokens, it will affect the current price of the pool you want to liquidate, and the previously calculated token amount will be incorrect. Therefore, you need to consider the (post-swap token amount) to determine the amount to swap.
Use the binary search method to find the amount to swap.
The amount of liquidity supplied for each price range is different, so a simple first-order calculation is not possible, so we need to find the liquidity to reach the final price to know how many tokens to swap.
Find and compare the amount of token 0 and token 1 to be used by the user with the liquidity conversion amount using the formula (6.29,6.30) in the unswapv3-core whitepaper.
Find the amount to be swapped using the binary search method.
2-1. If L0 is greater than L1, find the swap amount of token 0 in the following way.deltaA0
For Swap(), we implemented it by removing all the parts of the V3Quoter method that use storage.
Search by binary search until the following equation is satisfied (maximum search depth: 72)
2-2. If L1 is greater than L0, find the amount of swap for token 1 in the following way.The reverse is true, so the expression is the same.