Skip to content

Commit

Permalink
Merge pull request #47 from balancer-labs/john/ethersv5-checkmethod
Browse files Browse the repository at this point in the history
Params & caching for wrapper
  • Loading branch information
Timur Badretdinov committed Oct 19, 2020
2 parents 314ceb7 + 53ea142 commit 4d3a370
Show file tree
Hide file tree
Showing 3 changed files with 211 additions and 105 deletions.
25 changes: 14 additions & 11 deletions src/subgraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export async function getTokenPairs(token) {
}

// Returns all public pools
export async function getAllPublicSwapPools() {
export async function getAllPublicSwapPools(SubgraphUrl: string = '') {
const query = `
{
pools (first: 1000, where: {publicSwap: true, active: true}) {
Expand All @@ -111,16 +111,19 @@ export async function getAllPublicSwapPools() {
}
`;

const response = await fetch(SUBGRAPH_URL, {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
query,
}),
});
const response = await fetch(
SubgraphUrl === '' ? SUBGRAPH_URL : SubgraphUrl,
{
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
query,
}),
}
);

const { data } = await response.json();
return data;
Expand Down
Loading

0 comments on commit 4d3a370

Please sign in to comment.