Saltar a contenido

Across

Connector for Across, a cross-chain bridge using optimistic verification.

almanak.framework.connectors.across

Across Bridge Adapter.

Across is a fast, secure, and capital-efficient cross-chain bridge that uses an optimistic verification model with UMA's oracle for dispute resolution.

Features: - Fast finality (~1-4 minutes for most routes) - Low fees using relayer competition - Supports ETH, USDC, WBTC and other major tokens - Available on Ethereum, Arbitrum, Optimism, Base, Polygon, and more

Example

from almanak.framework.connectors.across import AcrossBridgeAdapter, AcrossConfig

config = AcrossConfig(timeout_seconds=1800) # 30 min timeout adapter = AcrossBridgeAdapter(config)

Get a quote

quote = adapter.get_quote( token="USDC", amount=Decimal("1000"), from_chain="arbitrum", to_chain="optimism", )

Build deposit transaction

tx = adapter.build_deposit_tx(quote, recipient="0x...")

AcrossBridgeAdapter

AcrossBridgeAdapter(
    config: AcrossConfig | None = None,
    token_resolver: TokenResolver | None = None,
)

Bases: BridgeAdapter

Across Protocol bridge adapter implementation.

Provides integration with the Across bridge for fast cross-chain transfers using relayers and optimistic verification.

Features: - Fast finality via relayer network - Competitive fees through relayer competition - Support for ETH, USDC, WBTC and other major tokens - Multi-chain support (Ethereum, Arbitrum, Optimism, Base, Polygon)

Example

adapter = AcrossBridgeAdapter()

Get quote

quote = adapter.get_quote( token="USDC", amount=Decimal("1000"), from_chain="arbitrum", to_chain="optimism", )

Build transaction

tx = adapter.build_deposit_tx(quote, "0xRecipient...")

Check status after deposit

status = adapter.check_status(deposit_tx_hash)

Initialize Across bridge adapter.

Parameters:

Name Type Description Default
config AcrossConfig | None

Optional configuration. Uses defaults if not provided.

None
token_resolver TokenResolver | None

Optional TokenResolver instance. If None, uses singleton.

None

name property

name: str

Get bridge adapter name.

supported_tokens property

supported_tokens: list[str]

Get list of supported tokens.

supported_routes property

supported_routes: list[BridgeRoute]

Get list of supported bridge routes.

get_quote

get_quote(
    token: str,
    amount: Decimal,
    from_chain: str,
    to_chain: str,
    max_slippage: Decimal = Decimal("0.005"),
) -> BridgeQuote

Get a quote for bridging tokens via Across.

Calls the Across API to get current fee and time estimates for the specified transfer.

Parameters:

Name Type Description Default
token str

Token symbol (e.g., "USDC", "ETH", "WBTC")

required
amount Decimal

Amount to bridge in token units

required
from_chain str

Source chain (e.g., "arbitrum", "optimism")

required
to_chain str

Destination chain

required
max_slippage Decimal

Maximum slippage tolerance (default 0.5%)

Decimal('0.005')

Returns:

Type Description
BridgeQuote

BridgeQuote with fee, timing, and route information

Raises:

Type Description
AcrossQuoteError

If quote cannot be retrieved

build_deposit_tx

build_deposit_tx(
    quote: BridgeQuote, recipient: str
) -> dict[str, Any]

Build the deposit transaction for an Across bridge transfer.

Creates the transaction data to call depositV3() on the SpokePool contract.

Parameters:

Name Type Description Default
quote BridgeQuote

BridgeQuote from get_quote()

required
recipient str

Address to receive tokens on destination chain

required

Returns:

Type Description
dict[str, Any]

Transaction data dict with 'to', 'value', 'data' fields

Raises:

Type Description
AcrossTransactionError

If transaction cannot be built

check_status

check_status(bridge_deposit_id: str) -> BridgeStatus

Check the status of an Across bridge transfer.

Polls the Across API to check if a deposit has been filled on the destination chain.

Parameters:

Name Type Description Default
bridge_deposit_id str

