Skip to main content

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:
  1. A Magic Publishable API Key from your Magic Dashboard
  2. A Base RPC endpoint (e.g., from Alchemy or QuickNode)
  3. USDC on Base in the user’s wallet
  4. ETH on Base for gas fees (typically fractions of a cent)

How It Works

  1. User authenticates with Magic
  2. The AAVE SDK generates a supply transaction (handling approval automatically)
  3. The transaction is sent through the user’s Embedded Wallet via viem
  4. The user receives aUSDC, which accrues interest automatically
  5. 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’s supply 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 the withdraw 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


Troubleshooting

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)
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
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
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.value field 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