Skip to content

LeverageStrategiesManager

The LeverageStrategiesManager is a Venus periphery contract that enables users to enter and exit leveraged positions atomically using flash loans. It integrates with the Venus Comptroller’s flash loan functionality and the SwapHelper contract to execute complex leverage operations in a single transaction.

Version scope: This API reference follows venus-periphery v1.2.0. The deployed manager is an upgradeable proxy whose implementation fixes the Comptroller, SwapHelper, and unsupported vBNB address. Verify the current proxy implementation and dependencies before approving tokens or delegation.

Leverage operations in DeFi typically require multiple transactions: borrowing, swapping, and supplying assets. The LeverageStrategiesManager consolidates these into atomic operations using flash loans, eliminating intermediate exposure and reducing gas costs.

The contract supports five distinct leverage strategies:

StrategyDescriptionSwap Required
enterSingleAssetLeverageAmplify exposure to a single assetNo
enterLeverageEnter leverage with collateral seed, borrow different assetYes
enterLeverageFromBorrowEnter leverage using borrowed asset as seedYes
exitSingleAssetLeverageClose single-asset leveraged positionNo
exitLeverageClose cross-asset leveraged positionYes

Before using the LeverageStrategiesManager, users must delegate account actions to the exact manager proxy for their network:

// On the Venus Comptroller
comptroller.updateDelegate(leverageStrategiesManagerAddress, true);

This delegation allows the contract to:

  • Borrow on behalf of the user
  • Mint vTokens on behalf of the user
  • Redeem vTokens on behalf of the user
  • Repay borrows on behalf of the user

Obtain leverageStrategiesManagerAddress from Deployed Contracts, not from an implementation address or the SwapHelper address. The delegation remains enabled until the user revokes it with updateDelegate(leverageStrategiesManagerAddress, false).

  • Ownable2StepUpgradeable - Two-step ownership transfer pattern
  • ReentrancyGuardUpgradeable - Reentrancy protection
  • IFlashLoanReceiver - Flash loan callback interface
  • ILeverageStrategiesManager - Contract interface
VariableTypeDescription
COMPTROLLERIComptrollerVenus Comptroller for market interactions and flash loan execution
swapHelperSwapHelperToken swap executor for cross-asset operations
vBNBIVTokenvBNB market address (not supported for leverage operations)
LeverageStrategiesManager Architecture

The contract uses EIP-1153 transient storage to pass state between entry functions and flash loan callbacks. These values are automatically cleared at transaction end:

VariableTypeDescription
operationTypeOperationTypeCurrent operation being executed
operationInitiatoraddressOriginal msg.sender of the entry function
collateralMarketIVTokenTarget collateral market
collateralAmountuint256Collateral seed or redeem amount
borrowedAmountSeeduint256User-provided borrowed asset seed
minAmountOutAfterSwapuint256Slippage protection threshold

Initializes two-step ownership and reentrancy protection on the manager proxy.

function initialize() external initializer

The implementation constructor fixes the Comptroller, SwapHelper, and vBNB addresses and disables initialization on the implementation. Verify that the deployed proxy has already been initialized.


Enters a leveraged position using the same asset for collateral and borrowing. No swap is required.

function enterSingleAssetLeverage(
IVToken _collateralMarket,
uint256 _collateralAmountSeed,
uint256 _collateralAmountToFlashLoan
) external
NameTypeDescription
_collateralMarketIVTokenThe vToken market to use for both collateral and borrowing
_collateralAmountSeeduint256Amount of underlying tokens the user provides as initial capital
_collateralAmountToFlashLoanuint256Amount to flash loan for leverage amplification

User has 10 ETH and wants 2x exposure:

  • Provide 10 ETH as seed
  • Flash loan 10 ETH
  • Supply 20 ETH as collateral
  • Final: 20 ETH collateral, 10 ETH debt (plus fees)
  • SingleAssetLeverageEntered emitted on success
  • DustTransferred emitted if residual tokens remain
  • User must have delegated to this contract via Comptroller.updateDelegate
  • ZeroFlashLoanAmount if _collateralAmountToFlashLoan is zero
  • MarketNotListed if market is not listed in Comptroller
  • VBNBNotSupported if the market is vBNB
  • NotAnApprovedDelegate if user has not delegated to this contract
  • AccrueInterestFailed if interest accrual fails on the market
  • EnterMarketFailed if entering the market fails
  • OperationCausesLiquidation if pre/post position is unsafe

