feat: Separate encoding swaps from encoding txs
This way the user is responsible for encoding the Tycho Router method inputs that are used as guardrails in execution. Interface changes: - Create EncodedSolution - StrategyEncoder - don't need to know have permit2 or token_in_already_in_router as attributes anymore - encode_strategy returns EncodedSolution now (no method encoding done here now) - TychoEncoder - add encode_solution() method. This is the recommended method for users - needs to have permit2, token_in_already_in_router and router_address as attributes - permit creation is made in the router now Also: - create encoding_utils.rs - update all tests Took 2 hours 42 minutes Took 3 minutes Took 13 minutes
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use alloy_primitives::PrimitiveSignature as Signature;
|
||||
use hex;
|
||||
use num_bigint::BigUint;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -8,6 +9,7 @@ use tycho_common::{
|
||||
|
||||
use crate::encoding::{
|
||||
errors::EncodingError,
|
||||
evm::approvals::permit2::PermitSingle,
|
||||
serde_primitives::{biguint_string, biguint_string_option},
|
||||
};
|
||||
|
||||
@@ -96,6 +98,22 @@ pub struct Transaction {
|
||||
pub data: Vec<u8>,
|
||||
}
|
||||
|
||||
/// Represents a solution that has been encoded for execution.
|
||||
///
|
||||
/// # Fields
|
||||
/// * `swaps`: Encoded swaps to be executed.
|
||||
/// * `selector`: The selector of the function to be called.
|
||||
/// * `n_tokens`: Number of tokens in the swap.
|
||||
/// * `permit`: Optional permit for the swap (if permit2 is enabled).
|
||||
/// * `signature`: Optional signature for the swap (if permit2 is enabled).
|
||||
pub struct EncodedSolution {
|
||||
pub swaps: Vec<u8>,
|
||||
pub selector: String,
|
||||
pub n_tokens: usize,
|
||||
pub permit: Option<PermitSingle>,
|
||||
pub signature: Option<Signature>,
|
||||
}
|
||||
|
||||
/// Represents necessary attributes for encoding an order.
|
||||
///
|
||||
/// # Fields
|
||||
|
||||
Reference in New Issue
Block a user