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

@@ -103,6 +103,8 @@ pub struct Transaction {
/// * `Transfer`: Transfer the token from the router into the pool.
/// * `TransferFrom`: Transfer the token from the swapper to the pool.
/// * `Permit2Transfer`: Transfer the token from the sender to the pool using Permit2.
/// * `TransferToRouter`: Transfer the token from the swapper to the router.
/// * `Permit2TransferToRouter`: Transfer the token from the swapper to the router using Permit2.
/// * `None`: No transfer is needed. Tokens are already in the pool.
#[repr(u8)]
#[derive(Clone, Debug, PartialEq)]
@@ -110,7 +112,9 @@ pub enum TransferType {
Transfer = 0,
TransferFrom = 1,
Permit2Transfer = 2,
None = 3,
TransferToRouter = 3,
Permit2TransferToRouter = 4,
None = 5,
}
/// Represents necessary attributes for encoding an order.