npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@prob/types

v0.0.1

Published

A TypeScript SDK for interacting with the Prob prediction market platform. This SDK provides a comprehensive interface for trading, managing positions, querying market data, and more.

Downloads

1,206

Readme

prob-sdk

A TypeScript SDK for interacting with the Prob prediction market platform. This SDK provides a comprehensive interface for trading, managing positions, querying market data, and more.

Features

  • Order Management: Create, sign, submit, and cancel limit and market orders
  • Market Data: Query orderbooks, prices, price history, and market information
  • Position Management: Query, split, merge, and redeem positions
  • Trade History: Access trading activity, PnL, and trade records
  • Event & Market Queries: Search and retrieve events and markets
  • Authentication: Support for L1 (wallet signature), L2 (API key)
  • Safe Proxy Wallet: Built-in support for Safe proxy wallet operations

Install

To use this SDK in your project, install the main package:

# Using pnpm
pnpm add @prob/clob

# Using npm
npm install @prob/clob

# Using yarn
yarn add @prob/clob

Package Structure

This is a monorepo containing three main packages:

  • @prob/clob: Main SDK package for CLOB (Central Limit Order Book) operations
  • @prob/core: Core utilities including exchange configs, ABIs, and token operations
  • @prob/types: TypeScript type definitions shared across packages

Quick Start

Setup

First, create a wallet client and then create the CLOB client:

