Skip to content
Termbook
Use cases

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.

PluginStates["perps"]
{
  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

CapabilityParametersPurpose
place_ordermarket_id, direction, order_type, amount: { margin, notional }, slippage_bps OR limit_price + expires_atOpen long or short exposure.
increase_positionposition_id, amount: { margin, notional }, slippage_bpsIncrease trading exposure.
decrease_positionposition_id, amount: { notional }, slippage_bpsReduce exposure.
add_margin / remove_marginposition_id, amountChange margin without changing the requested notional.
cancel_orderorder_idCancel a pending order.
close_positionposition_id, slippage_bpsClose the remaining position.

Open a position

place_order
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.

Documentation
8 results

Let’s talk

Tell us what you have in mind.

Supply liquidity