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.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
config
|
AcrossConfig | None
|
Optional configuration. Uses defaults if not provided. |
None
|
token_resolver
|
TokenResolver | None
|
Optional TokenResolver instance. If None, uses singleton. |
None
|
supported_routes
property
¶
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.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
token
|
str
|
Token symbol (e.g., "USDC", "ETH", "WBTC") |
必需 |
amount
|
Decimal
|
Amount to bridge in token units |
必需 |
from_chain
|
str
|
Source chain (e.g., "arbitrum", "optimism") |
必需 |
to_chain
|
str
|
Destination chain |
必需 |
max_slippage
|
Decimal
|
Maximum slippage tolerance (default 0.5%) |
Decimal('0.005')
|
返回:
| 类型 | 描述 |
|---|---|
BridgeQuote
|
BridgeQuote with fee, timing, and route information |
引发:
| 类型 | 描述 |
|---|---|
AcrossQuoteError
|
If quote cannot be retrieved |
build_deposit_tx
¶
Build the deposit transaction for an Across bridge transfer.
Creates the transaction data to call depositV3() on the SpokePool contract.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
quote
|
BridgeQuote
|
BridgeQuote from get_quote() |
必需 |
recipient
|
str
|
Address to receive tokens on destination chain |
必需 |
返回:
| 类型 | 描述 |
|---|---|
dict[str, Any]
|
Transaction data dict with 'to', 'value', 'data' fields |
引发:
| 类型 | 描述 |
|---|---|
AcrossTransactionError
|
If transaction cannot be built |
check_status
¶
Check the status of an Across bridge transfer.
Polls the Across API to check if a deposit has been filled on the destination chain.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
bridge_deposit_id
|
str
|
Source chain deposit transaction hash |
必需 |
返回:
| 类型 | 描述 |
|---|---|
BridgeStatus
|
BridgeStatus with current transfer status |
引发:
| 类型 | 描述 |
|---|---|
AcrossStatusError
|
If status cannot be retrieved |
estimate_completion_time
¶
Estimate completion time for a route.
Returns typical completion time based on historical data and relayer network activity.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
from_chain
|
str
|
Source chain identifier |
必需 |
to_chain
|
str
|
Destination chain identifier |
必需 |
返回:
| 类型 | 描述 |
|---|---|
int
|
Estimated completion time in seconds |
引发:
| 类型 | 描述 |
|---|---|
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.
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
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 |
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
¶
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.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
**kwargs
|
Any
|
Keyword arguments passed by the receipt_registry. chain: Source chain name (for token-decimal resolution). |
{}
|
parse_receipt
¶
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.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
receipt
|
dict[str, Any]
|
Source-chain transaction receipt (dict form). |
必需 |
from_chain
|
str | None
|
Source chain name, forwarded by the enricher from
|
None
|
to_chain
|
str | None
|
Destination chain name (from |
None
|
token
|
str | None
|
Token symbol (from |
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
|
返回:
| 类型 | 描述 |
|---|---|
BridgeData | None
|
|
BridgeData | None
|
|
BridgeData | None
|
(benign — the enricher maps this to |