Api

Orderbook API

Markets, orders, trades, streaming market and DEX events

The Orderbook API exposes Hydra App's OrderbookService — initialised markets, the live orderbook, your own orders + trades, and two streaming surfaces (SubscribeMarketEvents for public market data, SubscribeDexEvents for your account activity).

JSON-RPC namespace: orderbook

Endpoints

Markets

Venue economics

Orders

Trades (public + per-account)

Streams


Shared types

OrderbookCurrency

Identifies an asset for orderbook RPCs (note: distinct from Network — flat shape).

FieldTypeNotes
protocolProtocol enumPROTOCOL_BITCOIN or PROTOCOL_EVM
network_idstringMagic bytes (Bitcoin) or decimal chain ID (EVM)
asset_idstringSee asset_id format below

asset_id format

Verified live against a running Hydra App; do not use the ticker.

AssetForm
Native BTCZero-padded 32-byte hex: 0x0000000000000000000000000000000000000000000000000000000000000000
Native asset of an EVM chain (ETH, …)The 20-byte zero address: 0x0000000000000000000000000000000000000000
Native TRXThe zero address in base58: T9yD14Nj9j7xAB4dbGeiX9h8unkKHxuWwb
ERC-20 tokenerc20:<lowercase-contract-address> (e.g. erc20:0x8cd0da3d001b013336918b8bc4e56d9dda1347e0)

The asset RPCs (asset_getAsset / asset_getNativeAsset) return the canonical form; if in doubt, fetch from there.

OrderAmount (oneof)

Used as the amount field on order requests and as the persisted-form remaining_amount / unmatched_amount / failed_amount on response orders. Exactly one variant:

VariantPayloadMeaning
base{ amount: DecimalString }Amount denominated in the base currency
quote{ amount: DecimalString }Amount denominated in the quote currency

DecimalString is always human-readable (e.g. "0.001" BTC, never satoshis). See Common Patterns → Amounts & Decimals.

⚠️ OrderAmount echoes the denomination you placed the order in

OrderAmount is a oneof precisely so it can carry either denomination. The side of an order (buy/sell) does not determine it. When you create a LimitOrder or MarketOrder, you choose base or quote freely — a buy can be sized in base or quote, and so can a sell. On response orders, remaining_amount, unmatched_amount, and failed_amount come back in the same variant you submitted, reduced as the order fills. A buy placed in base reports base remaining; a buy placed in quote reports quote remaining.

