Loopify Finance - Technical Documentation
Loopify Finance is a leverage optimization protocol for USDe/sUSDe yield strategies on Converge Network. This documentation provides technical specifications and integration patterns for developers.
Overview
Loopify Finance enables atomic leverage execution using flash loans, Euler V3 (EVC), and Pendle integration for PT/YT strategies. The platform uses a $0.75 transaction fee model with 70-85% gas savings compared to manual execution.
Core Concepts
Health Factor Calculation
The health factor determines position safety and liquidation risk:
// Correct Health Factor Formula
Health Factor = (Collateral Value × Liquidation Threshold) / Borrowed Amount
// Example calculation
const collateralValue = 10000; // $10,000 USDC
const liquidationThreshold = 0.8; // 80% LTV
const borrowedAmount = 6000; // $6,000 USDe
const healthFactor = (collateralValue * liquidationThreshold) / borrowedAmount;
// Result: 1.33 (above 1.0 = safe, below 1.0 = liquidation risk)
Strategy Architecture
User Assets → Loopify Smart Wallet → Strategy Engine → DeFi Protocols
↓
Risk Monitor
Technical Architecture
Flash Loan Strategy Pattern
// Conceptual Strategy Interface
interface ILoopifyStrategy {
struct StrategyParams {
uint256 leverage; // 100-500 (1x to 5x)
uint256 maxLTV; // Max 80%
uint256 loops; // Max 5 iterations
address asset; // USDe or sUSDe
}
function executeStrategy(
uint256 amount,
StrategyParams calldata params
) external;
}
Atomic Execution Flow
// Flash Loan → EVC Batch → Pendle Operations → Repayment
contract AtomicStrategy {
// 1. Flash loan USDC from Balancer
function receiveFlashLoan(
address[] memory tokens,
uint256[] memory amounts,
uint256[] memory fees,
bytes memory userData
) external {
// 2. EVC batch: deposit → enable → borrow
_executeEVCBatch(amounts[0]);
// 3. Pendle: USDe → SY → PT+YT
_executePendleOperations();
// 4. Loop or finalize based on params
_handleLoopLogic();
// 5. Repay flash loan
_repayFlashLoan(amounts[0] + fees[0]);
}
}
Strategy Configuration Examples
// Yield Optimization Strategy Configuration
const yieldOptConfig = {
strategy: "yield-optimization",
asset: "USDe",
targetAPY: 18.5,
riskLevel: "low",
fees: {
management: 0.001, // 0.1% annual
transaction: 0.75 // $0.75 fixed
}
};
// Loop Strategy Configuration
const loopConfig = {
strategy: "loop",
asset: "sUSDe",
leverage: 3.0,
maxLTV: 0.75,
loops: 3,
riskLevel: "high",
fees: {
strategy: 0.005, // 0.5%
transaction: 0.75 // $0.75 fixed
}
};
Strategy Examples
1. USDe Leverage Strategy Flow
Interactive Strategy Flow Diagram:
USDe Leverage Strategy Process:
- Initial Deposit: User deposits USDe as collateral
- Flash Loan: Borrow additional USDe via flash loan
- PT/YT Minting: Convert borrowed USDe to PT-USDe/YT-USDe via Pendle
- Collateral Deposit: Use PT-USDe as additional collateral
- Leverage Loop: Repeat process for desired leverage ratio
- Position Monitoring: Continuous health factor tracking
2. Smart Contract Integration Example
// Flash Loan Strategy Implementation Pattern
contract LoopifyStrategy is IFlashLoanRecipient {
// Core strategy execution
function receiveFlashLoan(
address[] memory tokens,
uint256[] memory amounts,
uint256[] memory feeAmounts,
bytes memory userData
) external override {
RunParams memory params = abi.decode(userData, (RunParams));
// 1. EVC Batch Operations
IEVC.BatchItem[] memory items = new IEVC.BatchItem[](4);
// Deposit USDC collateral
items[0] = IEVC.BatchItem({
targetContract: USDC_VAULT,
onBehalfOfAccount: address(this),
value: 0,
data: abi.encodeWithSelector(
IEulerVault.deposit.selector,
amounts[0],
address(this)
)
});
// Enable collateral
items[1] = IEVC.BatchItem({
targetContract: EVC,
onBehalfOfAccount: address(0),
value: 0,
data: abi.encodeWithSelector(
IEVC.enableCollateral.selector,
address(this),
USDC_VAULT
)
});
// Enable controller
items[2] = IEVC.BatchItem({
targetContract: EVC,
onBehalfOfAccount: address(0),
value: 0,
data: abi.encodeWithSelector(
IEVC.enableController.selector,
address(this),
USDE_VAULT
)
});
// Borrow USDe
items[3] = IEVC.BatchItem({
targetContract: USDE_VAULT,
onBehalfOfAccount: address(this),
value: 0,
data: abi.encodeWithSelector(
IEulerVault.borrow.selector,
borrowAmount,
address(this)
)
});
IEVC(EVC).batch(items);
// 2. Pendle Operations
_executePendleStrategy();
// 3. Repay flash loan
IERC20(tokens[0]).transfer(BALANCER_VAULT, amounts[0] + feeAmounts[0]);
}
}
Integration Patterns
Error Handling
// Strategy Error Handling Pattern
try {
const result = await loopifyStrategy.execute(params);
return { success: true, data: result };
} catch (error) {
switch (error.code) {
case 'INSUFFICIENT_COLLATERAL':
return handleLowCollateral(error);
case 'SLIPPAGE_EXCEEDED':
return handleSlippage(error);
case 'HEALTH_FACTOR_LOW':
return handleHealthFactor(error);
default:
return { success: false, error: error.message };
}
}
Position Monitoring
// Position Health Monitoring
const monitorPosition = async (positionId) => {
const position = await getPosition(positionId);
const healthFactor = calculateHealthFactor(position);
if (healthFactor < 1.5) {
await triggerRebalance(positionId);
}
return {
healthFactor,
collateralValue: position.collateral * getPrice(position.asset),
debtValue: position.debt * getPrice(position.debtAsset),
liquidationPrice: calculateLiquidationPrice(position)
};
};
Technical Specifications
Fee Structure
- Transaction Fee: $0.75 fixed (70-85% savings vs manual)
- Management Fee: 0.1% annual (yield optimization)
- Strategy Fee: 0.5% (leverage strategies)
Risk Parameters
- Maximum Leverage: 5x
- Maximum LTV: 80%
- Health Factor Minimum: 1.2
- Maximum Loops: 5 iterations
Network Configuration
{
"chainId": "0x...",
"chainName": "Converge Network",
"rpcUrls": ["https://rpc.converge.network"],
"nativeCurrency": {
"name": "Converge",
"symbol": "CVG",
"decimals": 18
}
}
Integration Guide (Coming Soon)
Prerequisites
- Web3 wallet integration
- Converge Network configuration
- USDe/sUSDe token approval patterns
- Gas estimation and optimization
Contract Interfaces (In Development)
- ILoopifyStrategy: Core strategy interface
- IPositionManager: Position management
- IYieldOptimizer: Yield optimization logic
- IRiskManager: Risk monitoring and alerts
Getting Started for Developers
- Connect to Converge Network
- Configure contract interfaces (interfaces coming soon)
- Implement error handling patterns
- Set up position monitoring
- Test with small amounts on testnet (when available)
Technical Architecture (Advanced)
Component Overview
- Strategy Engine: Atomic execution logic
- Risk Monitor: Health factor tracking and liquidation prevention
- Yield Optimizer: Cross-protocol yield optimization
- Position Manager: Portfolio management and rebalancing
Data Flow
User Request → Strategy Validation → Flash Loan → EVC Batch →
Pendle Operations → Position Creation → Monitoring Setup
Note: This is technical documentation for a protocol in active development. Contract interfaces and advanced integration patterns will be available as the platform evolves. All code examples are conceptual and for educational purposes.
Risk Disclaimer: Smart contract interactions involve risks including but not limited to smart contract bugs, market volatility, and potential loss of funds. Always audit code and test thoroughly before mainnet deployment.