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 operationsconfig: Protocol configurationposition: Position page management and utilitiesmarketCreator: Market creator lifecycle and updates
Trade Methods
Market Operations
getAllMarkets(): Get all marketsgetMarketsByAuthority(authority): Get markets created by an authoritygetMarketById(marketId): Get market by IDgetMarketByAddress(address): Get market by PDA addresscreateMarket(args): Create a new market (supportsmintAddress?,bettingStartTime?)resolveMarket({ marketId, payer, resolutionValue? }): Resolve a marketcloseMarket(marketId, payer): Close a market and collect remaining liquidityupdateMarket(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: ProviderpcEndpointINVALID_ASSET_ID: Asset must be a validPublicKeyNO_PAYOUT_INSTRUCTIONS: Builder produced no instructions (checkmarketId/assetId/payer)
- Notes:
- All SDK key inputs are web3.js
PublicKey(UMI keys are not required) - Helpers available:
buildV0Message(ixs, alts, payer),normalizeResult(res)
- All SDK key inputs are web3.js
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 configgetConfig(): Fetch protocol configupdateFee(feeAmount): Update fee amountupdateFeeVault(newFeeVault): Update fee vault addressupdateAuthority(newAuthority): Update config authoritycloseConfig(payer): Close config (if no active markets)
Position Methods
findAvailablePageForMarket(marketId, payer): Find or create a position page with available slotsgetAllPositionPagesForMarket(marketId): List all position pages and slot usageprunePosition({ 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 tradingENDED: Market has ended, no new positionsRESOLVING: Market is being resolvedRESOLVED: Market has been resolved
Market Types
LIVE: Market starts immediatelyFUTURE: Market starts at a future time
Oracle Types
SWITCHBOARD: Uses Switchboard oracle for resolutionMANUAL: Manual resolution by admin
For detailed argument types, see the SDK TypeScript types or the protocol IDL.
