Skip to content

feat(deepbook-predict): add DeepBook Predict TypeScript SDK#1126

Draft
tonylee08 wants to merge 1 commit into
mainfrom
tlee/deepbook-predict-sdk
Draft

feat(deepbook-predict): add DeepBook Predict TypeScript SDK#1126
tonylee08 wants to merge 1 commit into
mainfrom
tlee/deepbook-predict-sdk

Conversation

@tonylee08

Copy link
Copy Markdown
Contributor

Summary

  • New standalone @mysten/deepbook-predict package wrapping the Predict protocol (on-chain European cash-settled range digitals). Mirrors the @mysten/deepbook-v3 two-layer anatomy (generated bindings + hand-written builders/queries/client).
  • Codegen (@mysten/codegen): bindings for deepbook_predict + account + propbook in src/contracts/**, used as the BCS-schema source. Regenerate with pnpm codegen.
  • Order-id codec (types/orderId.ts): TS mirror of deepbook_predict::order (packed u256, 196 bits) — the Move module exposes no public accessors, so the SDK replicates the packing.
  • Transaction builders: trader (account custody, loadLivePricer, mint/redeem, predict_account builder codes), LP (plp supply/withdraw requests + cancel, DEEP stake, loss-rebate, sponsor), and the keeper fullFlush (single-PTB hot-potato sequence).
  • Queries: on-chain MarketQueries / VaultQueries (via client.core.simulateTransaction) + propbook feed resolution, and a typed IndexerClient for predict-server. PredictClient facade + predict() $extend registration.
  • Scope (v1): trader + LP; oracle read-only; slippage-guard trading (no off-chain quote previewer).

Key decisions

  • Standalone package (not folded into deepbook-v3): Predict has no Move dependency on deepbook and a separate, pre-launch release cadence.
  • Tx layer uses the generated thunks (via tx.add) instead of hand-written tx.moveCall({target}). This diverges from deepbook-v3's tx idiom by design: the thunks auto-inject Clock, normalize args in the exact Move param order, and resolve the (unpublished) package id via a package override from PredictConfig.ids.
  • Pre-publish config: Predict isn't deployed, so there's no per-network id block; PredictConfig requires explicit ids. Testnet is the initial target; real ids get filled at deploy.
  • Account/position/history reads use the indexer, not on-chain: account::balance and the predict_account getters take &Account, a borrow that can't cross PTB commands from a shared AccountWrapper. Market/vault getters take their object directly, so those reads are on-chain.
  • No changeset yet (new 0.0.0 package, not being published in this PR).

Test plan

  • pnpm codegen regenerates src/contracts/** (sui move summary + codegen) cleanly
  • tsc --noEmit passes
  • vitest run — 33 tests: order-id codec (reference-packing, round-trip, rejections), tx arg-shaping (incl. the full-flush hot-potato sequence), query decode via a stub client, indexer URL building
  • oxlint clean (0 warnings / 0 errors)
  • tsdown bundle builds (esm + .d.mts)
  • Integration test against a live Predict deployment — blocked on the testnet deploy (no published package/object ids yet)

🤖 Generated with Claude Code

New standalone `@mysten/deepbook-predict` package wrapping the Predict
protocol (European cash-settled range digitals): codegen bindings, the
packed-u256 order-id codec, trader + LP + keeper transaction builders,
on-chain + indexer queries, and the `PredictClient` facade.

Pre-launch (0.0.0): Predict is not yet deployed, so `PredictConfig` takes
explicit `ids`; oracle is read-only and there is no off-chain quote
previewer in this first cut.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 1, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
sui-typescript-docs Error Error Jul 1, 2026 7:38pm

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