fix: Don't PLE-encode for Ekubo

Our encoding uses PLE for subsequent swaps in a swap group. The EkuboExecutor assumes hard-coded hop length, which did not match the encoding side - leading to corrupted calldata in any swap after the first swap.
This commit is contained in:
TAMARA LIPOWSKI
2025-10-07 12:08:49 +02:00
parent 13563a6fa9
commit ae1b1f8850
6 changed files with 968 additions and 724 deletions

View File

@@ -53,3 +53,11 @@ pub static CALLBACK_CONSTRAINED_PROTOCOLS: LazyLock<HashSet<&'static str>> = Laz
set.insert("vm:balancer_v3");
set
});
/// These groupable protocols use simple concatenation when forming swap groups instead of PLE
/// encoding for grouped protocol data.
pub static NON_PLE_ENCODED_PROTOCOLS: LazyLock<HashSet<&'static str>> = LazyLock::new(|| {
let mut set = HashSet::new();
set.insert("ekubo_v2");
set
});

View File

@@ -6,6 +6,7 @@ use tycho_common::{models::Chain, Bytes};
use crate::encoding::{
errors::EncodingError,
evm::{
constants::NON_PLE_ENCODED_PROTOCOLS,
group_swaps::group_swaps,
strategy_encoder::{
strategy_validators::{SequentialSwapValidator, SplitSwapValidator, SwapValidator},
@@ -139,7 +140,13 @@ impl StrategyEncoder for SingleSwapStrategyEncoder {
}
if !grouped_protocol_data.is_empty() {
initial_protocol_data.extend(ple_encode(grouped_protocol_data));
if NON_PLE_ENCODED_PROTOCOLS.contains(grouped_swap.protocol_system.as_str()) {
for protocol_data in grouped_protocol_data {
initial_protocol_data.extend(protocol_data);
}
} else {
initial_protocol_data.extend(ple_encode(grouped_protocol_data));
}
}
let swap_data = self.encode_swap_header(
@@ -305,7 +312,13 @@ impl StrategyEncoder for SequentialSwapStrategyEncoder {
}
if !grouped_protocol_data.is_empty() {
initial_protocol_data.extend(ple_encode(grouped_protocol_data));
if NON_PLE_ENCODED_PROTOCOLS.contains(grouped_swap.protocol_system.as_str()) {
for protocol_data in grouped_protocol_data {
initial_protocol_data.extend(protocol_data);
}
} else {
initial_protocol_data.extend(ple_encode(grouped_protocol_data));
}
}
let swap_data = self.encode_swap_header(
@@ -511,7 +524,13 @@ impl StrategyEncoder for SplitSwapStrategyEncoder {
}
if !grouped_protocol_data.is_empty() {
initial_protocol_data.extend(ple_encode(grouped_protocol_data));
if NON_PLE_ENCODED_PROTOCOLS.contains(grouped_swap.protocol_system.as_str()) {
for protocol_data in grouped_protocol_data {
initial_protocol_data.extend(protocol_data);
}
} else {
initial_protocol_data.extend(ple_encode(grouped_protocol_data));
}
}
let swap_data = self.encode_swap_header(