Developer Integration

ABI Locations

After building with forge build, full ABIs are emitted to:

contracts/out/<ContractName>.sol/<ContractName>.json

Extract the abi field for use in frontends or scripts:

jq '.abi' contracts/out/MarketFactory.sol/MarketFactory.json > abi/MarketFactory.json

Pre-extracted frontend ABIs are available in frontend/src/lib/contracts/abis/.

Contract Addresses

Deploy scripts print all addresses as JSON to stdout. After deployment, save this output and use it to configure your application. See Deployments for currently deployed addresses.

Interacting with Contracts

Using wagmi/viem (TypeScript)

import { readContract, writeContract } from '@wagmi/core';
import { parseEther } from 'viem';
import MarketFactoryABI from './abis/MarketFactory.json';
import VaultABI from './abis/Vault.json';
import OrderBookABI from './abis/OrderBook.json';

// Read market metadata
const meta = await readContract({
  address: MARKET_FACTORY_ADDRESS,
  abi: MarketFactoryABI,
  functionName: 'marketMeta',
  args: [factoryMarketId],
});

// Approve Vault for USDT (one-time)
await writeContract({
  address: USDT_ADDRESS,
  abi: erc20ABI,
  functionName: 'approve',
  args: [VAULT_ADDRESS, parseEther('1000')],
});

Using ethers.js (v6)

Market ID Types

Strike uses two distinct market ID systems. Understanding the difference is critical.

ID
Source
Used By

factoryMarketId

Sequential counter in MarketFactory

MarketFactory, PythResolver, Redemption, frontend

orderBookMarketId

Sequential counter in OrderBook

OrderBook, BatchAuction, Vault, OutcomeToken

The mapping is stored in MarketFactory.marketMeta[factoryMarketId].orderBookMarketId.

When to use which:

  • User-facing / API: Always use factoryMarketId. It is the canonical market identifier for resolution, redemption, and display.

  • Trading operations: OrderBook.placeOrder and BatchAuction.clearBatch use orderBookMarketId.

  • Token IDs: OutcomeToken derives YES/NO token IDs from orderBookMarketId (marketId*2 = YES, marketId*2+1 = NO).

Key Flows

1. Approve Vault for USDT

One-time approval. The Vault uses safeTransferFrom to pull USDT when orders are placed.

2. Place an Order

Collateral is locked in the Vault automatically:

  • Bid: lots * LOT_SIZE * tick / 100

  • Ask: lots * LOT_SIZE * (100 - tick) / 100

Where LOT_SIZE = 1e18 = 1 USDT.

3. Batch Clearing (Atomic Settlement)

Finds the clearing tick via the segment tree, records the BatchResult, and settles all orders atomically in the same transaction:

  • Filled collateral (at clearing price) moves to the market's redemption pool

  • Excess refund (order tick vs clearing tick difference) returned to owner

  • Uniform fee (20 bps) deducted and sent to protocolFeeCollector

  • Unfilled collateral returned (GoodTilBatch) or rolled to next batch (GoodTilCancel)

  • Outcome tokens minted: Bid fills receive YES tokens, Ask fills receive NO tokens

No separate claim step is needed — settlement happens inline.

4. Redeem After Resolution

Burns tokenAmount winning outcome tokens and pays out tokenAmount * LOT_SIZE USDT from the market's redemption pool.

Collateral Formulas

All values in wei. LOT_SIZE = 1e18 (1 USDT).

Side
Collateral Required

Bid (YES)

lots * LOT_SIZE * tick / 100

Ask (NO)

lots * LOT_SIZE * (100 - tick) / 100

Tick represents implied probability (1--99%). A bid at tick 60 means "willing to pay 60% of LOT_SIZE per lot for YES exposure."

Reading Market State

Getting Price Data from Pyth Hermes API

PythResolver requires Pyth price update data. Fetch it from the Hermes REST API:

In TypeScript:

Common Pyth Price Feed IDs

Asset
Price Feed ID

BTC/USD

0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43

BNB/USD

0x2f95862b045670cd22bee3114c39763a4a08beeb663b145d283c31d7d1101c4f

WebSocket / Indexer API

The Strike indexer (in the strike-infra repo) provides:

  • REST API for market data, order book state, and user positions

  • WebSocket for real-time order book updates and batch clearing events

See the strike-infra documentation for API endpoints and schemas.

Last updated