feat: Support encoding only the pool swap

Create StraightToPoolStrategyEncoder
This commit is contained in:
Diana Carvalho
2025-01-14 12:56:37 +00:00
parent 4991883fc8
commit 3e609c75ae
4 changed files with 42 additions and 10 deletions

View File

@@ -1,7 +1,7 @@
use crate::encoding::models::Order;
use crate::encoding::strategy_encoder::{
SequentialExactInStrategyEncoder, SingleSwapStrategyEncoder, SlipSwapStrategyEncoder,
StrategyEncoder,
StraightToPoolStrategyEncoder, StrategyEncoder,
};
pub trait StrategySelector {
@@ -12,7 +12,9 @@ pub struct DefaultStrategySelector;
impl StrategySelector for DefaultStrategySelector {
fn select_strategy(&self, order: &Order) -> Box<dyn StrategyEncoder> {
if order.swaps.len() == 1 {
if order.straight_to_pool {
Box::new(StraightToPoolStrategyEncoder {})
} else if order.swaps.len() == 1 {
Box::new(SingleSwapStrategyEncoder {})
} else if order.swaps.iter().all(|s| s.split == 0.0) {
Box::new(SequentialExactInStrategyEncoder {})