Rebalance the leveraged credit book
Rebalance the leveraged credit book in ONE atomic transaction.
List only the positions to change — anything not named is left untouched; remove a position with close=true. Each target states an end state: target_equity_usd (net USD committed) × target_multiplier.
Releasing targets run first (each unwind/delever frees tokens into the Credit Account), the freed tokens are then routed by swaps at a GUARANTEED minimum output (enforced on-chain), and consuming targets run last — so moving a levered position between markets, token pairs, or protocols (Aave ↔ Morpho) is simply a close plus an open in the same transaction.
Net book growth is funded from the Credit Account’s existing idle balance — fund it first via /v2/credit/transfer; a net release stays in the Credit Account as idle balance. Any swap surplus above the guaranteed floors also stays in the Credit Account (preview.estimated_max_dust) — recoverable, never lost.
A book already at its target returns transaction: null with the preview — the call is idempotent and safe to drive from a converge-to-target loop.
A rebalance too large for one transaction is rejected with a 422 — split it into two calls. Every deleveraging step keeps the health factor ≥ 1.02 and every leveraging step respects the protocol’s borrow limits; Aave targets share one account-level health factor, which the preview reports.
Dust tails and routing swaps below the swap router’s minimum routable size do not fail the call: a releasing target that cannot fully unwind returns its honest residual in the preview, and an unroutable routing swap is skipped (its uncovered amount only 422s the rebalance if it breaches the funding tolerance).
For protocol=MORPHO pass a market_id from /v2/credit/morpho_markets; inspect the current book via /v2/credit/looped_positions.
Body
Rebalance one or more Credit Account positions to their named end-states — lever up or down, grow or shrink equity, open a new position, close an existing one, or migrate (close one and open another) — all in ONE atomic transaction from the Credit Account.
The address that owns the Credit Account.
"0x4D3c07d1db7E4A9E44285fae9810d6549655bc74"
Blockchain network.
base, ethereum, arbitrum, hyperevm, tempo, bsc "ethereum"
The positions to change. Scoped: only positions named here are touched; any position not listed is left untouched.
1[
{
"borrow_token": "USDC",
"collateral_token": "WETH",
"protocol": "AAVE",
"target_multiplier": 2
}
]Request-level per-swap slippage tolerance in percent (including routing swaps). A per-target max_slippage_percent overrides it where set.
0 < x <= 100.3
If true, returns EIP-712 typed data for gas-sponsored execution instead of an unsigned transaction.
false
Response
Successful Response
The atomic rebalance transaction plus its guaranteed-floor preview.
Projected end state, computed on guaranteed swap floors.
Unsigned transaction for direct execution by the owner. Present when gas_sponsorship=false. Null when the book is already at its target — nothing to execute.
{
"chainId": "0x2105",
"data": "0x1688f0b900000000000000000000000029fcb43b46531bca003ddc8fcb67ffe91900c762000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000675f4a3d",
"from": "0x4A83b4413CF41C3244027e1590E35a0F48403F0c",
"gas": "0x7a120",
"maxFeePerGas": "0x59682f00",
"maxPriorityFeePerGas": "0x3b9aca00",
"nonce": "0x5",
"to": "0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67",
"value": "0x0"
}EIP-712 typed data for gas-sponsored execution. Present when gas_sponsorship=true.
{
"domain": {
"chainId": 8453,
"verifyingContract": "0x6B90E8B4E3E971E74C1A47a3a20976377E2dB4b1"
},
"message": {
"baseGas": "0",
"data": "0x8d80ff0a0000000000000000000000000000000000000000000000000000000000000020",
"gasPrice": "0",
"gasToken": "0x0000000000000000000000000000000000000000",
"nonce": "7",
"operation": 1,
"refundReceiver": "0x0000000000000000000000000000000000000000",
"safeTxGas": "0",
"to": "0x93C23AAE4793C14D6DF35D2A2A2234204e1559dA",
"value": "0"
},
"primaryType": "SafeTx",
"types": {
"EIP712Domain": [
{ "name": "chainId", "type": "uint256" },
{
"name": "verifyingContract",
"type": "address"
}
],
"SafeTx": [
{ "name": "to", "type": "address" },
{ "name": "value", "type": "uint256" },
{ "name": "data", "type": "bytes" },
{ "name": "operation", "type": "uint8" },
{ "name": "safeTxGas", "type": "uint256" },
{ "name": "baseGas", "type": "uint256" },
{ "name": "gasPrice", "type": "uint256" },
{ "name": "gasToken", "type": "address" },
{
"name": "refundReceiver",
"type": "address"
},
{ "name": "nonce", "type": "uint256" }
]
}
}