Resources
Aave Docs
Official documentation for Aave protocol and smart contracts.
Privy Wallets
Privy Wallets are a powerful tool for helping users interact with DeFi.
Integrate with Aave protocol
There are two ways to integrate Aave into your application:- Supply directly to Aave: Directly supply tokens into Aave’s liquidity pools to earn interest. Your tokens become available for borrowers and you earn yield from interest payments.
- Create a managed Aave vault: Create ERC-4626 compliant vaults that hold aTokens (Aave’s interest-bearing tokens). Vaults allow applications to manage supplied tokens on behalf of users and earn a percentage of the yield generated.
Install and configure the Aave SDK
Installation
Setup
Below is a minimal setup for Privy provider with Aave provider setup. To customize your Privy provider, follow the instructions in the Privy Quickstart to get your app set up with Privy.Supply directly to Aave protocol
This approach lets users deposit tokens directly into Aave’s lending pools to earn interest. When you supply tokens, they become available for other users to borrow, and you earn yield from the borrowing fees. This is the simplest way to start earning on idle assets.1
1. Execute the supply transaction
The Aave SDK returns transaction objects that you execute with Privy’s
sendTransaction
:Create a managed Aave vault
Aave Vaults are ERC-4626 compliant yield-bearing vaults that allow users to supply and withdraw ERC-20 tokens supported by Aave V3. Vaults enable applications to manage supplied tokens on behalf of users and earn a percentage of revenue.1
1. Get reserve information for vault deployment
2
2. Deploy a new vault
3
3. Deposit into a vault
Key integration tips
-
In NodeJS: the
sendWith
method from the Aave SDK is feature-rich and streamlines complex transaction flows. It automatically handles token approvals when required and then sends the main Aave transaction, making the overall process more seamless. -
Handle transaction plans: The Aave SDK returns various plan types (actions) like
TransactionRequest
andApprovalRequired
which can be used to handle different transaction scenarios accordingly. This allows for flexible handling of different approval and execution patterns. - Add error handling: Production applications should wrap all async functions in try/catch blocks to handle common blockchain errors like user rejection, insufficient funds, network issues, and contract failures. Consider implementing user-friendly error messages and retry mechanisms for failed transactions.