diff --git a/src/encoding/evm/strategy_encoder/strategy_encoders.rs b/src/encoding/evm/strategy_encoder/strategy_encoders.rs index de59a54..c9792b2 100644 --- a/src/encoding/evm/strategy_encoder/strategy_encoders.rs +++ b/src/encoding/evm/strategy_encoder/strategy_encoders.rs @@ -277,7 +277,7 @@ impl StrategyEncoder for SplitSwapStrategyEncoder { Bytes::from_str(swap_encoder.executor_address()).map_err(|_| { EncodingError::FatalError("Invalid executor address".to_string()) })?, - self.encode_executor_selector(swap_encoder.executor_selector()), + self.encode_executor_selector(swap_encoder.swap_selector()), grouped_protocol_data.abi_encode_packed(), ); swaps.push(swap_data); @@ -360,15 +360,7 @@ impl StrategyEncoder for ExecutorStrategyEncoder { let executor_address = Bytes::from_str(swap_encoder.executor_address()) .map_err(|_| EncodingError::FatalError("Invalid executor address".to_string()))?; - Ok(( - protocol_data, - executor_address, - Some( - swap_encoder - .executor_selector() - .to_string(), - ), - )) + Ok((protocol_data, executor_address, Some(swap_encoder.swap_selector().to_string()))) } fn get_swap_encoder(&self, protocol_system: &str) -> Option<&Box> { diff --git a/src/encoding/evm/swap_encoder/swap_encoders.rs b/src/encoding/evm/swap_encoder/swap_encoders.rs index 69b037a..69ae085 100644 --- a/src/encoding/evm/swap_encoder/swap_encoders.rs +++ b/src/encoding/evm/swap_encoder/swap_encoders.rs @@ -17,11 +17,11 @@ use crate::encoding::{ /// /// # Fields /// * `executor_address` - The address of the executor contract that will perform the swap. -/// * `executor_selector` - The selector of the swap function in the executor contract. +/// * `swap_selector` - The selector of the swap function in the executor contract. #[derive(Clone)] pub struct UniswapV2SwapEncoder { executor_address: String, - executor_selector: String, + swap_selector: String, } impl UniswapV2SwapEncoder { @@ -32,7 +32,7 @@ impl UniswapV2SwapEncoder { impl SwapEncoder for UniswapV2SwapEncoder { fn new(executor_address: String) -> Self { - Self { executor_address, executor_selector: "swap(uint256,bytes)".to_string() } + Self { executor_address, swap_selector: "swap(uint256,bytes)".to_string() } } fn encode_swap( @@ -63,8 +63,8 @@ impl SwapEncoder for UniswapV2SwapEncoder { &self.executor_address } - fn executor_selector(&self) -> &str { - &self.executor_selector + fn swap_selector(&self) -> &str { + &self.swap_selector } fn clone_box(&self) -> Box { @@ -76,11 +76,11 @@ impl SwapEncoder for UniswapV2SwapEncoder { /// /// # Fields /// * `executor_address` - The address of the executor contract that will perform the swap. -/// * `executor_selector` - The selector of the swap function in the executor contract. +/// * `swap_selector` - The selector of the swap function in the executor contract. #[derive(Clone)] pub struct UniswapV3SwapEncoder { executor_address: String, - executor_selector: String, + swap_selector: String, } impl UniswapV3SwapEncoder { @@ -91,7 +91,7 @@ impl UniswapV3SwapEncoder { impl SwapEncoder for UniswapV3SwapEncoder { fn new(executor_address: String) -> Self { - Self { executor_address, executor_selector: "swap(uint256,bytes)".to_string() } + Self { executor_address, swap_selector: "swap(uint256,bytes)".to_string() } } fn encode_swap( @@ -134,8 +134,8 @@ impl SwapEncoder for UniswapV3SwapEncoder { fn executor_address(&self) -> &str { &self.executor_address } - fn executor_selector(&self) -> &str { - &self.executor_selector + fn swap_selector(&self) -> &str { + &self.swap_selector } fn clone_box(&self) -> Box { Box::new(self.clone()) @@ -146,12 +146,12 @@ impl SwapEncoder for UniswapV3SwapEncoder { /// /// # Fields /// * `executor_address` - The address of the executor contract that will perform the swap. -/// * `executor_selector` - The selector of the swap function in the executor contract. +/// * `swap_selector` - The selector of the swap function in the executor contract. /// * `callback_selector` - The selector of the callback function in the executor contract. #[derive(Clone)] pub struct UniswapV4SwapEncoder { executor_address: String, - executor_selector: String, + swap_selector: String, callback_selector: String, } @@ -173,7 +173,7 @@ impl SwapEncoder for UniswapV4SwapEncoder { fn new(executor_address: String) -> Self { Self { executor_address, - executor_selector: "swap(uint256,bytes)".to_string(), + swap_selector: "swap(uint256,bytes)".to_string(), callback_selector: "unlockCallback(bytes)".to_string(), } } @@ -255,8 +255,8 @@ impl SwapEncoder for UniswapV4SwapEncoder { &self.executor_address } - fn executor_selector(&self) -> &str { - &self.executor_selector + fn swap_selector(&self) -> &str { + &self.swap_selector } fn clone_box(&self) -> Box { @@ -268,11 +268,11 @@ impl SwapEncoder for UniswapV4SwapEncoder { /// /// # Fields /// * `executor_address` - The address of the executor contract that will perform the swap. -/// * `executor_selector` - The selector of the swap function in the executor contract. +/// * `swap_selector` - The selector of the swap function in the executor contract. #[derive(Clone)] pub struct BalancerV2SwapEncoder { executor_address: String, - executor_selector: String, + swap_selector: String, vault_address: String, } @@ -280,7 +280,7 @@ impl SwapEncoder for BalancerV2SwapEncoder { fn new(executor_address: String) -> Self { Self { executor_address, - executor_selector: "swap(uint256,bytes)".to_string(), + swap_selector: "swap(uint256,bytes)".to_string(), vault_address: "0xba12222222228d8ba445958a75a0704d566bf2c8".to_string(), } } @@ -315,8 +315,8 @@ impl SwapEncoder for BalancerV2SwapEncoder { fn executor_address(&self) -> &str { &self.executor_address } - fn executor_selector(&self) -> &str { - &self.executor_selector + fn swap_selector(&self) -> &str { + &self.swap_selector } fn clone_box(&self) -> Box { Box::new(self.clone()) diff --git a/src/encoding/swap_encoder.rs b/src/encoding/swap_encoder.rs index a0a9d0f..6061fb2 100644 --- a/src/encoding/swap_encoder.rs +++ b/src/encoding/swap_encoder.rs @@ -20,7 +20,7 @@ pub trait SwapEncoder: Sync + Send { fn executor_address(&self) -> &str; /// The selector of the executor function that will be called in order to perform a swap. - fn executor_selector(&self) -> &str; + fn swap_selector(&self) -> &str; /// Clones the swap encoder as a trait object. /// This allows the encoder to be cloned when it is being used as a `Box`.