Skip to main content

Overview

The AcrossFacet enables cross-chain token transfers using the Across Protocol. Across is a cross-chain bridge optimized for capital efficiency and fast transfers.

Contract Interface

Functions

startBridgeTokensViaAcross

Bridges tokens to another chain using Across Protocol.
function startBridgeTokensViaAcross(
  BridgeData _bridgeData,
  AcrossData _acrossData
) external payable
_bridgeData
BridgeData
Standard bridge data containing transaction details
_acrossData
AcrossData
Across-specific bridging parameters

swapAndStartBridgeTokensViaAcross

Performs a token swap on the source chain before bridging via Across.
function swapAndStartBridgeTokensViaAcross(
  BridgeData _bridgeData,
  SwapData[] _swapData,
  AcrossData _acrossData
) external payable
_bridgeData
BridgeData
Standard bridge data
_swapData
SwapData[]
Array of swap operations to execute before bridging
_acrossData
AcrossData
Across-specific parameters

Data Structures

AcrossData

struct AcrossData {
  int64 relayerFeePct;    // Relayer fee as percentage
  uint32 quoteTimestamp;  // Quote timestamp
  bytes message;          // Optional message
  uint256 maxCount;       // Maximum relay count
}

Usage Example

import { AcrossFacet } from '@lifi/contract-types';

const acrossFacet = AcrossFacet__factory.connect(facetAddress, signer);

const bridgeData = {
  transactionId: '0x...',
  bridge: 'across',
  integrator: 'my-dapp',
  referrer: '0x0000000000000000000000000000000000000000',
  sendingAssetId: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // USDC
  receiver: '0x...',
  minAmount: ethers.utils.parseUnits('100', 6),
  destinationChainId: 10, // Optimism
  hasSourceSwaps: false,
  hasDestinationCall: false
};

const acrossData = {
  relayerFeePct: ethers.BigNumber.from('5000'), // 0.5%
  quoteTimestamp: Math.floor(Date.now() / 1000),
  message: '0x',
  maxCount: ethers.BigNumber.from('1')
};

const tx = await acrossFacet.startBridgeTokensViaAcross(
  bridgeData,
  acrossData,
  { value: 0 }
);

await tx.wait();

Events

The facet emits standard LiFi events:
  • LiFiTransferStarted(BridgeData bridgeData)
  • LiFiTransferCompleted
  • AssetSwapped (when using swapAndStart variant)

See Also

Build docs developers (and LLMs) love