Skip to content
Termbook
Use cases

Spot

Buy and sell actual assets using swaps or an orderbook.

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["spot"]
{
  block: context.block,
  holdings: [
    { holding_id: "usdc", asset: usdc, amount: 100_000n,
      held_at: context.account, controlled_by: context.account,
      withdrawable_now: 100_000n },
  ],
  liabilities: [],
  orders: [],
}

Orders are present for resting orders, partial fills and cancellation requests. An atomic-only adapter can return an empty array when it proves no venue obligation remains. Purchased tokens are spot holdings, not perpetual positions.

Capabilities

CapabilityParametersResult
place_order · marketmarket_id, direction, order_type, amount, slippage_bpsExecute a protected buy or sell.
place_order · limitmarket_id, direction, order_type, amount, limit_price, expires_atPlace an order bounded by price and expiry.
modify_orderorder_id, market_id, direction, amount, limit_price, expires_atModify an existing limit order.
cancel_orderorder_idRequest cancellation; final fills and refunds still need reconciliation.

direction is buy or sell. amount has exactly one of spend or receive, independently of market or limit. spend fixes input and requires output protection; receive fixes output and requires an input cap. An integration may support only selected combinations.

Buy & sell

Buy · 0.1 USDC
termbook.open({
  action: {
    "use_case": "spot",
    "capability": "place_order",
    "params": {
      "market_id": "MON-USDC",
      "direction": "buy",
      "order_type": "market",
      "amount": {
        "spend": 100000n
      },
      "slippage_bps": 50
    }
  },
});
Sell · 0.1 MON
termbook.open({
  action: {
    "use_case": "spot",
    "capability": "place_order",
    "params": {
      "market_id": "MON-USDC",
      "direction": "sell",
      "order_type": "market",
      "amount": {
        "spend": 100000000000000000n
      },
      "slippage_bps": 50
    }
  },
});

Market IDs in these generic examples are illustrative. For Kuru use its registered address-based market ID. A buy can draw settlement credit; a sell spends owned tokens and returns proceeds to the account. Repayment remains a separate operation.

Limit orders

Buy · receive a fixed amount
termbook.open({
  action: {
    "use_case": "spot",
    "capability": "place_order",
    "params": {
      "market_id": "MON-USDC",
      "direction": "buy",
      "order_type": "limit",
      "amount": {
        "receive": 100000000000000000n
      },
      "limit_price": 2000000n,
      "expires_at": Math.floor(Date.now() / 1000) + 3600
    }
  },
});

Read limit_price using the registered integration’s declared scale. Integrations with native expiry require expires_at in Unix seconds. A venue without enforced expiry declares expiry: none and rejects expires_at. Kuru prices use 18 decimals; its orders remain open until filled or cancelled.

Exit requirements

Cancel pending orders, reconcile fills, withdraw any venue-held assets and sell remaining admitted holdings through protected routes. Shared assessment must account for committed funds and sale depth.

Documentation
8 results

Let’s talk

Tell us what you have in mind.

Supply liquidity