Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: query all pools and gauges via apiv3 #38

Merged
merged 16 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions bal_tools/graphql/apiv3/get_gauges.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
query AllGauges($chain: GqlChain!) {
poolGetPools(where: { chainIn: [$chain] }) {
staking {
gauge {
gaugeAddress
otherGauges {
id
}
}
}
chain
symbol
}
}
9 changes: 9 additions & 0 deletions bal_tools/graphql/apiv3/get_pools.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
query AllPools($chain: GqlChain!) {
poolGetPools(where: { chainIn: [$chain] }) {
id
symbol
dynamicData {
swapEnabled
}
}
}
27 changes: 27 additions & 0 deletions bal_tools/pools_gauges.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,33 @@ def query_root_gauges(self, skip=0, step_size=100) -> list:
result += self.query_root_gauges(skip + step_size, step_size)
return result

def query_all_gauges(self, include_other_gauges=True) -> list:
"""
query all gauges from the apiv3 subgraph
"""
data = self.subgraph.fetch_graphql_data("apiv3", "get_gauges", {"chain": self.chain.upper()})
all_gauges = []
for gauge in data["poolGetPools"]:
if gauge['staking'] is not None:
if gauge['staking']['gauge'] is not None: # this is an edge case for the 80bal20weth pool
all_gauges.append({"id": gauge['staking']['gauge']['gaugeAddress'], "symbol": f"{gauge['symbol']}-gauge"})
if include_other_gauges:
for other_gauge in gauge['staking']['gauge']['otherGauges']:
all_gauges.append({"id": other_gauge['id'], "symbol": f"{gauge['symbol']}-gauge"})
return all_gauges

def query_all_pools(self) -> list:
"""
query all pools from the apiv3 subgraph
filters out disabled pools
"""
data = self.subgraph.fetch_graphql_data("apiv3", "get_pools", {"chain": self.chain.upper()})
all_pools = []
for pool in data["poolGetPools"]:
if pool['dynamicData']['swapEnabled']:
all_pools.append({"address": pool['id'], "symbol": pool['symbol']})
return all_pools

def get_last_join_exit(self, pool_id: int) -> int:
"""
Returns a timestamp of the last join/exit for a given pool id
Expand Down