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:
26
src/encoding/evm/swap_encoder/builder.rs
Normal file
26
src/encoding/evm/swap_encoder/builder.rs
Normal file
@@ -0,0 +1,26 @@
|
||||
use crate::encoding::{
|
||||
evm::swap_encoder::encoders::{BalancerV2SwapEncoder, UniswapV2SwapEncoder},
|
||||
swap_encoder::SwapEncoder,
|
||||
};
|
||||
|
||||
pub struct SwapEncoderBuilder {
|
||||
protocol_system: String,
|
||||
executor_address: String,
|
||||
}
|
||||
|
||||
impl SwapEncoderBuilder {
|
||||
pub fn new(protocol_system: &str, executor_address: &str) -> Self {
|
||||
SwapEncoderBuilder {
|
||||
protocol_system: protocol_system.to_string(),
|
||||
executor_address: executor_address.to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn build(self) -> Result<Box<dyn SwapEncoder>, String> {
|
||||
match self.protocol_system.as_str() {
|
||||
"uniswap_v2" => Ok(Box::new(UniswapV2SwapEncoder::new(self.executor_address))),
|
||||
"vm:balancer_v2" => Ok(Box::new(BalancerV2SwapEncoder::new(self.executor_address))),
|
||||
_ => Err(format!("Unknown protocol system: {}", self.protocol_system)),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user