Tetu Zap Solution
Zap solution converts a token to another using a defined route and deposit to the destination contract.
Withdraw and converting to the token is also possible.
This solution included three contracts
    PriceCalculator
    MultiSwap
    ZapContract

PriceCalculator

In this solution Price Calculator will find the best liquidity pool across predefined Swap Platforms.
getLargestPool(address token, address[] memory usedLps)
For calculation price for any LiquidityPool pair using
getPriceFromLp(address lpAddress, address token)

MultiSwap

This contract has two purposes:
Find the best route for swap two tokens. The result will contain swap pairs.
findLpsForSwaps(address _tokenIn, address _tokenOut)
The function should be called as a view from UI before the swap
Multi-swap will execute swaps for a given route. Used inside ZapContract but also can be used as a dedicated solution.
multiSwap(address[] memory lps, address tokenIn, address tokenOut, uint256 amount, uint256 slippageTolerance)

ZapContract

This contract implements all required steps for deposit/withdraw to the vault.
Last modified 2mo ago
Export as PDF
Copy link