Skip to content

Instantly share code, notes, and snippets.

@kmcintyre
Created April 5, 2021 00:54
Show Gist options
  • Save kmcintyre/f8557d1017a2494cf177a12724b8d74f to your computer and use it in GitHub Desktop.
Save kmcintyre/f8557d1017a2494cf177a12724b8d74f to your computer and use it in GitHub Desktop.
const { request, gql } = require('graphql-request');
// first is proxied in case you f' up and get cloudflared
//const endpoint = 'https://beta.scewpt.com/subgraphs/name/dasconnor/pangolindex'
const endpoint = 'https://graph-node.avax.network/subgraphs/name/dasconnor/pangolindex'
const avaxusdtpairid = '0x9ee0a4e21bd333a6bb2ab298194320b8daa26516'
const avaxdaipairid = '0x17a2e8275792b4616befb02eb9ae699aa0dcb94b'
const pngdaipairid = '0xd765b31399985f411a9667330764f62153b42c76'
const pngusdtpairid = '0xe8acf438b10a2c09f80aef3ef2858f8e758c98f9'
const pngusdtpairid = '0xe8acf438b10a2c09f80aef3ef2858f8e758c98f9'
const pricequoteusdtpairql = gql`query getPair($pairId: String!) {
pair(id: $pairId) {
id
token0Price
token0 {
symbol
}
token1Price
token1 {
symbol
}
}
}`;
[avaxusdtpairid, avaxdaipairid, pngdaipairid, pngusdtpairid].forEach(stablepair => {
request(endpoint, pricequoteusdtpairql, { pairId: stablepair }).then(response => {
console.log(`${response.pair.token0.symbol}:`, response.pair.token0Price, `${response.pair.token1.symbol}:`, response.pair.token1Price);
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment