feat: Generalize group_swaps method

- This can now be used for any groupable protocols - not just USV4.
This commit is contained in:
TAMARA LIPOWSKI
2025-02-17 17:23:29 -05:00
parent 957bf898f2
commit 47b61802ee
2 changed files with 112 additions and 7 deletions

View File

@@ -1,2 +1,16 @@
use std::{collections::HashSet, sync::LazyLock};
pub const DEFAULT_EXECUTORS_JSON: &str =
include_str!("../../../src/encoding/config/executor_addresses.json");
/// These protocols support the optimization of grouping swaps.
///
/// This requires special encoding to send call data of multiple swaps to a single executor,
/// as if it were a single swap. The protocol likely uses flash accounting to save gas on token
/// transfers.
pub static GROUPABLE_PROTOCOLS: LazyLock<HashSet<&'static str>> = LazyLock::new(|| {
let mut set = HashSet::new();
set.insert("uniswap_v4");
set.insert("balancer_v3");
set
});