This returns the same Market type. The id comes from listMarkets.
Market Type
Metadata Shape
The outcomes array is critical for labelling: outcomes[0] is the label for outcomeIdx: 0.
The key address fields here are:
Field
Purpose
market.id
Pass to getMarket({ id })
market.id
Pass as marketAddress to SDK trading, quote, and approval calls
market.implementation
Implementation contract address; do not use as marketAddress
Market Status Values
Status
Meaning
open
Trading active
awaiting_settlement
Trading deadline passed, awaiting settlement
settled
Winning outcome set; positions redeemable
expired
Market expired without settlement; liquidate positions
failed
Oracle could not resolve the market; liquidate positions
The API returns these as strings.
The underlying contract exposes an int enum: 0 = open, 1 = awaiting settlement, 2 = settled, 3 = expired, and 4 = failed.
A winning outcome is set by the oracle on automated-settlement markets. Legacy markets use the creator's winner submission.
Usage Patterns
You can paginate through all markets like this:
Or, find a market using a question keyword:
Positions
listPositions(params)
Retrieve positions for a wallet address.
Position Type
Be careful when parsing, because shares and tokensRedeemed are string representations of bigints.
Redemption
Markets must be settled (winner submitted) before redeeming. Only holders of the winning outcome receive tokens.
expired and failed markets have no winning outcome. Use liquidate() rather than redeemMarket() for these positions.
Positions with shares === "0" cannot be redeemed or liquidated because the wallet holds no stake.
The positions API may return zero-share entries for markets the wallet previously participated in but fully exited. Always check BigInt(position.shares) > 0n before attempting redeem or liquidate calls.
1. Single (Market) Redemption
2. Batch (Market) Redemption
3. Batch-Redeeming all Unredeemed, Settled Positions
4. Liquidating Expired or Failed Positions
getMarketStatus() reads the current on-chain status. Use it when REST data may be stale.
Estimating Portfolio Value
Estimate the current liquidation value of all active positions:
export interface Market {
id: string; // On-chain contract address of the market proxy
appMarketId: string; // UUID identifying the market in the Delphi app UI
marketUrl: string; // Direct link to the market on the Delphi app
status: MarketStatus; // "open" | "awaiting_settlement" | "settled" | "expired" | "failed"
category: string; // Market category, e.g. "crypto", "sports", "politics"
deployer: string; // Wallet address that deployed/created the market
implementation: string; // Market implementation contract address
metadataUri: string; // URI pointing to the market metadata
metadataUriContentHash: string; // Content hash for the metadata URI
metadata: unknown; // Parsed market metadata returned by the API
dataSources: unknown; // Data sources used for market resolution/verification
createdAt: string; // ISO timestamp when the market was created
fetchedAt: string | null; // ISO timestamp when metadata was last fetched, or null
fetchResponseStatus: string | null; // Status from the metadata fetch attempt, or null
resolvesAt: string | null; // ISO timestamp when the market is expected to resolve, or null
settledAt: string | null; // ISO timestamp when the market was settled, or null
settlesAt: string | null; // ISO timestamp for scheduled settlement, or null
winningOutcomeIdx: string | null; // Winning outcome index after settlement, or null
tradingFee: string | null; // Trading fee value returned by the API, or null
proof: string | null; // Resolution proof or verification reference, or null
error: string | null; // Error message related to market metadata/resolution, or null
verifiable: boolean; // Whether the market has verifiable settlement enabled
}
const meta = market.metadata as {
question?: string; // The market question
title?: string; // Alternative title
description?: string;
category?: string;
outcomes?: string[]; // Outcome labels — index matches outcomeIdx
resolutionCriteria?: string;
endDate?: string; // ISO date
} | null;
const { positions } = await client.listPositions({
wallet: myAddress,
redeemedOrLiquidated: false,
});
const settledProxies: `0x${string}`[] = [];
for (const p of positions ?? []) {
if (BigInt(p.shares) === 0n) continue;
const market = await client.getMarket({ id: p.marketProxy });
if (market.status === "settled") {
settledProxies.push(p.marketProxy as `0x${string}`);
}
}
if (settledProxies.length > 0) {
const { results, totalTokensOut } = await client.redeemPositions({
marketAddresses: settledProxies,
});
}
import { LIQUIDATABLE_MARKET_STATUSES } from "@gensyn-ai/gensyn-delphi-sdk";
for (const p of positions ?? []) {
if (BigInt(p.shares) === 0n) continue;
const marketAddress = p.marketProxy as `0x${string}`;
const status = await client.getMarketStatus(marketAddress);
if (!LIQUIDATABLE_MARKET_STATUSES.includes(status)) continue;
await client.liquidate({
marketAddress,
outcomeIndices: [0, 1], // Binary market; include every outcome index.
});
}