feat: Support new transfer logic in encoding
The transfer from the user into the router is supposed to happen in the router (we only support this in the executors for callback constrained protocols). This is necessary because of some security concerns that were found in the audit. This way we reduce the space of attack. - Refactored TransferOptimization not to handle TransferTypes anymore but just return bools. - Split get_transfer_type into get_transfers and get_in_between_transfer. Updates tests - Updated the strategies to use this - Updated function signatures to pass transfer_from and funds_receiver - Updated SwapEncoders to handle this - SplitSwapStrategy just assumes all tokens are sent to and from the router at all times Took 2 hours 46 minutes
This commit is contained in:
@@ -34,11 +34,12 @@ pub static IN_TRANSFER_REQUIRED_PROTOCOLS: LazyLock<HashSet<&'static str>> = Laz
|
||||
set
|
||||
});
|
||||
|
||||
// The protocols here are a subset of the ones defined in IN_TRANSFER_REQUIRED_PROTOCOLS. The tokens
|
||||
// can not be sent directly from the previous pool into a pool of this protocol. The tokens need to
|
||||
// be sent to the router and only then transferred into the pool. This is the case for uniswap v3
|
||||
// because of the callback logic. The only way for this to work it would be to call the second swap
|
||||
// during the callback of the first swap. This is currently not supported.
|
||||
// The protocols here are a subset of the ones defined in IN_TRANSFER_REQUIRED_PROTOCOLS. The in
|
||||
// transfer needs to be performed inside the callback logic. This means, the tokens can not be sent
|
||||
// directly from the previous pool into a pool of this protocol. The tokens need to be sent to the
|
||||
// router and only then transferred into the pool. This is the case for uniswap v3 because of the
|
||||
// callback logic. The only way for this to work it would be to call the second swap during the
|
||||
// callback of the first swap. This is currently not supported.
|
||||
pub static CALLBACK_CONSTRAINED_PROTOCOLS: LazyLock<HashSet<&'static str>> = LazyLock::new(|| {
|
||||
let mut set = HashSet::new();
|
||||
set.insert("uniswap_v3");
|
||||
|
||||
Reference in New Issue
Block a user