Source chain deposit transaction hash

required

Returns:

Type Description
BridgeStatus

BridgeStatus with current transfer status

Raises:

Type Description
AcrossStatusError

If status cannot be retrieved

estimate_completion_time

estimate_completion_time(
    from_chain: str, to_chain: str
) -> int

Estimate completion time for a route.

Returns typical completion time based on historical data and relayer network activity.

Parameters:

Name Type Description Default
from_chain str

Source chain identifier

required
to_chain str

Destination chain identifier

required

Returns:

Type Description
int

Estimated completion time in seconds

Raises:

Type Description
AcrossError

If route is not supported

AcrossConfig dataclass

AcrossConfig(
    api_base_url: str = "https://app.across.to/api",
    timeout_seconds: int = DEFAULT_TIMEOUT_SECONDS,
    request_timeout: int = 30,
    max_retries: int = 3,
)

Configuration for Across bridge adapter.

Attributes:

Name Type Description
api_base_url str

Across API base URL

timeout_seconds int

Timeout for bridge operations (default 30 min)

request_timeout int

HTTP request timeout in seconds

max_retries int

Maximum number of retry attempts for API calls

__post_init__

__post_init__() -> None

Validate configuration.

AcrossError

Bases: BridgeError

Base exception for Across-related errors.

AcrossQuoteError

Bases: AcrossError, BridgeQuoteError

Error when retrieving an Across quote.

AcrossStatusError

Bases: AcrossError, BridgeStatusError

Error when checking Across transfer status.

AcrossTransactionError

Bases: AcrossError, BridgeTransactionError

Error when building or submitting an Across transaction.

AcrossReceiptParser

AcrossReceiptParser(**kwargs: Any)

Receipt parser for Across V3 bridge deposits.

Implements the ResultEnricher extraction contract by exposing extract_bridge_data(receipt, **hints) -> BridgeData | None. The parser declares SUPPORTED_EXTRACTIONS so the enricher skips fields that do not apply to bridges (swap_amounts, position_id, etc.) without emitting spurious warnings.

Initialize AcrossReceiptParser.

Parameters:

Name Type Description Default
**kwargs Any

Keyword arguments passed by the receipt_registry. chain: Source chain name (for token-decimal resolution).

{}

parse_receipt

parse_receipt(receipt: dict[str, Any]) -> dict[str, Any]

Return a minimal parsed view of the receipt.

The framework caches this call during enrichment (see ResultEnricher._install_parse_cache). We keep the shape simple since extract_bridge_data does the real work.

extract_bridge_data

extract_bridge_data(
    receipt: dict[str, Any],
    *,
    from_chain: str | None = None,
    to_chain: str | None = None,
    token: str | None = None,
    amount: str | Decimal | None = None,
    bridge: str | None = None,
    expected_amount_out: str | Decimal | None = None,
) -> BridgeData | None

Extract typed bridge data from an Across deposit receipt.

Parameters:

Name Type Description Default
receipt dict[str, Any]

Source-chain transaction receipt (dict form).

required
from_chain str | None

Source chain name, forwarded by the enricher from ActionBundle.metadata["from_chain"].

None
to_chain str | None

Destination chain name (from metadata["to_chain"]).

None
token str | None

Token symbol (from metadata["token"]). When the parser can compute amount_sent from the on-chain event, it still needs the symbol for BridgeData.token_symbol.

None
amount str | Decimal | None

Human-readable amount from the compiler quote. Used only as a last-resort fallback when neither the deposit event nor a wallet ERC-20 Transfer log are parseable.

None
bridge str | None

Adapter display name (unused — included so the parser tolerates the kwargs the enricher always threads in).

None
expected_amount_out str | Decimal | None

Compiler quote output amount (post-fee, pre-slippage) if available.

None

Returns:

Type Description
BridgeData | None

BridgeData when the source-chain deposit can be decoded,

BridgeData | None

None when the receipt does not describe an Across deposit

BridgeData | None

(benign — the enricher maps this to ExtractMissing).