feat: Add interacting_with to EncodedSolution

- Remove encode_full_calldata from the TychoEncoder trait
- Make the TychoExecutorEncoder use encode_solutions instead of encode_full_calldata
- Update tycho-encode.rs accordingly

Took 1 hour 3 minutes


Took 12 seconds
This commit is contained in:
Diana Carvalho
2025-05-21 18:00:19 +01:00
parent 08056c4a6c
commit facdf716bd
8 changed files with 174 additions and 299 deletions

View File

@@ -61,17 +61,17 @@ fn main() {
};
// Encode the solution
let tx = encoder
.encode_calldata(vec![solution.clone()])
let encoded_solution = encoder
.encode_solutions(vec![solution.clone()])
.expect("Failed to encode router calldata")[0]
.clone();
println!(" ====== Simple swap WETH -> USDC ======");
println!(
"The simple swap encoded transaction should be sent to address {:?} with the value of {:?} and the \
"The simple swap encoded solution should be sent to address {:?} and selector {:?} and the \
following encoded data: {:?}",
tx.to,
tx.value,
hex::encode(tx.data)
encoded_solution.interacting_with,
encoded_solution.selector,
hex::encode(encoded_solution.swaps)
);
// ------------------- Encode a swap with multiple splits -------------------
@@ -134,17 +134,17 @@ fn main() {
complex_solution.swaps = vec![swap_weth_dai, swap_weth_wbtc, swap_dai_usdc, swap_wbtc_usdc];
// Encode the solution
let complex_tx = encoder
.encode_calldata(vec![complex_solution])
let complex_encoded_solution = encoder
.encode_solutions(vec![complex_solution])
.expect("Failed to encode router calldata")[0]
.clone();
println!(" ====== Complex split swap WETH -> USDC ======");
println!(
"The complex solution encoded transaction should be sent to address {:?} with the value of {:?} and the \
"The complex swaps encoded solution should be sent to address {:?} and selector {:?} and the \
following encoded data: {:?}",
complex_tx.to,
complex_tx.value,
hex::encode(complex_tx.data)
complex_encoded_solution.interacting_with,
complex_encoded_solution.selector,
hex::encode(complex_encoded_solution.swaps)
);
}