- Free Compass API Key
- Wallet (EOA or smart account guide)
Introduction
Leverage lending (also know as “looping”) lets you boost yield by borrowing against your deposit, swapping the loan, and re-depositing — all to multiply exposure. With Compass SDK, you can run the entire leverage workflow in one atomic transaction, no Solidity, no manual steps, minimal gas. Normally this would require complex smart contract logic and multiple transaction steps. With Compass SDK, you abstract all of that away. This tutorial walks you through implementing Aave leverage strategies to achieve your target leverage.Example Aave Leverage Lending

- Collateral Asset: USDC
- Loan Asset: ETH
- Initial Collateral Amount: 1000 USDC
- Loan to Value Ratio: 70%
- Leverage: 2.19x
Setup
1
Install Dependencies
Install the required packages.
2
Set Environment Variables
Create a .env file in your project root.
.env
3
Import Libraries & Environment Variables
4
Initialize SDK and Account
The full, uninterrupted code is available at the end of the tutorial.
Get Authorization
Before you can execute Aave leverage, you need to get an authorization from the Compass API and sign it with your private key. This ensures only you can execute the batch.1
Get and Sign Authorization
Request authorization from the Compass API and sign it with your wallet to authenticate the transaction batching.
Configure Aave Leverage Strategy
Now that we have authorization, let’s configure the Aave leverage strategy. This involves setting up the parameters for your leverage strategy including collateral token, borrow token, initial amount, and target multiplier.1
Configure Leverage Parameters
Set up the Aave leverage strategy with your desired parameters. This includes specifying the collateral and borrow tokens, initial amount, leverage multiplier, and risk parameters.
Execute the Transaction
The final step is to sign and broadcast the transaction to the network. This will execute your Aave leverage strategy in a single atomic transaction.1
Sign and Broadcast Transaction
Sign the returned transaction with your private key and broadcast it to the network. This is the final step to actually send your Aave leveraged transaction to Ethereum.
Understanding the Parameters
Let’s break down the key parameters for the Aave leverage strategy:Aave Loop Parameters
- collateral_token: The token you want to supply as collateral (e.g., “USDC”, “WETH”, “WBTC”)
- borrow_token: The token you want to borrow (e.g., “WETH”, “USDC”)
- initial_collateral_amount: The amount of collateral token to supply initially
- multiplier: The leverage multiplier (e.g., 2.0 means double exposure)
- max_slippage_percent: Maximum allowed slippage for token swaps (1-100)
- loan_to_value: The loan-to-value ratio in percentage (0-100)
The loan-to-value (LTV) ratio determines how much you can borrow against your collateral. For example, if LTV is 80%, you can borrow up to 80% of your collateral’s value. Be cautious with high LTV ratios as they increase liquidation risk.The maximum possible multiplier is determined by the formula:
1 / (1 - loan_to_value/100)
. For example, with an LTV of 80%, the maximum multiplier would be 1 / (1 - 80/100) = 1 / 0.2 = 5
. This represents the theoretical maximum leverage possible at that LTV ratio.Example Strategies
Here are some example configurations for different risk appetites:Conservative Strategy
Moderate Strategy
Aggressive Strategy
Risk Considerations
When implementing Aave leverage strategies, consider the following risks:- Liquidation Risk: Higher LTV ratios increase the risk of liquidation if the collateral value drops
- Interest Rate Risk: Borrowing rates may increase, affecting the profitability of your position
- Slippage Risk: Large trades may experience significant slippage, especially in volatile markets
- Smart Contract Risk: Always verify contract addresses and permissions
For further practice, try different token pairs, test with various leverage multipliers, or explore other Compass Bundler features to bundle additional transactions.