This page provides example queries for the Predy subgraph, you can try any of these queries or write your own on the . Refer to The Graph - to learn how subgraph queries are structured.
Asset
Returns a list of all contracts that generated entities for the subgraph.
VaultEntity
Gets the 5
most recently created vaults and returns their owner address (account
) and a history of their trading/margin actions.
Copy {
vaultEntities(
first: 5
orderBy: vaultId
orderDirection: desc
) {
vaultId
account
history {
txid
subVaultIndex
timestamp
productId
action
tradeAmount
tradePrice
marginAmount
}
}
}
SubVaultEntity
Gets the subvaults for vault number XX
and returns the subvault ID and metadata.
Copy {
subVaultEntities(
where: { vault: "XX" }
) {
subVaultId
metadata
}
}
TradeHistoryEntity
Gets all trade/margin events between timestamps 1655272800
(June 15 2022 00:00:00) and 1655359200
(June 16 2022 00:00:00).
Copy {
tradeHistoryEntities(
where: { timestamp_gte: 1655272800, timestamp_lt: 1655359200 }
) {
txid
action
productId
tradeAmount
tradePrice
fundingFeePerPosition
marginAmount
}
}
PoolDepositedEntity
Gets pool deposits over $10,000, ordered largest to smallest, return the USDC deposited and the amount of LP tokens minted.
Copy {
poolDepositedEntities(
where: { depositAmount_gt: 10000000 }
orderBy: depositAmount
orderDirection: desc
) {
id
mintAmount
depositAmount
}
}
PoolWithdrawnEntity
Get the 10
most recent pool withdrawals and return the amount of LP token burned and the USDC withdrawn.
Copy {
poolWithdrawnEntities(
first: 10
orderBy: timestamp
orderDirection: desc
) {
id
burnAmount
withdrawAmount
}
}
HedgedEntity
Get the hedging actions performed, ordered oldest to most recent, and returns the amount of USDC and ETH traded and the direction of the trade.
Copy {
hedgedEntities(
orderBy: timestamp
) {
timestamp
isBuyingUnderlying
usdcAmount
underlyingAmount
}
}
FundingPaymentEntity
Get the highest 10
funding rates since timestamp 1655272800
(June 15 2022 00:00:00), returning the timestamp and rate.
Copy {
fundingPaymentEntities(
first: 10
where: { timestamp_gte: 1655272800 }
orderBy: fundingRate
orderDirection: desc
) {
timestamp
fundingRate
}
}
VarianceUpdatedEntity
Gets the 10
most recent variance updates and returns the timestamp, ETH price, and variance for those updates.
Copy {
varianceUpdatedEntities(
first: 10
orderBy: timestamp
orderDirection: desc
) {
timestamp
price
variance
}
}
MetricsEntity
Gets the metrics entities for the current PerpetualMarket contract (0xadbaee9665c101413ebff07e20520bdb67c71ab6
).
Copy {
metricsEntities(
where: { asset: "0xadbaee9665c101413ebff07e20520bdb67c71ab6" }
) {
id
openLong
openShort
notionalVolume
}
}
AggregatedVolume
Gets all WEEKLY
aggregated volume statistics for product ID 1
(ETH²)
Copy {
aggregatedVolumes(
where: { interval: WEEKLY, productId: 1 }
) {
interval
openTimestamp
closeTimestamp
productId
volume
notionalVolume
}
}
AggregatedFundingPayment
Gets the aggregated DAILY
funding statistics since timestamp 1655078400
(June 13 2022 00:00:00) for product ID 0
(ETH).
Copy {
aggregatedFundingPayments(
where: { interval: DAILY, openTimestamp_gt: 1655078400, productId: 0 }
) {
openTimestamp
openFundingRate
poolReceived
}
}
LPTokenPriceEntity
Gets the first 100
LP token price updates since timestamp 1655078400
(June 13 2022 00:00:00).
Copy {
lpTokenPriceEntities(
first: 100
orderBy: timestamp
orderDirection: asc
where: {timestamp_gt: 1655078400}
) {
id
timestamp
price
}
}
AggregatedLpTokenPriceEntity
Gets the aggregated WEEKLY
LP token price details (open
, close
, high
, low
) ordered by most recent to oldest.
Copy {
aggregatedLpTokenPriceEntities(
orderDirection: desc
where: { interval: WEEKLY }
) {
openTimestamp
open
close
high
low
}
}
OpenInterestEntity
Gets the latest 50
open interest updates for product ID 1
(ETH²).
Copy {
openInterestEntities(
first: 50
orderBy: timestamp
orderDirection: desc
where: { productId: 1 }
) {
timestamp
openLong
openShort
}
}
AggregatedOpenInterestEntity
Gets the aggregated HOURLY
open interest details (open
, close
, high
, low
) for the past 24 hours, ordered by most recent to oldest.
Copy {
aggregatedOpenInterestEntities(
first: 24
orderBy: openTimestamp
orderDirection: desc
where: { interval: HOURLY }
) {
openTimestamp
open
close
high
low
}
}