feat: (WIP) Support selection of transfer into router

- For protocols like Balancer and Curve, which expect funds to be in the router at the time of swap, we must support also transferring funds from the user into the router. Doing this in the router would mean we are dealing with transfers in two different places: in the router main methods and in the executors. To avoid this, we are now performing transfers just in the executors, and two transfer types have been added to support transfers into the router.

TODO:
- Add this for Balancer and Curve (only added for USV4 atm).
- TODO consider renaming TRANSFER_FROM and TRANSFER_PERMIT2 to include "pool" in the name
This commit is contained in:
TAMARA LIPOWSKI
2025-04-11 23:25:45 -04:00
committed by Diana Carvalho
parent 59a80dc392
commit a301a1cef3
19 changed files with 426 additions and 240 deletions

View File

@@ -26,3 +26,14 @@ pub static IN_TRANSFER_OPTIMIZABLE_PROTOCOLS: LazyLock<HashSet<&'static str>> =
set.insert("uniswap_v3");
set
});
/// These protocols expect funds to be in the router at the time of swap.
pub static PROTOCOLS_EXPECTING_FUNDS_IN_ROUTER: LazyLock<HashSet<&'static str>> =
LazyLock::new(|| {
let mut set = HashSet::new();
set.insert("curve");
set.insert("balancer_v2");
// TODO remove uniswap_v4 when we add callback support for transfer optimizations
set.insert("uniswap_v4");
set
});