Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get all SynthExchange events in the last 24hours using The Graph
const graphAPI = 'https://api.thegraph.com/subgraphs/name/synthetixio-team/synthetix';
const ts = Math.floor(Date.now()/1e3);
const oneDayAgo = ts - (3600 * 24);
const response = await fetch(graphAPI, {
method: 'POST',
body: `{"query":"{synthExchanges(orderBy:timestamp, orderDirection:desc, where:{timestamp_gt: ${oneDayAgo}}){id,from,gasPrice,fromAmount,fromCurrencyKey,toCurrencyKey,block,timestamp,toAddress}}","variables":null}`
});
const json = await response.json();
const { synthExchanges } = json.data;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.