Before you start
- An API key. See the Quick Start.
- An Earn Account with positions to move. See Account Lifecycle.
How it works
- Read the current positions with
GET /v2/earn/positions. - 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.
- 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
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: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
feeto anyV2_MANAGEaction 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.