Skip to content

Instantly share code, notes, and snippets.

@jjgonecrypto
Created July 3, 2019 21:37
Show Gist options
  • Save jjgonecrypto/eebcb7430a79c1cffb3377de3e71f1a5 to your computer and use it in GitHub Desktop.
Save jjgonecrypto/eebcb7430a79c1cffb3377de3e71f1a5 to your computer and use it in GitHub Desktop.
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