Skip to content

Commit

Permalink
Merge pull request #284 from balancer/subgraph
Browse files Browse the repository at this point in the history
setting up new subgraph urls
  • Loading branch information
gmbronco authored Jun 27, 2024
2 parents 77535f6 + 178aae8 commit 69d7d77
Show file tree
Hide file tree
Showing 18 changed files with 113 additions and 35 deletions.
7 changes: 0 additions & 7 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -604,13 +604,6 @@ export class BalancerPoolsAPI extends Stack {
updatePrices.addMethod('POST', updateTokenPricesIntegration);
addCorsOptions(updatePrices);

const test = api.root.addResource('test');
const testFunction = new NodejsFunction(this, 'testFunction', {
entry: join(__dirname, 'src', 'lambdas', 'test-function.ts'),
...nodeJsFunctionProps,
});
test.addMethod('GET', new LambdaIntegration(testFunction));

const sor = api.root.addResource('sor');
const sorOnChain = sor.addResource('{chainId}');
sorOnChain.addMethod('POST', runSORIntegration, {
Expand Down
46 changes: 32 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"dependencies": {
"@aws-cdk/aws-appsync-alpha": "^2.33.0-alpha.0",
"@aws/dynamodb-auto-marshaller": "^0.7.1",
"@balancer-labs/sdk": "^1.1.6-beta.20",
"@balancer-labs/sdk": "^1.1.6-beta.23",
"@ethersproject/contracts": "^5.0.5",
"@ethersproject/providers": "^5.0.5",
"@sentry/serverless": "^7.29.0",
Expand Down
2 changes: 2 additions & 0 deletions src/config/arbitrum.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"GqlChain": "ARBITRUM",
"rpc": "https://arbitrum-mainnet.infura.io/v3/{{INFURA_PROJECT_ID}}",
"subgraph": "https://gateway-arbitrum.network.thegraph.com/api/{{SUBGRAPH_API_KEY}}/subgraphs/id/98cQDy6tufTJtshDCuhh9z2kWXsQWBHVh2bqnLHsGAeS",
"gaugesSubgraph": "https://gateway-arbitrum.network.thegraph.com/api/{{SUBGRAPH_API_KEY}}/subgraphs/id/Bb1hVjJZ52kL23chZyyGWJKrGEg3S6euuNa1YA6XRU4J",
"blocksSubgraph": "https://api.studio.thegraph.com/query/48427/arbitrum-blocks/version/latest",
"addresses": {
"nativeAsset": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
"wrappedNativeAsset": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
Expand Down
2 changes: 2 additions & 0 deletions src/config/avalanche.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"GqlChain": "AVALANCHE",
"rpc": "https://avalanche-mainnet.infura.io/v3/{{INFURA_PROJECT_ID}}",
"subgraph": "https://gateway-arbitrum.network.thegraph.com/api/{{SUBGRAPH_API_KEY}}/subgraphs/id/7asfmtQA1KYu6CP7YVm5kv4bGxVyfAHEiptt2HMFgkHu",
"gaugesSubgraph": "https://gateway-arbitrum.network.thegraph.com/api/{{SUBGRAPH_API_KEY}}/subgraphs/id/GzGBUh1X4Cq9RBdyKoCrPLhYW1saBYHwFBgcTsARPYUG",
"blocksSubgraph": "https://api.studio.thegraph.com/query/48427/avalanche-blocks/version/latest",
"addresses": {
"nativeAsset": "0x0000000000000000000000000000000000000000",
"wrappedNativeAsset": "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",
Expand Down
2 changes: 2 additions & 0 deletions src/config/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"GqlChain": "BASE",
"rpc": "https://developer-access-mainnet.base.org",
"subgraph": "https://api.studio.thegraph.com/query/24660/balancer-base-v2/version/latest",
"gaugesSubgraph": "https://api.studio.thegraph.com/query/24660/balancer-gauges-base/version/latest",
"blocksSubgraph": "https://api.studio.thegraph.com/query/48427/bleu-base-blocks/version/latest",
"addresses": {
"nativeAsset": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
"wrappedNativeAsset": "0x4200000000000000000000000000000000000006",
Expand Down
2 changes: 2 additions & 0 deletions src/config/fraxtal.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"GqlChain": "FRAXTAL",
"rpc": "https://rpc.frax.com/",
"subgraph": "https://api.goldsky.com/api/public/project_clwhu1vopoigi01wmbn514m1z/subgraphs/balancer-fraxtal-v2/latest/gn",
"gaugesSubgraph": "https://api.goldsky.com/api/public/project_clwhu1vopoigi01wmbn514m1z/subgraphs/balancer-gauges-fraxtal/latest/gn",
"blocksSubgraph": "https://api.goldsky.com/api/public/project_clwhu1vopoigi01wmbn514m1z/subgraphs/fraxtal-blocks/1.0.0/gn",
"addresses": {
"nativeAsset": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
"wrappedNativeAsset": "0xfc00000000000000000000000000000000000006",
Expand Down
2 changes: 2 additions & 0 deletions src/config/gnosis-chain.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"GqlChain": "GNOSIS",
"rpc": "https://poa-xdai.gateway.pokt.network/v1/lb/91bc0e12a76e7a84dd76189d",
"subgraph": "https://gateway-arbitrum.network.thegraph.com/api/{{SUBGRAPH_API_KEY}}/subgraphs/id/EJezH1Cp31QkKPaBDerhVPRWsKVZLrDfzjrLqpmv6cGg",
"gaugesSubgraph": "https://gateway-arbitrum.network.thegraph.com/api/{{SUBGRAPH_API_KEY}}/subgraphs/id/HW5XpZBi2iYDLBqqEEMiRJFx8ZJAQak9uu5TzyH9BBxy",
"blocksSubgraph": "https://api.studio.thegraph.com/query/48427/gnosis-blocks/version/latest",
"addresses": {
"nativeAsset": "",
"wrappedNativeAsset": "0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d",
Expand Down
4 changes: 2 additions & 2 deletions src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Network } from '@/constants';
import arbitrum from './arbitrum.json';
import avalanche from './avalanche.json';
import base from './base.json';
import goerli from './goerli.json';
import gnosis from './gnosis-chain.json';
import mainnet from './mainnet.json';
import polygon from './polygon.json';
Expand All @@ -17,6 +16,8 @@ export interface Config {
network: string;
rpc: string;
subgraph: string;
gaugesSubgraph: string;
blocksSubgraph: string;
GqlChain: string;
addresses: {
nativeAsset: string;
Expand All @@ -33,7 +34,6 @@ export interface Config {

const config: Record<number, Config> = {
[Network.MAINNET]: mainnet,
[Network.GOERLI]: goerli,
[Network.POLYGON]: polygon,
[Network.ARBITRUM]: arbitrum,
[Network.GNOSIS]: gnosis,
Expand Down
2 changes: 2 additions & 0 deletions src/config/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"GqlChain": "MAINNET",
"rpc": "https://mainnet.infura.io/v3/{{INFURA_PROJECT_ID}}",
"subgraph": "https://gateway-arbitrum.network.thegraph.com/api/{{SUBGRAPH_API_KEY}}/subgraphs/id/C4ayEZP2yTXRAB8vSaTrgN4m9anTe9Mdm2ViyiAuV9TV",
"gaugesSubgraph": "https://gateway-arbitrum.network.thegraph.com/api/{{SUBGRAPH_API_KEY}}/subgraphs/id/4sESujoqmztX6pbichs4wZ1XXyYrkooMuHA8sKkYxpTn",
"blocksSubgraph": "https://api.studio.thegraph.com/query/48427/ethereum-blocks/version/latest",
"addresses": {
"nativeAsset": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
"wrappedNativeAsset": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
Expand Down
2 changes: 2 additions & 0 deletions src/config/mode.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"GqlChain": "MODE",
"rpc": "https://1rpc.io/mode",
"subgraph": "https://api.studio.thegraph.com/proxy/75376/balancer-mode-v2/version/latest",
"gaugesSubgraph": "https://api.studio.thegraph.com/query/75376/balancer-gauges-mode/version/latest",
"blocksSubgraph": "https://api.studio.thegraph.com/query/48427/bleu-mode-blocks/version/latest",
"addresses": {
"nativeAsset": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
"wrappedNativeAsset": "0x4200000000000000000000000000000000000006",
Expand Down
2 changes: 2 additions & 0 deletions src/config/optimism.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"GqlChain": "OPTIMISM",
"rpc": "https://optimism-mainnet.infura.io/v3/{{INFURA_PROJECT_ID}}",
"subgraph": "https://gateway-arbitrum.network.thegraph.com/api/{{SUBGRAPH_API_KEY}}/subgraphs/id/FsmdxmvBJLGjUQPxKMRtcWKzuCNpomKuMTbSbtRtggZ7",
"gaugesSubgraph": "https://gateway-arbitrum.network.thegraph.com/api/{{SUBGRAPH_API_KEY}}/subgraphs/id/CbLt7GqU7sypjRaCfwissEBkFeCw3dUz2emrvBNJ7dZu",
"blocksSubgraph": "https://api.studio.thegraph.com/query/48427/optimism-blocks/version/latest",
"addresses": {
"nativeAsset": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
"wrappedNativeAsset": "0x4200000000000000000000000000000000000006",
Expand Down
2 changes: 2 additions & 0 deletions src/config/polygon.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"GqlChain": "POLYGON",
"rpc": "https://polygon-mainnet.infura.io/v3/{{INFURA_PROJECT_ID}}",
"subgraph": "https://gateway-arbitrum.network.thegraph.com/api/{{SUBGRAPH_API_KEY}}/subgraphs/id/H9oPAbXnobBRq1cB3HDmbZ1E8MWQyJYQjT1QDJMrdbNp",
"gaugesSubgraph": "https://gateway-arbitrum.network.thegraph.com/api/{{SUBGRAPH_API_KEY}}/subgraphs/id/FxSLKXiieSqBCjDGPbqayhqbxyNtwaEC5M3rxr6hUa8h",
"blocksSubgraph": "https://api.studio.thegraph.com/query/48427/polygon-blocks/version/latest",
"addresses": {
"nativeAsset": "0x0000000000000000000000000000000000001010",
"wrappedNativeAsset": "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",
Expand Down
2 changes: 2 additions & 0 deletions src/config/sepolia.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"GqlChain": "SEPOLIA",
"rpc": "https://sepolia.infura.io/v3/{{INFURA_KEY}}",
"subgraph": "https://api.studio.thegraph.com/query/24660/balancer-sepolia-v2/version/latest",
"gaugesSubgraph": "https://api.studio.thegraph.com/query/24660/balancer-gauges-sepolia/version/latest",
"blocksSubgraph": "https://api.studio.thegraph.com/query/48427/bleu-sepolia-blocks/version/latest",
"addresses": {
"nativeAsset": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
"wrappedNativeAsset": "0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9",
Expand Down
2 changes: 2 additions & 0 deletions src/config/zkevm.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"GqlChain": "ZKEVM",
"rpc": "https://polygonzkevm-mainnet.g.alchemy.com/v2/{{ALCHEMY_KEY}}",
"subgraph": "https://api.studio.thegraph.com/query/24660/balancer-polygon-zk-v2/version/latest",
"gaugesSubgraph": "https://api.studio.thegraph.com/query/24660/balancer-gauges-polygon-zk/version/latest",
"blocksSubgraph": "https://api.studio.thegraph.com/query/48427/bleu-polygon-zkevm-blocks/version/latest",
"addresses": {
"nativeAsset": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
"wrappedNativeAsset": "0x4F9A0e7FD2Bf6067db6994CF12E4495Df938E6e9",
Expand Down
6 changes: 0 additions & 6 deletions src/lambdas/test-function.ts

This file was deleted.

34 changes: 34 additions & 0 deletions src/modules/network/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,40 @@ export function getSubgraphUrl(networkId: number): string {
return subgraphUrl;
}

export function getBlockNumberSubgraphUrl(networkId: number): string {
requireValidNetworkId(networkId);

const templateUrl = configs[networkId].blocksSubgraph;
if (templateUrl.match(/SUBGRAPH_API_KEY/) && SUBGRAPH_API_KEY == null) {
throw new Error(
`SUBGRAPH_API_KEY env variable must be set for network ${networkId}`
);
}

const subgraphUrl = template(templateUrl, {
SUBGRAPH_API_KEY,
});

return subgraphUrl;
}

export function getGaugesSubgraphUrl(networkId: number): string {
requireValidNetworkId(networkId);

const templateUrl = configs[networkId].gaugesSubgraph;
if (templateUrl.match(/SUBGRAPH_API_KEY/) && SUBGRAPH_API_KEY == null) {
throw new Error(
`SUBGRAPH_API_KEY env variable must be set for network ${networkId}`
);
}

const subgraphUrl = template(templateUrl, {
SUBGRAPH_API_KEY,
});

return subgraphUrl;
}

export function isValidNetworkId(networkId: number): boolean {
return Object.values(Network).includes(networkId);
}
Expand Down
Loading

0 comments on commit 69d7d77

Please sign in to comment.