Enters a leveraged position by providing collateral seed and borrowing a different asset. The borrowed asset is swapped to collateral.

function enterLeverage(
IVToken _collateralMarket,
uint256 _collateralAmountSeed,
IVToken _borrowedMarket,
uint256 _borrowedAmountToFlashLoan,
uint256 _minAmountOutAfterSwap,
bytes calldata _swapData
) external
NameTypeDescription
_collateralMarketIVTokenThe vToken market to supply collateral to
_collateralAmountSeeduint256Amount of collateral underlying the user provides
_borrowedMarketIVTokenThe vToken market to borrow from
_borrowedAmountToFlashLoanuint256Amount of borrowed asset to flash loan
_minAmountOutAfterSwapuint256Minimum collateral tokens expected from swap (slippage protection)
_swapDatabytesEncoded swap data from Venus Swap API

User has 1,000 USDC and wants 3x USDC exposure:

  • Provide 1,000 USDC as collateral seed
  • Flash loan 2,000 USDT
  • Swap 2,000 USDT → ~2,000 USDC
  • Supply 3,000 USDC as collateral
  • Final: 3,000 USDC collateral, 2,000 USDT debt (plus fees)
  • LeverageEntered emitted on success
  • DustTransferred emitted for residual collateral and borrowed tokens
  • User must have delegated to this contract via Comptroller.updateDelegate
  • ZeroFlashLoanAmount if _borrowedAmountToFlashLoan is zero
  • IdenticalMarkets if collateral and borrowed markets are the same
  • MarketNotListed if either market is not listed in Comptroller
  • VBNBNotSupported if either market is vBNB
  • NotAnApprovedDelegate if user has not delegated to this contract
  • AccrueInterestFailed if interest accrual fails on either market
  • EnterMarketFailed if entering either market fails
  • SlippageExceeded if swap output is below _minAmountOutAfterSwap
  • TokenSwapCallFailed if swap execution reverts
  • OperationCausesLiquidation if position becomes unsafe

Enters a leveraged position by providing the borrowed asset as seed. Both seed and flash loan are swapped to collateral.

function enterLeverageFromBorrow(
IVToken _collateralMarket,
IVToken _borrowedMarket,
uint256 _borrowedAmountSeed,
uint256 _borrowedAmountToFlashLoan,
uint256 _minAmountOutAfterSwap,
bytes calldata _swapData
) external
NameTypeDescription
_collateralMarketIVTokenThe vToken market to supply collateral to
_borrowedMarketIVTokenThe vToken market providing the seed and flash loan
_borrowedAmountSeeduint256Amount of borrowed asset the user provides as seed
_borrowedAmountToFlashLoanuint256Amount of borrowed asset to flash loan
_minAmountOutAfterSwapuint256Minimum collateral tokens expected from swap
_swapDatabytesEncoded swap data (must account for seed + flash loan amount)

User has 1 ETH and wants leveraged USDC exposure:

  • Provide 1 ETH as seed
  • Flash loan 2 ETH
  • Swap 3 ETH → ~6,000 USDC
  • Supply 6,000 USDC as collateral
  • Final: 6,000 USDC collateral, 2 ETH debt (plus fees)
  • LeverageEnteredFromBorrow emitted on success
  • DustTransferred emitted for residual tokens
  • User must have delegated to this contract
  • ZeroFlashLoanAmount if _borrowedAmountToFlashLoan is zero
  • MarketNotListed if either market is not listed in Comptroller
  • VBNBNotSupported if either market is vBNB
  • NotAnApprovedDelegate if user has not delegated to this contract
  • AccrueInterestFailed if interest accrual fails on either market
  • EnterMarketFailed if entering either market fails
  • SlippageExceeded if swap output is below _minAmountOutAfterSwap
  • TokenSwapCallFailed if swap execution reverts
  • OperationCausesLiquidation if position becomes unsafe

Closes or reduces a single-asset leveraged position. Flash loans the asset to repay debt, then redeems collateral to cover the flash loan.

