Quote
The quote endpoint returns a projected conversion result for a given source token, destination token, and amount. Use it to show fee breakdowns and expected output to users before they initiate a deposit or withdrawal.
Endpoint
Section titled “Endpoint”POST https://bridge.openfish.fun/quoteRequest Body
Section titled “Request Body”| Field | Type | Required | Description |
|---|---|---|---|
from_chain_id | string | Yes | Source chain ID (e.g., "1" for Ethereum) |
from_token_address | string | Yes | Token contract address on the source chain |
to_token_address | string | Yes | Token contract address on the destination chain |
from_amount_base_unit | string | Yes | Amount to convert in base units (e.g., "10000000" for 10 USDC) |
Example Request
Section titled “Example Request”curl -X POST https://bridge.openfish.fun/quote \ -H "Content-Type: application/json" \ -d '{ "from_chain_id": "1", "from_token_address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", "to_token_address": "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174", "from_amount_base_unit": "10000000" }'Response
Section titled “Response”{ "estimated_output": "9985000", "estimated_output_usd": 9.985, "gas_cost_usd": 0.012, "bridge_fee_usd": 0.003, "slippage_percent": 0.05, "route": "1inch", "expires_at": 1700000000}Response Fields
Section titled “Response Fields”| Field | Type | Description |
|---|---|---|
estimated_output | string | Expected output amount in destination base units |
estimated_output_usd | number | Estimated output value in USD |
gas_cost_usd | number | Estimated gas fee in USD |
bridge_fee_usd | number | Bridge routing fee in USD |
slippage_percent | number | Estimated price slippage as a percentage |
route | string | Aggregator used for the swap route |
expires_at | number | Unix timestamp when the quote expires |
Rust SDK Example
Section titled “Rust SDK Example”use openfish_client_sdk::BridgeClient;
#[tokio::main]async fn main() -> anyhow::Result<()> { let bridge = BridgeClient::new("https://bridge.openfish.fun");
let quote = bridge .quote( "1", // Ethereum "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC on Ethereum "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174", // USDC.e on Polygon "10000000", // 10 USDC ) .await?;
println!("Estimated output: {} base units", quote.estimated_output); println!("Gas cost: ${:.4}", quote.gas_cost_usd); println!("Slippage: {:.2}%", quote.slippage_percent);
Ok(())}How It Works
Section titled “How It Works”Openfish routes quote calculations through the 1inch aggregator API, finding the best swap path between source and destination tokens. The returned estimate factors in:
- Gas costs on both the source and destination chains.
- Bridge fees imposed by the underlying cross-chain relay.
- Swap slippage determined by current DEX pool depth.
Quotes are informational projections. The actual output may shift slightly due to price movement between quote time and execution.
When to Use Quotes
Section titled “When to Use Quotes”- Before a deposit, to preview the USDC.e amount that will be credited.
- Before a withdrawal, to show the expected destination token amount.
- To compare costs across different source tokens or source chains.
Quote Expiry
Section titled “Quote Expiry”Every quote carries an expires_at timestamp. Once expired, the estimate is stale and should be refreshed. Quotes are typically valid for 30 seconds.
Next Steps
Section titled “Next Steps”- Deposit — Execute a deposit after reviewing the quote.
- Withdraw — Execute a withdrawal after reviewing the quote.
- Supported Assets — Check which tokens and chains are available.