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.48 kB
const tradesByUserQuery = (userAddress, count) => ` { EVM(dataset: realtime, network: matic) { DEXTradeByTokens( orderBy: { descending: Block_Time } limit: { count: ${count} } where: { TransactionStatus: { Success: true } Transaction: { From: { is: "${userAddress}" } } Trade: { Side: { Currency: { SmartContract: { is: "0x2791bca1f2de4661ed88a30c99a7a9449aa84174" } } } Dex: { ProtocolName: { is: "polymarket" } } } } ) { 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 tradesByUserStream = (userAddress) => ` subscription { EVM(network: matic) { DEXTradeByTokens( where: { TransactionStatus: { Success: true } Transaction: { From: { is: "${userAddress}" } } Trade: { Side: { Currency: { SmartContract: { is: "0x2791bca1f2de4661ed88a30c99a7a9449aa84174" } } } Dex: { ProtocolName: { is: "polymarket" } } } } ) { 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 { tradesByUserQuery, tradesByUserStream };