function exitSingleAssetLeverage(
IVToken _collateralMarket,
uint256 _collateralAmountToFlashLoan
) external
NameTypeDescription
_collateralMarketIVTokenThe vToken market for both collateral and debt
_collateralAmountToFlashLoanuint256Amount to flash loan for debt repayment

User has 20 ETH collateral and 10 ETH debt:

  • Flash loan 10 ETH
  • Repay 10 ETH debt
  • Redeem ~10 ETH (plus fees) from collateral
  • Final: ~10 ETH collateral, 0 debt
  • SingleAssetLeverageExited emitted on success
  • DustTransferred emitted for residual tokens
  • User must have delegated to this contract
  • ZeroFlashLoanAmount if flash loan amount is zero
  • MarketNotListed if market is not listed in Comptroller
  • VBNBNotSupported if the market is vBNB
  • NotAnApprovedDelegate if user has not delegated to this contract
  • AccrueInterestFailed if interest accrual fails on the market
  • InsufficientFundsToRepayFlashloan if redemption insufficient for repayment
  • OperationCausesLiquidation if final position is unsafe

Closes or reduces a cross-asset leveraged position. Flash loans borrowed asset to repay debt, redeems collateral, and swaps to cover the flash loan.

function exitLeverage(
IVToken _collateralMarket,
uint256 _collateralAmountToRedeemForSwap,
IVToken _borrowedMarket,
uint256 _borrowedAmountToFlashLoan,
uint256 _minAmountOutAfterSwap,
bytes calldata _swapData
) external
NameTypeDescription
_collateralMarketIVTokenThe vToken market holding user’s collateral
_collateralAmountToRedeemForSwapuint256Amount of collateral to redeem and swap
_borrowedMarketIVTokenThe vToken market where user has debt
_borrowedAmountToFlashLoanuint256Amount to flash loan for debt repayment
_minAmountOutAfterSwapuint256Minimum borrowed tokens expected from swap
_swapDatabytesEncoded swap data

User has 3,000 USDC collateral and 1 ETH debt:

  • Flash loan 1 ETH
  • Repay 1 ETH debt
  • Redeem 2,000 USDC from collateral
  • Swap 2,000 USDC → ~1 ETH (plus fees)
  • Final: ~1,000 USDC collateral, 0 ETH debt
  • LeverageExited emitted on success
  • DustTransferred emitted for residual tokens
  • User must have delegated to this contract
  • ZeroFlashLoanAmount if flash loan amount is zero
  • IdenticalMarkets if collateral and borrowed markets are the same
  • MarketNotListed if either market is not listed in Comptroller
  • VBNBNotSupported if either market is vBNB
  • NotAnApprovedDelegate if user has not delegated to this contract
  • AccrueInterestFailed if interest accrual fails on either market
  • SlippageExceeded if swap output is below minimum
  • InsufficientFundsToRepayFlashloan if swap output insufficient for repayment
  • OperationCausesLiquidation if final position is unsafe

Flash loan callback invoked by the Comptroller. Routes execution to the appropriate handler based on operationType.

function executeOperation(
IVToken[] calldata vTokens,
uint256[] calldata amounts,
uint256[] calldata premiums,
address initiator,
address onBehalf,
bytes calldata param
) external override nonReentrant returns (bool success, uint256[] memory repayAmounts)
NameTypeDescription
vTokensIVToken[]Array with the borrowed vToken market (single element)
amountsuint256[]Array with the borrowed underlying amount (single element)
premiumsuint256[]Array with the flash loan fee amount (single element)
initiatoraddressAddress that initiated the flash loan (must be this contract)
onBehalfaddressUser for whom debt will be opened
parambytesEncoded auxiliary data for the operation
  • Only callable by the Comptroller
  • UnauthorizedExecutor if caller is not Comptroller
  • InitiatorMismatch if initiator is not this contract
  • OnBehalfMismatch if onBehalf does not match operationInitiator
  • FlashLoanAssetOrAmountMismatch if arrays length is not 1
  • InvalidExecuteOperation if operation type is unknown

Transfers the manager’s full balance of an ERC-20 token to its current owner. This is a recovery function, not a user refund path.

