UNPKG

polymarket-api

Version:

Node.js SDK for querying Polymarket prediction market data. Get new prediction markets, resolved predictions, position tokens, and trading data from Polymarket using Bitquery APIs.

138 lines (135 loc) 2.5 kB
const tradesByAddressQuery = (address, count) => ` { EVM(dataset: realtime, network: matic) { DEXTradeByTokens( orderBy: { descending: Block_Time } limit: { count: ${count} } where: { TransactionStatus: { Success: true } Trade: { Side: { Currency: { SmartContract: { is: "0x2791bca1f2de4661ed88a30c99a7a9449aa84174" } } } Dex: { ProtocolName: { is: "polymarket" } } Ids: { includes: { in: ["${address}"] } } } } ) { Block { Time Number Hash } Transaction { Hash From To } Trade { Dex { OwnerAddress ProtocolFamily ProtocolName } AmountInUSD Amount PriceInUSD Side { Type Amount AmountInUSD Currency { Symbol SmartContract Name } Ids OrderId } Currency { Symbol SmartContract Name } Ids OrderId } } } } `; const tradesByAddressStream = (address) => ` subscription { EVM(network: matic) { DEXTradeByTokens( where: { TransactionStatus: { Success: true } Trade: { Side: { Currency: { SmartContract: { is: "0x2791bca1f2de4661ed88a30c99a7a9449aa84174" } } } Dex: { ProtocolName: { is: "polymarket" } } Ids: { includes: { in: ["${address}"] } } } } ) { Block { Time Number Hash } Transaction { Hash From To } Trade { Dex { OwnerAddress ProtocolFamily ProtocolName } AmountInUSD Amount PriceInUSD Side { Type Amount AmountInUSD Currency { Symbol SmartContract Name } Ids OrderId } Currency { Symbol SmartContract Name } Ids OrderId } } } } `; export { tradesByAddressQuery, tradesByAddressStream };