PredictionLabs

Client Reference

Full API reference for PredictionLabsClient.

Constructor

new PredictionLabsClient({
  publicClient: PublicClient,
  walletClient?: WalletClient,
  addresses: ProtocolAddresses,
})

A walletClient is only required for write operations (placing orders, creating markets, etc). Read-only usage only needs publicClient.

Read Methods

getMarket(conditionId)

Returns market data from the factory.

const market = await client.getMarket("0x...");
// { questionId, conditionId, deadline, outcomeSlotCount, resolved, creator, resolver }

isTrading(conditionId)

Returns true if the market exists and is not yet resolved.

isResolvable(conditionId)

Returns true if the market is past its deadline and not yet resolved.

getOrder(orderId)

Returns order data from the order book.

const order = await client.getOrder(1n);
// { orderId, maker, side, cancelled, conditionId, outcomeIndex, price, amount, filled }

getPosition(owner, conditionId, outcomeIndex)

Returns the user's token balance for a specific outcome.

const pos = await client.getPosition("0x...", "0x...", 0);
// { conditionId, outcomeIndex, positionId, balance }

getPositionId(conditionId, outcomeIndex)

Returns the ERC-1155 token ID for an outcome slot.

bondAmount(resolverType?)

Returns the current UMA/Kalshi bond requirement.

const bond = await client.bondAmount("uma"); // default
const kalshiBond = await client.bondAmount("kalshi");

Fee Math

calculateFee(amount)

Computes the protocol fee (0.1%, rounded up) for a given USDC amount.

client.calculateFee(1_000_000n); // 1000n ($0.001)

estimateFillBuyVsBuy(price0, remaining0, price1, remaining1)

Estimates fill result for two opposing buy orders.

const est = client.estimateFillBuyVsBuy(650_000n, 100e6n, 400_000n, 100e6n);
// { fillAmount, cost, fee, surplus }

estimateFillBuyVsSell(buyPrice, buyRemaining, sellPrice, sellRemaining)

Estimates fill result for a buy order matched against a sell order.

Write Methods

All write methods require a walletClient with an account.

createMarket(question, outcomeSlotCount, deadline, resolver)

Creates a new binary market. Returns the conditionId.

forceVoid(conditionId)

Voids a stuck market (90 days past deadline with no pending resolutions, or 180 days emergency).

approveUsdc(spender, amount?)

Approves USDC spending. Defaults to maxUint256.

approveCtf(operator)

Sets ERC-1155 approval for all on the CTF contract.

placeBuyOrder(conditionId, outcomeIndex, price, amount)

Places a buy order. Returns the orderId.

placeBuyOrders(conditionIds, outcomeIndexes, prices, amounts)

Batch buy order placement. Returns array of orderIds.

placeSellOrder(conditionId, outcomeIndex, price, amount)

Places a sell order. Returns the orderId.

fillBuyVsBuy(buyId0, buyId1, fillAmount)

Matches two opposing buy orders.

fillBuyVsSell(buyId, sellId, fillAmount)

Matches a buy order against a sell order.

cancelOrder(orderId)

Cancels your own order.

cancelOrders(orderIds)

Batch cancel.

cancelExpiredOrder(orderId)

Cancels any order on a resolved market. Anyone can call.

UMA Resolver

assertOutcome(conditionId, assertedOutcome)

Asserts a market outcome via UMA. Requires USDC bond approval.

assertOutcomeFor(conditionId, assertedOutcome, asserter)

Asserts on behalf of another address (bond refund goes to asserter).

settleAssertion(assertionId, resolverType?)

Settles a UMA/Kalshi assertion after the liveness period.

Kalshi Resolver

kalshiLinkMarket(conditionId, ticker)

Links a market to a Kalshi ticker. Must be called before deadline.

kalshiAssertOutcome(conditionId, assertedOutcome)

Asserts outcome for a Kalshi-linked market.

kalshiAssertOutcomeFor(conditionId, assertedOutcome, asserter)

Assert on behalf of another address.

Polymarket Resolver

polymarketLinkMarket(conditionId, polymarketConditionId)

Links a market to a Polymarket condition. Must be called before deadline.

polymarketResolve(conditionId)

Resolves from the linked Polymarket condition's payouts.

Redemption

redeemWinnings(conditionId, outcomeIndices)

Redeems winning outcome tokens for USDC via the CTF.

await client.redeemWinnings("0x...", [0]); // Redeem YES tokens

NegRiskAdapter

createMultiOutcomeMarket(question, outcomeLabels, deadline, resolver)

Creates a multi-outcome market. Returns the marketId.

getOutcomeCount(marketId)

Returns the number of outcomes in a multi-outcome market.

getOutcomeConditionId(marketId, outcomeIndex)

Returns the binary market conditionId for a specific outcome leg.

getAllConditionIds(marketId)

Returns all binary market conditionIds for every leg.

getOutcomeLabel(marketId, outcomeIndex)

Returns the label string for a specific outcome.

isMultiOutcomeResolved(marketId)

Returns true when all legs of the multi-outcome market have been resolved.

Safety Checks

isTrustedResolver(conditionId, trustedResolvers)

Returns true if the market's resolver is in the trusted set.

isKalshiLinked(conditionId)

Returns true if the Kalshi market has a linked ticker.

isPolymarketLinked(conditionId)

Returns true if the Polymarket market has a linked condition.

isPastDeadline(conditionId)

Returns true if the market is past deadline but not resolved.

On this page

ConstructorRead MethodsgetMarket(conditionId)isTrading(conditionId)isResolvable(conditionId)getOrder(orderId)getPosition(owner, conditionId, outcomeIndex)getPositionId(conditionId, outcomeIndex)bondAmount(resolverType?)Fee MathcalculateFee(amount)estimateFillBuyVsBuy(price0, remaining0, price1, remaining1)estimateFillBuyVsSell(buyPrice, buyRemaining, sellPrice, sellRemaining)Write MethodscreateMarket(question, outcomeSlotCount, deadline, resolver)forceVoid(conditionId)approveUsdc(spender, amount?)approveCtf(operator)placeBuyOrder(conditionId, outcomeIndex, price, amount)placeBuyOrders(conditionIds, outcomeIndexes, prices, amounts)placeSellOrder(conditionId, outcomeIndex, price, amount)fillBuyVsBuy(buyId0, buyId1, fillAmount)fillBuyVsSell(buyId, sellId, fillAmount)cancelOrder(orderId)cancelOrders(orderIds)cancelExpiredOrder(orderId)UMA ResolverassertOutcome(conditionId, assertedOutcome)assertOutcomeFor(conditionId, assertedOutcome, asserter)settleAssertion(assertionId, resolverType?)Kalshi ResolverkalshiLinkMarket(conditionId, ticker)kalshiAssertOutcome(conditionId, assertedOutcome)kalshiAssertOutcomeFor(conditionId, assertedOutcome, asserter)Polymarket ResolverpolymarketLinkMarket(conditionId, polymarketConditionId)polymarketResolve(conditionId)RedemptionredeemWinnings(conditionId, outcomeIndices)NegRiskAdaptercreateMultiOutcomeMarket(question, outcomeLabels, deadline, resolver)getOutcomeCount(marketId)getOutcomeConditionId(marketId, outcomeIndex)getAllConditionIds(marketId)getOutcomeLabel(marketId, outcomeIndex)isMultiOutcomeResolved(marketId)Safety ChecksisTrustedResolver(conditionId, trustedResolvers)isKalshiLinked(conditionId)isPolymarketLinked(conditionId)isPastDeadline(conditionId)