Queries
Sample Subgraph Queries
Last updated
{
transfersCommitteds(orderBy: timestamp, orderDirection: desc) {
totalAmount
transactionHash
token
timestamp
}
}{
transferSents(
where: {
transferId: "0x696c75a27f70ae5210192164a0006a105e71a5b09c117340756bb09d85ddd9a5"
}
) {
timestamp
amount
bonderFee
transactionHash
token
from
recipient
}
}{
poolSnapshots(
first: 1000
orderBy: timestamp
orderDirection: asc
where: {
pool: "0x5c6ee304399dbdb9c8ef030ab642b10820db8f56000200000000000000000014"
}
) {
amounts
totalShares
swapVolume
swapFees
liquidity
pool {
id
}
}
}{
transferSents(
where: {
timestamp_gt: 1650331530
timestamp_lt: 1652898343
destinationChainId: 42161
}
) {
transferId
amount
bonderFee
transactionHash
token
timestamp
from
recipient
}
}{
transferSentToL2S(
where: {
timestamp_gt: 1650331530
timestamp_lt: 1652898343
destinationChainId: 42161
}
) {
amount
relayerFee
transactionHash
token
timestamp
from
recipient
}
}{
withdrawalBondeds {
amount
transferId
timestamp
transactionHash
}
}{
volumes {
amount
token
}
}{
transferSents {
destinationChainId
amount
token
}
}{
transferSentToL2S {
destinationChainId
amount
token
}
}{
dailyVolumes(
where: { token: "ETH", date_gt: 1636416000, date_lte: 1636583276 }
orderBy: date
orderDirection: desc
first: 1
) {
id
amount
token
date
}
}const now = Math.floor(Date.now() / 1000)
const dayId = Math.floor(now / 86400)
const startDate = (dayId - 1) * 86400
const endDate = now{
tvls {
amount
token
}
}{
ammTvls {
amount
token
}
}{
ammFees {
amount
token
}
}{
bonderFees {
amount
token
}
}{
transferSents {
bonderFee
destinationChainId
token
}
}{
tokenSwaps {
tokensSold
token
}
} async function queryFetch(url, query, variables) {
const res = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Accept: 'application/json'
},
body: JSON.stringify({
query,
variables: variables || {}
})
})
const jsonRes = await res.json()
if (jsonRes.errors && json.errors.length) {
throw new Error(jsonRes.errors[0].message)
}
return jsonRes.data
}
async function main() {
const url = 'https://api.thegraph.com/subgraphs/name/hop-protocol/hop-mainnet'
const query = `
query TransferSentToL2($destinationChainId: Int) {
events: transferSentToL2S(
where: {
destinationChainId: $destinationChainId
},
orderBy: timestamp,
orderDirection: desc
) {
id
destinationChainId
amount
amountOutMin
relayerFee
recipient
deadline
transactionHash
timestamp
token
from
}
}
`
const variables = {
destinationChainId: 137
}
const result = await queryFetch(url, query, variables)
console.log(result)
}
main().catch(console.error)