Aave Looping with Compass SDK (Typescript)

This guide demonstrates how to implement Aave looping strategies using the Compass API SDK in Typescript. Aave looping involves supplying collateral, borrowing assets, and reinvesting them to maximize yield.

Prerequisites

1

Install Dependencies

Install the required packages:

npm install @compass-labs/api-sdk viem dotenv
2

Set Environment Variables

Create a .env file in your project root:

# .env
PRIVATE_KEY="your_wallet_private_key"
RPC_URL="your_ethereum_rpc_url"
COMPASS_API_KEY="your_compass_api_key"

Implementation Guide

1

Import dependencies and load environment

First, import the necessary dependencies and load your environment variables.

2

Initialize SDK, Wallet, and Account

Set up the Compass API SDK, create your wallet client, and initialize your account.

3

Get and sign authorization for transaction batching

Before you can execute Aave looping, 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.

4

Configure and execute the Aave looping transaction

Configure the Aave looping strategy and prepare the transaction using the Compass API SDK.

5

Sign and broadcast the 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 looping transaction to Ethereum.

Full Code

Here is the full script from the tutorial. Copy and paste in your code editor and play around!