fix: usv4 integration tests and remove selector from swap/strategy encoder
This commit is contained in:
@@ -24,7 +24,6 @@ use crate::encoding::{
|
||||
#[derive(Clone)]
|
||||
pub struct UniswapV2SwapEncoder {
|
||||
executor_address: String,
|
||||
swap_selector: String,
|
||||
}
|
||||
|
||||
impl UniswapV2SwapEncoder {
|
||||
@@ -35,7 +34,7 @@ impl UniswapV2SwapEncoder {
|
||||
|
||||
impl SwapEncoder for UniswapV2SwapEncoder {
|
||||
fn new(executor_address: String) -> Self {
|
||||
Self { executor_address, swap_selector: "swap(uint256,bytes)".to_string() }
|
||||
Self { executor_address }
|
||||
}
|
||||
|
||||
fn encode_swap(
|
||||
@@ -66,10 +65,6 @@ impl SwapEncoder for UniswapV2SwapEncoder {
|
||||
&self.executor_address
|
||||
}
|
||||
|
||||
fn swap_selector(&self) -> &str {
|
||||
&self.swap_selector
|
||||
}
|
||||
|
||||
fn clone_box(&self) -> Box<dyn SwapEncoder> {
|
||||
Box::new(self.clone())
|
||||
}
|
||||
@@ -83,7 +78,6 @@ impl SwapEncoder for UniswapV2SwapEncoder {
|
||||
#[derive(Clone)]
|
||||
pub struct UniswapV3SwapEncoder {
|
||||
executor_address: String,
|
||||
swap_selector: String,
|
||||
}
|
||||
|
||||
impl UniswapV3SwapEncoder {
|
||||
@@ -94,7 +88,7 @@ impl UniswapV3SwapEncoder {
|
||||
|
||||
impl SwapEncoder for UniswapV3SwapEncoder {
|
||||
fn new(executor_address: String) -> Self {
|
||||
Self { executor_address, swap_selector: "swap(uint256,bytes)".to_string() }
|
||||
Self { executor_address }
|
||||
}
|
||||
|
||||
fn encode_swap(
|
||||
@@ -128,9 +122,6 @@ impl SwapEncoder for UniswapV3SwapEncoder {
|
||||
fn executor_address(&self) -> &str {
|
||||
&self.executor_address
|
||||
}
|
||||
fn swap_selector(&self) -> &str {
|
||||
&self.swap_selector
|
||||
}
|
||||
fn clone_box(&self) -> Box<dyn SwapEncoder> {
|
||||
Box::new(self.clone())
|
||||
}
|
||||
@@ -145,8 +136,6 @@ impl SwapEncoder for UniswapV3SwapEncoder {
|
||||
#[derive(Clone)]
|
||||
pub struct UniswapV4SwapEncoder {
|
||||
executor_address: String,
|
||||
swap_selector: String,
|
||||
callback_selector: String,
|
||||
}
|
||||
|
||||
impl UniswapV4SwapEncoder {
|
||||
@@ -157,11 +146,7 @@ impl UniswapV4SwapEncoder {
|
||||
|
||||
impl SwapEncoder for UniswapV4SwapEncoder {
|
||||
fn new(executor_address: String) -> Self {
|
||||
Self {
|
||||
executor_address,
|
||||
swap_selector: "swap(uint256,bytes)".to_string(),
|
||||
callback_selector: "unlockCallback(bytes)".to_string(),
|
||||
}
|
||||
Self { executor_address }
|
||||
}
|
||||
|
||||
fn encode_swap(
|
||||
@@ -206,7 +191,6 @@ impl SwapEncoder for UniswapV4SwapEncoder {
|
||||
group_token_out_address,
|
||||
zero_to_one,
|
||||
callback_executor,
|
||||
encode_function_selector(&self.callback_selector),
|
||||
pool_params,
|
||||
);
|
||||
|
||||
@@ -217,10 +201,6 @@ impl SwapEncoder for UniswapV4SwapEncoder {
|
||||
&self.executor_address
|
||||
}
|
||||
|
||||
fn swap_selector(&self) -> &str {
|
||||
&self.swap_selector
|
||||
}
|
||||
|
||||
fn clone_box(&self) -> Box<dyn SwapEncoder> {
|
||||
Box::new(self.clone())
|
||||
}
|
||||
@@ -230,11 +210,10 @@ impl SwapEncoder for UniswapV4SwapEncoder {
|
||||
///
|
||||
/// # Fields
|
||||
/// * `executor_address` - The address of the executor contract that will perform the swap.
|
||||
/// * `swap_selector` - The selector of the swap function in the executor contract.
|
||||
/// * `vault_address` - The address of the vault contract that will perform the swap.
|
||||
#[derive(Clone)]
|
||||
pub struct BalancerV2SwapEncoder {
|
||||
executor_address: String,
|
||||
swap_selector: String,
|
||||
vault_address: String,
|
||||
}
|
||||
|
||||
@@ -242,7 +221,6 @@ impl SwapEncoder for BalancerV2SwapEncoder {
|
||||
fn new(executor_address: String) -> Self {
|
||||
Self {
|
||||
executor_address,
|
||||
swap_selector: "swap(uint256,bytes)".to_string(),
|
||||
vault_address: "0xba12222222228d8ba445958a75a0704d566bf2c8".to_string(),
|
||||
}
|
||||
}
|
||||
@@ -277,9 +255,6 @@ impl SwapEncoder for BalancerV2SwapEncoder {
|
||||
fn executor_address(&self) -> &str {
|
||||
&self.executor_address
|
||||
}
|
||||
fn swap_selector(&self) -> &str {
|
||||
&self.swap_selector
|
||||
}
|
||||
fn clone_box(&self) -> Box<dyn SwapEncoder> {
|
||||
Box::new(self.clone())
|
||||
}
|
||||
@@ -418,7 +393,6 @@ mod tests {
|
||||
.encode_swap(swap, encoding_context)
|
||||
.unwrap();
|
||||
let hex_swap = encode(&encoded_swap);
|
||||
println!("{}", hex_swap);
|
||||
|
||||
assert_eq!(
|
||||
hex_swap,
|
||||
@@ -478,6 +452,7 @@ mod tests {
|
||||
.encode_swap(swap, encoding_context)
|
||||
.unwrap();
|
||||
let hex_swap = encode(&encoded_swap);
|
||||
println!("{}", hex_swap);
|
||||
|
||||
assert_eq!(
|
||||
hex_swap,
|
||||
@@ -490,8 +465,6 @@ mod tests {
|
||||
"01",
|
||||
// executor address
|
||||
"f62849f9a0b5bf2913b396098f7c7019b51a820a",
|
||||
// callback selector for "unlockCallback(bytes)"
|
||||
"91dd7346",
|
||||
// pool params:
|
||||
// - intermediary token
|
||||
"dac17f958d2ee523a2206206994597c13d831ec7",
|
||||
@@ -637,6 +610,7 @@ mod tests {
|
||||
|
||||
let combined_hex =
|
||||
format!("{}{}", encode(&initial_encoded_swap), encode(&second_encoded_swap));
|
||||
println!("{}", combined_hex);
|
||||
|
||||
assert_eq!(
|
||||
combined_hex,
|
||||
@@ -649,8 +623,6 @@ mod tests {
|
||||
"01",
|
||||
// executor address
|
||||
"f62849f9a0b5bf2913b396098f7c7019b51a820a",
|
||||
// callback selector for "unlockCallback(bytes)"
|
||||
"91dd7346",
|
||||
// pool params:
|
||||
// - intermediary token USDT
|
||||
"dac17f958d2ee523a2206206994597c13d831ec7",
|
||||
|
||||
Reference in New Issue
Block a user