Note: The core scripts for the cross-chain lending workflows have been completed. Integration with AggSandbox is underway, and we are actively developing the frontends and polishing the full end-to-end workflow. Please see the detailed description below for the complete implementation and usage notes.
Cross-Chain Lending demonstrates fundamental concepts of using assets from one blockchain as collateral to borrow on another blockchain. This educational example shows how to bridge LP tokens from Sepolia and use them as collateral in Morpho Blue's isolated lending markets on Tatara (Katana testnet) to borrow AUSD, showcasing advanced DeFi composability across chains.
| Concept | What You'll Learn | Real-World Application |
|---|---|---|
| Isolated Lending Markets | How Morpho Blue creates risk-isolated lending pools | Advanced lending protocol design |
| Cross-Chain Collateral | Using assets from one chain as collateral on another | Multi-chain capital efficiency |
| Oracle Integration | Price feeds for non-standard collateral types | Custom asset valuation systems |
| Risk Parameters | LTV ratios and liquidation mechanics | DeFi risk management |
- Understanding Morpho Blue Architecture
- Cross-Chain Collateral Logic
- Market Creation and Management
- Oracle and Price Discovery
- Lending Flow Implementation
- File Structure and Responsibilities
- Key Implementation Patterns
- Educational Code Examples
Traditional Lending vs Isolated Markets:
Traditional Lending (Compound/Aave)
├── Shared risk pools
├── System-wide liquidation risk
└── Limited asset support
Morpho Blue Isolated Markets
├── Each market is independent
├── Isolated risk per market
└── Any asset can have its own market
A Morpho Blue market consists of:
| Component | Description | Example |
|---|---|---|
| Loan Token | What users borrow | AUSD |
| Collateral Token | What users deposit | LP tokens from Sepolia |
| Oracle | Price feed for collateral | Custom LP token oracle |
| IRM | Interest rate model | Dynamic rate based on utilization |
| LLTV | Liquidation Loan-to-Value | 86% (860000000000000000) |
Why Isolation Matters:
- Each market has independent risk parameters
- Bad debt in one market doesn't affect others
- Custom oracles for exotic collateral types
- Flexible interest rate models per asset pair
File: scripts/morpho-complete-test.js
Core Concept: Instead of just bridging tokens for trading, we bridge them with lending instructions.
Cross-Chain Flow Design:
Sepolia LP Position
│
├── LP tokens represent liquidity provision
├── Have inherent value from underlying assets
└── Exist as ERC-20 tokens
│
Bridge + Lending Instructions
│
├── Bridge LP tokens to Tatara
├── Include market parameters
├── Include borrowing preferences
└── Execute lending operations automatically
│
Tatara Lending Market
│
├── Receive LP tokens as collateral
├── Create/verify market exists
├── Supply collateral to Morpho
└── Borrow AUSD against collateral
Educational Insight: LP tokens are complex assets that require custom price oracles.
LP Token Value Components:
- Underlying Token A reserves
- Underlying Token B reserves
- Current exchange rates
- Pool fees accumulated
- Impermanent loss considerations
File: scripts/final-morpho-blue-test.js
Purpose: Understanding how Morpho markets are configured and created.
Market Parameter Structure:
MarketParams Configuration
│
├── loanToken: AUSD_ADDRESS
│ ├── The asset users will borrow
│ └── Must be an ERC-20 token
│
├── collateralToken: LP_TOKEN_ADDRESS
│ ├── The asset users deposit as collateral
│ └── Bridged LP tokens from Sepolia
│
├── oracle: LP_ORACLE_ADDRESS
│ ├── Price feed for LP token valuation
│ └── Returns price in 1e36 scaled format
│
├── irm: IRM_ADDRESS
│ ├── Interest rate model contract
│ └── Calculates borrow/supply rates
│
└── lltv: 860000000000000000
├── 86% liquidation threshold
└── Maximum borrowable amount ratio
Educational Flow: Markets must be created before they can be used for lending.
Creation Sequence:
- Parameter Validation: Ensure all addresses are valid contracts
- Market Creation: Call
createMarket()with parameters - Liquidity Seeding: Supply initial AUSD liquidity for borrowers
- Market Activation: Market becomes available for collateral deposits
File: scripts/complete-morpho-workflow.js
Educational Challenge: How do you price LP tokens that don't have standard market prices?
LP Token Pricing Strategy:
LP Token Price Calculation
│
├── 1. Get Underlying Reserves
│ ├── Read TokenA balance in pool
│ ├── Read TokenB balance in pool
│ └── Get current exchange rates
│
├── 2. Calculate Total Value
│ ├── TokenA_value = reserves_A × price_A
│ ├── TokenB_value = reserves_B × price_B
│ └── Total_pool_value = TokenA_value + TokenB_value
│
└── 3. Compute LP Token Price
├── LP_supply = total LP tokens outstanding
├── Price_per_LP = Total_pool_value / LP_supply
└── Return price in 1e36 scaled format
Morpho Blue Oracle Requirements:
- Must implement
price()function - Returns price scaled by 1e36 (not 1e8 like Chainlink)
- Must handle decimal conversions properly
- Should include staleness checks for security
File: scripts/morpho-complete-test.js
Purpose: Orchestrate the full lending cycle from collateral deposit to AUSD borrowing.
Workflow Stages:
Lending Cycle Execution
│
├── 1. Market Preparation
│ ├── Verify market exists or create it
│ ├── Ensure sufficient AUSD liquidity
│ └── Validate oracle functionality
│
├── 2. Collateral Operations
│ ├── Approve LP tokens for Morpho
│ ├── Call supplyCollateral() with LP amount
│ └── Verify collateral is recorded
│
├── 3. Borrowing Capacity Calculation
│ ├── Get LP token price from oracle
│ ├── Calculate collateral value in USD
│ ├── Apply LLTV ratio (86%)
│ └── Determine safe borrow amount
│
└── 4. AUSD Borrowing
├── Calculate desired borrow amount
├── Ensure it's below max LTV
├── Execute borrow() transaction
└── Verify borrowed AUSD received
Educational Focus: Understanding how lending protocols manage risk.
Risk Parameters:
- LTV Monitoring: Current borrowed amount vs collateral value
- Liquidation Threshold: Point where position can be liquidated
- Safety Buffer: Recommended borrowing below maximum
- Interest Accrual: Borrowed amount grows over time
| Component | Contract Address | Purpose |
|---|---|---|
| MorphoBlue | 0xC263...b9021 |
Main protocol entry point |
| AUSD | 0xa9012a055bd4... |
Loan token for borrowing |
| LP Tokens | Bridged from Sepolia | Collateral tokens |
| Oracle | Custom deployment | LP token price feed |
Universal Principle: Any cross-chain asset can be used as collateral through proper bridging and market setup.
1. BRIDGE COLLATERAL
├── Transfer LP tokens cross-chain
├── Include lending parameters
└── Preserve asset properties
2. CREATE MARKET
├── Define loan/collateral pair
├── Set risk parameters
└── Deploy custom oracle
3. SUPPLY & BORROW
├── Deposit bridged assets as collateral
├── Calculate borrowing capacity
└── Execute AUSD borrowing
Key Insight: Each market operates independently, allowing for innovative collateral types.
Isolation Benefits:
- Custom risk parameters per asset
- Experimental collateral types don't affect other markets
- Flexible liquidation mechanisms
- Independent interest rate models
This educational walkthrough demonstrates how cross-chain assets can be effectively used as collateral in isolated lending markets, showcasing the composability of DeFi protocols across different blockchains while maintaining proper risk management and price discovery mechanisms. The key insight is that any asset with deterministic value can become collateral through proper oracle integration and market design.