Skip to main content

getFlowQuote

Fetches a conversion quote for a flow. The quote includes the amounts, fees, estimated time, and an expiry. Call this after attaching a source.

Usage

import { getFlowQuote } from '@dynamic-labs-sdk/client';

const flow = await getFlowQuote({
  flowId: 'your-flow-id',
  fromTokenAddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
});

console.log('Send:', flow.quote.fromAmount);
console.log('Receive:', flow.quote.toAmount);
console.log('Fees:', flow.quote.fees?.totalFeeUsd);

Parameters

ParameterTypeDescription
flowIdstringThe flow ID.
fromTokenAddressstring (optional)Token contract address (EVM) or mint (Solana) the sender is paying with. Defaults to the native token for the chain set during source attachment. Use 0x0000000000000000000000000000000000000000 for native ETH, or 11111111111111111111111111111111 for native SOL.
fromChainIdstring (optional)Override the chain ID recorded at source attachment. The chain family (fromChainName) is locked at attachment — to switch families, call attachFlowSource again.
slippagenumber (optional)Slippage tolerance as a decimal (e.g., 0.005 for 0.5%).

Returns

Promise<Flow> — the updated flow with quote populated:
type FlowQuote = {
  version: number;
  fromAmount: string;
  toAmount: string;
  estimatedTimeSec?: number;
  fees?: {
    totalFeeUsd?: string;
    gasEstimate?: {
      usdValue: string;
      nativeValue: string;
      nativeSymbol: string;
    };
  };
  createdAt: string;
  expiresAt: string;
};
Quotes expire in 60 seconds. If the quote expires before you submit, call getFlowQuote again.

Examples

Quote with a specific ERC-20 token

import { getFlowQuote } from '@dynamic-labs-sdk/client';

const flow = await getFlowQuote({
  flowId: 'your-flow-id',
  fromTokenAddress: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', // USDC on Base
});

Quote with native ETH

import { getFlowQuote } from '@dynamic-labs-sdk/client';

const flow = await getFlowQuote({
  flowId: 'your-flow-id',
  fromTokenAddress: '0x0000000000000000000000000000000000000000',
});

Quote with slippage tolerance

import { getFlowQuote } from '@dynamic-labs-sdk/client';

const flow = await getFlowQuote({
  flowId: 'your-flow-id',
  fromTokenAddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
  slippage: 0.005,
});