function sweepToken(address token) external onlyOwner nonReentrant
  • Current contract owner only
  • The call transfers the entire token balance and has no protected-token list or lifecycle condition. Integrations should avoid leaving balances on the manager and should verify the live proxy owner before relying on recovery.
EventParametersDescription
SingleAssetLeverageEntereduser, collateralMarket, collateralAmountSeed, collateralAmountToFlashLoanSingle-asset leverage position opened
LeverageEntereduser, collateralMarket, collateralAmountSeed, borrowedMarket, borrowedAmountToFlashLoanCross-asset leverage position opened with collateral seed
LeverageEnteredFromBorrowuser, collateralMarket, borrowedMarket, borrowedAmountSeed, borrowedAmountToFlashLoanCross-asset leverage position opened with borrowed seed
LeverageExiteduser, collateralMarket, collateralAmountToRedeemForSwap, borrowedMarket, borrowedAmountToFlashLoanCross-asset leverage position closed
SingleAssetLeverageExiteduser, collateralMarket, collateralAmountToFlashLoanSingle-asset leverage position closed
DustTransferredrecipient, token, amountResidual tokens transferred after operation
TokensSwepttoken, recipient, amountOwner recovered the manager’s full token balance
  • Delegate Requirement: All operations verify the user has delegated to this contract via Comptroller.updateDelegate()
  • Flash Loan Callback: executeOperation validates msg.sender is the Comptroller
  • Initiator Validation: Callback verifies initiator == address(this) to prevent unauthorized triggers
  • OnBehalf Validation: Callback verifies onBehalf == operationInitiator for user consistency

The executeOperation function is protected by OpenZeppelin’s nonReentrant modifier, preventing reentrant calls during flash loan callback execution.

All swap operations accept a minAmountOutAfterSwap parameter. The transaction reverts with SlippageExceeded if the swap output falls below this threshold.

  • Enter operations perform pre-checks to ensure the user is not already at liquidation risk
  • All operations perform post-checks to verify the final position is healthy
  • Exit operations skip the initial liquidity pre-check because they begin by reducing debt, but they also redeem collateral to settle the flash loan. The contract therefore still performs a final account-liquidity check; an exit is not assumed safe solely because debt decreased.

After every operation, any residual token balances are transferred back to the user:

  • Collateral dust → User
  • Borrowed dust (all operations) → User

See Deployed Contracts for current addresses.

  1. Enable Delegation: Resolve the network’s manager proxy from Deployed Contracts, then call Comptroller.updateDelegate(leverageStrategiesManagerAddress, true)
  2. Approve Tokens: Grant token spending approval to LeverageStrategiesManager for collateral tokens
  3. Execute Operations: Call the appropriate entry function with parameters
  4. Revoke When Finished: Call Comptroller.updateDelegate(leverageStrategiesManagerAddress, false) when the manager no longer needs to act for the account

LeverageStrategiesManager exposes a clear interface for integration:

interface ILeverageStrategiesManager {
function enterSingleAssetLeverage(
IVToken _collateralMarket,
uint256 _collateralAmountSeed,
uint256 _collateralAmountToFlashLoan
) external;
function enterLeverage(
IVToken _collateralMarket,
uint256 _collateralAmountSeed,
IVToken _borrowedMarket,
uint256 _borrowedAmountToFlashLoan,
uint256 _minAmountOutAfterSwap,
bytes calldata _swapData
) external;
function exitSingleAssetLeverage(
IVToken _collateralMarket,
uint256 _collateralAmountToFlashLoan
) external;
function exitLeverage(
IVToken _collateralMarket,
uint256 _collateralAmountToRedeemForSwap,
IVToken _borrowedMarket,
uint256 _borrowedAmountToFlashLoan,
uint256 _minAmountOutAfterSwap,
bytes calldata _swapData
) external;
}

Cross-asset operations (enterLeverage, enterLeverageFromBorrow, exitLeverage) require signed swap data from the Venus Swap API:

  1. Request a swap quote from the API with source and destination tokens
  2. Receive encoded multicall parameters with backend signature
  3. Pass the signed _swapData to the entry function

Published LeverageStrategiesManager audit reports are indexed in the venus-periphery v1.2.0 release. Check each report’s scope and reviewed commit against the current proxy implementation.