Skip to main content
Users end up with positions spread across venues, and rates move. Rebalancing by hand means several transactions and signatures, so most users never do it. The Portfolio Rebalancer lets you move funds between Aave markets, vaults and Pendle markets in one atomic transaction: every step succeeds, or nothing happens. It’s built on the Earn bundle endpoint, so it works wherever Earn works, from the same Earn Account.

Before you start

How it works

  1. Read the current positions with GET /v2/earn/positions.
  2. Work out the moves. Withdraw from venues that are over target, swap if the target venue takes a different token, deposit into venues that are under target.
  3. Send the moves as one bundle. Actions run in the order you list them, and the user signs once.

Example: move 50 USDC from Aave to a vault

The user signs transaction and sends it. Set gas_sponsorship: true to get eip_712 instead, so your wallet can pay the gas. See Gas Sponsorship.

Example: change token on the way

To move USDC out of Aave and into a WETH vault, add a swap between the withdrawal and the deposit:
A deposit needs a fixed amount, and a swap’s output isn’t known until it runs. Get the expected output from GET /v2/earn/swap_quote, then deposit at most that amount reduced by your slippage, so the deposit can never exceed what the swap delivers. Whatever the swap delivers on top stays in the Earn Account.

Actions you can bundle

Ready-made UI

The Portfolio Manager widget shows a user’s positions, lets them set target allocations, previews the plan and runs the bundle. Try it in the Widget Studio, and see Widgets to embed it in your app.

Good to know

  • Order matters. Each action can only use what earlier actions left in the account. Withdraw first, then swap, then deposit.
  • All or nothing. If any action fails, the whole transaction reverts and nothing moves.
  • Fees. Add a fee to any V2_MANAGE action to charge on the rebalance. See Embedded Fees.

Endpoints

Next

Earn

The venues you can rebalance between.

Transaction Bundling

How bundles work.

Gas Sponsorship

Let users rebalance without holding ETH.