Developers
Technical architecture and smart contract details for leveraged vaults.
Leveraged Vaults are built on the ERC-4626 tokenized vault standard with a modular architecture that enables automated looping, risk management, and withdrawals.
The system minimizes custom logic by composing audited protocol components with Superlend-specific automation.
Architecture Overview
Leveraged Vaults integrate the following modules:
Flash Loans – atomic looping and unlooping execution
Universal DEX Module – token swaps during looping and withdrawals
Withdraw Manager – queued and scheduled withdrawals
Accountant Module – NAV calculation and fee accounting
Rebalancing Engine – maintains healthy leverage and target parameters
All components are orchestrated by the vault contract and executed onchain.
Core Components
SuperloopVault ERC-4626 vault implementation with supply caps and performance fees.
SuperloopActions Executes modular strategy actions during loop, unloop, and rebalance operations.
SuperloopBase Handles roles, permissions, and administrative controls.
Aave V3 Modules Supply, Borrow, Withdraw, Repay, and E-Mode integrations.
Flashloan Module Uses Aave V3 flash loans with callback handling.
Universal DEX Module Executes swaps internally or via external liquidity sources.
AccountantAaveV3 Calculates total assets, profits, and performance fees.
WithdrawManager Queues and resolves scheduled withdrawals.
VaultRouter Enables token-agnostic deposits by swapping into the vault’s base asset.
Deployment & Initialization
Leveraged Vaults are deployed behind a TransparentUpgradeableProxy and initialized using DataTypes.VaultInitData.
Initialization includes:
Base asset, name, and symbol
Supply cap
Module registry and strategy modules
Accountant and withdraw manager modules
Admin addresses (vault admin, treasury)
After initialization:
Modules and callback handlers are registered
Accountant and withdraw manager are set via admin functions
Roles & Permissions
Vault Admin Can update supply caps, module registry, parameters, and treasury.
Privileged Addresses Allowed to transfer shares under guarded conditions.
Modules Restricted to execution within a valid vault execution context.
WithdrawManager Callable only by the vault during withdrawal resolution.
Module Execution Flow
Strategy execution uses Superloop.operate(DataTypes.ModuleExecutionData[]):
Start execution context
Execute each module action (CALL / DELEGATECALL)
End execution context
operateSelf is used for internal calls during execution (e.g. flash loan callbacks).
Flash Loan Flow
Flash loan triggered via
flashLoanSimpleCallback routed to a registered handler using
(msg.sender, msg.sig)Handler processes approvals, repayments, and optional re-entry into
operateSelf
This enables atomic looping and deleveraging.
Withdrawals
Instant Withdrawals Uses
instantWithdrawModule(if available) to redeem shares directly.Scheduled Withdrawals Requests are queued in
WithdrawManager. The vault unwinds leveraged positions and resolves liquidity before users claim.
VaultRouter (Token-Agnostic Deposits)
If
tokenIn == vault.asset()→ direct depositOtherwise:
Swap via Universal DEX Module
Approve resulting base asset
Deposit into the vault
Integration Patterns
Common strategy flows include:
Initial Looping
Flash loan → supply → borrow → swap → repayLeverage Adjustment Repay / withdraw / swap via flash loan to reach target exposure
Queued Withdrawals
Approve → request → vault unloops → user claims
Last updated