Skip to main content

Overview

The Bridging SDK enables cross-chain token swaps by combining CoW Protocol swaps with bridge providers like Across and Bungee. It automatically routes trades through optimal paths and manages the bridging process.

Installation

BridgingSdk

Main SDK class for bridging tokens between different chains.

Constructor

BridgingSdkOptions
required
Configuration options for the SDK
BridgeProvider[]
required
Array of bridge providers (e.g., AcrossBridgeProvider, BungeeBridgeProvider)
TradingSdk
Optional TradingSdk instance. Creates a new one if not provided.
OrderBookApi
Optional OrderBookApi instance
boolean
Enable debug logging
BridgingSdkCacheConfig
Cache configuration settings
boolean
default:"true"
Enable caching for networks and tokens
number
default:"300000"
TTL in milliseconds for intermediate tokens cache (default: 5 minutes)
number
default:"120000"
TTL in milliseconds for buy tokens cache (default: 2 minutes)
AbstractProviderAdapter
Optional provider adapter (ethers v5, ethers v6, or viem)

getQuote()

Get a cross-chain quote with a callback to post the order.
QuoteBridgeRequest
required
Quote parameters
OrderKind
required
Order type: OrderKind.SELL or OrderKind.BUY
bigint
required
Amount to sell or buy (in token atoms)
SupportedChainId
required
Source chain ID
string
required
Sell token contract address
number
required
Sell token decimals
TargetChainId
required
Destination chain ID
string
required
Buy token contract address
number
required
Buy token decimals
SignerLike
required
Wallet signer
string
Order owner address (defaults to signer address)
number
Slippage tolerance for the swap in basis points
number
Slippage tolerance for the bridge in basis points
SwapAdvancedSettings
Optional advanced settings for the swap
CrossChainQuoteAndPost
Returns either QuoteAndPost for same-chain swaps or BridgeQuoteAndPost for cross-chain swaps
QuoteResults
CoW Protocol swap quote details
BridgeQuoteResults
Bridge quote details (only for cross-chain swaps)
BridgeQuoteAmountsAndCosts
Bridging amounts and costs breakdown
object
Bridge fees
bigint
Relayer capital cost fee (in token atoms)
bigint
Destination gas fee (in token atoms)
number
Estimated time to complete the bridge
function
Callback function to post the order on-chain

getMultiQuotes()

Get quotes from multiple bridge providers in parallel with progressive results.
MultiQuoteRequest
required
Multi-quote request parameters
QuoteBridgeRequest
required
Base quote parameters
string[]
Optional array of provider IDs to query. If not provided, queries all available providers.
MultiQuoteOptions
Optional behavior configuration
function
Callback invoked as soon as each provider returns a result
number
default:"40000"
Maximum time to wait for all providers (milliseconds)
number
default:"20000"
Maximum time to wait for each provider (milliseconds)
MultiQuoteResult[]
Array of results from each provider
string
Provider identifier
BridgeQuoteAndPost | null
Quote result, or null if the provider failed
Error
Error if the provider failed

getBestQuote()

Get the best quote from multiple providers based on buyAmount after slippage.
MultiQuoteRequest
required
Same parameters as getMultiQuotes()
MultiQuoteResult | null
The best quote result found, or null if no successful quotes

getSourceNetworks()

Get available source networks for bridging.
ChainInfo[]
Array of supported source chain information

getTargetNetworks()

Get available target networks for bridging.
ChainInfo[]
Array of supported destination chains across all providers

getBuyTokens()

Get available buy tokens for a specific target chain.
BuyTokensParams
required
Token query parameters
TargetChainId
required
Destination chain ID
SupportedChainId
Source chain ID (for filtering)
string
Sell token address (for filtering)
GetProviderBuyTokens
TokenInfo[]
Array of available buy tokens
boolean
Whether any route is available

getOrder()

Get details about a cross-chain order.
GetOrderParams
required
SupportedChainId
required
Chain where order was settled
string
required
Order unique identifier
CowEnv
Environment (‘prod’ or ‘staging’)
CrossChainOrder | null
Order details including bridge status, or null if not found

Cache Management

The SDK provides methods to manage the internal cache.

Bridge Providers

AcrossBridgeProvider

Bridge provider using the Across Protocol.

BungeeBridgeProvider

Bridge provider using Bungee (Socket).

NearIntentsBridgeProvider

Bridge provider for NEAR Protocol intents.

Types

QuoteBridgeRequest

Parameters for requesting a bridge quote.

BridgeQuoteResult

Result of a bridge quote request.

BridgeQuoteAndPost

Combined quote result for cross-chain swaps.

Examples

Basic Cross-Chain Swap

Compare Multiple Providers

Get Available Tokens