Subgraph
Querying historical on-chain event data through the Goldsky-indexed GraphQL endpoint.
Overview
The Delphi SDK includes a SubgraphClient that queries on-chain event data indexed by a Goldsky subgraph.
This gives read-only access to historical buys, sells, redemptions, liquidations, and settlements without needing an archive node or parsing raw logs.
Accessing the Subgraph Client
getSubgraph() returns a SubgraphClient instance configured with the correct Goldsky endpoint for the active network.
import { DelphiClient } from "@gensyn-ai/gensyn-delphi-sdk";
const client = new DelphiClient();
const subgraph = client.getSubgraph();URL Resolution Order
config.subgraphUrl(constructor option onDelphiClient)DELPHI_SUBGRAPH_URLenvironment variableNetwork default
Testnet
https://api.goldsky.com/api/public/project_cmnoqdag1obop01z3efnu8ssq/subgraphs/delphi-testnet-autoset/1.0.0/gn
Mainnet
https://api.goldsky.com/api/public/project_cmnoqdag1obop01z3efnu8ssq/subgraphs/delphi-mainnet-autoset/1.0.0/gn
Competition testnet
https://api.goldsky.com/api/public/project_cmnoqdag1obop01z3efnu8ssq/subgraphs/delphi-agent-competition/1.0.0/gn
The default endpoints index automated-settlement gateways only. Set DELPHI_SUBGRAPH_URL to the legacy delphi-testnet or delphi-mainnet endpoint for legacy history.
SubgraphClient API
query(query, variables?)
You can execute any arbitrary GraphQL query against the subgraph. Returns the data field from the response or throws on errors.
getMarketTrades(marketProxy, params?)
Returns all buy and sell events for a given market proxy address, sorted most-recent-first.
Defaults: first = 100, skip = 0.
getMarketSettlement(marketProxy)
Returns settlement data for a market. A market can be settled or failed, never both.
On competition testnet, marketCreatorReward, refund, and marketCreatorTradingFeesCut are null. Do not request these fields in hand-written competition queries.
getMeta()
Returns the current indexed block, deployment hash, and whether the subgraph has indexing errors. Useful for checking data freshness.
Types
SubgraphBuy
SubgraphSell
SubgraphMeta
SubgraphMarketSettled fields
SubgraphMarketFailed fields
SubgraphMarketResolutionRequested fields
GraphQL Schema Entities
The automated-settlement subgraph indexes market activity and settlement events.
Each entity is available as both a singular query (by id) and a plural collection query with filtering, ordering, and pagination.
GatewayBuy
gatewayBuy(id)
gatewayBuys(...)
Share purchase events
GatewaySell
gatewaySell(id)
gatewaySells(...)
Share sale events
GatewayRedemption
gatewayRedemption(id)
gatewayRedemptions(...)
Settled market redemptions
GatewayLiquidation
gatewayLiquidation(id)
gatewayLiquidations(...)
Position liquidations
GatewayMarketSettled
gatewayMarketSettled(id)
gatewayMarketSettleds(...)
Market settlement events
GatewayMarketFailed
gatewayMarketFailed(id)
gatewayMarketFaileds(...)
Failed market events
MarketResolutionRequested
marketResolutionRequested(id)
marketResolutionRequesteds(...)
Oracle resolution requests
Initialized
initialized(id)
initializeds(...)
Entity Fields
Common Fields (All Entities)
id
ID!
Unique event identifier
block_number
BigInt!
Block number of the event
timestamp_
BigInt!
Unix timestamp (seconds)
transactionHash_
String!
Transaction hash
contractId_
String!
Gateway contract address
Additional Fields (Specific Entities)
GatewayBuy additional fields:
marketProxy,buyer,outcomeIdx,tokensIn(collateral, 6-dec),sharesOut(shares, 18-dec)GatewaySell additional fields:
marketProxy,seller,outcomeIdx,sharesIn(shares, 18-dec),tokensOut(collateral, 6-dec)GatewayRedemption additional fields:
marketProxy,redeemer,sharesIn(18-dec),tokensOut(collateral, 6-dec)GatewayLiquidation additional fields:
marketProxy,liquidator,outcomeIndices,sharesIn,totalTokensOut(collateral, 6-dec)GatewayMarketSettled additional fields:
marketProxy,winningOutcomeIdx,marketCreatorReward,refund,marketCreatorTradingFeesCut. The economics fields arenullon competition testnet.GatewayMarketFailed additional fields:
marketProxyMarketResolutionRequested additional fields:
marketProxy,keeper
Collection Query Parameters
All plural queries accept these:
first
Int
Max results (default 100, max 1000)
skip
Int
Pagination offset
orderBy
<Entity>_orderBy
Field to sort by (e.g. timestamp_, tokensIn)
orderDirection
OrderDirection
asc or desc
where
<Entity>_filter
Filter conditions
block
Block_height
Query at a specific block height
Filtering (where clause)
(none)
equals
{ marketProxy: "0x..." }
_not
not equals
{ buyer_not: "0x..." }
_gt
greater than
{ timestamp__gt: "1700000000" }
_lt
less than
{ tokensIn_lt: "1000000" }
_gte
greater or equal
{ block_number_gte: "100" }
_lte
less or equal
{ block_number_lte: "500" }
_in
in list
{ outcomeIdx_in: ["0", "1"] }
_not_in
not in list
{ marketProxy_not_in: [...] }
Usage Examples
Here are some common subgraph query examples.
1. Listing recent trades for a given market
2. Querying global recent buys
3. Filtering buys by wallet address
4. Filtering buys by time range
5. Querying redemptions for a given market
6. Querying market settlements
7. Checking subgraph indexing status
8. Pagination
9. Parsing subgraph values
Last updated