Skip to content

Depredict SDK API Reference

This page provides an overview of the main classes and methods available in the Depredict SDK.

DepredictClient

The main entry point for interacting with the Depredict protocol.

import DepredictClient from '@endcorp/depredict';
 
const client = new DepredictClient(connection, adminKey, feeVault);

Properties

  • trade: Market and trading operations
  • config: Protocol configuration
  • position: Position page management and utilities
  • marketCreator: Market creator lifecycle and updates

Trade Methods

Market Operations

  • getAllMarkets(): Get all markets
  • getMarketsByAuthority(authority): Get markets created by an authority
  • getMarketById(marketId): Get market by ID
  • getMarketByAddress(address): Get market by PDA address
  • createMarket(args): Create a new market (supports mintAddress?, bettingStartTime?)
  • resolveMarket({ marketId, payer, resolutionValue? }): Resolve a market
  • closeMarket(marketId, payer): Close a market and collect remaining liquidity
  • updateMarket(marketId, payer, marketEnd?, marketState?): Update a market's end time or state

Position Operations

  • openPosition(args): Open a new position (auto-finds/creates position page; mint derived from market)
  • payoutPosition({ marketId, payer, assetId, rpcEndpoint, returnMode? }): Settle a position via compressed NFT proofs

payoutPosition details

  • Inputs: marketId: number, payer: PublicKey, assetId: PublicKey, rpcEndpoint: string, returnMode?: 'ixs' | 'message' | 'transaction' (default 'ixs')
  • Returns (by returnMode):
    • 'ixs'{ ixs: TransactionInstruction[]; alts: (AddressLookupTableAccount | string)[] }
    • 'message'{ message: Uint8Array; alts: string[] }
    • 'transaction'{ transaction: VersionedTransaction; alts: string[] }
  • Errors:
    • MISSING_DAS_RPC: Provide rpcEndpoint
    • INVALID_ASSET_ID: Asset must be a valid PublicKey
    • NO_PAYOUT_INSTRUCTIONS: Builder produced no instructions (check marketId/assetId/payer)
  • Notes:
    • All SDK key inputs are web3.js PublicKey (UMI keys are not required)
    • Helpers available: buildV0Message(ixs, alts, payer), normalizeResult(res)

Lookup Table Helpers

  • ensureMarketCreatorLookupTable({ authority, payer?, additionalAddresses?, existingLookupTable? }): Create or extend the creator-wide LUT with shared accounts (config, creator PDA, Bubblegum resources). Returns { lookupTableAddress, createTx?, extendTxs }.
  • extendMarketCreatorLookupTable({ authority, lookupTableAddress, additionalAddresses? }): Extend an existing creator LUT with new shared addresses.
  • buildMarketCreatorLookupTableCloseTxs({ authority, lookupTableAddress, recipient? }): Returns deactivate/close transactions so rent can be reclaimed.
  • ensureMarketLookupTable({ marketId, authority, payer?, creatorLookupTableAddress?, pageIndexes?, additionalAddresses?, existingLookupTable? }): Create or extend a market-specific LUT, automatically excluding addresses already present in the creator LUT.
  • extendMarketLookupTable({ marketId, authority, lookupTableAddress, creatorLookupTableAddress?, pageIndexes?, proofNodes?, additionalAddresses? }): Extend the market LUT with new page PDAs or proof nodes.
  • buildMarketLookupTableCloseTxs({ authority, lookupTableAddress, recipient? }): Returns deactivate/close transactions for reclaiming per-market LUT rent.

Config Methods

  • createConfig(feeAmount, payer): Initialize protocol config
  • getConfig(): Fetch protocol config
  • updateFee(feeAmount): Update fee amount
  • updateFeeVault(newFeeVault): Update fee vault address
  • updateAuthority(newAuthority): Update config authority
  • closeConfig(payer): Close config (if no active markets)

Position Methods

  • findAvailablePageForMarket(marketId, payer): Find or create a position page with available slots
  • getAllPositionPagesForMarket(marketId): List all position pages and slot usage
  • prunePosition({ marketId, signer, pageIndex, slotIndex }): Prune a slot (creator-only)
  • closePositionPage({ marketId, signer, pageIndex }): Close an empty page (creator-only)

Market Types

Market States

  • ACTIVE: Market is open for trading
  • ENDED: Market has ended, no new positions
  • RESOLVING: Market is being resolved
  • RESOLVED: Market has been resolved

Market Types

  • LIVE: Market starts immediately
  • FUTURE: Market starts at a future time

Oracle Types

  • SWITCHBOARD: Uses Switchboard oracle for resolution
  • MANUAL: Manual resolution by admin

For detailed argument types, see the SDK TypeScript types or the protocol IDL.

Depredict is an END Corp. project. | Copyright © 2025 END Corp.