Skip to main content

FyndClient

Struct FyndClient 

Source
pub struct FyndClient<P = RootProvider<Ethereum>>
where P: Provider<Ethereum> + Clone + Send + Sync + 'static,
{ /* private fields */ }
Expand description

The main entry point for interacting with the Fynd DEX router.

Construct via FyndClientBuilder. All methods are async and require a Tokio runtime.

The type parameter P is the alloy provider used for Ethereum RPC calls. In production code this is RootProvider<Ethereum> (the default). In tests a mocked provider can be used.

Implementations§

Source§

impl<P> FyndClient<P>
where P: Provider<Ethereum> + Clone + Send + Sync + 'static,

Source

pub async fn quote(&self, params: QuoteParams) -> Result<Quote, FyndError>

Request a quote for one or more swap orders.

The returned Quote has token_out and receiver populated on each OrderQuote from the corresponding input Order (matched by index).

Retries automatically on transient failures according to the client’s RetryConfig.

Source

pub async fn health(&self) -> Result<HealthStatus, FyndError>

Get the health status of the Fynd RPC server.

Source

pub async fn swap_payload( &self, quote: Quote, hints: &SigningHints, ) -> Result<SwapPayload, FyndError>

Build a swap payload for a given order quote, ready for signing.

For BackendKind::Fynd quotes, this resolves the sender nonce and EIP-1559 fee parameters from the RPC node (unless overridden via hints), then constructs an unsigned EIP-1559 transaction targeting the RouterV3 contract.

BackendKind::Turbine is not yet implemented and returns FyndError::Protocol.

token_out and receiver are read directly from the quote (populated during quote()). Pass &SigningHints::default() to auto-resolve all transaction parameters.

Source

pub async fn execute_swap( &self, order: SignedSwap, options: &ExecutionOptions, ) -> Result<ExecutionReceipt, FyndError>

Broadcast a signed swap and return an ExecutionReceipt that resolves once the transaction is mined.

Pass ExecutionOptions::default for standard on-chain submission. Set ExecutionOptions::dry_run to true to simulate only — the receipt resolves immediately with values derived from eth_call (settled amount) and eth_estimateGas (gas cost).

For real submissions, this method returns immediately after broadcasting. The inner future polls every 2 seconds and has no built-in timeout; wrap with tokio::time::timeout to bound the wait.

Source

pub async fn info(&self) -> Result<&InstanceInfo, FyndError>

Fetch and cache static instance metadata from GET /v1/info.

The result is fetched at most once per FyndClient instance; subsequent calls return the cached value without making a network request.

Source

pub async fn approval( &self, params: &ApprovalParams, hints: &SigningHints, ) -> Result<Option<ApprovalPayload>, FyndError>

Build an unsigned EIP-1559 approve(spender, amount) transaction for the given token, or None if the allowance is already sufficient.

  1. Calls info() to resolve the spender address from params.spender.
  2. If params.check_allowance is true, checks the current ERC-20 allowance and returns None immediately if it is already sufficient (skipping nonce and fee resolution).
  3. Resolves nonce and EIP-1559 fees via hints (same semantics as swap_payload).
  4. Encodes the approve(spender, amount) calldata using the ERC-20 ABI.

Gas defaults to hints.gas_limit().unwrap_or(65_000).

Source

pub async fn execute_approval( &self, approval: SignedApproval, ) -> Result<TxReceipt, FyndError>

Broadcast a signed approval transaction and return a TxReceipt that resolves once the transaction is mined.

This method returns immediately after broadcasting. The inner future polls every 2 seconds and has no built-in timeout; wrap with tokio::time::timeout to bound the wait.

Auto Trait Implementations§

§

impl<P = RootProvider> !Freeze for FyndClient<P>

§

impl<P = RootProvider> !RefUnwindSafe for FyndClient<P>

§

impl<P> Send for FyndClient<P>

§

impl<P> Sync for FyndClient<P>

§

impl<P> Unpin for FyndClient<P>
where P: Unpin,

§

impl<P> UnsafeUnpin for FyndClient<P>
where P: UnsafeUnpin,

§

impl<P = RootProvider> !UnwindSafe for FyndClient<P>

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<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: 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: 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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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