docs: add docs for TychoEncoder, StrategyEncoder and SwapEncoder traits

This commit is contained in:
royvardhan
2025-02-20 23:23:18 +05:30
parent 30a7d5bbe4
commit 4b20a1164b
3 changed files with 53 additions and 9 deletions

View File

@@ -3,9 +3,17 @@ use crate::encoding::{
models::{Solution, Transaction},
};
/// An encoder must implement this trait in order to encode a solution into a Transaction for
/// execution using a Tycho router or related contracts.
/// A high-level encoder that converts solutions into executable transactions. Allows for modularity
/// in the encoding process.
pub trait TychoEncoder {
/// Encodes solutions into transactions that can be executed by the Tycho router.
///
/// # Arguments
/// * `solutions` - Vector of solutions to encode, each potentially using different setups (swap
/// paths, protocols, etc.)
///
/// # Returns
/// * `Result<Vec<Transaction>, EncodingError>` - Vector of executable transactions
fn encode_router_calldata(
&self,
solutions: Vec<Solution>,