Support selling and buying LP tokens on the UniswapV2Executor.
Corresponding simulation issue:
propeller-heads/tycho-simulation#129
The Executor contract should use the same steps the simulation logic uses:
- Sell LP token
- check is the input token is an LP token
- burn the LP token in exchange for two reserves
- sell one of the reserves on the pool to provide a single reserve to the caller
- Buy LP token
- check if the output token is an LP token
- take one of the reserves and swap it to the second reserve
- This will require a method that uses the current spot price to determine how much of one reserve should be swapped for the other.
- then deposit both reserves to receive the LP token
Most of this logic is already implemented in the UniswapV2Router02 [docs] [code] in the following methods: addLiquidity, removeLiquidity, addLiquidityETH, removeLiquidityETH. We can perhaps copy these methods into our UniswapV2Executor to avoid some calls to an external contract (and maybe save gas).
On the encoding side, nothing needs to change.
Support selling and buying LP tokens on the UniswapV2Executor.
Corresponding simulation issue:
propeller-heads/tycho-simulation#129
The Executor contract should use the same steps the simulation logic uses:
Most of this logic is already implemented in the
UniswapV2Router02[docs] [code] in the following methods:addLiquidity,removeLiquidity,addLiquidityETH,removeLiquidityETH. We can perhaps copy these methods into ourUniswapV2Executorto avoid some calls to an external contract (and maybe save gas).On the encoding side, nothing needs to change.