chore: update executor_selector to swap_selector in swap encoder trait and attribute
This commit is contained in:
@@ -277,7 +277,7 @@ impl StrategyEncoder for SplitSwapStrategyEncoder {
|
|||||||
Bytes::from_str(swap_encoder.executor_address()).map_err(|_| {
|
Bytes::from_str(swap_encoder.executor_address()).map_err(|_| {
|
||||||
EncodingError::FatalError("Invalid executor address".to_string())
|
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(),
|
grouped_protocol_data.abi_encode_packed(),
|
||||||
);
|
);
|
||||||
swaps.push(swap_data);
|
swaps.push(swap_data);
|
||||||
@@ -360,15 +360,7 @@ impl StrategyEncoder for ExecutorStrategyEncoder {
|
|||||||
|
|
||||||
let executor_address = Bytes::from_str(swap_encoder.executor_address())
|
let executor_address = Bytes::from_str(swap_encoder.executor_address())
|
||||||
.map_err(|_| EncodingError::FatalError("Invalid executor address".to_string()))?;
|
.map_err(|_| EncodingError::FatalError("Invalid executor address".to_string()))?;
|
||||||
Ok((
|
Ok((protocol_data, executor_address, Some(swap_encoder.swap_selector().to_string())))
|
||||||
protocol_data,
|
|
||||||
executor_address,
|
|
||||||
Some(
|
|
||||||
swap_encoder
|
|
||||||
.executor_selector()
|
|
||||||
.to_string(),
|
|
||||||
),
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_swap_encoder(&self, protocol_system: &str) -> Option<&Box<dyn SwapEncoder>> {
|
fn get_swap_encoder(&self, protocol_system: &str) -> Option<&Box<dyn SwapEncoder>> {
|
||||||
|
|||||||
@@ -17,11 +17,11 @@ use crate::encoding::{
|
|||||||
///
|
///
|
||||||
/// # Fields
|
/// # Fields
|
||||||
/// * `executor_address` - The address of the executor contract that will perform the swap.
|
/// * `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)]
|
#[derive(Clone)]
|
||||||
pub struct UniswapV2SwapEncoder {
|
pub struct UniswapV2SwapEncoder {
|
||||||
executor_address: String,
|
executor_address: String,
|
||||||
executor_selector: String,
|
swap_selector: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UniswapV2SwapEncoder {
|
impl UniswapV2SwapEncoder {
|
||||||
@@ -32,7 +32,7 @@ impl UniswapV2SwapEncoder {
|
|||||||
|
|
||||||
impl SwapEncoder for UniswapV2SwapEncoder {
|
impl SwapEncoder for UniswapV2SwapEncoder {
|
||||||
fn new(executor_address: String) -> Self {
|
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(
|
fn encode_swap(
|
||||||
@@ -63,8 +63,8 @@ impl SwapEncoder for UniswapV2SwapEncoder {
|
|||||||
&self.executor_address
|
&self.executor_address
|
||||||
}
|
}
|
||||||
|
|
||||||
fn executor_selector(&self) -> &str {
|
fn swap_selector(&self) -> &str {
|
||||||
&self.executor_selector
|
&self.swap_selector
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clone_box(&self) -> Box<dyn SwapEncoder> {
|
fn clone_box(&self) -> Box<dyn SwapEncoder> {
|
||||||
@@ -76,11 +76,11 @@ impl SwapEncoder for UniswapV2SwapEncoder {
|
|||||||
///
|
///
|
||||||
/// # Fields
|
/// # Fields
|
||||||
/// * `executor_address` - The address of the executor contract that will perform the swap.
|
/// * `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)]
|
#[derive(Clone)]
|
||||||
pub struct UniswapV3SwapEncoder {
|
pub struct UniswapV3SwapEncoder {
|
||||||
executor_address: String,
|
executor_address: String,
|
||||||
executor_selector: String,
|
swap_selector: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UniswapV3SwapEncoder {
|
impl UniswapV3SwapEncoder {
|
||||||
@@ -91,7 +91,7 @@ impl UniswapV3SwapEncoder {
|
|||||||
|
|
||||||
impl SwapEncoder for UniswapV3SwapEncoder {
|
impl SwapEncoder for UniswapV3SwapEncoder {
|
||||||
fn new(executor_address: String) -> Self {
|
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(
|
fn encode_swap(
|
||||||
@@ -134,8 +134,8 @@ impl SwapEncoder for UniswapV3SwapEncoder {
|
|||||||
fn executor_address(&self) -> &str {
|
fn executor_address(&self) -> &str {
|
||||||
&self.executor_address
|
&self.executor_address
|
||||||
}
|
}
|
||||||
fn executor_selector(&self) -> &str {
|
fn swap_selector(&self) -> &str {
|
||||||
&self.executor_selector
|
&self.swap_selector
|
||||||
}
|
}
|
||||||
fn clone_box(&self) -> Box<dyn SwapEncoder> {
|
fn clone_box(&self) -> Box<dyn SwapEncoder> {
|
||||||
Box::new(self.clone())
|
Box::new(self.clone())
|
||||||
@@ -146,12 +146,12 @@ impl SwapEncoder for UniswapV3SwapEncoder {
|
|||||||
///
|
///
|
||||||
/// # Fields
|
/// # Fields
|
||||||
/// * `executor_address` - The address of the executor contract that will perform the swap.
|
/// * `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.
|
/// * `callback_selector` - The selector of the callback function in the executor contract.
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct UniswapV4SwapEncoder {
|
pub struct UniswapV4SwapEncoder {
|
||||||
executor_address: String,
|
executor_address: String,
|
||||||
executor_selector: String,
|
swap_selector: String,
|
||||||
callback_selector: String,
|
callback_selector: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,7 +173,7 @@ impl SwapEncoder for UniswapV4SwapEncoder {
|
|||||||
fn new(executor_address: String) -> Self {
|
fn new(executor_address: String) -> Self {
|
||||||
Self {
|
Self {
|
||||||
executor_address,
|
executor_address,
|
||||||
executor_selector: "swap(uint256,bytes)".to_string(),
|
swap_selector: "swap(uint256,bytes)".to_string(),
|
||||||
callback_selector: "unlockCallback(bytes)".to_string(),
|
callback_selector: "unlockCallback(bytes)".to_string(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -255,8 +255,8 @@ impl SwapEncoder for UniswapV4SwapEncoder {
|
|||||||
&self.executor_address
|
&self.executor_address
|
||||||
}
|
}
|
||||||
|
|
||||||
fn executor_selector(&self) -> &str {
|
fn swap_selector(&self) -> &str {
|
||||||
&self.executor_selector
|
&self.swap_selector
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clone_box(&self) -> Box<dyn SwapEncoder> {
|
fn clone_box(&self) -> Box<dyn SwapEncoder> {
|
||||||
@@ -268,11 +268,11 @@ impl SwapEncoder for UniswapV4SwapEncoder {
|
|||||||
///
|
///
|
||||||
/// # Fields
|
/// # Fields
|
||||||
/// * `executor_address` - The address of the executor contract that will perform the swap.
|
/// * `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)]
|
#[derive(Clone)]
|
||||||
pub struct BalancerV2SwapEncoder {
|
pub struct BalancerV2SwapEncoder {
|
||||||
executor_address: String,
|
executor_address: String,
|
||||||
executor_selector: String,
|
swap_selector: String,
|
||||||
vault_address: String,
|
vault_address: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,7 +280,7 @@ impl SwapEncoder for BalancerV2SwapEncoder {
|
|||||||
fn new(executor_address: String) -> Self {
|
fn new(executor_address: String) -> Self {
|
||||||
Self {
|
Self {
|
||||||
executor_address,
|
executor_address,
|
||||||
executor_selector: "swap(uint256,bytes)".to_string(),
|
swap_selector: "swap(uint256,bytes)".to_string(),
|
||||||
vault_address: "0xba12222222228d8ba445958a75a0704d566bf2c8".to_string(),
|
vault_address: "0xba12222222228d8ba445958a75a0704d566bf2c8".to_string(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -315,8 +315,8 @@ impl SwapEncoder for BalancerV2SwapEncoder {
|
|||||||
fn executor_address(&self) -> &str {
|
fn executor_address(&self) -> &str {
|
||||||
&self.executor_address
|
&self.executor_address
|
||||||
}
|
}
|
||||||
fn executor_selector(&self) -> &str {
|
fn swap_selector(&self) -> &str {
|
||||||
&self.executor_selector
|
&self.swap_selector
|
||||||
}
|
}
|
||||||
fn clone_box(&self) -> Box<dyn SwapEncoder> {
|
fn clone_box(&self) -> Box<dyn SwapEncoder> {
|
||||||
Box::new(self.clone())
|
Box::new(self.clone())
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ pub trait SwapEncoder: Sync + Send {
|
|||||||
fn executor_address(&self) -> &str;
|
fn executor_address(&self) -> &str;
|
||||||
|
|
||||||
/// The selector of the executor function that will be called in order to perform a swap.
|
/// 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.
|
/// Clones the swap encoder as a trait object.
|
||||||
/// This allows the encoder to be cloned when it is being used as a `Box<dyn SwapEncoder>`.
|
/// This allows the encoder to be cloned when it is being used as a `Box<dyn SwapEncoder>`.
|
||||||
|
|||||||
Reference in New Issue
Block a user