Always discriminate on the oneof variant actually set — never on the side:

  • Python: WhichOneof('amount') (hasattr is useless on oneofs — it's always true).
  • TypeScript: getAmountCase() / hasBase() / hasQuote().
  • Go: type-switch on *pb.OrderAmount_Base_ vs *pb.OrderAmount_Quote_.
  • Rust: match amount.amount { Some(order_amount::Amount::Base(_)) | Some(order_amount::Amount::Quote(_)) => … }.

Do not confuse this with LiquidityPosition.amount in the public orderbook (GetOrderbook). That field is a single scalar reporting offered liquidity, so it genuinely is base-on-sell / quote-on-buy. The remaining_amount / unmatched_amount / failed_amount on your own order do not follow that rule — they follow your placement choice.

Enum values (full names)

JSON-RPC and gRPC responses use the full proto constant names. Match these exactly:

EnumValues
OrderSideORDER_SIDE_UNSPECIFIED (0), ORDER_SIDE_BUY (1), ORDER_SIDE_SELL (2)
OrderTypeORDER_TYPE_UNSPECIFIED (0), ORDER_TYPE_LIMIT (1), ORDER_TYPE_LIQUIDITY (2), ORDER_TYPE_MARKET (3), ORDER_TYPE_SWAP (4)
AmountSideAMOUNT_SIDE_UNSPECIFIED (0), AMOUNT_SIDE_BASE (1), AMOUNT_SIDE_QUOTE (2)
TimeInForceTIME_IN_FORCE_UNSPECIFIED (0), TIME_IN_FORCE_GTC (1), TIME_IN_FORCE_POST_ONLY (2), TIME_IN_FORCE_IOC (3), TIME_IN_FORCE_FOK (4)
SelfTradePreventionSELF_TRADE_PREVENTION_UNSPECIFIED (0), SELF_TRADE_PREVENTION_NONE (1), SELF_TRADE_PREVENTION_CANCEL_TAKER (2), SELF_TRADE_PREVENTION_CANCEL_MAKER (3), SELF_TRADE_PREVENTION_CANCEL_BOTH (4)
SwapRoleSWAP_ROLE_UNSPECIFIED (0), SWAP_ROLE_LAST_MAKER (1), SWAP_ROLE_INTERMEDIATE_MAKER (2), SWAP_ROLE_TAKER (3)
SwapStatusSWAP_STATUS_UNSPECIFIED (0) → SWAP_STATUS_SWAP_FAILED (9). See proto for the full list.
SwapFunds (2026-10-14)SWAP_FUNDS_UNSPECIFIED (0), SWAP_FUNDS_NONE_SENT (1), SWAP_FUNDS_RETURNED (2), SWAP_FUNDS_LOCKED (3), SWAP_FUNDS_CLAIMING (4), SWAP_FUNDS_SETTLED (5), SWAP_FUNDS_NOT_RECEIVED (6)
CandlestickIntervalCANDLESTICK_INTERVAL_UNSPECIFIED (0), ..._ONE_MINUTE (1), ..._THREE_MINUTES (2), … ..._ONE_MONTH (15)

SWAP_ROLE_TAKER was renumbered (0 → 3) on 2026-05-03. Re-map if you persisted raw integers.


Init Market

Initialise a new trading market. Idempotent — repeat calls with the same pair return the existing MarketInfo.

Method: InitMarket

ParamTypeDescription
first_currencyOrderbookCurrencyOne side of the pair
other_currencyOrderbookCurrencyThe other side

Response: { market_info?: MarketInfo } — present when the market was successfully initialised; absent if the pair is unsupported or the hub lists no market of it.


Get Initialized Markets

List every market initialised on this Hydra App.

Method: GetInitializedMarkets

Params: none.

Response: { markets: MarketInfo[] }.


Get Markets Info

Like GetInitializedMarkets but additionally fetches live MarketInfo (fees, precision, min amounts) for every market.

The hub's markets are the ones its operator lists, every one that takes orders. A market the operator stops listing stays here, reading MARKET_STATE_CANCEL_ONLY, while it is open for the orders resting on it, and leaves the list once the hub restarts with none resting on it.

Method: GetMarketsInfo

Params: none.

Response: { markets: MarketInfo[] }.

MarketInfo:

FieldTypeDescription
baseCurrencyInfoBase currency + on-chain decimals
quoteCurrencyInfoQuote currency + on-chain decimals
taker_base_feeDecimalStringList taker fee ratio on the base side — see the note below
taker_quote_feeDecimalStringList taker fee ratio on the quote side
maker_base_feeDecimalStringList maker fee ratio on the base side. Negative = a rebate paid to the maker
maker_quote_feeDecimalStringList maker fee ratio on the quote side
base_precisionuint32Decimal places of a base amount: the lot is 10^-base_precision — see Amounts and prices
quote_precisionuint32Decimal places of a price. A quote amount is not on this grid — see Amounts and prices
min_base_amountDecimalStringStructural minimum, base side — see below
min_quote_amountDecimalStringStructural minimum, quote side
min_place_base_amountDecimalString?(2026-08-15) Advisory placement-floor snapshot, base side — see below
min_place_quote_amountDecimalString?(2026-08-15) Advisory placement-floor snapshot, quote side. Carries the decimal places of a quote amount, not of a price
order_min_notional_usdDecimalString?(2026-08-15) The pair's USD placement floor. Absent when disabled.
max_taker_discountDecimalString?(2026-09-04) Deepest discount a taker's fee on this market is struck at. 0 = takers pay list here
max_maker_discountDecimalString?(2026-09-04) Deepest discount a maker's rate on this market is struck at. 0 = makers trade at list here. What a limit order holds of your receiving balance is sized at it — see Sizing an order to fit your balance
stateMarketState(2026-09-16) Whether this market still takes orders — see below

These are list rates, not yours

MarketInfo advertises the fee ratios that apply to every client alike. What you are charged is these with your own fee-tier discount struck off. Don't derive that by hand — call GetMarketFeeRates, which returns a market's four ratios already priced for this node in both roles. A discount makes a fee shrink and a rebate deepen, and the naive listed × (1 − discount) gets the rebate case backwards.

The three optional fields marked ? above are genuinely absent on a server that does not stamp them — distinguish "absent" from "0".

state — whether the market is taking orders

(2026-09-16) MARKET_STATE_ENABLED (1) trades normally. MARKET_STATE_CANCEL_ONLY (2) refuses new limit and market orders but keeps resting orders and accepts cancels, and swap orders still route through the market, taking its resting orders — that is how it drains. MARKET_STATE_FROZEN (3) additionally closes it to swap routing: nothing new matches there, while resting orders can still be cancelled and swaps already matched settle. MARKET_STATE_UNSPECIFIED (0) comes only from a hub that predates the field.

MARKET_STATE_POST_ONLY (4) takes new limit orders only, every one of them post-only: one that would take an order on offer is refused with post_only_would_cross. Market and swap orders are refused, and no swap routes through the market; resting orders stand and may be cancelled. An operator reopens a market through it after maintenance, so the book refills without crossing.

A market allows only what both of its currencies' states allow: it goes cancel-only the moment either side does, and a market with one post-only side (new limit orders, no routing) and one cancel-only side (routing, no new orders) takes neither — it reads MARKET_STATE_FROZEN. Compare states by name, never by number: the numbers follow no order.

A market the operator stops listing reads MARKET_STATE_CANCEL_ONLY: it takes no new order, while the orders resting on it can be cancelled, settle, and are taken by swaps routed through it.

Update your client before a market goes post-only. A client that fails on an enum value it does not know cannot read a MARKET_STATE_POST_ONLY market at all; the operator puts no market in that state until clients are updated. Read a state you do not know as FROZEN.

It hot-reloads, so a cached copy goes stale silently. The operator changes it by editing the hub's asset registry or its market list — no restart, no disconnect, nothing your client would notice. Subscribe to market_info on the market stream and replace your copy when it arrives, rather than learning about it from a market_state rejection. Both GetMarketsInfo and GetMarketInfo stamp it; a MarketInfo embedded anywhere else may not.

Amounts and prices

A market counts its three kinds of figure on three grids:

FigureDecimal placesExample, BTC/USDC (base_precision 7, quote_precision 2, USDC holds 6)
Base amountbase_precision: a whole number of lots0.0000179
Pricequote_precision83672.58
Quote amountthe quote currency's own decimals, or base_precision + quote_precision where that is fewer (never more than 12) — derived from MarketInfo alone1.497739

A fill is whole lots at the maker's price. Its quote amount is that price times its base amount, in the quote currency's units and rounded down: 0.0000179 BTC at 83672.58 is worth 1.497739182 USDC and pays 1.497739. Every fill is priced so, whoever its maker and its taker are. The side receiving the quote bears the rounding — under one unit of a quote amount's last decimal place per fill (a unit of the currency where a quote amount carries all its decimals), so an ask can be filled that far under its price and never further. Fees are computed on these amounts, at each currency's own decimals.

A quote amount you send — an order's amount, a swap's from or to — may carry as many decimal places as a quote amount has, not only as many as a price. One with more is refused with INVALID_ARGUMENT. (2026-10-14) Before this change, quote amounts were counted on the price grid: a hub that predates the change still refuses a quote amount with more decimals than quote_precision.

Two different minimums

An order has to clear both floors, and they behave differently:

Structural minimum — min_base_amount / min_quote_amount. The market's grid minimum: the smallest amount a single fill may carry, and the minimum size of an order of any type. It is stable and authoritative. A partially consumed maker whose remainder would fall below it is evicted at match time, which is what guarantees that any resting size ≥ this minimum is fully takeable.

A fill is whole lots, so the smallest fill at a price is the larger of min_base_amount and the fewest lots worth min_quote_amount — and those are worth min_quote_amount or up to a lot more. An order that spends a quote amount fills there only if it covers that: on a BTC/USDC market with min_quote_amount 1.00 and min_base_amount 0.0000100, buying with exactly 1.00 USDC at 83672.58 takes nothing, because the smallest fill — 120 lots — costs 1.004070. Such an order is refused with below_best_fill, whose min_fill is what the smallest fill costs.

Advisory placement floor — min_place_base_amount / min_place_quote_amount. A snapshot of the hub's USD placement floor (order_min_notional_usd) converted to base/quote units at the hub's last oracle read. It is advisory only — it moves with oracle prices, so treat it as a sizing hint, not a contract. It is absent when the floor is disabled, when a side is unpriceable, or when the serving endpoint does not stamp it (notably the market-list RPC, GetMarketsInfo); size by the structural minimums in that case.

The authoritative placement floor is the rejection, not the snapshot. When an order is refused for being too small, the rejection carries the live min_place= value. Re-read it from there and refetch GetMarketInfo — see Errors → Placement rejections. Sizing purely off a cached min_place_* will intermittently fail as prices move.


Get Market Info

Same shape as GetMarketsInfo, scoped to one (first_currency, other_currency) pair.

Method: GetMarketInfo

Params: { first_currency: OrderbookCurrency, other_currency: OrderbookCurrency }

Response: { market_info?: MarketInfo } — absent when the hub lists no market of the pair and has none open: an order on it is refused with market_not_listed.


Get Market Fee Rates

(2026-09-03) The four fee ratios this node trades a market at — the market's published rates with this node's own discounts already struck off, each role at its own figure. Read from the same market copy the node's own estimates price against.

Method: GetMarketFeeRates

Params: { first_currency: OrderbookCurrency, other_currency: OrderbookCurrency }

Response: { fee_rates?: MarketFeeRates } — absent when the pair is not a market.

MarketFeeRates:

FieldTypeDescription
taker_base_feeDecimalStringCharged on the base this node receives when it takes liquidity
taker_quote_feeDecimalStringCharged on the quote this node receives when it takes liquidity
maker_base_feeDecimalStringCharged on the base this node receives when one of its resting orders fills. Negative = a rebate paid to this node
maker_quote_feeDecimalStringCharged on the quote this node receives when one of its resting orders fills
taker_discountDecimalStringThe discount the taker rates above were struck at, after bounding by MarketInfo.max_taker_discount. 0 when this node holds no rung or the market honours none
maker_discountDecimalStringThe discount the maker rates were struck at, after bounding by MarketInfo.max_maker_discount

This is a snapshot. Your discounts move as you settle volume and as the operator edits the ladders, and a fill is priced at whatever you hold when it fills. Refresh on a fee_discount_update event rather than caching indefinitely.


Get Currencies

(2026-09-02) The orderbook operator's asset allowlist — every currency it trades, with its ticker, class and lifecycle state.

Method: GetCurrencies

Params: none.

Response: { currencies: ListedCurrency[] } — ordered by network, then ticker.

ListedCurrency:

FieldTypeDescription
currencyOrderbookCurrencyThe currency itself
tickerstring?The currency's identity on the orderbook — what fee rules and holding ladders are keyed on. Absent for a currency found in a persisted market but no longer listed
classCurrencyClassCURRENCY_CLASS_STANDARD (1) or CURRENCY_CLASS_STABLECOIN (2)
stateCurrencyState..._ENABLED (1), ..._CANCEL_ONLY (2), ..._FROZEN (3), ..._POST_ONLY (4)
min_notional_usdDecimalString?This currency's own USD placement floor. Policy input, not the floor an order is checked against
min_native_amountDecimalString?A floor in the currency's own units, always in effect

The same ticker on two networks is one asset bridged across chains — that is the point of the ticker, and it is deliberately distinct from the symbol the chain reports. A holding ladder for HDN counts your HDN wherever it lives.

Lifecycle states:

StateNew ordersCancels & in-flight settlementSwap routing
ENABLED✅✅✅
CANCEL_ONLY❌✅✅
FROZEN❌✅❌
POST_ONLYLimit orders only, every one of them post-only✅❌

A market takes what both of its currencies' states allow — see market states. Read a state you do not know as FROZEN.

Both enums reserve their zero value and are never sent. A field at 0 reads as unset, so a real variant at 0 would be indistinguishable from an unset one — treat CURRENCY_CLASS_UNSPECIFIED / CURRENCY_STATE_UNSPECIFIED as a conversion error, not a default. A currency with no ticker is always CANCEL_ONLY and carries STANDARD (having no configured class) plus none of the floors.

Currency floors, most specific first: the currency's own min_notional_usd wins over the network's, which wins over the orderbook-wide one. min_native_amount is taken alongside the USD floor and binds whenever it is the larger of the two — so a market keeps a minimum even when the oracle is absent or wrong. To size an actual order, read the market's min_base_amount / min_place_base_amount; these are the policy inputs behind them.


Fee discounts

(2026-09-02, reshaped 2026-09-04) The operator runs up to two kinds of discount ladder, and what a fill costs you depends on which rungs you hold. Three RPCs cover it:

RPCAnswers
GetFeeDiscountProgramsWhat ladders exist, as configured
GetFeeDiscountWhere you stand on them
GetMarketFeeRatesWhat one market costs you, both roles, already priced

The arithmetic

A discount is a fraction applied to your own rate in that role, in your favor:

effective = listed − discount × |listed|

Applying it to a signed rate is the whole trick: a positive rate (a fee) shrinks, a negative one (a rebate) deepens. The intuitive listed × (1 − discount) is only correct for fees — on a maker rebate it moves the number the wrong way.

A discount never touches a counterparty's rate, and each market bounds each role's discount by its own published maximum (MarketInfo.max_taker_discount / max_maker_discount). Your volume and holding rungs sum.


Get Fee Discount Programs

The ladders the operator runs, as configured. An absent volume or an empty holdings means that program does not run.

Method: GetFeeDiscountPrograms

Params: none.

Response:

FieldTypeDescription
volumeVolumeDiscountProgram?The volume ladder
holdingsHoldingDiscountProgram[]One entry per holding ladder
max_taker_discountDecimalString?Operator's default ceiling on a market's taker discount. Absent = only the ladders' own maxima bound it
max_maker_discountDecimalString?Same for the maker discount

A market's own terms may replace either ceiling for that market — MarketInfo.max_taker_discount / max_maker_discount is the result.

VolumeDiscountProgram — rolling weighted settled USD volume buys a rung: { window_days: uint32, tiers: VolumeDiscountTier[] } (ascending). VolumeDiscountTier — { from_volume_usd, maker_discount, taker_discount }; from_volume_usd is an inclusive threshold.

HoldingDiscountProgram — holding an asset above a threshold buys a rung: { ticker, currencies: OrderbookCurrency[], tiers: HoldingDiscountTier[] }. currencies is exactly the set whose balances count as holding the asset, summed across them. HoldingDiscountTier — { from_amount, maker_discount, taker_discount }, in the asset's native units, inclusive.


Get Fee Discount

Your own standing on those programs, and the two figures your fills are priced at.

Method: GetFeeDiscount

Params: none.

Response: { standing: FeeDiscountStanding }

FeeDiscountStanding is a oneof — exactly one is set:

VariantMeaning
no_programThe operator runs no discount program: every fill is list price
excludedThis node is excluded: list price in both roles, and its settled volume earns nothing
activeActiveFeeDiscount — your standing on the programs that run

ActiveFeeDiscount:

FieldTypeDescription
taker_discountDecimalStringThe taker columns of your volume rung and every holding rung, summed — what your taker fills are priced at on a market with no ceiling
maker_discountDecimalStringThe same for your maker fills
volumeVolumeDiscountStanding?Absent when the operator runs no volume ladder
holdingsHoldingDiscountStanding[]One per configured holding ladder; empty when none run

taker_discount / maker_discount here are figures to show, not to price with. Every market bounds them by its own maximum. To price an order, call GetMarketFeeRates — it returns the market's rates already struck at the bounded figure.

VolumeDiscountStanding: { window_days, settled_volume_usd, tier: uint32, maker_discount, taker_discount, next_tier?: VolumeDiscountTier }. tier is 1-based; 0 is the undiscounted base. next_tier is absent at the top of the ladder. settled_volume_usd counts every settled hop for its taker and its maker alike, at its own notional scaled by its market's volume weight; a self-trade counts once.

HoldingDiscountStanding: { ticker, held_amount, by_currency: CurrencyHolding[], tier: uint32, maker_discount, taker_discount, next_tier?: HoldingDiscountTier, measured_at?: Timestamp }. tier 0 means below the first threshold; measured_at is absent until the first measurement.

CurrencyHolding: { currency, channel_amount, onchain_amount? } — what the hub measured of one counted currency. channel_amount is your own side of your channels with the hub. onchain_amount is the token balance at your node's wallet address, and is absent on networks whose node ids are not wallet addresses (Bitcoin), or when the last read failed with no earlier figure to carry.

Your standing arrives by subscription, not by polling. The hub opens the private DEX stream with your standing and pushes the whole standing again whenever it moves — see fee_discount_update. Silence means unchanged; the last message received is the one to hold. Call GetFeeDiscount to seed a UI, then follow the stream.


Get Sub-Economic Policy

(2026-09-16)

Method: GetSubEconomicPolicy

Params: none.

Response: { policy?: SubEconomicPolicy } — absent when the hub prices no network, which means nothing is sub-economic anywhere and none of this applies.

What the venue bounds

Nothing is refused for being small. What the venue bounds is what your concurrent small swaps would cost the hub to force-close if your node went dark. Every amount in this message is a quantity of that cost — never a trade notional, and reading them as notionals will be wrong by orders of magnitude.

A force-closure is billed in two dimensions, and both are published per network:

force_close_usd = asset_channel_close_usd × asset channels at risk
                + htlc_resolution_usd     × HTLCs at risk

summed over every network you hold channels on. The asset channel (channel, asset) is what one closure resolves: several small swaps on one of them share its close, but each leaves its own pending HTLC to resolve.

Escaping it entirely

A swap is not tracked at all when its own value covers force-closing its own legs in the worst case. With K the channels you hold with the hub for that asset:

untracked  ⇔  notional ≥ K × (asset_channel_close_usd + htlc_resolution_usd)

K, not one. Until a payment is actually sent it may still be MPP-split across every one of those channels, and recovering it then costs one closure in each. This is why the hub publishes the inputs rather than a single "safe notional" — that number is K × one closure, and K is yours, not the venue's. A client holding one channel and a client holding a hundred have thresholds two orders of magnitude apart on the same market.

The check

allowance = client_force_close_allowance_usd
          + min(earned_usd_per_usd_settled × settled_usd, earned_cap_usd)

refused   ⇔ Δforce_close_usd > 0
            ∧ force_close_usd + Δforce_close_usd > allowance

where settled_usd is what you have settled inside earned_window_days. A match that adds nothing — every leg landing on asset channels you already have at risk, on a network whose htlc_resolution_usd is zero — is admitted however full your allowance is.

SubEconomicPolicy:

FieldTypeDescription
by_networkSubEconomicNetworkPolicy[]Per-network pricing. A network with no entry has the mechanism off — nothing there is ever sub-economic
client_force_close_allowance_usdDecimalStringHow much force-closure cost a client with no settled volume may have at risk, across every network at once
earned_usd_per_usd_settledDecimalStringExtra allowance earned per USD settled inside the window. Zero means the ladder is off
earned_cap_usdDecimalStringCeiling on the earned part
earned_window_daysuint32Rolling window the settled volume is measured over

SubEconomicNetworkPolicy:

FieldTypeDescription
networkNetworkThe network this pricing applies to
asset_channel_close_usdDecimalStringWhat force-closing one asset channel costs the hub here, carrying no pending payments
htlc_resolution_usdDecimalStringWhat resolving one pending HTLC inside that closure costs on top. May be zero
peer_htlc_capuint32Most concurrent sub-economic HTLC legs one peer may hold here

peer_htlc_cap is not part of the cost arithmetic. What those HTLCs cost to resolve is already priced by htlc_resolution_usd and charged to your allowance. The cap bounds a different resource: HTLC slots are finite per channel, and a lane whose slots are full carries nothing — including the large payments the venue exists for. It has its own rejection, sub_economic_htlc_cap, which clears as the HTLCs resolve.

Every value here changes only when the hub restarts, so fetching once at startup is enough. A restart drops your connection, which is your signal to refetch.

What is deliberately not published. There is a venue-wide ceiling behind a separate sub_economic_venue_limit rejection — a backstop against a fleet of identities filling the hub's total, not something normal trading meets. It cannot be mirrored locally and is retryable, and it carries its own numbers on the rejection. Your own live figure is not pushed either: it is dominated by the worst-case projection above, which collapses within seconds of each payment reporting where it went, so a snapshot would be stale on arrival.


Get Orderbook Balances

Your balance on the venue in every currency you can trade.

Method: GetOrderbookBalances

Params: none.

Response: { balances: OrderbookBalance[] } — one entry per currency, each { currency: OrderbookCurrency, balance: CurrencyBalance }.

The *_sending figures are your side of your channels with the hub in that currency, what you pay the hub with; the *_receiving figures are the hub's side, what it pays you with.

FieldTypeDescription
sendingDecimalStringThe largest amount a new order can send now, the figure the venue admits an order against: what one payment over your channels that reach the floor can carry, less what your orders hold. An order fits when what it holds here does — see Sizing an order to fit your balance
receivingDecimalStringThe largest amount a new order can receive now: what one payment from the hub over the channels that reach the floor can carry, less what your orders hold, and no more than the hub can still forward to you. An order fits when what it holds here does, which for a limit order is more than its bare amount when the market pays makers a rebate
pending_sending / pending_receivingDecimalStringArriving from a deposit or channel open whose funding has not confirmed yet; spendable once it does
unavailable_sending / unavailable_receivingDecimalStringOwned but not spendable now: the channel reserve, payments in flight, balance being withdrawn or redeemed, and balance on channels that cannot pay
in_use_sending / in_use_receivingDecimalStringHeld by your open orders and the swaps they matched into
ineligible_sending / ineligible_receivingDecimalStringFree on channels whose payment deadline bound is below the floor, or not learned by the venue yet. No order can use it; a channel opened with a long enough dispute period can. 0 from a node that predates these fields
on_demand_receivingDecimalString(2026-11-17) What capacity on demand can add to the largest receive you can take now: an order with a budget, max_capacity_fee, fits against receiving plus this. The venue's estimate; the purchase at the swap is what counts. 0 while the hub sells none, while your asset channel waits for an earlier funding to land, while your node has its most receives on demand under way at once, and on a network without capacity on demand. See Trading with no receiving capacity
on_demand_fee_boundDecimalString, optional(2026-11-17) The most capacity on demand costs any one receive in this currency now, whatever its size or buyer. An order takes capacity on demand while what is left of its max_capacity_fee is at or above this; a receive pays the hub's actual price, at most this. Unset while the hub sells no capacity, and on a network without capacity on demand
on_demand_min_receiveDecimalString, optional(2026-11-17) The smallest receive the hub sells capacity on demand for in this currency now: a smaller one fits only receiving. Unset while the hub sells no capacity, and on a network without capacity on demand

The floor. A channel counts toward sending and receiving only when its payment_deadline_bound_secs (GetChannelTerms) reaches the deadline of the last leg of the longest route the venue builds: 39 hours with the production ladder, so a channel opened with a 48-hour dispute period counts and a 24-hour one does not. The rule is the same for every order, resting, market or swap, on either side and over any route, so sending and receiving are what an order is admitted against; (2026-11-17) on the receiving side, your orders on several markets share receiving as Sizing an order to fit your balance says. A Lightning channel reports no bound and always counts. The Simple Swap opens and leases channels that reach the floor on its own.

A BalanceUpdate event carries the same CurrencyBalance whenever it changes.

Sizing an order to fit your balance

The venue admits an order only when what it holds of each side fits: sending in the currency it gives, receiving in the one it gets. There is one balance per currency, shared by every order of yours that touches it, on any market. (2026-11-17) On the receiving side, orders on several markets share it: each order fits within what the hub can pay you now, and your orders receiving the currency on several markets may together hold up to that many times it — an ETH/USDC ask and a BTC/USDC ask may each receive up to your whole USDC receiving, twice it together. receiving takes every order's hold out of one balance, so an order on another market can still fit when it reads less: see An order on another market.

  1. Read the balance. sending and receiving, from GetOrderbookBalances or the BalanceUpdate event. What your open orders already hold is taken out of them (in_use_*). Size from these figures, not from a channel's remote balance: they are what the venue checks.
  2. Work out what the order holds. A limit order, whatever its time in force:
    • Sending: what it gives in full, with no fee — sized in base, a sell its amount and a buy its amount × price, rounded up to the quote amount's decimals; sized in quote, a buy its quote amount and a sell the base its quote covers at its price.
    • Receiving: what it receives in full — sized in base, a sell its amount × price and a buy its amount; sized in quote, a sell its quote amount and a buy its quote amount ÷ price — times 1 − f + d × |f|, rounded up to the decimals the market counts that amount in: base_precision for what a buy receives, the quote amount's decimals for what a sell receives (see Amounts and prices). f is the market's list maker rate on the currency received — maker_quote_fee for a sell, maker_base_fee for a buy — and d is max_maker_discount, both from MarketInfo. A fill pays you at your rung when it lands, and your rung can deepen while the order rests, so the hold covers the deepest rate the market strikes: with a maker rebate, more than the bare amount.

    A market order or a swap holds what its estimate sends and receives, the received side net of the taker fee; one with a worst price holds the most it can send up to that price, its taker fee included. If its match takes more than the estimate, the difference is held too.
  3. Check the fit. Each order is checked as it arrives against what the earlier ones left, so the holds of all your orders in a currency, summed, must stay within the balance (2026-11-17: on the receiving side, within it times the markets they span). The largest single limit order sized in base is receiving ÷ (price × (1 − f + d × |f|)) for a sell and receiving ÷ (1 − f + d × |f|) for a buy, rounded down to base_precision; work out its hold and go one lot lower if rounding pushed it over. A cancel that removes an order gives its hold back at once; one whose swap is in flight keeps what that swap holds until it ends.

Example. A −0.0375 % maker rate and a max_maker_discount of 1 give 1.00075. An ask of 0.009684 ETH at 2722.76 USDC receives 26.36720784 in full and holds 26.386984, so a receiving of 26.377179 refuses it although its amount × price fits; 0.009680 ETH holds 26.376085 and fits. On a market with base_precision 2 and a factor of 1.0005, a bid for 26.36 holds 26.38 — the rounding is up.

An order on another market

(2026-11-17) receiving takes off what your orders on every market hold, so it cannot tell whether an order fits on a market where none of your orders rests yet. Call C what your channels can receive in one payment with nothing held: receiving + in_use_receiving, while your orders hold no more than that. Such an order fits while its hold is at most C, less while the hub has a payment in flight to you, and the holds of all your orders receiving the currency, this one included, come to at most C times the number of markets they rest on, this one's counted.

Example. C is 1,000 USDC and an ETH/USDC ask holds 1,000, so receiving reads 0. A BTC/USDC ask holding up to 1,000 still fits: 2,000 in all, within 2 × 1,000.

A refusal names what was short: (2026-10-14) insufficient_capacity: currency=… leg=receiving required=… available=…, see Placement rejections. If your capacity later falls below what your orders hold — a withdrawal, a channel closing, a lease ending — the venue cancels orders until the rest fit.

(2026-11-17) An order with max_capacity_fee fits against receiving + on_demand_receiving on its receiving side: see Receiving on demand.


Get Orderbook

Fetch the current snapshot of one orderbook.

Method: GetOrderbook

Params: { base: OrderbookCurrency, quote: OrderbookCurrency }

Response: { orderbook?: Orderbook }.

Orderbook:

FieldTypeDescription
infoMarketInfoMarket configuration
ordersmap<string, LiquidityPosition>Active liquidity positions, keyed by order_id

LiquidityPosition:

FieldTypeDescription
client_pubkeybytesEd25519 public key of the position owner
sideOrderSideBuy or sell
priceDecimalStringPrice (quote per base)
amountDecimalStringOffered — base amount on sell orders, quote on buy orders
matched_amountDecimalStringAmount already matched
pending_cancelboolTrue if a cancellation is in flight

Example:

import { GetOrderbookRequest } from './proto/orderbook_pb'

const SIGNET_BTC = { protocol: 1, networkId: '0a03cf40',
  assetId: '0x0000000000000000000000000000000000000000000000000000000000000000' }
const SEPOLIA_USDC = { protocol: 2, networkId: '11155111',
  assetId: 'erc20:0x8cd0da3d001b013336918b8bc4e56d9dda1347e0' }

const req = new GetOrderbookRequest()
req.setBase(SIGNET_BTC)
req.setQuote(SEPOLIA_USDC)

const resp = await orderbook.getOrderbook(req, {})
const ob = resp.getOrderbook()
if (ob) {
  ob.getOrdersMap().forEach((pos, orderId) => {
    console.log(orderId, pos.getSide(), pos.getPrice()?.getValue(), pos.getAmount()?.getValue())
  })
}

Get Market Daily Stats

Read one market's 24-hour statistics as this node mirrors them — the same figures a daily_stats_update on SubscribeMarketEvents carries, at any time. Unary.

Method: GetMarketDailyStats

Params: { base: OrderbookCurrency, quote: OrderbookCurrency } — the pair as the market names it.

Response: { stats?: MarketDailyStats } (MarketDailyStats). Absent when this node has not initialised the market (InitMarket).

Read it once your stream is open, then follow the stream. The venue sends a daily_stats_update when a trade happens or leaves the 24-hour window, so on a quiet market the stream alone can leave you without stats for a long time. Read them again on is_synced: true.

Example:

import { GetMarketDailyStatsRequest } from './proto/orderbook_pb'

const req = new GetMarketDailyStatsRequest()
req.setBase(SIGNET_BTC)
req.setQuote(SEPOLIA_USDC)

const stats = (await orderbook.getMarketDailyStats(req, {})).getStats()
if (stats) {
  const v = stats.getVolatility()
  console.log(v?.getLastPrice()?.getValue(), v?.getBaseVolume()?.getValue())
}

Estimate Order

Dry-run an order — see the matching it would produce without actually creating it.

Method: EstimateOrder

Params: { order_variant: OrderVariant } — same OrderVariant shape as CreateOrder.

Response: { order_match?: OrderMatch }. Absent when no matching is possible.

A limit order is estimated as its walk of the book would go: at its price or better, in its own amount (fee included), and — for TIME_IN_FORCE_FOK — not at all unless it fills in full; one that rests without taking has no estimate. A market order is estimated within its limit_price. The estimate reads your node's copy of the book: it does not know the market's state, and does not tell your own orders apart from others' for self-trade prevention.


Create Order

Place an order on the orderbook.

Method: CreateOrder

ParamTypeRequiredDescription
order_variantOrderVariantYESExactly one of LimitOrder / MarketOrder / SwapOrder
client_order_idstringNOAdded 2026-05-03. Your own identifier, max 64 chars. See idempotency note below.
settlementOrderSettlementNOPer-leg channel vs on-chain settlement. See On-chain settlement.
self_trade_preventionSelfTradePreventionNOWhat the order does at your own orders, on every market it trades on. Leave it unset for no prevention. See Self-trade prevention.

Response: { order_id: string, released?: OrderRelease }.

  • released is set when a limit order matched part of what it asked for at once and the rest could not rest: the order is placed at what it matched, and released says what was not placed and why — below_best_fill, self_trade_prevented, immediate_or_cancel, too_small_to_rest or, (2026-11-17), insufficient_capacity. See Price priority and How an order ends. The order's OrderCreated event carries it too.
  • A request sent again under the client_order_id of its order gets the answer that order's placement gave, released included, and places nothing, so your retry after a lost answer reads as the answer it lost. The node's hub client retries a transport failure the same way, under the key it sent — one it makes up per request when you send no client_order_id.

Idempotent order creation. A client_order_id names one of your orders: from the request that places it, while the order lives, and for a retention period after it ends (24 hours by default; the hub's operator sets it). Send the same order again under it — the same order_variant, settlement and self_trade_prevention, every amount and price written the same way (1.0 and 1.00 differ) — and you get the answer that order's placement gave, live or ended — its order_id, and what it released — with nothing placed, so a network blip or DEADLINE_EXCEEDED retry never double-places. A different order under it is refused with ALREADY_EXISTS and the client_order_id_taken prefix, naming the order the id already names. A request the hub refuses frees the id at once, so a retry places anew. See Errors → Idempotency.

An order that has ended is not open, so GetOrder and GetOrderByClientId answer empty for it while its client_order_id still names it. Use a fresh client_order_id for every new order.

⚠️ AddLiquidity was removed from CreateOrder (2026-06-11)

The add_liquidity request variant — the range-based min_buy_price / mid_price / max_sell_price / remove_on_fill form — no longer exists. OrderVariant now creates only limit_order, market_order, or swap_order.

Provide maker / passive liquidity by placing limit orders (one or more LimitOrders at your chosen prices) — a resting limit order is a maker order and pays maker fees when filled. The LiquidityOrder message and ORDER_TYPE_LIQUIDITY still exist as the persisted / returned form (PairOrder.liquidity_order) for positions created that way, so you can still read, hold, and cancel pre-existing liquidity orders — you just can't create new ones through this call.

OrderVariant — the three variants

Exactly one variant must be set. To settle a leg on-chain instead of through a channel, see On-chain settlement below.

LimitOrder — fixed price, take it or wait (and the maker / liquidity path)

FieldTypeDescription
base / quoteOrderbookCurrencyPair
sideOrderSideORDER_SIDE_BUY or ORDER_SIDE_SELL
priceDecimalStringQuote per base
amountOrderAmountBase or quote denomination
time_in_forceTimeInForceHow the order meets the book; unset is GTC. See Time in force.

MarketOrder — fill at the best available price

FieldTypeDescription
base / quoteOrderbookCurrencyPair
amountOrderAmountBase or quote denomination
sideOrderSideORDER_SIDE_BUY or ORDER_SIDE_SELL
limit_priceDecimalString (optional)The worst price it takes at — a buy's highest, a sell's lowest — on the market's price grid. Unset takes at any price. When nothing is on offer within it, the order is refused with nothing_to_take. A capped market order locks the most it can send at that price rather than at its estimate.

SwapOrder — multi-hop cross-currency swap

FieldTypeDescription
from_currencyOrderbookCurrencySource currency
currency_pathOrderbookCurrency[]Intermediate hop currencies (may be empty)
to_currencyOrderbookCurrencyDestination currency
amountSwapAmount{ from: { amount } } or { to: { amount } }
limit_amountDecimalString (optional)(2026-11-17) The worst the order accepts, on the side amount leaves open: for an order sized by what it sends (from), the least it receives, in to_currency, net of the venue's fee, of the swap's on-chain fee and of what its receive pays for capacity on demand, the fee fixed for it at the match; for one sized by what it receives (to), the most it sends, in from_currency. A match past it is refused whole with swap_limit_unmet (FAILURE_REASON_VENUE_SWAP_LIMIT_UNMET): nothing is matched. A match of part of the order is held to the same share of it: the share of amount the match sends, for a from order, or receives, for a to order. Above zero, on the grid of that side (the last hop's receiving grid, or the first hop's sending grid); otherwise INVALID_ARGUMENT. Unset: no limit. A simple swap sets it on each of its orders

Time in force

Upgrade your node before you rely on a new order term. Over gRPC, a node that predates a field drops it without a word — protobuf skips fields it does not know — so a newer client talking to an older node places the order without it: a node that predates time_in_force places an IOC as a plain limit order, one that predates limit_price places a capped market order uncapped. A node that knows the field but not a value in it refuses the order (INVALID_ARGUMENT). JSON-RPC refuses fields it does not know.

A limit order's time_in_force says how it meets the book, and is signed into it. Market and swap orders have none: they take what they can at once, and the rest is dropped (a market order's limit_price bounds what it takes at). Leave it unset for GTC — an explicit value is refused by a hub that predates the field, and unset and GTC are different orders to a resend under the same client_order_id.

ValueBehaviour
TIME_IN_FORCE_UNSPECIFIED (0, default)A limit order's own behaviour: GTC
TIME_IN_FORCE_GTC (1)Good till cancelled: the order takes what it crosses, and what is left rests until it fills or is cancelled
TIME_IN_FORCE_POST_ONLY (2)Rest without taking. An order that would trade against an order on offer when it arrives is refused with post_only_would_cross (FAILED_PRECONDITION), naming the best price on offer it would have taken; nothing is created. An order the hub puts back on the book across an order on offer later — after a failed swap of either, a hub restart, or its owner shown again — is cancelled with CANCEL_REASON_POST_ONLY_WOULD_CROSS instead of taking it
TIME_IN_FORCE_IOC (3)Immediate or cancel: take what it can at its price or better, and rest nothing. One that filled something is placed at what it filled, and released reports the rest — reason immediate_or_cancel, or below_best_fill / self_trade_prevented when that stopped it first. One that filled nothing is refused with nothing_to_take (or below_best_fill / self_trade_prevented); nothing is created
TIME_IN_FORCE_FOK (4)Fill or kill: take its whole amount at its price or better at once, or nothing. When the book cannot fill it, it is refused with fill_or_kill_unfilled (or self_trade_prevented, when its rule would stop it), nothing is created, and the book is left as it was — a self-trade rule that would cancel one of your orders cancels none. What it has left that cannot rest — below the smallest fill at its price, or, for an ask sized in quote, beyond the base it locked (see Orders sized in the other unit) — is released with reason immediate_or_cancel

A post-only order pays maker fees only: it never takes. IOC and FOK orders pay taker fees only: they never rest. Both are refused with market_state on a market in MARKET_STATE_POST_ONLY. A fill of either that fails gives it nothing back: it ends once its fills settle — completed when they all did, cancelled with CANCEL_REASON_FILL_FAILED otherwise.

Which taker to use. A market order takes at any price unless you give it a limit_price; its amount is what you net when you size it in what you receive (the venue tops it up for the fee). A limit order's amount is gross — what its fills take off the book, fee included — and it never takes beyond its price: IOC for "whatever is there now", FOK for "all of it now or nothing". A limit order also locks its worst case at its price up front, so no book change between your estimate and its match can move what it pays.

OrderSized inIts amount is
Market buybasewhat you receive, net of the fee
Market buyquotewhat you pay
Market sellbasewhat you pay
Market sellquotewhat you receive, net of the fee
Limit (any time in force)base or quotegross: what its fills take, fee included

Self-trade prevention

self_trade_prevention says what the order does when it would trade against another order of yours — one of your node's, or of another key whose session with the hub carries the same identity — on every market it trades on, each hop of a swap route included. It is signed into the order. Leave it unset for no prevention — an explicit value is refused by a hub that predates the field, and unset and SELF_TRADE_PREVENTION_NONE are different orders to a resend under the same client_order_id.

Of the two orders, the newer one's rule decides: your incoming order's, or, when two of your resting orders meet because one of them came back to the book (after a failed swap, a hub restart, or its owner shown again), the one placed later.

Value of the newer orderThe newer orderThe older order
SELF_TRADE_PREVENTION_UNSPECIFIED (0, default) / SELF_TRADE_PREVENTION_NONE (1)trades with it, as with any other order, (2026-11-17) except where both are your node's and the newer order would settle either asset in one of your node's Lithium channels: there it stops, as with CANCEL_TAKERis filled, (2026-11-17) or stays as it is in that case
SELF_TRADE_PREVENTION_CANCEL_TAKER (2)stops there: it keeps what it filled before it, and the rest does not rest — a new limit order is placed at what it filled (released in its answer), a limit order that came back to the book is cancelled with CANCEL_REASON_SELF_TRADE_PREVENTED once its fills settle, a market or swap order leaves it unfilled. An incoming order that filled nothing is refused with self_trade_prevented, naming your order it metstays as it is
SELF_TRADE_PREVENTION_CANCEL_MAKER (3)goes on to the next orderis cancelled with CANCEL_REASON_SELF_TRADE_PREVENTED (a pending cancel if a fill of it is still settling)
SELF_TRADE_PREVENTION_CANCEL_BOTH (4)stops, as with CANCEL_TAKERis cancelled, as with CANCEL_MAKER

An order a rule cancels stays cancelled whatever becomes of the other, refused or not.

Price priority: nothing trades through an order it cannot fill

Every fill has a minimum size at its price (the market's structural minimums, see Two different minimums). A taker walks the book best price first and stops at the first order it may take but is too small for — it never skips it to fill at a worse price. What that means for each order type:

  • Market and swap orders keep what they filled before that order; the rest is dropped, as when the book runs out. One that filled nothing is refused with below_best_fill: min_fill is the smallest fill of that order, at price.
  • A new limit order whose remainder could rest at its own price but would then rest across that order does not rest across it:
    • with nothing filled it is refused with below_best_fill, as above — nothing is created;
    • after a fill it is placed at what it filled, as an order filled in full: its amount becomes what those fills take off it, in its own unit (base or quote, as you sized it); it completes when they settle, and a fill that fails without you at fault gives it that quantity back, to meet the book again. The CreateOrder answer and the OrderCreated event carry released: what was not placed, in the order's own amount, and why — below_best_fill { price, min_fill } (min_fill in the order's own unit too), self_trade_prevented { resting_order_id }, too_small_to_rest or, (2026-11-17), insufficient_capacity (both below).
  • A limit order the hub puts back on the book (after a failed swap, a restart, or its owner shown again) that would rest across such an order is cancelled with CANCEL_REASON_BELOW_BEST_FILL, once any fill of it settles.

Re-place larger, or at a price that does not cross price.

A new limit order that filled something and whose remainder is too small to rest at its own price — under the smallest fill there, or, for an order sized in quote, what cannot buy or sell one more lot — is placed at what it filled in the same way: released carries what was left, with reason too_small_to_rest, and the order completes when its fills settle. One that filled nothing is refused with INVALID_ARGUMENT, and nothing is created.

(2026-11-17) A new limit order that filled something and whose remainder would rest across orders its swap could not settle for want of receiving capacity is placed at what it filled in the same way: released carries what was left, with reason insufficient_capacity. One that filled nothing is refused instead, with the refusal of the receive that lacks the capacity, such as insufficient_capacity, or with maker_unavailable.

Orders sized in the other unit

The book holds a bid in quote and an ask in base. A bid sized in base, or an ask sized in quote, still takes in its own amount and never more than it asked: crossing better prices, a bid for 25 base buys 25 base — not what its quote at its own price would buy there — and an ask for 10 quote is paid at most 10 quote, selling less base. What is left rests at its price: a bid as its base; an ask as the whole lots its quote covers there, so it is never paid more than its quote — and never sells more base than it locked, whatever its fills are paid (a restart locks it again, for what its record has left). A bid sized in base never pays more than its lots are worth at the fill's price, nor more than it locked; a failed fill gives such an order back in its own amount.

Orders sized in quote

An order sized in quote trades whole lots, each fill priced as any fill is, so its amount is met to within what a lot is worth:

  • The quote it spends is a ceiling. A bid, and a market or swap buy with a quote budget, take at most their amount. What cannot buy one more lot is left: under a lot's worth, or under the next order's smallest fill when what is left cannot take it. A market or swap order ends with that unspent, reported as its unmatched_amount.
  • The quote it receives is a target. A market or swap sell for a quote amount sells the fewest lots that bring it, net of the taker fee: you receive at least what you asked, to within two units of a quote amount's last decimal place per fill (two millionths of a USDC per fill on a USDC market: the rounding of each fill and of its fee), and under a lot's worth more. You receive less only where the book does not hold it.
  • A limit order sized in quote takes within its amount, then rests the most lots what is left covers at its price, and counts what it holds again after every fill. A bid sized in quote pays every fill what its lots are worth at its price, rounded down.

How an order ends

An order completes (OrderCompleted) when what it asked has settled — or when the book has nothing more of it: every lot it offered was taken and has settled, and what is left of its amount is what those lots could not take. For an order sized in quote that is the quote that buys or sells no further lot, under a lot's worth. It is never spent, and its reservation is released with the order. A new order whose remainder is too small to rest when it arrives is placed at what it filled (released, reason too_small_to_rest) and completes the same way.

An order goes back as a cancel — OrderCanceled with CANCEL_REASON_HOUSEKEEPING, once the fills in flight settle — when the book still holds lots of it that it cannot offer (a residue under one legal fill, left by a partial fill), or when a fill that fails leaves it nothing it can offer. (2026-11-25) So does an order resting across an earlier order on offer that it cannot trade with. Two rare paths end a fully executed order sized in quote that way too: a restart of the hub while its last fill settles, when what it has left pays for a lot at the rounding of a fill, and its last fill settling before the hub has finished placing it. (2026-10-14) Before this change, a fully executed order sized in quote could end that way as a rule.

On-chain settlement

Added 2026-06-11 / 2026-06-15.

By default every swap leg settles through a payment channel. A taker order (market_order / swap_order) can opt individual legs onto on-chain HTLC settlement instead, so you can trade a currency you hold on-chain without first opening a channel for it. This is signed into the order as an OrderSettlement (from currency.proto):

FieldTypeDescription
sendingLegSettlementHow you send to the hub: CHANNEL (0, default), ONCHAIN (1), or CHANNEL_OR_ONCHAIN (2, orderbook picks — prefers channel)
receivingLegSettlementHow you receive from the hub (same values)
route_filteruint32 (optional)Taker-only route-wide method bitmask (bit 0 = Channel, bit 1 = On-chain). Absent = no constraint. Must be absent on a resting maker order.
receiving_claimReceivingClaim(2026-10-29) Who claims your receive when it settles on chain: RECEIVING_CLAIM_RECIPIENT (1, your node claims the hub's lock and the swap charges nothing for the claim) or RECEIVING_CLAIM_VENUE (2, the venue claims it for you once the secret is out and the swap charges the claim; only on an asset the venue lists, else FAILURE_REASON_VENUE_CLAIM_NOT_OFFERED). Required when receiving may settle on chain; leave it unset (RECEIVING_CLAIM_UNSPECIFIED, 0) for a receive in a channel and on a resting maker order.
max_capacity_feeDecimalString (optional)(2026-11-17) The order's budget for capacity on demand: the most it pays for capacity in all, across its fills, in the currency it receives. A receive your channels cannot carry pays the hub's price at the match, which comes off the budget; a swap order sized by what it receives (to) fixes its fee at the hub's quote when you place it. Valid on resting and taker orders whose receiving can settle in a channel. See Receiving on demand

Absent settlement ⇒ channel on both legs (the previous behavior). On-chain is valid only for taker orders — resting maker orders are channel-only. The on-chain refund/claim addresses are not declared here; the node supplies them later at the orderbook's PrepareSwap, and the per-hop details surface on the matched-order route (SwapHop.sending_onchain / receiving_onchain) and as simple-swap milestones. See the channel-vs-on-chain settlement model for the full picture.

Example — market sell 0.0005 BTC for USDC:

import { CreateOrderRequest, OrderVariant, OrderSide, OrderAmount } from './proto/orderbook_pb'

const market = new OrderVariant.MarketOrder()
market.setBase(SIGNET_BTC)
market.setQuote(SEPOLIA_USDC)
market.setSide(OrderSide.ORDER_SIDE_SELL)
const amt = new OrderAmount()
amt.setBase({ amount: { value: '0.0005' } })
market.setAmount(amt)

const variant = new OrderVariant()
variant.setMarketOrder(market)

const req = new CreateOrderRequest()
req.setOrderVariant(variant)
req.setClientOrderId('bot:bid-2026-06-08:0001')   // idempotent retry

const resp = await orderbook.createOrder(req, {})
console.log('order id:', resp.getOrderId())

Receiving on demand

(2026-11-17) An order can receive more than your channels can. Give it a budget for capacity on demand, max_capacity_fee in its OrderSettlement. When a fill's receive is more than your channels can carry, the hub sells your node the capacity for it as the fill settles, in one of two ways:

  • A JIT channel. Your node buys a JIT channel from the hub for that receive and receives the fill less that channel's fee: a deposit into your channel (Lithium), otherwise a new channel (Lightning). It buys it fund first where the hub sells that: the hub publishes the funding before the fill goes out, and your node claims once it sees the funding out, as settings.fund_first_reveal says. While the hub sells only secret first, your node buys secret first, at the same price, and trusts the hub with the payment until the funding is out.
  • A deposit paid in advance (Lightning). Where your channel to the hub can take a deposit and you can pay its fee from your side of it, the hub sells you one: your node pays its fee first, over that channel, the hub splices its own coins into the channel, both sides lock the splice at zero confirmations, and the hub claims the fee once both have; your node then receives the whole fill over the channel. A deposit not locked in time has its fee given back, and your node declines the swap.
  • What it costs. The setup of the funding, plus rent on the extra capacity the hub leaves for your next fills. GetJitChannelTerms with the hub's node gives the fee now.
  • max_capacity_fee is the order's budget. It is the most the order pays for capacity in all, across its fills. Each receive that needs capacity pays the hub's price at the match, and what it pays, or holds while its swap is in flight, comes off the budget (Order.capacity_fee_used). The order takes capacity on demand while what is left is at or above on_demand_fee_bound. A taker whose receive the hub prices above what it has left is refused with capacity_fee_above_max (FAILURE_REASON_VENUE_CAPACITY_FEE_ABOVE_MAX), the hub's price in its capacity_fee metadata: nothing is matched.
  • A swap order sized by what it receives (to). When you place it, with CreateOrder, CreateOrders or Swap, your node takes the hub's quote for the receive and fixes the fee there, rounded up to the receiving currency's grid: the order is matched for its amount plus that fee, receives its amount, and buys the capacity under that quote. A larger budget does not make it pay more. An order whose amount is more than receiving on your balance is refused when you place it, with nothing sent to the venue: with FAILURE_REASON_VENUE_CAPACITY_FEE_ABOVE_MAX, the quoted fee in its capacity_fee metadata, when the quote is above max_capacity_fee; with the reason your node gives, such as FAILURE_REASON_PEER_NOT_CONNECTED, when the hub cannot be asked; and with FAILURE_REASON_NO_LIQUIDITY when the hub quotes no capacity for the receive, or none that stands until its payments.
  • What you receive. Over a JIT channel, the receive less the venue's fee less the capacity fee. Over a deposit paid in advance, the receive less the venue's fee, the deposit's fee having been paid apart. Your trades record either fee as capacity_fee.
  • When the fee moved. A resting order sits out on-demand fills while on_demand_fee_bound is above what is left of its max_capacity_fee. Raise the budget with AmendOrder: the order keeps its place. If the hub sells no capacity for the receive when your node buys it, your node declines the swap.

max_capacity_fee is in the currency you receive, above zero, on that currency's grid, on an order whose receiving leg can settle in a channel; otherwise INVALID_ARGUMENT. An order with it is admitted against receiving + on_demand_receiving.

Trading with no receiving capacity

(2026-11-17) On a network where the hub sells capacity on demand, you do not need receiving capacity before you trade. Give an order a budget for it, max_capacity_fee: the most it may spend on capacity in all, in the currency it receives. A fill your channels cannot carry then buys the capacity it needs as it settles, at the hub's price at that moment. A simple swap does this for its order by itself when its proceeds stay in the channel.

  1. Read the balance of the currency the order receives, from GetOrderbookBalances or the BalanceUpdate event: receiving, on_demand_receiving, on_demand_fee_bound (the most capacity costs any one receive now) and on_demand_min_receive.
  2. Work out what the order receives and holds. For a limit order, what it receives in full and its hold, as Sizing an order to fit your balance says. For a market order or a swap, what its estimate receives, net of the taker fee.
  3. Decide:
CaseTestDo
It fitsthe hold ≤ receivingNothing: leave max_capacity_fee unset
On demandon_demand_fee_bound is set; the hold ≤ receiving + on_demand_receiving; the receive ≥ on_demand_min_receiveSet the budget, as in step 4
Not soldon_demand_fee_bound is unset: the hub sells no capacity in this currency nowLease capacity first (Rental), or trade within receiving
Too large nowthe hold > receiving + on_demand_receivingPlace a smaller order, or lease capacity first
Too smallthe receive < on_demand_min_receiveLease capacity first, or trade within receiving
  1. Set the budget.
    • A simple rule: your share × what the order receives, rounded down to the receiving currency's grid (base_precision for what a buy receives, the quote amount's decimals for what a sell receives). For example, 2 % of an 800.00 USDC receive is 16.00.
    • To take capacity now, the budget must be at least on_demand_fee_bound. When it is not, allow that order more, or trade without capacity on demand.
    • A swap order sized by what it receives (to) is quoted when you place it, and pays that quote, never more than its budget.
  2. Watch the order.
    • Order.max_capacity_fee is the budget, and Order.capacity_fee_used what the order's fills paid, or hold while their swaps are in flight. Order.listed_amount is how much of a resting order the book shows now.
    • While on_demand_fee_bound is above what is left, a resting order sits out the fills your channels cannot carry: it is listed at what they can carry. It shows in full again when the bound falls back, or when you raise its budget with AmendOrder max_capacity_fee, which keeps its place.
  3. Read what you paid. It is capacity_fee on ClientMarketTrade and ClientSwapTrade: the fee of the JIT channel the receive was paid net of, or of the deposit paid in advance. (2026-11-25) receive_capacity_kind says which (ON_DEMAND or PREPAID_DEPOSIT), and capacity_fee_record names a deposit fee's payment.

A taker whose receive needs capacity is filled only by makers that can settle it so, which can be further down the book: bound its price with limit_price or limit_amount. On each market, your orders receiving one currency share receiving and the on-demand room, best price first; each market's book lists them against all of it.

Refusals:

CodeWhenDo
insufficient_capacity (619), leg=receivingWhen you place it: the order receives more than receiving, or, with a budget, more than receiving + on_demand_receiving. At the match: no maker able to settle the receive on demand can fill it, or the receive is under on_demand_min_receiveSize within the figures, or place it again
capacity_fee_above_max (629)The hub prices the receive above what is left of the budget, at the match; or, for a swap order sized by what it receives, its quote when you place it is above the budget. capacity_fee is the hub's price, max_capacity_fee what was leftPlace it again with a budget that covers capacity_fee, or later
swap_limit_unmet (630)A swap order with limit_amount would fill worse than its limit. What it receives counts net of the capacity feeEstimate again and place it again
FAILURE_REASON_NO_LIQUIDITYA swap order sized by what it receives, whose receive the hub quotes no capacity for when you place itLease capacity, or lower the amount
INVALID_ARGUMENTThe budget is zero or off the grid, or the order's receive cannot settle in a channel; an amended budget is below what the order has usedCorrect the value

Example. On a BTC/USDC market with USDC on Arbitrum, a maker fee of −0.05 % and a max_maker_discount of 1, the balance reads receiving 120.00 USDC, on_demand_receiving 2,350.00, on_demand_fee_bound 0.20 and on_demand_min_receive 10.00.

  • Placing. A limit sell of 0.01 BTC at 80,000 receives 800.00 USDC and holds 800.00 × 1.001 = 800.80. That is more than 120.00 and within 2,470.00, so with a 2 % share it is placed with max_capacity_fee: "16.00".
  • Filling. A first-time receiver pays the setup alone, 0.10 USDC, at the first fill that needs capacity, and receives 800.00 + 0.40 rebate − 0.10 = 800.30 USDC: capacity_fee reads 0.10, and so does capacity_fee_used. The 15.90 left stays for later fills that need capacity.
  • On Bitcoin. A limit buy of 0.01 BTC over Lightning with a budget of 0.0002 BTC takes capacity on demand while on_demand_fee_bound is 0.00014672 BTC, its value at 10 sat/vB. At 50 sat/vB the bound is 0.0007336 BTC: the order sits out those fills until the fee rate falls back, or you raise its budget.
use rust_decimal::{Decimal, RoundingStrategy};

/// The budget for capacity on demand of an order that receives `receive`
/// and holds `hold`, at `share` of what it receives, on a grid of
/// `decimals`: `None` when the order fits `receiving`, when the hub sells
/// no capacity or cannot add what it lacks now, and when the most one
/// receive costs now is above that budget.
fn capacity_budget(
    balance: &CurrencyBalance,
    hold: Decimal,
    receive: Decimal,
    share: Decimal,
    decimals: u32,
) -> Option<DecimalString> {
    let read = |d: &Option<DecimalString>| d.as_ref()?.value.parse::<Decimal>().ok();
    let receiving = read(&balance.receiving)?;
    if hold <= receiving {
        return None;
    }
    let bound = read(&balance.on_demand_fee_bound)?;
    let room = read(&balance.on_demand_receiving)?;
    let smallest = read(&balance.on_demand_min_receive).unwrap_or(Decimal::ZERO);
    let budget = (receive * share).round_dp_with_strategy(decimals, RoundingStrategy::ToZero);
    (hold <= receiving + room && receive >= smallest && budget >= bound)
        .then(|| DecimalString { value: budget.to_string() })
}

// The limit sell above: it receives 800.00 USDC and holds 800.80, on a 2-decimal grid,
// at a 2 % share.
let settlement = OrderSettlement {
    max_capacity_fee: capacity_budget(&usdc_balance, "800.80".parse()?, "800.00".parse()?, "0.02".parse()?, 2),
    ..Default::default()
};

Create Orders

(2026-10-29) Place several orders in one request.

Method: CreateOrders

Params: { orders: CreateOrderRequest[] }, at most 500, each as CreateOrder takes it.

Response: { results: CreateOrderResult[] }, one per order in the order given: response (what CreateOrder answers) or error, a BatchItemError — the gRPC code, the message and the detail CreateOrder would have failed with.

  • One market's orders are placed one after the other, in the order given, and the markets side by side. A refused order does not stop the others.
  • A request the node cannot send at all fails whole, with the status CreateOrder would fail with: more than 500 orders, refused with FAILURE_REASON_MALFORMED_REQUEST before any is read, or the venue unreachable.
  • A batch that runs out of time fails whole with FAILURE_REASON_SERVER_DEADLINE and outcome_unknown: some of its orders may be placed.
  • Give each order a client_order_id to make the batch safe to resend: a resend gets each order's answer back and places none twice.

Cancel Order

Method: CancelOrder

Params: { order_id: string }

Response: { removed: bool, pending: bool } — removed is true when the cancel was accepted: the order is off the book and matches no further. With pending: false it is gone and its liquidity released.

removed: false is a successful call, not an error. It means there was nothing to cancel: the order had already filled, already been cancelled, or never existed. Treat it as "the order is not on the book", which is the state you were asking for either way.

pending: true means a fill against the order is still settling. Added 2026-09-20. The order stays listed — GetOrder / GetAllOrders return it with pending_cancel: true — and still reserves the in-flight portion until that fill settles, at which point OrderCanceled (or OrderCompleted, if the fill consumed it) arrives on the private stream. The rest of its liquidity is released at once. Nothing you do speeds this up: a second CancelOrder is accepted and changes nothing. Treat it as cancelled and wait for the terminal update before dropping it from your mirror.


Cancel Orders

(2026-10-29) Cancel several orders in one request.

Method: CancelOrders

Params: { order_ids: string[] }, at most 500.

Response: { results: CancelOrderResult[] }, one per ID in the order given: its order_id, and response (what CancelOrder answers) or error (a BatchItemError, for an ID that does not parse).

  • More than 500 IDs fails whole, as for CreateOrders.
  • A batch that runs out of time fails whole with FAILURE_REASON_SERVER_DEADLINE and outcome_unknown. Sending it again is safe, but an order the first attempt cancelled then reads removed: false.

Cancel All Orders

Cancel every open order belonging to the caller.

Method: CancelAllOrders

Params: none.

Response: empty.


Amend Order

(2026-10-29) Change a resting limit order in place, keeping its ID: its price, its total quantity, (2026-11-17) its max_capacity_fee, or any of them.

Method: AmendOrder

ParamTypeRequiredDescription
order_idstringYESA resting limit order of yours: TIME_IN_FORCE_GTC or TIME_IN_FORCE_POST_ONLY.
priceDecimalStringNOThe new limit price, positive, on the market's price grid. Unset keeps it.
quantityDecimalStringNOThe new total, positive, in the order's own unit (base or quote, as it was placed), on the market's amount grid: what it traded, what is settling and what it still offers. Unset keeps it.
crossingAmendCrossingNOWhat it does where its new price would cross an order on offer: see below.
max_capacity_feeDecimalStringNO(2026-11-17) The order's new budget for capacity on demand, in all (OrderSettlement.max_capacity_fee): at least what it has used (Order.capacity_fee_used), on the receiving currency's grid, on an order whose receive can settle in a channel; otherwise INVALID_ARGUMENT. The order keeps its place, and answers requeued: false. Unset keeps it. See Trading with no receiving capacity.

Name price, quantity or both, (2026-11-17) or max_capacity_fee: an amend naming none is refused with FAILURE_REASON_MALFORMED_REQUEST, as is a price that is not positive or is finer than the market's grid; a quantity that is not positive or is finer than the grid is refused with FAILURE_REASON_INVALID_AMOUNT. An order that is not open among yours, ended, unknown or another user's, is answered NOT_FOUND.

Response: one of amended { order, requeued, released? } (the order as GetOrder reads it now) or cancelled { pending }.

  • Queue place. A smaller total at the same price keeps the order's place, (2026-11-17) as a new budget alone does. A new price or a larger total moves it to the back of its price, as a new order would go, and answers requeued: true; it counts against your order rate as a new order does.
  • A total, not a change. On an order for 1.0 that traded 0.4, quantity: 0.8 leaves 0.4 on offer. The same amend sent again changes nothing, so a retry is safe.
  • A total at or below what the order traded and has settling cancels it: cancelled, with pending as CancelOrder answers it.
  • Across the book.
    crossingA GTC orderA post-only order
    unsettakesrefused
    AMEND_CROSSING_TAKEtakesrefused
    AMEND_CROSSING_REFUSErefusedrefused

    An amend that takes does as a new limit order would, at taker rates and with the order's own self_trade_prevention, and what is left rests at the back of its new price; released says what was not placed when the rest could not rest. A refused amend, amend_would_take, leaves the order as it was, at its place.
  • Refusals. order_not_resting for a market, swap, IOC, FOK or liquidity order, one matched in full or with a cancel pending; too_small_to_rest when what would be left on offer is under the smallest fill at its price; and what a new order meets for the amended terms, such as below_minimum or insufficient_capacity. See Placement rejections.
  • The private stream sends OrderUpdated with the amended order.
  • A hub whose venue does not amend orders answers UNIMPLEMENTED.

Amend Orders

(2026-10-29) Amend several orders in one request.

Method: AmendOrders

Params: { amends: AmendOrderRequest[] }, at most 500, each as AmendOrder takes it.

Response: { results: AmendOrderResult[] }, one per amend in the order given: its order_id, and response (what AmendOrder answers) or error (a BatchItemError). One market's amends run one after the other, in the order given, and the markets side by side.

  • An order is amended once per batch: a second amend of it in the same batch is refused with FAILURE_REASON_MALFORMED_REQUEST, so the same batch sent again changes nothing more.
  • More than 500 amends fails whole, as for CreateOrders.
  • A batch that runs out of time fails whole with FAILURE_REASON_SERVER_DEADLINE and outcome_unknown. Sending it again is safe, but an amend the first attempt made then reads requeued: false.

Get Order

Method: GetOrder

Params: { order_id: string }

Response: { order?: Order }. Returns empty when the order is not open: an order that has ended is not returned.

Order — the persisted form

The Order message is a oneof over PairOrder (limit / market / liquidity) and SwapOrder (cross-currency), plus the client_order_id you supplied and whether a cancel is waiting on a settling fill:

Order {
  oneof order {
    PairOrder pair_order = 1;     // limit_order | market_order | liquidity_order
    SwapOrder swap_order = 2;
  }
  optional string client_order_id = 3;
  bool pending_cancel = 4;        // added 2026-09-20, see Cancel Order; only a limit or liquidity order is ever pending a cancel
  DecimalString listed_amount = 5; // 2026-11-17: how much of the order the public book shows now, in its remaining_amount's unit
  optional DecimalString max_capacity_fee = 6; // 2026-11-17: its budget for capacity on demand
  DecimalString capacity_fee_used = 7;         // 2026-11-17: what its fills paid or hold of it
}
  • listed_amount (2026-11-17): the book shows each resting order only as far as a taker would match it now, in the unit of the order's remaining_amount. What remains of it, capped by what the hub can pay you on its receiving side now: your receiving capacity, plus capacity on demand while what is left of the order's budget covers on_demand_fee_bound. On one market your orders receiving the same currency share that capacity, best price first; each market's book lists against all of it. "0" while nothing would match: the hub can pay you nothing there now. The order is kept and shows again when it would match. Unset on an order that does not rest. Below what the order has on offer, it moves in whole smallest fills at the order's price, so it changes only when what the hub can pay you crosses a whole fill. It is not a fill: fills arrive as MatchedOrder events and move the order's sold and bought amounts.
  • max_capacity_fee, capacity_fee_used (2026-11-17): the order's budget for capacity on demand, as placed or last amended, unset for an order placed without one; and what its fills paid for capacity on demand, with what its swaps in flight hold of the budget, "0" when none. Both are in the currency it receives. See Trading with no receiving capacity.
  • PairOrder is a oneof of LiquidityOrder (passive provision), LimitOrder (fixed price), or MarketOrder (best-available).
  • SwapOrder carries from_currency / currency_path[] / to_currency and detailed fill / fee accounting. (2026-10-29) Its bought_to_currency_amount is what its swaps delivered, net of the venue's fee and before the on-chain fee each charged, which its ClientSwapTrade.onchain_fee itemises. An order sized by what it receives (to) whose legs settle on chain is matched for its target plus one swap's on-chain fee, and counts that in remaining_amount.
  • Each order type's view carries its own terms, as placed: a LimitOrder its time_in_force (7) and self_trade_prevention (8), a MarketOrder its self_trade_prevention (8) and limit_price (9), a SwapOrder its self_trade_prevention (11) and, (2026-11-17), its limit_amount (12), unset for no limit. A value your client does not know reads as the unspecified one.
  • (2026-11-25) A SwapOrder's unclaimed_to_currency_amount (13) is, of bought_to_currency_amount, what its swaps paid you that you never claimed: zero when everything reached you. Zero as well for an order whose swaps settled before the venue recorded receives: read that as received, as RECEIVE_OUTCOME_UNSPECIFIED is. Each such swap reads RECEIVE_OUTCOME_UNCLAIMED on its ClientSwapTrade.receive_outcome.

Field-level shapes are in orderbook.proto — they're long, exhaustive, and best read there rather than mirrored here.

⚠️ LimitOrder (and friends) — same name, different shape on request vs response

The proto reuses the names LimitOrder / MarketOrder / SwapOrder for two distinct messages:

  • The request form is OrderVariant.LimitOrder (nested under OrderVariant) — it carries the order spec you submit to CreateOrder / EstimateOrder.
  • The response / persisted form is the top-level LimitOrder — it carries the order as it lives in the orderbook, with created_at, remaining_amount, and a variant: OrderSideVariant field instead of a flat OrderSide side.

The two have non-trivially different fields. In particular, the response form's variant is itself a oneof (OrderSideVariant) of Buy { bought_base_amount, sold_quote_amount, paid_base_fee } or Sell { sold_base_amount, bought_quote_amount, paid_quote_fee }. A response LimitOrder does not carry a flat side: OrderSide field — WhichOneof('side') on variant is the discriminator, and the fill / fee accounting fields differ per side.

In practice:

  • When writing an order, you reference the nested OrderVariant.LimitOrder (see Create Order → OrderVariant).
  • When reading an order back, you reference the top-level LimitOrder (this section).
  • Same applies to MarketOrder and SwapOrder.

Some clients (e.g. when generated Python imports both into one namespace) will alias-collide here; rename or scope the imports to keep the two distinct.


Get Order By Client Id

Added 2026-05-03. Pair with idempotent order creation.

Method: GetOrderByClientId

Params: { client_order_id: string }

Response: { order?: Order }. Empty when no open order matches — including an id that names an order that has ended, which it keeps naming at CreateOrder for the retention period.


Get Own Orders

The caller's open orders for one pair.

Method: GetOwnOrders

Params: { base: OrderbookCurrency, quote: OrderbookCurrency }

Response: { orders: map<string, Order> } — keyed by order_id.


Get All Own Orders

The caller's open orders across every pair.

Method: GetAllOwnOrders

Params: none.

Response: { orders: map<string, Order> } — keyed by order_id.


Get Trade History

Public trade history for one market — anyone trading the pair, paginated.

Method: GetTradeHistory

Params: { base: OrderbookCurrency, quote: OrderbookCurrency, pagination?: PaginationRequest } — (2026-11-25) pagination is optional: absent, the first page, of the default size

Response: { trade_history: Trade[], pagination: PaginationResponse }, newest first: (2026-10-29) by when each trade settled.

The field is trade_history, not trades — only the caller's own trade calls (GetPairMarketTrades, GetPairSwapTrades) use trades.

Trade:

FieldTypeDescription
taker_order_idstringThe order that crossed the book
base_amountDecimalStringBase amount of the fill
quote_amountDecimalStringQuote amount of the fill
priceDecimalStringPre-fee execution price
final_priceDecimalStringAfter-fee effective price
timestampTimestampWhen the engine matched the fill and fixed its price
maker_order_sideOrderSideThe maker side of the trade
trade_iduint64(2026-10-29) The trade's number on its market: the same here and on SubscribeMarketEvents, rising with settled_at, (2026-11-25) and on your own fill of it, as ClientMarketTrade.trade_id. In JSON a decimal string
settled_atTimestamp(2026-10-29) When the fill's swap settled and the trade became public

(2026-10-29) A trade is public once its swap settles, and settled_at is that time. Trade history is ordered by it, and candles and 24-hour figures are filed by it, so a candle never changes after it closed. timestamp stays the match time. A trade that settled more than one minute after its match, longer than the shortest candle, counts in volumes and trade counts but sets no price: no candle open, high, low or close, no last price and no 24-hour price figure, unless the market has no price yet. Key trades by trade_id: a market's numbers rise with settled_at, though not one by one.


Get Pair Market Trades

The caller's market trades for one pair.

Method: GetPairMarketTrades

Params: { base: OrderbookCurrency, quote: OrderbookCurrency, pagination?: PaginationRequest } — (2026-11-25) pagination is optional: absent, the first page, of the default size

Response: { trades: ClientMarketTrade[], pagination: PaginationResponse }.

ClientMarketTrade:

FieldTypeDescription
swap_idstringThe DEX swap ID backing the fill
order_idstringCaller's order that produced the fill
base_amount, quote_amountDecimalStringFilled volumes
base_feeDecimalStringThe fill's fee on the base side, charged to whoever received base
quote_feeDecimalStringThe fill's fee on the quote side, charged to whoever received quote
price, final_priceDecimalStringPre- and after-fee prices
timestampTimestampWhen the engine matched the fill and fixed its price
order_sideOrderSideSide of the caller's order
order_typeOrderTypeORDER_TYPE_LIMIT / ORDER_TYPE_MARKET / ORDER_TYPE_LIQUIDITY
role (2026-09-19)TradeRoleTRADE_ROLE_MAKER or TRADE_ROLE_TAKER — which side of the fill the caller was on
settled_atTimestamp(2026-10-29) When the fill's swap settled. The caller's trades are ordered by it
capacity_feeDecimalString(2026-11-17) This fill's share of the capacity fee its swap's receive paid, in the currency you received, a deposit's fee paid in advance included; the shares add up to it. 0 when none. See Receiving on demand
receive_outcomeReceiveOutcome?(2026-11-25) What reached you of this fill's proceeds — see ReceiveOutcome below. Absent when the venue recorded no outcome for the trade: read it as received
sending_recordLegRecord?(2026-11-25) Your node's record of what you sent in this fill's swap, on the network of the currency you sent in that swap. Every fill of a swap you took carries the swap's records
receiving_recordLegRecord?(2026-11-25) Your node's record of what you received in this fill's swap, on the network of the currency you received in that swap
prepay_recordLegRecord?(2026-11-25) Your node's record of the prepay the swap asked of you, on the network of the currency you sent. Absent when the swap asked none
trade_iduint64(2026-11-25) The fill's trade id: the id the market's public trades show it under, unique within the market — Trade.trade_id in GetTradeHistory and on SubscribeMarketEvents, id on the market data's /api/v1/trades and t on its @trade. Both parties of the fill see the same one; with role it identifies this fill. In JSON a decimal string
receive_capacity_kindReceiveCapacityKind?(2026-11-25) How your receive in this fill's swap got its capacity, which says what capacity_fee is — see ReceiveCapacityKind below. Absent when the venue recorded none for the trade
capacity_fee_recordLegRecord?(2026-11-25) Your node's record of the payment of a prepaid deposit's fee (RECEIVE_CAPACITY_KIND_PREPAID_DEPOSIT), on the network of the currency you received. The fills of one receive share it. Absent otherwise

Only one of the two fee columns is yours. A fill has two sides and both are priced, so every record carries both figures: the base fee belongs to whoever received base, the quote fee to whoever received quote. On a BUY you received base, so base_fee is yours and quote_fee is your counterparty's — it moved no balance of yours. On a SELL it is the other way round. Summing both columns double-counts a fee you never paid.

The sign is not the role. Positive means the fee was taken, negative that it was credited back — nothing more. The operator sets a market's maker and taker rates independently, and either may be negative, zero or positive; the only constraint is that the maker rate never exceeds the taker rate. role is what says which of the two your fee was struck at — the one on the side you received. The other column is your counterparty's, struck at the opposite role's rate. Without role, neither may be inferred.

TradeRole: TRADE_ROLE_MAKER (1) — your resting order was filled. TRADE_ROLE_TAKER (2) — your order crossed the book. TRADE_ROLE_UNSPECIFIED (0) means the role is not being reported: the hub could not classify the stored fill.

ReceiveOutcome (2026-11-25): what reached the party of a settled trade's proceeds. RECEIVE_OUTCOME_RECEIVED (1) — the party claimed the payment the trade owed it. RECEIVE_OUTCOME_UNCLAIMED (2) — the trade stands, but the party never claimed the payment it was owed before that payment's deadline: nothing of the proceeds reached it. RECEIVE_OUTCOME_UNSPECIFIED (0) is never sent: a trade the venue recorded no outcome for has no receive_outcome.

ReceiveCapacityKind (2026-11-25): how a trade's receive got its capacity, which says what its capacity_fee is. RECEIVE_CAPACITY_KIND_CHANNELS (1) — over your channels with the hub as they were: no capacity bought, and capacity_fee is zero. RECEIVE_CAPACITY_KIND_ON_DEMAND (2) — over a JIT channel your node bought for the receive: capacity_fee is its fee, and the payment you received was net of it. RECEIVE_CAPACITY_KIND_PREPAID_DEPOSIT (3) — over a deposit you prepaid: capacity_fee is the deposit's fee, which you paid apart (capacity_fee_record names that payment), and the payment you received is the whole receive. RECEIVE_CAPACITY_KIND_UNSPECIFIED (0) is never sent: a trade the venue recorded none for has no receive_capacity_kind.

LegRecord

(2026-11-25) The record your node keeps of one leg of a swap, by the key that record carries. Exactly one arm is set:

ArmPayloadThe record
payment (1){ lock_word: LockWord }Your payments over a channel locked under lock_word, every attempt included: your GetPayments by their lock_word, or, for a hash lock, GetPaymentsByHash with lock_word.hash
lock (2){ lock_id: string }A lock on chain: your transactions whose lock operation — lock, claim or refund — carries lock_id (an HtlcOperation's htlc_id), in GetTransactions. On Bitcoin txid:vout, on EVM and Tron the contract's 32-byte id
settlement (3){ txid: string }The one transaction that settled both legs of a same-chain swap: your transaction whose id it is. No swap carries it yet

LockWord (lock.proto): what a lock or a payment is locked under. Exactly one arm is set: hash (1), a hash lock, the SHA-256 of a 32-byte secret in hex, the same string as the hash of a payment locked under it; or point (2), a point lock, the lock's point in hex as its network encodes it (on EVM and Tron the 20-byte address of the point), which no lock carries yet. Both are hex strings in gRPC and in JSON alike.

capacity_fee_record names the payment of a prepaid deposit's fee the same way, as a payment.

Join a trade to what settled it by these records, not by amounts or times. Look each record up on the network of its currency: a payment by its lock word, a lock by its id, a settlement by its transaction. A trade the venue holds no records for carries none: show its payments and transactions on their own. A simple swap's trades are those whose order_id is in its order_ids. (2026-11-25) Key a fill by its market, trade_id and role.


Get All Market Trades

The caller's market trades across every pair. Same response shape as GetPairMarketTrades.

Method: GetAllMarketTrades

Params: { pagination?: PaginationRequest } — (2026-11-25) pagination is optional: absent, the first page, of the default size

Response: { trades: ClientMarketTrade[], pagination: PaginationResponse }.

This is the complete fill history, in both roles — reconcile balances against it. One record per fill, whether you took it or your resting order made it. Its sibling GetAllSwapTrades records takers only, so a history built from that feed alone is short by every fill you made.


Get Pair Swap Trades

The caller's multi-currency swap trades for one (from, to) pair.

Method: GetPairSwapTrades

Params: { from_currency: OrderbookCurrency, to_currency: OrderbookCurrency, pagination?: PaginationRequest } — (2026-11-25) pagination is optional: absent, the first page, of the default size

Response: { trades: ClientSwapTrade[], pagination: PaginationResponse }.

ClientSwapTrade:

FieldTypeDescription
swap_idstringDEX swap ID
order_idstringCaller's order that produced the swap
from_currency_amountDecimalStringAmount sent in the source currency
to_currency_amountDecimalStringThe final hop's output before its own fee — see below
to_currency_feeDecimalStringFee taken on the final hop, in the destination currency
timestampTimestampWhen the engine matched the swap's first fill
settled_atTimestamp(2026-10-29) When the swap settled. The caller's swaps are ordered by it
onchain_feeDecimalString(2026-10-29) What the swap charged for the hub's on-chain steps, in the destination currency — see below. 0 when every leg settled in a channel
capacity_feeDecimalString(2026-11-17) What your receive paid for on-demand capacity, in the destination currency: the fee of the JIT channel it was paid net of, or of the deposit paid for in advance. 0 when it needed none. See Receiving on demand
receive_outcomeReceiveOutcome?(2026-11-25) What reached you of what this swap paid you: RECEIVE_OUTCOME_UNCLAIMED when the payment owed to you went unclaimed past its deadline. The trade stands and its amounts are as matched; nothing of them reached you. Absent when the venue recorded no outcome for the trade: read it as received. See ReceiveOutcome
sending_recordLegRecord?(2026-11-25) Your node's record of what you sent in this swap, on the network of from_currency
receiving_recordLegRecord?(2026-11-25) Your node's record of what you received in this swap, on the network of to_currency
prepay_recordLegRecord?(2026-11-25) Your node's record of the prepay the swap asked of you, on the network of from_currency. Absent when the swap asked none
receive_capacity_kindReceiveCapacityKind?(2026-11-25) How your receive got its capacity, which says what capacity_fee is. Absent when the venue recorded none for the trade. See ReceiveCapacityKind
capacity_fee_recordLegRecord?(2026-11-25) Your node's record of the payment of a prepaid deposit's fee (RECEIVE_CAPACITY_KIND_PREPAID_DEPOSIT), on the network of to_currency. Absent otherwise

You received to_currency_amount − to_currency_fee − onchain_fee − capacity_fee, not to_currency_amount. The final hop's fee is still to be subtracted. Every earlier hop's fee already is: each hop hands the next its net proceeds, so a route's intermediate costs are baked into this figure and are not subtracted again. A deposit's capacity_fee is paid in advance, the receive itself then carrying to_currency_amount − to_currency_fee − onchain_fee. (2026-11-25) receive_capacity_kind says which: RECEIVE_CAPACITY_KIND_PREPAID_DEPOSIT for a deposit paid in advance, RECEIVE_CAPACITY_KIND_ON_DEMAND for a receive paid net of the fee. (2026-11-25) A swap whose receive_outcome is RECEIVE_OUTCOME_UNCLAIMED stands as matched, and nothing of it reached you.

onchain_fee is what the swap charged for the steps the hub took on chain for your legs that settled there: locking your receive, claiming it for you and refunding the lock if the swap failed, and claiming your on-chain send. The venue prices them from the hub's estimate for each network at the match, at its margins, and charges them in the currency you receive. It is not part of to_currency_fee: it rides the matched order's route, folded into the last SwapHop.receiving_fee.

A routed swap therefore pays a fee at every hop, and only the last one appears here. The earlier ones are charged in their own hops' currencies and itemised, one per hop, by the ClientMarketTrade records sharing this swap_id. Totalling to_currency_fee across a route understates what you paid.


Get All Swap Trades

The caller's swap trades across every (from, to) pair. Same shape as GetPairSwapTrades.

Method: GetAllSwapTrades

Params: { pagination?: PaginationRequest } — (2026-11-25) pagination is optional: absent, the first page, of the default size

Taker only, and one record per swap — not per fill. A swap is recorded against the caller whose order crossed the book. A fill your resting order made has no record here and never will; it appears in GetAllMarketTrades with role = TRADE_ROLE_MAKER. The two feeds look like mirrors for a caller that only ever takes, which is exactly how the difference gets missed: a limit order that crosses on arrival and rests with its remainder produces taker fills in both feeds and a later maker fill in one. Build accounting from GetAllMarketTrades; use this feed for the taker's cross-currency view of a route.


Subscribe Market Events

Public market data for one pair — orderbook deltas, trades, daily stats, candlesticks. Server-streaming.

Method: SubscribeMarketEvents

Params: { base: OrderbookCurrency, quote: OrderbookCurrency }

Stream of MarketEvent:

MarketEvent {
  oneof update {
    bool is_synced = 1;
    OrderbookUpdate orderbook_update = 2;   // {updated_orders, removed_orders}
    Trade trade_update = 3;                 // public Trade
    MarketDailyStats daily_stats_update = 4;
    CandlestickUpdate candlestick_update = 5;
    VenueStatus venue_status = 6;           // the hub entered or left maintenance
    MarketInfo market_info = 7;             // this market's configuration, full state
  }
  google.protobuf.Timestamp timestamp = 8;  // when it was sent: the hub's time, your node's on is_synced
}

Market data arrives once a second. The hub publishes each market's changes over a second together: an order changed several times within it appears once, at its latest state, so a change reaches you up to about a second after the hub made it. (2026-10-14) Every event carries timestamp: when the hub sent it, by its clock, so every change in it was made before then; on is_synced, your node's time. venue_status is sent at once, and your own activity on SubscribeDexEvents is not batched. See Delivery cadence.

Subscribe before you act. If you place an order before the stream attaches, you can miss the fill notification. See Streaming guide.

Read the market again on is_synced: true. is_synced: false then true arrives whenever the feed re-syncs, and also when the node's relay of the market fell so far behind the feed that events were dropped: the market may have changed meanwhile, and the stream carries on only from then.

Every stream opens with the market's sync state: is_synced: true when the market is synced, is_synced: false while it is not — the market's own is_synced: true follows once it is done. Read the market's current state once the stream is open — GetOrderbook, GetMarketDailyStats — and apply the stream's events from then on.

Any number of clients can subscribe to the same pair: each stream gets every event of the market, whoever else is watching it, whichever way round it names the pair. A pair not initialised yet is not an error: the stream stays open, and opens once the market is — by any client's InitMarket, or by the node itself.

Available over gRPC as a server-stream, or over JSON-RPC as a WebSocket subscription (orderbook_subscribeMarketEvents). A one-shot HTTP POST cannot carry it.


Subscribe DEX Events

Your personal account activity — balance updates, order lifecycle, fills, ongoing swap progress. Server-streaming.

Method: SubscribeDexEvents

Params: none.

Stream of DexEvent:

DexEvent {
  google.protobuf.Timestamp timestamp = 1;
  oneof update {
    bool is_synced = 2;
    BalanceUpdate balance_update = 3;
    OrderUpdate order_update = 4;     // OrderCreated / OrderUpdated / OrderCompleted / OrderCanceled
    MatchedOrder order_matched = 5;
    SwapUpdate swap_update = 6;
    MarketTradeUpdate market_trade_update = 7;
    SwapTradeUpdate swap_trade_update = 8;
    FeeDiscountStanding fee_discount_update = 9;   // 2026-09-03
  }
}

MarketTradeUpdate carries a ClientMarketTrade (same shape as GetPairMarketTrades); SwapTradeUpdate carries a ClientSwapTrade. Use these to populate a live "my trades" view. (2026-11-25) Each carries its trade's leg records, so a trade joins what settled it as it arrives. A fill's MarketTradeUpdate comes once the fill is public on its market, under its trade_id; one made public later is not sent, and the trade lists carry it.

fee_discount_update (2026-09-03) carries the full FeeDiscountStanding — your fee-discount standing changed, in either role. The hub opens this stream with your standing and pushes the whole standing again whenever it moves, so silence means unchanged and the last message received is the one to hold. Nothing needs to poll GetFeeDiscount; a dropped stream heals by reconnecting into a fresh opening standing. Refresh any displayed rates — and any cached GetMarketFeeRates — when one arrives.

Same two transports as SubscribeMarketEvents — gRPC server-stream, or the orderbook_subscribeDexEvents WebSocket subscription.


Common pitfalls

SymptomCauseFix
Invalid sending currency: Conversion errorUsed assetId: "BTC" or mixed-case ERC20:0xAbC…Use the canonical forms — see asset_id format
Order placed, no fill eventsSubscribed to SubscribeMarketEvents (or SubscribeDexEvents) after placing the orderSubscribe at startup, then act
Two orders placed after a DEADLINE_EXCEEDED retryCreateOrder is not idempotent without client_order_idAlways set client_order_id on retry-prone paths
FAILED_PRECONDITION with post_only_would_crossA post-only order (or any limit order on a MARKET_STATE_POST_ONLY market) would have taken an order on offerRe-price it so it does not cross — below best for a bid, above it for an ask
FAILED_PRECONDITION with self_trade_preventedThe order's self_trade_prevention stopped it at your own resting order resting_order_id before it filled anythingCancel or move that order, or place with SELF_TRADE_PREVENTION_CANCEL_MAKER
FAILED_PRECONDITION with below_best_fillThe best order the order can take has a smallest fill (min_fill, at price) larger than what the order hadRe-place larger, or at a price that does not cross price — see Price priority
FAILED_PRECONDITION with insufficient_capacity on an order sized to your whole receivingA limit order holds what it receives in full at the market's max_maker_discount, so a maker rebate adds to it, and every order of yours that receives a currency on one market shares one receiving (on several markets, see Sizing an order to fit your balance)Size by Sizing an order to fit your balance
FAILED_PRECONDITION with insufficient_capacity (leg=receiving) or maker_unavailable on an order that would trade (2026-10-14; before: Hub cannot forward this swap: …)The order would trade, and the hub's channel to a party it would pay cannot carry that payment now, given what is already in flight: yours (insufficient_capacity), or a maker's (maker_unavailable, which names no maker). Market orders, swaps and limit orders that cross the book are refused alike. (2026-11-17) A maker that cannot receive a fill is passed over and the next maker fills the order, so maker_unavailable means no maker of the book can take this order nowRetry later or smaller; a limit order priced not to cross rests instead
FAILED_PRECONDITION with capacity_fee_above_max (2026-11-17)The hub prices the order's receive at capacity_fee, more than what is left of its budget, max_capacity_fee: at the match, or, for a swap order sized by what it receives (to), in the quote your node took when you placed itPlace it again with a budget that covers capacity_fee, or once the hub's price has come down. See Trading with no receiving capacity
FAILED_PRECONDITION with swap_limit_unmet (2026-11-17)The venue would fill the swap order past its limit_amount: got against limit, for the part of the order the match fillsRead the book again and place it with a limit it can meet, or wait for the book to move
FAILED_PRECONDITION with channel_slot_busy (2026-11-03)The order could not start now; nothing was startedSend it again shortly
FAILED_PRECONDITION with capability_required (2026-11-17)The liquidity the order matched settles in a way your build of Hydra App does not followUpdate Hydra App
A limit order placed smaller than you asked, released in the answerIt filled part at once and the rest would have rested across an order it is too small for, its self-trade rule stopped it, the rest was too small to rest at its own price (too_small_to_rest), or, (2026-11-17), the rest would have rested across orders its swap could not settle for want of receiving capacity (insufficient_capacity)Read released; place the rest again if you still want it and it is large enough to rest
A market or swap buy with a quote budget refused with below_best_fill at the market minimumThe smallest fill is whole lots: where min_quote_amount sets it, it is worth that or up to a lot moreSpend at least min_fill — see Two different minimums
ALREADY_EXISTS with client_order_id_taken on a new orderThe client_order_id still names an earlier order — live, or ended within the retention periodUse a fresh client_order_id for every new order; resend the earlier order unchanged to get its answer back
Streaming call returns -32603 Internal error via JSON-RPCSubscribed over a one-shot HTTP POST, which cannot carry a streamOpen a WebSocket to the same URL and subscribe there — see Subscriptions over WebSocket — or use gRPC
Bot decodes SwapRole integer 0 as takerSwapRole was renumbered on 2026-05-03 (TAKER moved 0 → 3)Re-map persisted integers; or compare against the string form
Fees charged don't match what you computedDerived your fee from MarketInfo's list rates, or applied listed × (1 − discount) to a maker rebateCall GetMarketFeeRates. The formula is listed − discount × |listed| — signed, so a rebate deepens
A maker rebate came out smaller after earning a tierSame sign bug, in the arithmeticSee the arithmetic
Bot reads a fill amount as zero or as the wrong currencyRead OrderAmount.base.amount (or .quote.amount) without checking which variant is setOrderAmount echoes the denomination you placed the order in — always discriminate on the oneof variant, not on side. Confusing the per-order remaining/unmatched/failed_amount with the public LiquidityPosition.amount (which is base-on-sell / quote-on-buy) leads to the same bug. See the OrderAmount callout
Buy-side LimitOrder fields look empty in the responseMixed up the request-form OrderVariant.LimitOrder (has flat side) with the response-form top-level LimitOrder (has variant: OrderSideVariant oneof)See LimitOrder request vs response — read variant.buy / variant.sell on responses

See also


Copyright © 2025