diff --git a/src/encoding/evm/tycho_encoders.rs b/src/encoding/evm/tycho_encoders.rs index 0d66c77..f22f59d 100644 --- a/src/encoding/evm/tycho_encoders.rs +++ b/src/encoding/evm/tycho_encoders.rs @@ -39,7 +39,6 @@ pub struct TychoRouterEncoder { native_address: Bytes, wrapped_address: Bytes, router_address: Bytes, - #[allow(dead_code)] token_in_already_in_router: bool, permit2: Option, } @@ -130,22 +129,21 @@ impl TychoRouterEncoder { } Ok(encoded_solution) } +} + +impl TychoEncoder for TychoRouterEncoder { + fn encode_solutions( + &self, + solutions: Vec, + ) -> Result, EncodingError> { + let mut result: Vec = Vec::new(); + for solution in solutions.iter() { + let encoded_solution = self.encode_solution(solution)?; + result.push(encoded_solution); + } + Ok(result) + } - /// Encodes a list of [`Solution`]s directly into executable transactions for the Tycho router. - /// - /// This method wraps around Tycho’s example encoding logic (see [`encode_tycho_router_call`]) - /// and should only be used for **prototyping or development**. - /// - /// # Warning - /// This implementation uses default logic to construct the outer calldata (e.g., for setting - /// `minAmountOut`). This might not be optimal or safe for production use. - /// - /// To ensure correctness, **users should implement their own encoding pipeline** using - /// [`encode_solutions`]. - /// - /// # Returns - /// A vector of fully constructed [`Transaction`]s that can be submitted to a node or bundler. - #[allow(dead_code)] fn encode_full_calldata( &self, solutions: Vec, @@ -165,20 +163,6 @@ impl TychoRouterEncoder { } Ok(transactions) } -} - -impl TychoEncoder for TychoRouterEncoder { - fn encode_solutions( - &self, - solutions: Vec, - ) -> Result, EncodingError> { - let mut result: Vec = Vec::new(); - for solution in solutions.iter() { - let encoded_solution = self.encode_solution(solution)?; - result.push(encoded_solution); - } - Ok(result) - } /// Raises an `EncodingError` if the solution is not considered valid. /// @@ -375,6 +359,15 @@ impl TychoEncoder for TychoExecutorEncoder { Ok(vec![encoded_solution]) } + fn encode_full_calldata( + &self, + _solutions: Vec, + ) -> Result, EncodingError> { + Err(EncodingError::NotImplementedError( + "Full calldata encoding is not supported for TychoExecutorEncoder".to_string(), + )) + } + /// Raises an `EncodingError` if the solution is not considered valid. /// /// A solution is considered valid if all the following conditions are met: diff --git a/src/encoding/tycho_encoder.rs b/src/encoding/tycho_encoder.rs index 49c2334..f66b1d4 100644 --- a/src/encoding/tycho_encoder.rs +++ b/src/encoding/tycho_encoder.rs @@ -1,6 +1,6 @@ use crate::encoding::{ errors::EncodingError, - models::{EncodedSolution, Solution}, + models::{EncodedSolution, Solution, Transaction}, }; /// A high-level interface for encoding solutions into Tycho-compatible transactions or raw call @@ -47,6 +47,25 @@ pub trait TychoEncoder { solutions: Vec, ) -> Result, EncodingError>; + /// Encodes a list of [`Solution`]s directly into executable transactions for the Tycho router. + /// + /// This method wraps around Tycho’s example encoding logic (see [`encode_tycho_router_call`]) + /// and should only be used for **prototyping or development**. + /// + /// # Warning + /// This implementation uses default logic to construct the outer calldata (e.g., for setting + /// `minAmountOut`). This might not be optimal or safe for production use. + /// + /// To ensure correctness, **users should implement their own encoding pipeline** using + /// [`encode_solutions`]. + /// + /// # Returns + /// A vector of fully constructed [`Transaction`]s that can be submitted to a node or bundler. + fn encode_full_calldata( + &self, + solutions: Vec, + ) -> Result, EncodingError>; + /// Performs solution-level validation and sanity checks. /// /// This function can be used to verify whether a proposed solution is structurally sound and