feat: Remove batch execute logic from StrategyEncoder

Add action_type and selector to StrategyEncoder
Rename SequentialExactInStrategyEncoder -> SequentialStrategyEncoder
This commit is contained in:
Diana Carvalho
2025-01-14 15:25:29 +00:00
parent 93410b4fe2
commit 68c5a914eb
3 changed files with 74 additions and 38 deletions

View File

@@ -22,8 +22,22 @@ impl<S: StrategySelector, A: UserApprovalsManager> RouterEncoder<S, A> {
let mut calldata_list: Vec<Vec<u8>> = Vec::new();
let encode_for_batch_execute = solution.orders.len() > 1;
for order in solution.orders {
let exact_out = order.exact_out.clone();
let straight_to_pool = order.straight_to_pool.clone();
let strategy = self.strategy_selector.select_strategy(&order);
let contract_interaction = strategy.encode_strategy(order, encode_for_batch_execute)?;
let method_calldata = strategy.encode_strategy(order)?;
let contract_interaction = if encode_for_batch_execute {
let args = (strategy.action_type(exact_out) as u16, method_calldata);
args.abi_encode()
} else {
if straight_to_pool {
method_calldata
} else {
encode_input(strategy.selector(exact_out), method_calldata)
}
};
calldata_list.push(contract_interaction);
}
if encode_for_batch_execute {