Cross-Chain USDC Supply to AAVE with Gasless Fusion Orchestration
This guide demonstrates how to use LiFi Protocol together with Biconomy’s Modular Execution Environment (MEE) to perform a cross-chain supply of USDC into AAVE, completely gasless using Fusion Orchestration.Overview
The integration enables:- Cross-chain bridging from Optimism to Base using LiFi Protocol
- Automated AAVE supply on the destination chain
- Gasless execution through Fusion Orchestration
- Single signature UX for the entire flow
- Optimized routing with FASTEST or CHEAPEST options
Architecture
Key Components
- LiFi Protocol: Smart routing aggregator for cross-chain swaps and bridges
- Biconomy MEE: Orchestrates the entire transaction flow
- Fusion Mode: Enables gasless execution with external wallets
- Companion Account: Temporary smart account for orchestration
Flow Diagram
Implementation Guide
1. Setup and Dependencies
First, create the LiFi Quote Service file. Copy and paste this entire code block into a new file calledlifi-quote-service.ts
:
2. Configure Token and Protocol Addresses
3. Initialize MEE Client and Orchestrator
4. Get LiFi Bridge Quote
Make sure you’ve created the
lifi-quote-service.ts
file from Step 1 before proceeding!5. Build Orchestration Instructions
Step 1: Define Trigger
The trigger initiates the orchestration by pulling tokens from the EOA:Step 2: Approve LiFi
Step 3: Execute Bridge Transaction
Step 4: Approve AAVE (with runtime balance)
Using runtime balance ensures we approve exactly what arrived:Step 5: Supply to AAVE
Step 6: Withdraw aUSDC to EOA
6. Execute Fusion Orchestration
Key Concepts
LiFi Smart Routing
LiFi aggregates multiple bridges and DEXs to find the best route:- FASTEST: Optimizes for speed
- CHEAPEST: Optimizes for lowest cost
- Multi-hop: Can route through multiple chains if needed
Runtime Balance Constraints
TheruntimeERC20BalanceOf
function ensures instructions use the exact amount that arrives:
- Handles bridge slippage automatically
- Ensures proper sequencing
- Avoids failed transactions
Constraints and Execution Order
Instructions execute only when their constraints are met:- AAVE approval waits for bridged funds
- AAVE supply waits for approval
- Withdrawal waits for aUSDC
Cleanup Mechanism
If any step fails, cleanup instructions ensure funds are returned:Gas Payment
The orchestration is gasless because:- Gas paid using bridged USDC
- MEE handles gas abstraction
- Users only sign once
LiFi Quote Service
Quote Parameters
Response Structure
Best Practices
- Always use runtime balances for cross-chain operations
- Include cleanup instructions for failure scenarios
- Set reasonable time bounds (60 seconds recommended)
- Test on testnets first before mainnet deployment
- Monitor transactions using MEE Scan
- Choose appropriate routing:
- Use
FASTEST
for time-sensitive operations - Use
CHEAPEST
for cost optimization
- Use
- Secure your API keys in environment variables
Error Handling
Advanced Features
Custom Slippage
Revenue Sharing
Earn fees by setting integrator params:Multi-Chain Cleanups
Supported Chains & Bridges
LiFi aggregates 30+ bridges across 20+ chains including:- Bridges: Stargate, Across, Hop, Connext, etc.
- DEXs: Uniswap, SushiSwap, Curve, etc.
- Chains: Ethereum, Arbitrum, Optimism, Base, Polygon, etc.
Monitoring & Analytics
Track your orchestrations:Optional: Using LiFi API Key
If you have high volume or need priority access, you can get a LiFi API key:- Visit LiFi Developer Portal
- Sign up and get your API key
- Update the
lifi-quote-service.ts
file:
- Set your environment variable:
Conclusion
This integration combines LiFi’s powerful routing engine with Biconomy MEE’s orchestration capabilities to deliver:- Access to the best cross-chain routes
- Completely gasless experience
- Single signature for complex flows
- Built-in failure protection