feat: Create a EVMEncoderBuilder

- It has two three methods to be created:
  - new: where the user can pass any custom StrategyEncoder
  - tycho_router: where the default SplitSwapStrategyEncoder with Tycho Router will be used
  - direct_execution: where the user can encode only the execution data and integrate this into their workflow.
- This replaces StrategyEncoderRegistry
- EVMTychoEncoder holds directly the StrategyEncoder and not the registry (per one init of the EVMTychoEncoder there is only one possible StrategyEncoder)
- Update quickstart
- Update bin (add subcommands to bin to create a different instance of EVMEncoderBuilder)

--- don't change below this line ---
ENG-4246 Took 33 minutes

Took 38 seconds

Took 38 seconds
This commit is contained in:
Diana Carvalho
2025-02-18 16:49:38 +00:00
parent f76e320ff7
commit 03506fabe9
15 changed files with 156 additions and 186 deletions

View File

@@ -1,4 +1,4 @@
use tycho_core::{dto::Chain, Bytes};
use tycho_core::Bytes;
use crate::encoding::{errors::EncodingError, models::Solution, swap_encoder::SwapEncoder};
@@ -13,19 +13,3 @@ pub trait StrategyEncoder {
fn get_swap_encoder(&self, protocol_system: &str) -> Option<&Box<dyn SwapEncoder>>;
fn clone_box(&self) -> Box<dyn StrategyEncoder>;
}
/// Contains the supported strategies to encode a solution, and chooses the best strategy to encode
/// a solution based on the solution's attributes.
pub trait StrategyEncoderRegistry {
fn new(
chain: Chain,
executors_file_path: Option<String>,
signer_pk: Option<String>,
) -> Result<Self, EncodingError>
where
Self: Sized;
/// Returns the strategy encoder that should be used to encode the given solution.
#[allow(clippy::borrowed_box)]
fn get_encoder(&self, solution: &Solution) -> Result<&Box<dyn StrategyEncoder>, EncodingError>;
}