3.2 KiB
Bridge Engine Specification
Overview
This document specifies the bridge engine that provides cross-chain asset transfers using CCIP and third-party bridge providers.
Provider Abstraction
Bridge Providers
CCIP: Chainlink CCIP (primary for supported chains) Third-Party:
- Stargate
- Hop Protocol
- Across Protocol
- Others as needed
Provider Interface
interface BridgeProvider {
getName(): string;
getSupportedChains(): number[];
getQuote(request: BridgeQuoteRequest): Promise<BridgeQuote>;
executeBridge(request: BridgeRequest): Promise<Transaction>;
getStatus(txHash: string): Promise<BridgeStatus>;
}
Quote Comparison
Quote Structure
{
"provider": "CCIP",
"from_chain": 138,
"to_chain": 1,
"from_token": "0x...",
"to_token": "0x...",
"amount_in": "1000000000000000000",
"amount_out": "990000000000000000",
"fee": "10000000000000000",
"estimated_time": 300, // seconds
"trust_score": 0.95,
"route": {
"steps": [...]
}
}
Comparison Factors
1. Fees: Lower is better 2. ETA: Faster is better 3. Trust Score: Higher is better (security, audits, track record) 4. Liquidity: Sufficient liquidity available 5. Supported Amounts: Amount within limits
Trust Scores
Factors:
- Security audits
- Total value locked (TVL)
- Incident history
- Team reputation
- Code maturity
CCIP Routing Integration
CCIP as Primary
When to Use: Chains supported by CCIP Benefits: Secure, audited, Chainlink-backed
CCIP Quote Flow
- Check CCIP router for quote
- Calculate fees (message fee + token fee)
- Estimate execution time
- Return quote
CCIP Execution
- Approve token spending (if needed)
- Call CCIP router send function
- Monitor source transaction
- Track CCIP message
- Monitor destination execution
Failover Routing
Strategy
Priority Order:
- CCIP (if available and competitive)
- Trusted third-party bridges
- Alternative routes
Failover Triggers
- CCIP unavailable
- CCIP quote significantly worse
- User preference
- Amount limits exceeded
Proof and Receipt Tracking
Tracking Flow
- Store source transaction hash
- Monitor CCIP message status
- Link to destination transaction
- Track execution status
- Provide end-to-end visibility
Status Updates
States:
pending: Source transaction pendingsent: Message sent to CCIPdelivered: Message deliveredexecuting: Executing on destinationcompleted: Bridge completedfailed: Bridge failed
API Endpoints
Get Bridge Quote
GET /api/v1/bridge/quote
Parameters:
from_chain: Source chain IDto_chain: Destination chain IDfrom_token: Source token addressto_token: Destination token addressamount: Amount to bridge
Response: Best quote from all providers
Execute Bridge
POST /api/v1/bridge/execute
Body: Bridge request parameters Response: Source transaction hash
Get Bridge Status
GET /api/v1/bridge/status/{tx_hash}
Response: Bridge status with source and destination transaction details
References
- CCIP Tracking: See
../ccip/ccip-tracking.md - Wallet Connectivity: See
wallet-connectivity.md