Skip to main content

Crate fynd_client

Crate fynd_client 

Source
Expand description

Rust client for the Fynd DEX router.

fynd-client lets you request swap quotes, build signable transaction payloads, and broadcast signed orders through the Fynd RPC API — all from a single typed interface.

For guides, API reference, and setup instructions see https://docs.fynd.xyz/.

§Workflow

A complete swap runs in three steps: quote → approve → sign and execute. See examples/swap_erc20.rs for a full walkthrough, or follow the quickstart to run a local Fynd instance.

§Constructing a client

Use FyndClientBuilder to configure and build a FyndClient:

let client = FyndClientBuilder::new(
    "http://localhost:3000",
    "https://reth-ethereum.ithaca.xyz/rpc",
)
.build()
.await?;

For quote-only use (no on-chain transactions), skip the RPC connection with FyndClientBuilder::build_quote_only:

let client = FyndClientBuilder::new("http://localhost:3000", "http://localhost:3000")
    .build_quote_only()?;

§Requesting a quote

// WETH → USDC on mainnet (Vitalik's address as sender).
let weth: Bytes = address!("C02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2").to_vec().into();
let usdc: Bytes = address!("A0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48").to_vec().into();
let sender: Bytes = address!("d8dA6BF26964aF9D7eEd9e03E53415D37aA96045").to_vec().into();

let quote = client
    .quote(QuoteParams::new(
        Order::new(
            weth,
            usdc,
            BigUint::from(1_000_000_000_000_000_000u64), // 1 WETH (18 decimals)
            OrderSide::Sell,
            sender,
            None,
        ),
        QuoteOptions::default(),
    ))
    .await?;

println!("amount out: {}", quote.amount_out());

Structs§

ApprovalParams
Parameters for FyndClient::approval.
ApprovalPayload
An unsigned EIP-1559 approve(spender, amount) transaction.
BlockInfo
Ethereum block at which a quote was computed.
ClientFeeParams
Client fee configuration for the Tycho Router.
EncodingOptions
Options that instruct the server to return ABI-encoded calldata in the quote response.
ExecutionOptions
Options controlling the behaviour of FyndClient::execute_swap.
FeeBreakdown
Breakdown of fees applied to the swap output by the on-chain FeeCalculator.
FyndClient
The main entry point for interacting with the Fynd DEX router.
FyndClientBuilder
Builder for FyndClient.
FyndPayload
A ready-to-sign EIP-1559 transaction produced by the Fynd execution path.
HealthStatus
Health information from the Fynd RPC server’s /v1/health endpoint.
InstanceInfo
Static metadata about this Fynd instance, returned by GET /v1/info.
MinedTx
The result of a successfully mined transaction (non-swap).
Order
A single swap intent submitted to the Fynd solver.
PermitDetails
Per-token details for a Permit2 single-token authorization.
PermitSingle
A single Permit2 authorization, covering one token for one spender.
Quote
The solver’s response for a single order.
QuoteOptions
Optional parameters that tune solving behaviour for a QuoteParams request.
QuoteParams
All inputs needed to call FyndClient::quote.
RetryConfig
Controls how FyndClient::quote retries transient failures.
Route
An ordered sequence of swaps that together execute a complete token swap.
SettledOrder
The result of a successfully mined or simulated swap transaction.
SignedApproval
An ApprovalPayload paired with its cryptographic signature.
SignedSwap
A SwapPayload paired with its cryptographic signature.
SigningHints
Optional hints to override auto-resolved transaction parameters.
StorageOverrides
Per-account EVM storage slot overrides for dry-run simulations.
Swap
A single atomic swap on one liquidity pool within a Route.
Transaction
An encoded EVM transaction returned by the server when EncodingOptions was set.

Enums§

AllowanceCheck
Controls whether FyndClient::approval checks the current on-chain allowance before building an approval transaction.
BackendKind
Which backend solver produced a given order quote.
ErrorCode
A structured error code returned by the Fynd RPC API.
ExecutionReceipt
A future that resolves once the swap transaction is mined and settled.
FyndError
Errors that can be returned by FyndClient methods.
OrderSide
The direction of a swap order.
QuoteStatus
High-level status of a single-order quote returned by the solver.
SwapPayload
A payload that needs to be signed before a swap can be executed.
TxReceipt
A future that resolves once a submitted transaction is mined.
UserTransferType
Token transfer method used when building an on-chain swap transaction.