Smart Contract API Documentation
Overview
Complete reference for interacting with Loopify Finance smart contracts on Ethereum mainnet.
Core Contracts
Multi-Asset Pendle Looping Strategies
Contract Address: 0x... (To be deployed)
Supported Assets at Launch:
- Top 5 Pendle assets by volume on Ethereum mainnet or others requested by our community
- USDT/USDC/USDE/USDF and other major stablecoin looping availability based on community demand
- Support for all major Pendle PT/YT pairs on the EVM network with sufficient liquidity
Launch Asset Portfolio:
- ETH-based strategies (ETH, stETH, rETH)
- Stablecoin strategies (USDC, USDT, DAI)
- LST strategies (weETH, ezETH, osETH)
- BTC strategies (WBTC, cbBTC, lBTC, eBTC)
- Additional high-volume Pendle markets
Expansion Strategy:
- Continuous monitoring of Pendle protocol for new high-volume markets
- Community governance for asset addition proposals
- Risk assessment framework for new asset integration
- Automatic strategy deployment for qualified assets
Functions
executeUltraFastLoop
function executeUltraFastLoop(LoopParams calldata params) external payable
Execute optimized PT/YT looping with flash loans.
Parameters:
params.inputAmount(uint256): Amount of input tokensparams.targetLeverage(uint256): Target leverage in basis points (300 = 3x)params.minPtOut(uint256): Minimum PT tokens to receiveparams.minYtOut(uint256): Minimum YT tokens to receiveparams.splitToYt(bool): Whether to split proceeds to YTparams.receiver(address): Address to receive tokens
Returns: Transaction hash
Gas Cost: ~250,000 - 350,000 gas
Example:
const params = {
inputAmount: ethers.parseEther("1.0"), // 1 ETH worth
targetLeverage: 300, // 3x leverage
minPtOut: ethers.parseEther("2.8"),
minYtOut: ethers.parseEther("2.8"),
splitToYt: true,
receiver: userAddress
};
await contract.executeUltraFastLoop(params);
getLoopQuote
function getLoopQuote(uint256 inputAmount, uint256 targetLeverage)
external view returns (uint256, uint256, uint256, uint256)
Get expected outputs for a loop transaction.
Parameters:
inputAmount(uint256): Amount of input tokenstargetLeverage(uint256): Target leverage in basis points
Returns:
expectedPt(uint256): Expected PT tokens to receiveexpectedYt(uint256): Expected YT tokens to receiveestimatedGas(uint256): Estimated gas costhealthFactor(uint256): Expected health factor after loop
Example:
const [expectedPt, expectedYt, estimatedGas, healthFactor] =
await contract.getLoopQuote(
ethers.parseEther("1.0"),
300 // 3x leverage
);
getPosition
function getPosition(address user) external view returns (LoopPosition memory)
Get current position details for a user.
Parameters:
user(address): User address to query
Returns:
user(address): Position ownerinitialAmount(uint256): Initial deposit amountptAmount(uint256): Current PT token balanceytAmount(uint256): Current YT token balanceleverage(uint256): Current leverage ratiohealthFactor(uint256): Current health factoractive(bool): Whether position is active
closePosition
function closePosition() external
Close the user's current loop position and redeem tokens.
Gas Cost: ~200,000 - 300,000 gas
LoopifyMetaVault
Address: 0x... (To be deployed)
Functions
deposit
function deposit(uint256 assets, address receiver) external returns (uint256 shares)
Deposit assets into the meta-vault for automatic strategy allocation.
Parameters:
assets(uint256): Amount of assets to depositreceiver(address): Address to receive vault shares
Returns:
shares(uint256): Amount of vault shares minted
withdraw
function withdraw(uint256 assets, address receiver, address owner)
external returns (uint256 shares)
Withdraw assets from the meta-vault.
Parameters:
assets(uint256): Amount of assets to withdrawreceiver(address): Address to receive assetsowner(address): Owner of the shares
Returns:
shares(uint256): Amount of vault shares burned
rebalance
function rebalance(uint256[] calldata allocations) external
Rebalance assets across strategies. Requires OPERATOR_ROLE.
Parameters:
allocations(uint256[]): New allocation percentages (basis points)
LoopingZap
Address: 0x... (To be deployed)
Functions
executePendleLoop
function executePendleLoop(PendleLoopParams calldata params)
external payable nonReentrant whenNotPaused
Execute Pendle PT/YT looping via the zap contract.
Parameters:
params.inputToken(address): Input token addressparams.inputAmount(uint256): Input amountparams.leverageRatio(uint256): Leverage ratio in basis pointsparams.minPtOut(uint256): Minimum PT outputparams.minYtOut(uint256): Minimum YT outputparams.receiver(address): Receiver address
Events
LoopExecuted
event LoopExecuted(
address indexed user,
uint256 inputAmount,
uint256 leverage,
uint256 ptReceived,
uint256 ytReceived,
uint256 gasUsed
)
Emitted when a loop position is successfully opened.
PositionClosed
event PositionClosed(
address indexed user,
uint256 ptRedeemed,
uint256 ytRedeemed,
uint256 outputAmount
)
Emitted when a loop position is closed.
Error Codes
Multi-Asset Pendle Strategy Errors
"Leverage too high"- Target leverage exceeds maximum allowed"Invalid input amount"- Input amount is zero or invalid"No active position"- User has no active position to close"Unauthorized callback"- Flash loan callback from unauthorized source
LoopifyMetaVault Errors
"Insufficient balance"- User has insufficient balance for operation"Invalid allocation"- Rebalance allocations don't sum to 100%"Paused"- Contract is paused for emergency
Integration Examples
Basic Loop Execution
import { ethers } from 'ethers';
// Initialize contract
const contract = new ethers.Contract(
PENDLE_STRATEGY_ADDRESS,
PENDLE_STRATEGY_ABI,
signer
);
// Get quote
const quote = await contract.getLoopQuote(
ethers.parseEther("1.0"), // 1 ETH
300 // 3x leverage
);
// Execute loop
const tx = await contract.executeUltraFastLoop({
inputAmount: ethers.parseEther("1.0"),
targetLeverage: 300,
minPtOut: quote.expectedPt,
minYtOut: quote.expectedYt,
splitToYt: true,
receiver: userAddress
});
await tx.wait();
Position Management
// Check current position
const position = await contract.getPosition(userAddress);
if (position.active) {
console.log(`PT Balance: ${ethers.formatEther(position.ptAmount)}`);
console.log(`YT Balance: ${ethers.formatEther(position.ytAmount)}`);
console.log(`Health Factor: ${ethers.formatUnits(position.healthFactor, 4)}`);
// Close position if health factor is low
if (position.healthFactor < 1500) { // 1.5
const closeTx = await contract.closePosition();
await closeTx.wait();
}
}
Event Monitoring
// Listen for loop executions
contract.on("LoopExecuted", (user, inputAmount, leverage, ptReceived, ytReceived, gasUsed) => {
console.log(`Loop executed by ${user}`);
console.log(`Input: ${ethers.formatEther(inputAmount)} ETH`);
console.log(`Leverage: ${leverage / 100}x`);
console.log(`PT received: ${ethers.formatEther(ptReceived)}`);
console.log(`YT received: ${ethers.formatEther(ytReceived)}`);
console.log(`Gas used: ${gasUsed}`);
});
Gas Optimization Tips
- Batch Operations: Combine multiple operations in single transaction
- Optimal Slippage: Use 0.3-0.5% slippage for better gas efficiency
- Peak Hours: We recommmend to avoid high gas periods (usually 12-4 PM UTC)
- Pre-approve Tokens: Approve tokens in advance to save gas on execution
- Monitor Health Factor: Close positions before forced liquidation
Rate Limits & Quotas
- Maximum Position Size: 10,000 ETH equivalent
- Maximum Leverage: 9.5x (950 basis points)
- Minimum Health Factor: 1.02 (1020 basis points)
- Cooldown Period: 1 block between operations per user
Real-Time Notifications
Powered by Notifi Network
Notification Features
- Real-time Health Factor Monitoring: Get instant alerts when your position health changes
- Multi-Channel Delivery: Receive notifications via Telegram and Email
- Customizable Thresholds: Set personalized alert levels for health factor warnings
- Position Status Updates: Stay informed about liquidation risks, rebalancing events, and yield changes
Notification Types
- Health Factor Alerts: Warnings when health factor drops below user-defined thresholds
- Liquidation Warnings: Critical alerts when positions approach liquidation risk
- Yield Updates: Notifications about significant APY changes in your strategies
- Position Changes: Confirmations for leverage adjustments, deposits, and withdrawals
- Market Events: Important protocol updates and market condition changes
Setup Instructions
- Connect Wallet: Link your wallet to enable position tracking
- Configure Channels: Set up Telegram and/or Email preferences via Notifi
- Set Thresholds: Customize alert levels (default: 1.2x health factor warning)
- Activate Monitoring: Enable real-time position monitoring
Coming Soon: Integration with Loopify Finance dashboard for seamless notification management
Testnet Addresses
Sepolia Testnet
- Multi-Asset Pendle Strategies:
0x...(To be deployed) - LoopifyMetaVault:
0x...(To be deployed) - LoopingZap:
0x...(To be deployed)
Supported Tokens (Sepolia)
- USDe
- USDT
- USDC
- sUSDe
- WETH
- wBTC