Migrate position (cross-lender)
GET/v1/actions/loop/migrate
Move a whole debt + collateral position from one lender to another in a single flash-loan transaction, optionally converting ONE leg (collateral OR debt) via an aggregator swap.
Flow (no conversion): flash the debt → repay the source → withdraw the source collateral → deposit it to the target → borrow the debt from the target → repay the flash. Same-lender / different-market moves (e.g. Morpho market A→B, Aave V4 reserve→reserve) are supported.
Supported sources & targets: Aave V2/V3, Aave V4, Compound V3, Morpho Blue / Lista, Fluid (an existing position via NFT-custody, OR a brand-new position — see below), Gearbox V3 (existing credit account as source; a fresh credit account is opened in-callback as target), Euler V2 (accountId 0; collateral-share transfer through the call forwarder). Not supported: Dolomite (either side), Euler as a TARGET, non-Venus Compound V2 as a target, both legs converting at once, Fluid↔Fluid.
Fluid target — existing vs fresh: pass the position's NFT id in
accountIdto migrate INTO an existing Fluid position (delivered via the VaultFactory NFT-custody flow). Omit it (or pass 0) to open a brand-new Fluid position: the migrate emits a single dual-axis Fluidoperatethat supplies the withdrawn collateral, borrows the debt, and mints the new position NFT straight to you — no NFT custody, no target-side consent, and the transaction targets the composer (deltaCompose) normally.
Native ↔ wrapped-native (wrap conversion): a native debt — e.g. a Venus
vBNBborrow — migrates into a target lender's wrapped-native debt market (WBNB). On-behalf borrowing cannot be delegated for the native asset, so the target MUST be the wrapped form; a native TARGET debt is rejected. The builder flashes the wrapped form, unwraps it to repay the native source, and borrows the wrapped form on the target — no aggregator needed. Compound V2 / Venus can be a migration source but never a target (no borrow delegation).
HTTP-route scope: this endpoint currently builds same-asset (and native↔wrapped-native) moves across Aave V2/V3/V4, Compound V3, Morpho/Lista and Fluid. An asset conversion (a collateral or debt swap leg) needs an aggregator quote, and Euler as a source needs an off-chain eVault share-balance read — both are available today via the
ComposerMigrate/prepareMigrateSDK; the route resolution for them is a follow-up and returns anUNSUPPORTEDerror.
Omit account for quote-only (returns data.quotes with price deltas). Include account to build full transaction calldata (populates actions with alternatives, transactions, and permissions).
Setup transactions (actions.permissions): returned only for the consents actually missing, to be executed BEFORE the migrate. These vary by lender pair — e.g. the source collateral withdrawal approval; Aave V4 Giver/Taker/Config Position-Manager authorizations + per-reserve borrow allowance + collateral-enable grant; Morpho setAuthorization; a Gearbox V3 SOURCE's setBotPermissions grant on the credit account; Euler collateral eVault share approval to the composer. Fluid legs need no separate permission (NFT custody — or, for a fresh open, the composer opening on your behalf — IS the authorization).
Delivery: the migrate transaction targets the composer (deltaCompose) normally, OR the Fluid VaultFactory.safeTransferFrom when a Fluid leg requires NFT custody — actions.transactions[0].to reflects this.
data.result (resulting position): a summary for the UI — from/to lenders with their collateral + debt assets (address/symbol/decimals/logo), the new position amounts (to.collateral.amount/amountUsd, to.debt.amount/amountUsd), netUsd, leverage, and — when depositApr/borrowApr are passed — apr: { deposit, borrow, net }, plus healthFactor when liqThreshold is passed. USD/symbol fields are best-effort (omitted when price/token metadata is unavailable). to.collateral.amount is present when the withdraw was sized server-side (Aave source) or passed explicitly.
Request
Responses
- 200
- 400
Quote or full build response
Validation error