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

@predexon/trade-sdk

v0.0.5

Published

Predexon Trade SDK for Polymarket and Kalshi

Readme

Predexon Trade SDK

Trading SDK for Polymarket (Polygon) and Kalshi (Solana).

Installation

npm install @predexon/trade-sdk

Requirements: Node.js 20.18+.

Quick Start

import { PredexonSDK, createEvmAdapter } from '@predexon/trade-sdk';

// Create SDK instance with wallet signer
const sdk = new PredexonSDK({
  apiKey: 'your-api-key',
  wallet: createEvmAdapter(yourWalletClient),
});

// Enable trading (required before placing orders)
await sdk.enableTrading({
  core: { venue: 'polymarket', wallet: walletAddress },
  approvals: 'auto',
});

// Place a market buy order
const result = await sdk.placeOrder({
  core: {
    venue: 'polymarket',
    wallet: walletAddress,
    side: 'buy',
    amount: '10', // $10 USDC
    type: 'market',
  },
  flags: { tokenId: 'your-token-id' },
});

Supported Venues

| Venue | Chain | Order Types | Features | |-------|-------|-------------|----------| | Polymarket | Polygon | Market, Limit | Full support | | Kalshi | Solana | Market only | Orders + redemption (no open orders or cancels) |

Order Semantics

Polymarket

  • Market BUY: amount (USDC) or size (shares), exactly one
  • Market SELL: size required
  • Limit BUY: size + price required
  • Limit SELL: size + price required

Kalshi

  • Market BUY: amount (USDC) required
  • Market SELL: size (tokens) required
  • Limit orders are not supported

Enable Trading

Polymarket

enableTrading() handles CLOB credential registration and contract approvals:

  • Signs EIP-712 typed data for CLOB authentication
  • Optionally signs and broadcasts approval transactions (via approvals: 'auto')
await sdk.enableTrading({
  core: { venue: 'polymarket', wallet: walletAddress },
  approvals: 'auto', // 'auto' | 'manual' | 'skip'
});

Kalshi

enableTrading() registers the Solana wallet with Predexon's server:

  • Signs a challenge message to prove wallet ownership
  • Server registers the wallet association with your API key
await sdk.enableTrading({
  core: { venue: 'kalshi', wallet: solanaWalletAddress },
});

Wallet Signing Requirements

Polymarket (Polygon)

Requires a wallet implementing:

  • getAddress(): Promise<string>
  • signTypedData(typedData): Promise<string> - EIP-712 signing
  • signTransaction(tx): Promise<string> - for approval transactions

Kalshi (Solana)

Requires additional methods:

  • signSolanaTransaction(base64): Promise<string> - for order transactions
  • signSolanaMessage(message): Promise<string> - for wallet registration (enableTrading only)

Order Construction

Polymarket

  • Uses canonical @polymarket/clob-client to build and sign orders locally
  • Market orders resolve price by walking the live orderbook
  • Limit orders validate min_order_size from the orderbook
  • prepareOrder() returns { order, signature } (SDK signs using your wallet adapter)

Kalshi

  • Server-assisted prepare/submit flow via DFlow
  • prepareOrder() returns { transaction, orderParams } (unsigned)
  • Your wallet signs the Solana transaction; SDK submits on placeOrder()/submitOrder()

Security Notes

  • The SDK is hard-locked to https://trade.predexon.com (no custom base URL).
  • Kalshi prepare responses are validated before signing (echo + signer checks).
  • Polymarket redemption transactions are constructed locally from server-provided metadata.
  • Node 20.18+ is required (per engines).

Redemption

Polymarket

await sdk.redeem({
  core: { venue: 'polymarket', wallet: walletAddress },
  flags: { tokenId: 'resolved-token-id' },
});

Kalshi

await sdk.redeem({
  core: { venue: 'kalshi', wallet: solanaWalletAddress },
  flags: { ticker: 'TICKER', outcome: 'Yes' },
});

API Reference

Core Methods

| Method | Description | |--------|-------------| | enableTrading(request) | Enable trading for a venue (registration + approvals) | | placeOrder(request) | Build, sign, and submit an order (primary API) | | prepareOrder(request) | Build order locally (Polymarket: returns signed order; Kalshi: returns unsigned transaction for wallet to sign) | | submitOrder(request) | Submit a prepared order (advanced) | | cancelOrder(params) | Cancel a specific open order (Polymarket only; Kalshi not supported) | | cancelAllOrders(params) | Cancel all open orders (Polymarket only; Kalshi not supported) | | getOpenOrders(params) | List open orders (returns empty for Kalshi) | | getPositions(params) | Get current positions | | getBalance(params) | Get wallet balance | | redeem(request) | Redeem resolved positions |

Idempotency

Provide an idempotencyKey on placeOrder/submitOrder when you need idempotent order submissions. Use the helper below to generate keys. enableTrading and redeem do not accept user-supplied idempotency keys.

import { generateIdempotencyKey } from '@predexon/trade-sdk';

const key = generateIdempotencyKey();
const customKey = generateIdempotencyKey('my-prefix');

Adapters

EVM Adapters (Polymarket)

import { createEvmAdapter, createPrivyEvmAdapter } from '@predexon/trade-sdk';

// Generic EVM adapter (viem, ethers, etc.)
const evmSigner = createEvmAdapter(yourWalletClient);

// Privy-specific EVM adapter
const privyEvmSigner = createPrivyEvmAdapter(privyEmbeddedWallet);

Solana Adapters (Kalshi)

import { createSolanaAdapter, createPrivySolanaAdapter } from '@predexon/trade-sdk';

// Generic Solana adapter (any wallet with signSolanaTransaction)
const solanaSigner = createSolanaAdapter({
  signSolanaTransaction: async (base64Tx) => signedBase64,
  signSolanaMessage: async (message) => signatureBase64,
});

// Privy-specific Solana adapter (Wallet Standard)
import { useSolanaStandardWallets } from '@privy-io/react-auth/solana';

const { wallets } = useSolanaStandardWallets();
const privyWallet = wallets.find(w => w.name === 'Privy');
const address = privyWallet.accounts[0].address;

const privySolanaSigner = createPrivySolanaAdapter(privyWallet, address);

Combined Wallet (Both Venues)

For apps supporting both Polymarket and Kalshi with Privy:

import { PredexonSDK, createPrivyEvmAdapter, createPrivySolanaAdapter } from '@predexon/trade-sdk';

const sdk = new PredexonSDK({
  apiKey: 'your-api-key',
  wallet: {
    ...createPrivyEvmAdapter(privyEvmWallet),
    ...createPrivySolanaAdapter(privySolanaWallet, solanaAddress),
  },
});

Configuration

const sdk = new PredexonSDK({
  apiKey: 'your-api-key',
  wallet: createEvmAdapter(yourWalletClient),
  timeouts: {
    requestMs: 30000,
  },
});

Note: the SDK is hard-locked to the production API base URL and does not support custom base URLs.