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