Skip to main content
POST
Python (SDK)

Authorizations

x-api-key
string
header
required

Your Compass API Key. Get your key here.

Body

application/json

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.

owner
string
default:0x4D3c07d1db7E4A9E44285fae9810d6549655bc74
required

The address that owns the Credit Account.

Example:

"0x4D3c07d1db7E4A9E44285fae9810d6549655bc74"

chain
enum<string>
default:ethereum
required

Blockchain network. Rebalance is not available on HyperEVM yet; use loop/unloop there.

Available options:
arbitrum,
base,
bsc,
ethereum,
tempo
Example:

"ethereum"

targets
RebalanceTarget · object[]
required

The positions to change. Scoped: only positions named here are touched; any position not listed is left untouched.

Minimum array length: 1
Example:
max_slippage_percent
default:0.5

Request-level per-swap slippage tolerance in percent (including routing swaps). A per-target max_slippage_percent overrides it where set.

Required range: 0 < x <= 10
Example:

0.3

gas_sponsorship
boolean
default:false

If true, returns EIP-712 typed data for gas-sponsored execution instead of an unsigned transaction.

Example:

false

Response

Successful Response

The atomic rebalance transaction plus its guaranteed-floor preview.

preview
CreditRebalancePreview · object
required

Projected end state, computed on guaranteed swap floors.

transaction
UnsignedTransaction · object | null

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.

Example:
eip_712
BatchedSafeOperationsResponse · object | null

EIP-712 typed data for gas-sponsored execution. Present when gas_sponsorship=true.

Example: