Overview
This guide shows how to use Magic’s Embedded Wallet to supply USDC to AAVE V3 on Base using the@aave/client SDK. Users deposit USDC into AAVE’s lending pool and receive aUSDC — an interest-bearing token that grows in value over time. When they’re ready, they can withdraw their USDC plus earned yield.
Prerequisites
Before starting, ensure you have:- A Magic Publishable API Key from your Magic Dashboard
- A Base RPC endpoint (e.g., from Alchemy or QuickNode)
- USDC on Base in the user’s wallet
- ETH on Base for gas fees (typically fractions of a cent)
How It Works
- User authenticates with Magic
- The AAVE SDK generates a supply transaction (handling approval automatically)
- The transaction is sent through the user’s Embedded Wallet via viem
- The user receives aUSDC, which accrues interest automatically
- When ready, the user withdraws their USDC plus earned yield
Setting Up the Clients
Install dependencies and initialize Magic, viem, and the AAVE client.TypeScript
Contract Addresses
TypeScript
Supplying USDC
Use the AAVE SDK’ssupply action to generate the transaction, then send it via the Magic wallet. The SDK returns an execution plan that may require an approval step before the supply transaction.
TypeScript
The AAVE SDK handles the approval check internally. If the Pool already has sufficient allowance, it returns a
TransactionRequest directly. Otherwise, it returns ApprovalRequired with both the approval and supply transactions.Withdrawing USDC
Use thewithdraw action to pull USDC back from the lending pool, including any earned yield.
TypeScript
Checking Position
Read the user’s aUSDC balance to see their current position including accrued yield. The aToken address is retrieved from the Pool’s reserve data.TypeScript
The aUSDC balance increases over time as interest accrues. Unlike vault-based protocols, AAVE’s aTokens are rebasing — the balance itself grows, so
1 aUSDC always equals 1 USDC of underlying value.Key Dependencies
| Package | Purpose |
|---|---|
magic-sdk | Magic authentication and Embedded Wallet |
viem | Ethereum client for transaction execution |
@aave/client | AAVE V3 SDK for building supply and withdraw transactions |
Troubleshooting
Supply transaction reverts
Supply transaction reverts
Symptoms: The supply transaction fails or reverts on-chain.Solutions:
- Check that the USDC approval was confirmed before the supply transaction
- Verify the user has sufficient USDC balance on Base
- Ensure the user has ETH on Base for gas fees
- Confirm the USDC address is correct (native USDC, not bridged USDbC)
Withdraw returns less than expected
Withdraw returns less than expected
Symptoms: The withdrawn amount is less than what was supplied.Solutions:
- This is unlikely with AAVE supply — depositors earn yield, not lose it
- Check that no other address withdrew on your behalf
- Verify you’re reading the aToken balance (not USDC balance) to see your position
aToken balance not increasing
aToken balance not increasing
Symptoms: The aUSDC balance appears static.Solutions:
- AAVE yield accrues continuously but can be very small over short periods
- On Base, supply APY for USDC depends on borrowing demand — check AAVE’s dashboard for current rates
- The balance is correct — yield accrual just takes time to be visible at small amounts
SDK returns InsufficientBalanceError
SDK returns InsufficientBalanceError
Symptoms: The
supply action returns a plan with __typename: "InsufficientBalanceError".Solutions:- The user doesn’t have enough USDC to supply the requested amount
- Check the
plan.required.valuefield for the amount needed - Verify the token balance on Base before calling
supply
Resources
Magic Embedded Wallets
Learn about Magic’s Embedded Wallet product
AAVE V3 Documentation
Official AAVE protocol documentation
EVM Transaction Signing
Guide for signing transactions with Magic wallets
AAVE Base Markets
View current AAVE supply rates on Base