Skip to main content

ClientFeeParams

Struct ClientFeeParams 

Source
pub struct ClientFeeParams { /* private fields */ }
Expand description

Client fee configuration for the Tycho Router.

When attached to EncodingOptions via EncodingOptions::with_client_fee, the router charges a client fee on the swap output.

Send these params unsigned. The signature covers the quoted swap, so it can only be produced after the quote comes back — compute the hash with ClientFeeParams::eip712_signing_hash and patch the result into the calldata with Quote::with_client_fee_signature.

Implementations§

Source§

impl ClientFeeParams

Source

pub fn new( bps: u16, receiver: Bytes, max_contribution: BigUint, deadline: u64, ) -> Self

Create client fee params.

Source

pub fn zero(receiver: Bytes, deadline: u64) -> Self

Create zero-fee client fee params that identify receiver as the fee client without charging anything.

The router resolves one fee client per swap from clientFeeReceiver; without client fee params that is the transaction sender. Zero-fee params attach receiver to the swap, so the router fee rates configured for that address apply, while fee_breakdown.client_fee stays 0 and no funds move to receiver. The receiver key must still sign every swap with ClientFeeParams::eip712_signing_hash, and the params expire at deadline.

Source

pub fn eip712_signing_hash( &self, chain_id: u64, router_address: &Bytes, amount_in: &BigUint, token_in: &Bytes, token_out: &Bytes, expected_amount_out: &BigUint, min_amount_out: &BigUint, receiver: &Bytes, swaps_hash: &[u8; 32], ) -> Result<[u8; 32], FyndError>

Compute the EIP-712 signing hash for the client fee params.

Pass the returned hash to the fee receiver’s signer, then patch the 65-byte result into the quote’s calldata with Quote::with_client_fee_signature.

The hash covers all 11 ClientFee fields. The swap-specific inputs (amount_in, token_in, token_out, expected_amount_out, min_amount_out, receiver, swaps_hash) come from the quote requested with unsigned params — see FeeBreakdown and the swap_client_fee example for the flow.

  • router_address: 20-byte address of the TychoRouter contract.
  • amount_in: exact input amount from the order.
  • token_in: 20-byte input token address.
  • token_out: 20-byte output token address.
  • expected_amount_out: quoted output amount — use Quote::amount_out.
  • min_amount_out: minimum output after fees — use FeeBreakdown::min_amount_received.
  • receiver: 20-byte address receiving the swap output.
  • swaps_hash: keccak256 of the encoded swaps bytes — use FeeBreakdown::swaps_hash.

The type hash, domain (TychoRouter/1), and field order must match TychoRouterV3.CLIENT_FEE_TYPEHASH. The same shape is encoded via sol! in fynd-core/src/encoding/disable_slippage_taking.rs for server-side signing; keep both in sync if the contract type changes.

Trait Implementations§

Source§

impl Clone for ClientFeeParams

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ClientFeeParams

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more