Perps
Manage margin and notional exposure with independently verifiable positions.
On this page
Return shape
Every account snapshot includes block, holdings and liabilities. Use actual venue data, with owners bound to the Credit Account. Optional public actions must be declared in the definition; a schema-supported capability does not mean every integration offers it.
{
block: context.block,
holdings: [], liabilities: [], orders: [],
positions: [{
position_id: "17", market_id: "ETH-USDC", owner: context.account,
assets: [{ asset: usdc, amount: 100_000_000n }],
liability: 0n, recoverable_value: 95_000_000n,
direction: "long", margin: 100_000_000n,
notional: 200_000_000n, unrealized_pnl: -5_000_000n,
}],
}PnL is signed. Recoverable value is nonnegative and must not exceed the independent close-and-withdraw valuation. Margin, notional, funding and venue liabilities use the registered market’s declared scales.
Capabilities
| Capability | Parameters | Purpose |
|---|---|---|
| place_order | market_id, direction, order_type, amount: { margin, notional }, slippage_bps OR limit_price + expires_at | Open long or short exposure. |
| increase_position | position_id, amount: { margin, notional }, slippage_bps | Increase trading exposure. |
| decrease_position | position_id, amount: { notional }, slippage_bps | Reduce exposure. |
| add_margin / remove_margin | position_id, amount | Change margin without changing the requested notional. |
| cancel_order | order_id | Cancel a pending order. |
| close_position | position_id, slippage_bps | Close the remaining position. |
Open a position
termbook.open({
action: {
"use_case": "perps",
"capability": "place_order",
"params": {
"market_id": "ETH-USDC",
"direction": "long",
"order_type": "market",
"amount": {
"margin": 100000000n,
"notional": 200000000n
},
"slippage_bps": 50
}
},
});direction is long or short. place_order and close_position builders are mandatory for the perps type. Exposure and margin must pass both venue checks and Termbook’s independent health policy.
Exit requirements
Cancel orders, settle partial fills, close exposure and withdraw collateral proceeds. Liquidation fees, funding, outstanding obligations and market-close liquidity must be deducted from recoverable value. A borrower-only close interface cannot satisfy keeper recovery.