Loan Manager
The loan manager is a pluggable component that handles the borrowing side of the carry trade. It abstracts away protocol-specific logic for creating loans, managing collateral, and monitoring health.
Overview
The ILoanManager interface allows the Zenji vault to work with different lending protocols without modification. Currently, two loan managers are supported:Battle-tested lending protocol with deep liquidity and competitive rates. Uses standard over-collateralized loans.
Curve Finance's lending protocol with soft liquidations and native crvUSD support. Uses LLAMMA (lending-liquidating AMM).
ILoanManager Interface
All loan managers implement a standard interface:Create a new loan position with the specified collateral and debt amounts.
Note: The bands parameter is only used by LlamaLend's LLAMMA system. For Aave, a default value is used.
Add more collateral to an existing loan without borrowing more debt.
Used during rebalancing to reduce LTV when the vault has excess collateral.
Borrow more debt against existing or additional collateral.
Used to increase leverage when LTV falls below target (e.g., after collateral appreciation).
Repay outstanding debt to reduce leverage or close the loan.
Used to decrease LTV when it exceeds the upper band (e.g., after collateral depreciation).
Remove collateral from the loan and return it to the vault.
Can only be done if the remaining LTV is still healthy after removal.
Unified function for unwinding positions, used during withdrawals.
This function handles the complex logic of:
- Calculating required debt repayment
- Withdrawing from yield strategy
- Swapping assets if needed
- Repaying debt and removing collateral
Returns the current loan-to-value ratio.
Example: 65e16 = 65%
Returns the loan's health factor.
- Positive: Position is healthy
- Zero or negative: Position is at risk of liquidation
For Aave: health = (collateralValue × liquidationThreshold) - debtValue
Aave V3 Loan Manager
The AaveLoanManagerV2 integrates with Aave V3's lending pools.How it Works
1. Collateral Deposit: Collateral is supplied to Aave's pool 2. Borrow: USDT is borrowed at variable rate 3. Health Monitoring: Continuously monitors Aave's health factor 4. Oracle: Uses Chainlink price feed for the collateral assetKey Features
- Variable interest rates: Borrow costs fluctuate with market demand - Instant liquidation: If health factor < 1.0, position can be liquidated by anyone - High liquidation threshold: Collateral typically has a 75-80% LTV threshold on Aave - Deep liquidity: Billions in TVL ensure borrowing capacityBorrow Rate Example
Typical Aave USDT variable borrow rates: - Low utilization: 2-4% APR - Medium utilization: 4-8% APR - High utilization: 8%+ APR The vault's conservative target LTV (65-70%) provides a buffer against liquidation even if rates spike.Contract Details
// Aave Pool interface
interface IPool {
function supply(address asset, uint256 amount, address onBehalfOf, uint16 referralCode);
function borrow(address asset, uint256 amount, uint256 interestRateMode, uint16 referralCode, address onBehalfOf);
function repay(address asset, uint256 amount, uint256 interestRateMode, address onBehalfOf);
function withdraw(address asset, uint256 amount, address to);
}LlamaLend Loan Manager
The LlamaLendLoanManager integrates with Curve Finance's lending protocol (formerly known as Curve Lending).How it Works
1. Collateral Deposit: Collateral is deposited into a lending market 2. Borrow: crvUSD is borrowed using LLAMMA (Lending-Liquidating AMM Algorithm) 3. Soft Liquidations: Uses a soft liquidation mechanism to prevent instant liquidations 4. Bands: Collateral is spread across multiple price bands for gradual deleveragingKey Features
- Soft liquidations: Instead of instant liquidation, collateral is gradually converted to debt as price falls - LLAMMA algorithm: Converts collateral ↔ debt automatically across price bands - Native crvUSD: Direct borrowing of crvUSD (no swap needed) - Capital efficiency: Can potentially maintain higher LTV safelySoft Liquidation Explained
Unlike Aave's instant liquidation, LlamaLend uses soft liquidation: Traditional (Aave): - Price falls → health < 1.0 → instant liquidation penalty (5-10%) Soft Liquidation (LlamaLend): - Price falls → collateral gradually swapped to debt across bands - No instant penalty - Position can recover if price rebounds - More forgiving during volatilityBands
Collateral is spread across multiple price bands (typically 4-10): - Higher bands: Collateral remains in original form - Active band: Partial conversion happening - Lower bands: Mostly converted to crvUSD The vault configures the number of bands based on risk tolerance.Swapper Contracts
The loan manager and strategy rely on swapper contracts to convert between assets (e.g. USDT ↔ crvUSD via Curve). The swapper is the only component that can be changed via timelocked governance. The vault validates swapper output — if a swapper returns fewer tokens than expected (based on oracle pricing and slippage bounds), the transaction reverts. This prevents a malicious swapper from draining funds. - Swapper change flow:proposeSwapper() → 1-week timelock → executeSwapper() - Output validation: Vault checks that swapped amounts are within acceptable bounds
- The loan manager and yield strategy themselves are immutable per vault deployment