feat: Add evm feature gate
- Move all evm code inside evm directory - StrategyEncoder: - Kept StrategyEncoder trait but created a new one: EVMStrategyEncoder to implement encode_protocol_header (that is evm specific). - All StrategyEncoders implement both traits now - Renamed DefaultStrategySelector -> EVMStrategySelector - RouterEncoder: - Created a RouterEncoder trait and a EVMRouterEncoder that implements it - Moved utils inside evm directory as well - Renamed config.json -> executor_addresses.json and moved it to a higher config directory - Make alloy optional and dependent on the evm feature gate --- don't change below this line --- ENG-4075 <#DTT#>
This commit is contained in:
28
src/encoding/evm/strategy_encoder/selector.rs
Normal file
28
src/encoding/evm/strategy_encoder/selector.rs
Normal file
@@ -0,0 +1,28 @@
|
||||
use crate::encoding::{
|
||||
evm::strategy_encoder::encoder::{
|
||||
SequentialStrategyEncoder, SingleSwapStrategyEncoder, SplitSwapStrategyEncoder,
|
||||
StraightToPoolStrategyEncoder,
|
||||
},
|
||||
models::Solution,
|
||||
strategy_encoder::{StrategyEncoder, StrategySelector},
|
||||
};
|
||||
|
||||
pub struct EVMStrategySelector;
|
||||
|
||||
impl StrategySelector for EVMStrategySelector {
|
||||
fn select_strategy(&self, solution: &Solution) -> Box<dyn StrategyEncoder> {
|
||||
if solution.straight_to_pool {
|
||||
Box::new(StraightToPoolStrategyEncoder {})
|
||||
} else if solution.swaps.len() == 1 {
|
||||
Box::new(SingleSwapStrategyEncoder {})
|
||||
} else if solution
|
||||
.swaps
|
||||
.iter()
|
||||
.all(|s| s.split == 0.0)
|
||||
{
|
||||
Box::new(SequentialStrategyEncoder {})
|
||||
} else {
|
||||
Box::new(SplitSwapStrategyEncoder {})
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user