Skip to content

estimateBridge ​

Quote a bridge/swap before committing — for the swap UI (in-app/public) and send-with-exit-bridge. Uses the broadcaster’s route planner, including its exit-portal carve. The route costs carve + providerFee in fromToken units: nativeFeeWei is already inside carve, and providerFee is what the provider (LiFi, the bridge, the integrator) deducts on the way. toAmount is the expected delivery and toAmountMin the current route's slippage floor. Execution quotes a fresh route, so neither is guaranteed. Amounts are bigint base units. Throws FeeEstimateUnavailableError when the provider's fees could not be priced, and RouteUnavailableError (generic message) when the broadcaster cannot route this transfer. The broadcaster prices one bridge per request; a refused bridge is asked again without it, up to maxBridgeAttempts.

Import ​

ts
import { estimateBridge } from "@0xcurvy/curvy-sdk/actions";

Usage ​

ts
const q = await estimateBridge({
  fromChainId, toChainId, fromToken, toToken,
  fromAmount: amount.toString(), fromAddress: portalAddress,
});
// q.toAmount → expected delivery; q.carve + q.providerFee → route cost in fromToken

Signature ​

ts
function estimateBridge(parameters: EstimateBridgeParameters): Promise<BridgeEstimate>

Returns ​

Promise<BridgeEstimate>

The action resolves or returns the value shown in the signature.

Parameters ​

fromChainId ​

  • Type: number
  • Required: yes

The source chain identifier.

ts
const result = await estimateBridge({
  fromChainId, 
  toChainId,
  fromToken,
  toToken,
  fromAmount,
  fromAddress,
});

toChainId ​

  • Type: number
  • Required: yes

The destination chain identifier.

ts
const result = await estimateBridge({
  fromChainId,
  toChainId, 
  fromToken,
  toToken,
  fromAmount,
  fromAddress,
});

fromToken ​

  • Type: string
  • Required: yes

The source token address.

ts
const result = await estimateBridge({
  fromChainId,
  toChainId,
  fromToken, 
  toToken,
  fromAmount,
  fromAddress,
});

toToken ​

  • Type: string
  • Required: yes

The destination token address.

ts
const result = await estimateBridge({
  fromChainId,
  toChainId,
  fromToken,
  toToken, 
  fromAmount,
  fromAddress,
});

fromAmount ​

  • Type: string
  • Required: yes

Gross input amount, decimal string (base units of fromToken).

ts
const result = await estimateBridge({
  fromChainId,
  toChainId,
  fromToken,
  toToken,
  fromAmount, 
  fromAddress,
});

fromAddress ​

  • Type: string
  • Required: yes

The sender address used for the quote (typically the deterministic portal address).

ts
const result = await estimateBridge({
  fromChainId,
  toChainId,
  fromToken,
  toToken,
  fromAmount,
  fromAddress, 
});

toAddress ​

  • Type: string
  • Required: no

Destination receiver; defaults to fromAddress when omitted.

ts
const result = await estimateBridge({
  fromChainId,
  toChainId,
  fromToken,
  toToken,
  fromAmount,
  fromAddress,
  toAddress, 
});

denyTools ​

  • Type: string[]
  • Required: no

Bridges to exclude, e.g. ones an earlier estimate refused (its 422 details.tool). Sent (even empty), the broadcaster prices one bridge per request and names a refused one; omitted, it tries every candidate.

ts
const result = await estimateBridge({
  fromChainId,
  toChainId,
  fromToken,
  toToken,
  fromAmount,
  fromAddress,
  denyTools, 
});

maxBridgeAttempts ​

  • Type: number
  • Required: no

Bridges to try, one request each, before giving up (default 3).

ts
const result = await estimateBridge({
  fromChainId,
  toChainId,
  fromToken,
  toToken,
  fromAmount,
  fromAddress,
  maxBridgeAttempts, 
});

config ​

  • Type: CurvyConfig
  • Required: no

Curvy config to use. Defaults to the ambient config.

ts
const result = await estimateBridge({
  fromChainId,
  toChainId,
  fromToken,
  toToken,
  fromAmount,
  fromAddress,
  config, 
});

Errors ​

Errors from config resolution and the underlying SDK operation are propagated to the caller.

Source ​

packages/@0xcurvy/sdk/src/actions/bridge/estimateBridge.ts