feat: remove direct execution hardcode

This commit is contained in:
royvardhan
2025-02-05 17:05:06 +05:30
parent 4f7fe3b96d
commit ae6b1ed658
3 changed files with 20 additions and 66 deletions

View File

@@ -22,11 +22,7 @@ impl StrategyEncoderRegistry for EVMStrategyEncoderRegistry {
executors_file_path: &str,
signer_pk: Option<String>,
) -> Result<Self, EncodingError> {
let swap_encoder_registry = if executors_file_path.is_empty() {
SwapEncoderRegistry::new_direct_execution()
} else {
SwapEncoderRegistry::new(executors_file_path, Chain::Ethereum)?
};
let swap_encoder_registry = SwapEncoderRegistry::new(executors_file_path, Chain::Ethereum)?;
let mut strategies: HashMap<String, Box<dyn StrategyEncoder>> = HashMap::new();
strategies.insert(

View File

@@ -29,25 +29,6 @@ impl SwapEncoderRegistry {
Ok(Self { encoders })
}
pub fn new_direct_execution() -> Self {
let mut encoders = HashMap::new();
// Add default encoders with their respective executor addresses
let default_encoders = [
("uniswap_v2", "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D"),
("vm:balancer_v2", "0xBA12222222228d8Ba445958a75a0704d566BF2C8"),
];
for (protocol, executor_address) in default_encoders {
let builder = SwapEncoderBuilder::new(protocol, executor_address);
if let Ok(encoder) = builder.build() {
encoders.insert(protocol.to_string(), encoder);
}
}
Self { encoders }
}
#[allow(clippy::borrowed_box)]
pub fn get_encoder(&self, protocol_system: &str) -> Option<&Box<dyn SwapEncoder>> {
self.encoders.get(protocol_system)