feat: add swap strategy#56
Conversation
6dd15e9 to
5f339db
Compare
cd42364 to
41ccabe
Compare
adcebcd to
82e8a46
Compare
82e8a46 to
2687b93
Compare
96a9772 to
4f212d5
Compare
da36194 to
5db23d9
Compare
| return { calls, totalGasEstimate } | ||
| } | ||
|
|
||
| // Find whether uniswap v2 or v3 is the best protocol to use based on the amountIn the filler has to pay |
There was a problem hiding this comment.
I'm not including V4 because it requires unlock patterns with IUnlockCallback that regular wallets can't handle directly. EIP-7702 workaround can be used, as the BatchExecutor contract code we are inheriting right now as an EOA can be updated. But it will add complexity to the contract.
V2/V3 already provide good liquidity coverage with simpler integration, and V3 uses the same fee structure the V4 does.
There was a problem hiding this comment.
How does the callback affect swapping in the pool? Don't EOAs currently interact with UniV4?
There was a problem hiding this comment.
Ohh, I see what you mean here https://docs.uniswap.org/contracts/v4/reference/core/PoolManager#unlock
There was a problem hiding this comment.
Yes correct. If we knew the amountIn already, we could easily send v4 swap to universal router as it handles everything.
To get the amountIn through the v4 quoter, we need to call quoteExactInputSingle which is a write function. This works through callback to the caller, always ending up reverting with revert reason being the amountIn, and gasEstimate data
A swap strategy will the following rules: