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
impl ClientFeeParams
Sourcepub fn new(
bps: u16,
receiver: Bytes,
max_contribution: BigUint,
deadline: u64,
) -> Self
pub fn new( bps: u16, receiver: Bytes, max_contribution: BigUint, deadline: u64, ) -> Self
Create client fee params.
Sourcepub fn zero(receiver: Bytes, deadline: u64) -> Self
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.
Sourcepub 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>
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 — useQuote::amount_out.min_amount_out: minimum output after fees — useFeeBreakdown::min_amount_received.receiver: 20-byte address receiving the swap output.swaps_hash: keccak256 of the encoded swaps bytes — useFeeBreakdown::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
impl Clone for ClientFeeParams
Auto Trait Implementations§
impl !Freeze for ClientFeeParams
impl RefUnwindSafe for ClientFeeParams
impl Send for ClientFeeParams
impl Sync for ClientFeeParams
impl Unpin for ClientFeeParams
impl UnsafeUnpin for ClientFeeParams
impl UnwindSafe for ClientFeeParams
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
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> ⓘ
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