Cross-Chain Swaps with deBridge
Execute cross-chain swaps using deBridge DLN (Debridge Liquidity Network) on the Tenzro Network. deBridge uses an intent-based model where market makers compete to fill your orders, resulting in fast settlement times (~90 seconds) and competitive fees. This tutorial covers token search, order creation, same-chain swaps, status tracking, and hook integration for post-fulfillment actions.
What You'll Build
- Query deBridge supported chains and token routes
- Create cross-chain swap orders (Ethereum to Solana, Arbitrum, Base, etc.)
- Execute same-chain swaps via deBridge DEX aggregation
- Track order status through the DLN lifecycle
- Use hooks for post-fulfillment actions (bridge + swap in one order)
deBridge Integration
Tenzro integrates deBridge through two paths: (1) the DeBridgeAdapter in the bridge router, accessible via the Rust/TS SDK and JSON-RPC, and (2) the official deBridge MCP server at https://agents.debridge.com/mcp for direct DLN API access. Both paths are available through the Tenzro Network.
Prerequisites
[dependencies]
tenzro-sdk = "0.1"
tokio = { version = "1", features = ["full"] }Step 1: Connect and Create Wallet
use tenzro_sdk::{TenzroClient, config::SdkConfig};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = SdkConfig::testnet();
let client = TenzroClient::connect(config).await?;
let identity = client.identity().register_human("deBridge Trader").await?;
let wallet = client.wallet().create_wallet().await?;
println!("Wallet: {}", wallet.address);Step 2: Search Tokens and Routes
# Search tokens on deBridge
# The deBridge MCP server at https://agents.debridge.com/mcp provides
# direct access to the DLN API
# Via JSON-RPC
curl -X POST https://rpc.tenzro.network \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "tenzro_getBridgeRoutes",
"params": {
"source_chain": "ethereum",
"destination_chain": "solana",
"token": "USDC"
},
"id": 1
}'
# Response shows deBridge as one of the available adapters:
# {
# "routes": [
# {
# "adapter": "debridge",
# "fee_native": "210000000000000",
# "fee_usd_estimate": "0.49",
# "estimated_time_seconds": 90
# },
# ...
# ]
# }Step 3: Get Supported Chains
// Get deBridge supported chains
let debridge_routes = client.bridge().get_routes(
"ethereum",
"solana",
"USDC",
"1000000000", // 1000 USDC
).await?;
// deBridge DLN supports:
// Ethereum, BSC, Polygon, Arbitrum, Avalanche, Optimism,
// Base, Solana, Fantom, Linea, and more
for route in &debridge_routes {
if route.adapter == "debridge" {
println!("deBridge: fee {} USD, ~{}s",
route.fee_usd_estimate, route.estimated_time_seconds);
}
}deBridge: fee 0.49 USD, ~90sStep 4: Create a Cross-Chain Swap
deBridge DLN works on an intent-based model. You create an order specifying what you want, and market makers (takers) compete to fill it. This typically results in faster settlement than messaging-based bridges:
// Create a cross-chain swap via deBridge DLN
// deBridge uses an intent-based model: you create an order,
// and market makers (takers) compete to fill it
let swap = client.bridge().bridge_tokens(
"ethereum", // source chain
"solana", // destination chain
"USDC", // token
"500000000", // 500 USDC (6 decimals)
&wallet.address, // recipient on Solana
Some("debridge"), // use deBridge adapter
).await?;
println!("deBridge Order Created:");
println!(" Tx Hash: {}", swap.transaction_hash);
println!(" Order ID: {}", swap.order_id);deBridge Order Created:
Tx Hash: 0x5b7e...f4a9
Order ID: ord-a1b2c3d4-e5f6-7890Step 5: Same-Chain Swap
deBridge also supports same-chain swaps through its DEX aggregation:
// Same-chain swap via deBridge
// deBridge also supports same-chain swaps through its DEX aggregation
let same_chain = client.bridge().bridge_tokens(
"ethereum", // source chain
"ethereum", // same destination
"ETH", // from ETH
"100000000000000000", // 0.1 ETH
&wallet.address,
Some("debridge"),
).await?;
println!("Same-chain swap: {}", same_chain.transaction_hash);Step 6: Track Order Status
Track the order through the DLN lifecycle. Status updates come from the deBridge stats API at stats-api.dln.trade:
// Track deBridge order status
// deBridge uses the stats API at https://stats-api.dln.trade
loop {
let status = client.bridge().get_status(&swap.order_id).await?;
println!("Status: {}", status.state);
match status.state.as_str() {
// DLN order lifecycle:
// OrderCreated -> GiveOrderClaimed -> ClaimedUnlock ->
// SentUnlock -> Fulfilled/Completed
"Fulfilled" | "Completed" | "Filled" => {
println!("Order filled!");
println!(" Destination tx: {}", status.destination_tx.unwrap_or_default());
println!(" Fill time: {}s", status.elapsed_seconds.unwrap_or(0));
break;
}
"Cancelled" | "Expired" | "OrderCancelled" => {
eprintln!("Order cancelled/expired");
break;
}
_ => {
// OrderCreated, GiveOrderClaimed, ClaimedUnlock, SentUnlock
println!(" Waiting for taker to fill...");
tokio::time::sleep(std::time::Duration::from_secs(10)).await;
}
}
}Status: OrderCreated
Waiting for taker to fill...
Status: GiveOrderClaimed
Waiting for taker to fill...
Status: Fulfilled
Order filled!
Destination tx: 5Kj7...mR9f
Fill time: 47sDLN order lifecycle. Orders move through: OrderCreated (order submitted on source chain) → GiveOrderClaimed (taker locked funds) → ClaimedUnlock / SentUnlock (unlock in progress) → Fulfilled / Completed (tokens delivered on destination). Typical fill time is 30-120 seconds.
Step 7: Hooks (Post-Fulfillment Actions)
Hooks let you chain actions after a bridge transfer completes. For example, bridge USDC and automatically swap into SOL on the destination chain:
// deBridge hooks: post-fulfillment actions
// Hooks allow you to chain actions after a bridge transfer completes.
// For example, swap into a different token on the destination chain
// or deposit into a DeFi protocol.
// Example: Bridge USDC from Ethereum, then swap to SOL on Solana
let hook_swap = client.bridge().bridge_tokens_with_hook(
"ethereum",
"solana",
"USDC",
"500000000",
&wallet.address,
Some("debridge"),
// Post-bridge hook: swap USDC -> SOL on destination
Some(BridgeHook {
hook_type: "swap",
target_token: "SOL",
slippage_bps: 50, // 0.5% max slippage
}),
).await?;
println!("Bridge + hook order: {}", hook_swap.order_id);
println!("After bridge, USDC will be swapped to SOL on Solana");TypeScript Example
import { TenzroClient } from "@tenzro/sdk";
const client = new TenzroClient({ network: "testnet" });
// Get routes and compare
const routes = await client.bridge.getRoutes({
sourceChain: "ethereum",
destinationChain: "arbitrum",
token: "USDC",
amount: "1000000000",
});
const debridgeRoute = routes.find(r => r.adapter === "debridge");
console.log(`deBridge fee: ${debridgeRoute?.feeUsdEstimate} USD`);
// Execute via deBridge
const result = await client.bridge.bridgeTokens({
sourceChain: "ethereum",
destinationChain: "arbitrum",
token: "USDC",
amount: "1000000000",
recipient: wallet.address,
adapter: "debridge",
});
console.log(`Order: ${result.orderId}`);
// Track until filled
let status;
do {
status = await client.bridge.getStatus(result.orderId);
console.log(`Status: ${status.state}`);
if (!["Fulfilled", "Completed", "Cancelled"].includes(status.state)) {
await new Promise(r => setTimeout(r, 10000));
}
} while (!["Fulfilled", "Completed", "Cancelled"].includes(status.state));Direct deBridge MCP API
For advanced usage, call the deBridge MCP server directly. This gives you access to the full DLN API including raw order creation parameters:
# Direct deBridge DLN API calls (advanced usage)
# The deBridge MCP server at https://agents.debridge.com/mcp
# exposes the full DLN API
# Create a cross-chain order directly
curl -X POST https://agents.debridge.com/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "create_order",
"arguments": {
"srcChainId": 1,
"dstChainId": 7565164,
"srcTokenAddress": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"dstTokenAddress": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
"srcAmount": "500000000",
"dstMinAmount": "495000000"
}
},
"id": 1
}'What You Learned
- Intent-based bridging — how deBridge DLN uses market makers to fill orders
- Route comparison — querying deBridge fees alongside other adapters
- Order creation — creating cross-chain and same-chain swap orders
- Status tracking — following the DLN lifecycle from creation to fulfillment
- Hooks — chaining post-bridge actions for bridge + swap in one order
- Direct API access — using the deBridge MCP server for raw DLN operations
Next Steps
- See the LI.FI Bridge Aggregation tutorial for a multi-bridge aggregator
- See the Cross-Chain DeFi App tutorial for the full multi-adapter flow
- Read the Cross-Chain Arbitrage tutorial for automated arbitrage using deBridge