diff --git a/src/encoding/evm/constants.rs b/src/encoding/evm/constants.rs index c2962f7..09da9f9 100644 --- a/src/encoding/evm/constants.rs +++ b/src/encoding/evm/constants.rs @@ -19,6 +19,7 @@ pub static GROUPABLE_PROTOCOLS: LazyLock> = LazyLock::new( }); /// These protocols support the optimization of transferring straight from the user. +/// Any protocols that are not defined here expect funds to be in the router at the time of swap. pub static IN_TRANSFER_OPTIMIZABLE_PROTOCOLS: LazyLock> = LazyLock::new(|| { let mut set = HashSet::new(); @@ -31,10 +32,12 @@ pub static IN_TRANSFER_OPTIMIZABLE_PROTOCOLS: LazyLock> = set }); -// These protocols do not support chained swaps from the same protocol. 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 PROTOCOLS_NOT_OPTIMIZED_CHAINED_SWAPS: LazyLock> = +// These protocols do not support chained swaps. 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 UNSUPPORTED_PROTOCOLS_FOR_CHAINED_SWAPS: LazyLock> = LazyLock::new(|| { let mut set = HashSet::new(); set.insert("uniswap_v3"); diff --git a/src/encoding/evm/strategy_encoder/strategy_encoders.rs b/src/encoding/evm/strategy_encoder/strategy_encoders.rs index ceb11d4..89a5f66 100644 --- a/src/encoding/evm/strategy_encoder/strategy_encoders.rs +++ b/src/encoding/evm/strategy_encoder/strategy_encoders.rs @@ -8,7 +8,7 @@ use crate::encoding::{ errors::EncodingError, evm::{ approvals::permit2::Permit2, - constants::{IN_TRANSFER_OPTIMIZABLE_PROTOCOLS, PROTOCOLS_NOT_OPTIMIZED_CHAINED_SWAPS}, + constants::{IN_TRANSFER_OPTIMIZABLE_PROTOCOLS, UNSUPPORTED_PROTOCOLS_FOR_CHAINED_SWAPS}, group_swaps::group_swaps, strategy_encoder::{ strategy_validators::{SequentialSwapValidator, SplitSwapValidator, SwapValidator}, @@ -311,9 +311,8 @@ impl StrategyEncoder for SequentialSwapStrategyEncoder { if IN_TRANSFER_OPTIMIZABLE_PROTOCOLS.contains(&next.protocol_system.as_str()) { // if the protocol does not allow for chained swaps, we can't optimize the // receiver of this swap nor the transfer in of the next swap - if PROTOCOLS_NOT_OPTIMIZED_CHAINED_SWAPS - .contains(&next.protocol_system.as_str()) && - PROTOCOLS_NOT_OPTIMIZED_CHAINED_SWAPS.contains(protocol.as_str()) + if UNSUPPORTED_PROTOCOLS_FOR_CHAINED_SWAPS + .contains(&next.protocol_system.as_str()) { next_in_between_swap_optimization = false; self.router_address.clone() diff --git a/src/encoding/evm/strategy_encoder/transfer_optimizations.rs b/src/encoding/evm/strategy_encoder/transfer_optimizations.rs index 9d53296..bb72ad0 100644 --- a/src/encoding/evm/strategy_encoder/transfer_optimizations.rs +++ b/src/encoding/evm/strategy_encoder/transfer_optimizations.rs @@ -30,7 +30,6 @@ pub trait TransferOptimization { } else if (swap.token_in == wrapped_token) && wrap { // Wrapping already happened in the router so we can just use a normal transfer. TransferType::TransferToProtocol - // first swap } else if is_first_swap { if in_transfer_optimizable { if permit2 {