Skip to content

feat(docs): add Orderbook integration page#314

Draft
JohnnyWyles wants to merge 2 commits into
mainfrom
feat/orderbook-integration-docs
Draft

feat(docs): add Orderbook integration page#314
JohnnyWyles wants to merge 2 commits into
mainfrom
feat/orderbook-integration-docs

Conversation

@JohnnyWyles
Copy link
Copy Markdown
Collaborator

@JohnnyWyles JohnnyWyles commented May 13, 2026

New page at docs/overview/integrate/orderbook.md documenting the sumtree-orderbook CosmWasm contract as an integration surface for the Osmosis docs site.

What the page covers

  • Discovery onchain: SQS /pools, the x/cosmwasmpool queries, and direct contract addressing.
  • Instantiation parameters (base_denom, quote_denom), with explicit documentation that the admin is hardcoded to the Osmosis governance module account and the moderator is hardcoded to a DAODAO circuit-breaker subDAO at compile time (verified via constants.rs and a live auth.admin / auth.moderator query against pool 1930).
  • Placing, cancelling, and claiming orders with osmosisd tx wasm execute examples for place_limit, cancel_limit,
    claim_limit, and batch_claim. The place_limit example uses claim_bounty: "0.0001" to match the hardcoded value in
    osmosis-frontend/packages/web/hooks/limit-orders/use-place-limit.ts.
  • Querying state — every query verified against pool 1930 on mainnet:
    • Pool-compatible: spot_price, calc_out_amount_given_in, get_total_pool_liquidity, get_swap_fee.
    • Orderbook-specific: denoms, orderbook_state (documented with its actual flat-field response shape), is_active,
      all_ticks, ticks_by_id, orders_by_owner and orders_by_tick (both with the { orders, count } response shape),
      get_maker_fee, get_unrealized_cancels.
  • Routing through SQS, sourced from routable_cw_orderbook_pool.go and pools_usecase.go rather than the SQS README:
    • SQS recognises an orderbook by matching code_id against the configured OrderbookCodeIDs list. New contract instances from an existing code id are picked up automatically.
    • The canonical-orderbook concept (highest-liquidity contract per pair), with the public /pools/canonical-orderbook and
      /pools/canonical-orderbooks endpoints.
    • SQS quotes orderbook swaps in-process by walking ticks via TickToPrice; it does not call the contract at quote time. The fill
      is a standard osmosis.poolmanager.v1beta1.MsgSwapExactAmountIn.
    • The "register your code id with SQS" caveat is narrowed: it only applies to brand-new orderbook code ids, not new contract
      instances.
  • Admin and moderator messages, sourced from auth.rs and reconciled against the ensure_is_* checks in each dispatcher.
    Documents the full admin/moderator/offered-address message surface plus the auth namespace. Notes the inconsistency where set_maker_fee and set_maker_fee_recipient are admin-only despite appearing in the enum's "Shared messages" section.

Sources

Every claim on the page was verified against either the live contract on pool 1930 (via direct LCD queries) or the upstream
Osmosis-labs source:

  • osmosis-labs/orderbookcontracts/sumtree-orderbook/src/{msg.rs,auth.rs,order.rs,constants.rs}
  • osmosis-labs/orderbook-claimbot — README and inspector source for the claim-bot scanning algorithm
  • osmosis-labs/sqsrouter/usecase/pools/routable_cw_orderbook_pool.go, pools/usecase/pools_usecase.go, domain/config.go
  • osmosis-labs/osmosis-frontendpackages/web/hooks/limit-orders/use-place-limit.ts for the live claim_bounty constant

Notes for the reviewer

Verification

  • yarn build clean.
  • Every query example verified live against pool 1930 (allBTC/USDC).
  • Admin and moderator addresses verified against auth { admin: {} } / auth { moderator: {} } on pool 1930.
  • Reviewer spot-check that the place_limit example reads correctly — --amount must match quantity of the side's
    collateral denom (quote for bids, base for asks)

Document the sumtree-orderbook CosmWasm contract as an integration
surface: how to discover live orderbook markets, place / cancel /
claim orders, query book state, and route swaps through SQS.

Content sourced from:

- osmosis-labs/orderbook contract source
  (contracts/sumtree-orderbook/src/msg.rs) for the ExecuteMsg and
  QueryMsg surface.
- osmosis-labs/orderbook-claimbot README for the batch_claim flow
  and scanning logic.
- osmosis-labs/sqs router/usecase/pools/routable_cw_orderbook_pool.go
  for the routing integration shape.

Notes on what was deliberately not included:

- No specific contract addresses. Orderbook markets are governance-
  instantiated CosmWasm contracts that rotate over time; the page
  tells integrators to read live SQS pools or chain state at
  submission time.
- No specific code IDs for the same reason.
- The two cross-references to the SQS integration page use absolute
  https://docs.osmosis.zone URLs because the SQS page lives on a
  parallel PR and is not yet on main. The URLs will resolve once
  that PR lands and can be relativised then.

sidebar_position: 14 (next to sqs.md / rpc.md / rest.md / grpc.md,
the API-integration cluster).
A pass through the page running every documented query against pool
1930 on mainnet and reading the SQS Go source (instead of READMEs)
surfaced several errors:

- place_limit example uses claim_bounty 0.0001 (matching the Osmosis
  frontend's hardcoded value in use-place-limit.ts) instead of an
  inflated example.
- calc_out_amt_given_in renamed to calc_out_amount_given_in - the
  former does not exist on the deployed contract (code id 885), the
  variant in source is the only one currently usable.
- orderbook_state response shape corrected to the actual flat fields
  (quote_denom, base_denom, current_tick, next_bid_tick,
  next_ask_tick) instead of describing it as the full Orderbook
  struct.
- orders_by_owner and orders_by_tick now document the
  { orders, count } response shape.
- Routing through SQS rewritten from sqs/router/usecase/pools/
  routable_cw_orderbook_pool.go and pools_usecase.go: SQS walks
  ticks in-process via TickToPrice rather than calling
  calc_out_amount_given_in at quote time; orderbooks are auto-
  discovered by matching code_id against the OrderbookCodeIDs
  config list, so new instances from existing code ids need no
  operator action; documents the public canonical-orderbook and
  canonical-orderbooks endpoints; narrows the "register your code
  id" caveat to brand-new code ids only.
- Admin and moderator section rewritten from auth.rs. Now lists the
  full message surface (transfer_admin, cancel_admin_transfer,
  claim_admin, reject_admin_transfer, renounce_adminship,
  offer_moderator, claim_moderator, reject_moderator_offer,
  set_active, set_maker_fee, set_maker_fee_recipient) and assigns
  each to its actual caller role per the ensure_is_* checks.
  Specifically: set_maker_fee and set_maker_fee_recipient are
  admin-only despite living in the enum's "Shared messages" section
  (the source comment was misleading); set_active is the only
  truly shared message.
- Instantiation section now documents that admin (Osmosis governance
  module account) and moderator (DAODAO circuit-breaker subDAO)
  are compile-time constants set in constants.rs, ignoring
  info.sender. The instantiating address gets no special privilege.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 13, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment May 13, 2026 11:17am
stage-docs Ready Ready Preview, Comment May 13, 2026 11:17am

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant