feat: Add encode_full_calldata to TychoEncoder trait

This is so that people can easily use it without downcasting the encoder

Took 32 minutes
This commit is contained in:
Diana Carvalho
2025-05-22 12:51:35 +01:00
parent facdf716bd
commit 5aff28e345
2 changed files with 43 additions and 31 deletions

View File

@@ -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<Solution>,
) -> Result<Vec<EncodedSolution>, EncodingError>;
/// Encodes a list of [`Solution`]s directly into executable transactions for the Tycho router.
///
/// This method wraps around Tychos 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<Solution>,
) -> Result<Vec<Transaction>, EncodingError>;
/// Performs solution-level validation and sanity checks.
///
/// This function can be used to verify whether a proposed solution is structurally sound and