pub struct TychoRouterEncoder { /* private fields */ }Expand description
Encodes solutions to be used by the TychoRouter.
§Fields
chain: Chain to be usedsingle_swap_strategy: Encoder for single swapssequential_swap_strategy: Encoder for sequential swapssplit_swap_strategy: Encoder for split swapsrouter_address: Address of the Tycho router contractuser_transfer_type: Type of user transferpermit2: Optional Permit2 instance for permit transferssigner: Optional signer (used only for permit2 and full calldata encoding)
Implementations§
Source§impl TychoRouterEncoder
impl TychoRouterEncoder
pub fn new( chain: Chain, swap_encoder_registry: SwapEncoderRegistry, router_address: Bytes, user_transfer_type: UserTransferType, signer: Option<PrivateKeySigner>, historical_trade: bool, ) -> Result<Self, EncodingError>
Trait Implementations§
Source§impl Clone for TychoRouterEncoder
impl Clone for TychoRouterEncoder
Source§fn clone(&self) -> TychoRouterEncoder
fn clone(&self) -> TychoRouterEncoder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl TychoEncoder for TychoRouterEncoder
impl TychoEncoder for TychoRouterEncoder
Source§fn validate_solution(&self, solution: &Solution) -> Result<(), EncodingError>
fn validate_solution(&self, solution: &Solution) -> Result<(), EncodingError>
Raises an EncodingError if the solution is not considered valid.
A solution is considered valid if all the following conditions are met:
- The solution is not exact out.
- The solution has at least one swap.
- If the solution is wrapping, the given token is the chain’s native token and the first swap’s input is the chain’s wrapped token.
- If the solution is unwrapping, the checked token is the chain’s native token and the last swap’s output is the chain’s wrapped token.
- The token cannot appear more than once in the solution unless it is the first and last token (i.e. a true cyclical swap).
Source§fn encode_solutions(
&self,
solutions: Vec<Solution>,
) -> Result<Vec<EncodedSolution>, EncodingError>
fn encode_solutions( &self, solutions: Vec<Solution>, ) -> Result<Vec<EncodedSolution>, EncodingError>
Encodes a list of
Solutions into EncodedSolutions, which include the function
signature and internal swap call data. Read moreSource§fn encode_full_calldata(
&self,
solutions: Vec<Solution>,
) -> Result<Vec<Transaction>, EncodingError>
fn encode_full_calldata( &self, solutions: Vec<Solution>, ) -> Result<Vec<Transaction>, EncodingError>
👎Deprecated: Please use
encode_solutions insteadAuto Trait Implementations§
impl !Freeze for TychoRouterEncoder
impl !RefUnwindSafe for TychoRouterEncoder
impl Send for TychoRouterEncoder
impl Sync for TychoRouterEncoder
impl Unpin for TychoRouterEncoder
impl !UnwindSafe for TychoRouterEncoder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more