phasis.
Phasis Docs
Developers

SDK overview & install

Install @phasis-lab/sdk and start building on the Phasis on-chain options protocol.

Overview

@phasis-lab/sdk is the official TypeScript SDK for integrating with the Phasis on-chain options protocol on Sui. It provides:

  • Transaction builders — typed PTB (programmable transaction block) helpers for every user-facing Move entry: open account, deposit, place trade, cancel order, withdraw.
  • Read views — async functions for fetching registry state, market data, series rows, accounts, orderbook levels, and stress snapshots via Sui gRPC/GraphQL.
  • Domain types — TypeScript mirrors of Move enums and structs (TradeIntent, DeepBookSide, OrderType, StrikeKey, positions, pending orders).
  • Encoding helpers — utilities for the protocol's fixed-point encoding (UD30x9 prices, 1e6 quantity decimals).
  • Constants — exported package IDs, shared object IDs, and coin types for testnet.

Prerequisites

  • Node.js 20+
  • A Sui client (SuiClient from @mysten/sui/client). The SDK reads via gRPC / GraphQL and writes via PTBs submitted through your client of choice.
  • A funded USDC balance on Sui testnet. The USDC type for Phasis is the permissionless faucet coin at 0x949572061c09bbedef3ac4ffc42e58632291616f0605117cec86d840e09bf519::usdc::USDC.

Install

pnpm add @phasis-lab/sdk
# or
npm install @phasis-lab/sdk
# or
yarn add @phasis-lab/sdk

The SDK depends on @mysten/sui@^2.17.0 and @mysten/bcs@^2.0.5. These are peer-compatible with the standard Sui dApp Kit stack.

Exports

import {
  // Constants
  PACKAGE_ID_TESTNET,
  REGISTRY_ID_TESTNET,
  STRESS_SNAPSHOT_ID_TESTNET,
  QUOTE_COIN_TYPE_TESTNET,

  // Read views
  getRegistry,
  getAccountRegistryId,
  listMarkets,
  getMarket,
  getAccount,
  getAccountOrders,
  getLevel2,
  getMidPrice,
  getStressSnapshot,
  findAccountId,

  // Tx builders (convenience wrappers)
  placeTrade,
  cancelOrder,
  refreshAssetMargin,

  // Domain types & enums
  TradeIntent,
  DeepBookSide,
  OrderType,
  intentToSide,

  // NAV/free-balance helpers
  accountNavCash,
  accountFreeQuote,

  // Generated namespaces (raw PTB builders)
  genUserEntry,
} from '@phasis-lab/sdk';

The genUserEntry namespace contains the raw generated builders (openAccountV2, depositUsdcV2, withdrawUsdcV2, tradeV2, cancelOrderV2, refreshAssetMarginV2). The convenience wrappers in trade.ts (placeTrade, cancelOrder, refreshAssetMargin) are the recommended interface for trading entries.

Build from source

cd sdk
pnpm install
pnpm run build        # tsc → dist/
pnpm run test         # vitest unit tests
pnpm run codegen      # regenerate BCS bindings after Move changes

After a new deployment or upgrade, run pnpm gen-config from the repo root to regenerate sdk/src/generated-deployment.ts, then rebuild the SDK so dist/ picks up the new IDs.

What the SDK does NOT include

  • A browser wallet adapter — use @mysten/dapp-kit for wallet connections.
  • A Pyth oracle client — price feed updates are published by the Phasis keeper service.
  • Order history indexing — use the GraphQL event API directly (see Reading market & account data).

Connect a Wallet

No Sui wallet detected in this browser.

Install Sui Wallet

Phasis supports any wallet that implements the Sui Wallet Standard.