import { createWalletClient, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { bscTestnet } from 'viem/chains'
import { createClobClient } from '@prob/clob'

// Create a wallet client
const account = privateKeyToAccount('0x...' as `0x${string}`)
const wallet = createWalletClient({
  chain: bscTestnet,
  transport: http(),
  account: account,
})

// Create the CLOB client
const client = createClobClient({
  baseUrl: '...',
  chainId: bscTestnet.id,
  wallet: wallet,
})

// For methods that require authentication (order operations, trades, etc.),
// generate an API key first. The API key will be automatically stored in the client.
await client.generateApiKey()

Note:

  • L1 authentication (wallet signature) is automatically handled when you provide a wallet to the client.
  • Methods that use l1AuthHttpClient or l2AuthHttpClient require calling generateApiKey() first. These include:
    • Order operations: postOrder, postOrders, getOrder, getOpenOrders, cancelOrder, cancelOrders, cancelAllOrders
    • Trade operations: getTrades
    • API key management: getApiKey, deleteApiKey
    • Info: getTokenIdsForEvent
  • Public methods (like getMarkets, getOrderBook, getEvents) don't require authentication.

Basic Usage

// Get markets (public, no authentication required)
const markets = await client.getMarkets({ eventId: '162' })

// Get orderbook (public, no authentication required)
const orderbook = await client.getOrderBook({
  tokenId: '74342822607920627529671190134784974807193804148539661920621719393105547397621',
})

// Get current positions (requires authentication, ensure generateApiKey() was called)
const positions = await client.getCurrentPositions({ eventId: '162' })

Main API Usage Examples

Order Operations

Create and Submit a Limit Order

import { OrderSide, LimitTimeInForce } from '@prob/clob'

const order = await client.createLimitOrder({
  tokenId: '74342822607920627529671190134784974807193804148539661920621719393105547397621',
  price: 0.6,
  size: 100,
  side: OrderSide.Buy,
  timeInForce: LimitTimeInForce.GTC,
})

const { orderId } = await client.postOrder(order)
console.log('Order created:', orderId)

Create and Submit a Market Order

const marketOrder = await client.createMarketOrder({
  tokenId: '74342822607920627529671190134784974807193804148539661920621719393105547397621',
  size: 100,
  side: OrderSide.Buy,
})

await client.postOrder(marketOrder)

Get Open Orders

// Get all open orders for an event
const openOrders = await client.getOpenOrders({ eventId: '162' })

// Get open orders for specific tokens
const tokenOrders = await client.getOpenOrders({
  tokenIds: [
    '74342822607920627529671190134784974807193804148539661920621719393105547397621',
  ],
})

// Get a specific order
const order = await client.getOrder({
  orderId: '123',
  tokenId: '74342822607920627529671190134784974807193804148539661920621719393105547397621',
})

Cancel Orders

// Cancel a single order
await client.cancelOrder({ orderId: '123', tokenId: '...' })

// Cancel multiple orders
await client.cancelOrders({
  tokenId: '...',
  orderIds: ['123', '456'],
})

// Cancel all orders
await client.cancelAllOrders({ eventId: '162' })

Market Data Queries

Get Prices

// Get current price for a token
const price = await client.getPrice({
  tokenId: '74342822607920627529671190134784974807193804148539661920621719393105547397621',
})

// Get prices for multiple tokens
const prices = await client.getPrices({
  tokenIds: [
    '74342822607920627529671190134784974807193804148539661920621719393105547397621',
    '109502175175535116549611025410934749011537522542042437183890832452933730647182',
  ],
})

// Get price history
const priceHistory = await client.getPricesHistory({
  tokenId: '74342822607920627529671190134784974807193804148539661920621719393105547397621',
  startTime: Date.now() - 86400000, // 24 hours ago
  endTime: Date.now(),
})

Get Orderbook

const orderbook = await client.getOrderBook({
  tokenId: '74342822607920627529671190134784974807193804148539661920621719393105547397621',
})

Get Midpoint Price

const midpoint = await client.getMidpoint({
  tokenId: '74342822607920627529671190134784974807193804148539661920621719393105547397621',
})

Position Management

Get Positions

// Get current positions
const currentPositions = await client.getCurrentPositions({ eventId: '162' })

// Get closed positions
const closedPositions = await client.getClosedPositions({ eventId: '162' })

// Get pending positions
const pendingPositions = await client.getPendingPositions({ eventId: '162' })

// Get position value
const positionValue = await client.getPositionValue({ eventId: '162' })

Split Position

const conditionId = '0x3614ed5aa3d8ab73edd3364541f8c1c48104aa7d0bb081ed51f0f634edd8dad9'
const txHash = await client.splitPosition({
  conditionId,
  formattedAmount: '1',
})

Merge Position

const conditionId = '0x3614ed5aa3d8ab73edd3364541f8c1c48104aa7d0bb081ed51f0f634edd8dad9'
const mergeTxHash = await client.mergePosition({
  conditionId,
  formattedAmount: '1',
})

Redeem Position

const conditionId = '0x3614ed5aa3d8ab73edd3364541f8c1c48104aa7d0bb081ed51f0f634edd8dad9'
const redeemTxHash = await client.redeemPosition({
  conditionId,
})

Trade History

Get Trading Activity

const activity = await client.getActivity({ eventId: '162' })

Get PnL (Profit and Loss)

const pnl = await client.getPnL({ eventId: '162' })

Get Trades

const trades = await client.getTrades({ eventId: '162' })

Event and Market Queries

Get Events

const events = await client.getEvents({ limit: 10 })

Get Event by ID or Slug

const event = await client.getEventById({ eventId: '162' })
const eventBySlug = await client.getEventBySlug({ slug: 'event-slug' })

Get Markets

const markets = await client.getMarkets({ eventId: '162' })
const market = await client.getMarketById({ marketId: '123' })

Search

const results = await client.search({ query: 'bitcoin' })

Safe Proxy Wallet Operations

Check if Safe Proxy Wallet Exists

const exists = await client.checkSafeProxyWalletExists()

Approve Collateral

// Approve collateral if needed (checks current allowance first)
await client.proxyApproveCollateralIfNeeded()

// Approve specific amount
await client.proxyApproveCollateral(BigInt(1000e6))

Execute Transaction via Proxy

const txHash = await client.proxyExecuteTx({
  to: '0x...',
  data: '0x...',
  value: BigInt(0),
})

Project Structure

prob-sdk/
├── packages/
│   ├── clob/          # Main SDK package
│   │   ├── src/
│   │   │   ├── auth/          # Authentication (L1, L2)
│   │   │   ├── clob/          # CLOB client and API methods
│   │   │   ├── order/         # Order creation and management
│   │   │   ├── positions/     # Position management
│   │   │   ├── price/         # Price and orderbook queries
│   │   │   ├── trades/        # Trade history
│   │   │   └── ...
│   │   └── e2e/               # End-to-end tests
│   ├── core/          # Core utilities
│   │   ├── src/
│   │   │   ├── abis/          # Contract ABIs
│   │   │   ├── constants/     # Exchange configs and addresses
│   │   │   ├── exchange/      # Exchange utilities
│   │   │   ├── token/         # Token operations
│   │   │   └── ...
│   └── types/         # Shared TypeScript types
│       └── src/
├── package.json
└── pnpm-workspace.yaml

Development

Setup

  1. Clone the repository
  2. Install dependencies: pnpm install
  3. Build all packages: pnpm build

Scripts

  • pnpm lint: Run Biome linter
  • pnpm lint:fix: Fix linting issues automatically
  • pnpm test: Run tests with Vitest
  • pnpm test:watch: Run tests in watch mode
  • pnpm build: Build all packages

Code Style

This project uses Biome for code formatting and linting. The configuration is in biome.jsonc.

Building Individual Packages

# Build clob package
pnpm --filter ./packages/clob build

# Build core package
pnpm --filter ./packages/core build

Testing

# Run all tests
pnpm test

# Run tests for a specific package
pnpm --filter ./packages/clob test

# Run tests in watch mode
pnpm test:watch