Skip to content

Commit

Permalink
add a query/function to fetch pools based on tvl and swap fee.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tritium-VLK committed Oct 9, 2024
1 parent 004d88d commit 8bb1838
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
25 changes: 25 additions & 0 deletions bal_tools/graphql/apiv3/get_swap_fees.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
query getSwapFees($where: GqlPoolFilter)
{
poolGetPools(where: $where) {
chain
id
symbol
address
type
dynamicData {
totalLiquidity
swapFee
}
}
}
## Example Where
#{
# "where": {
# "minTvl": 100000,
# "poolTypeIn": [
# "STABLE",
# "META_STABLE",
# "COMPOSABLE_STABLE"
# ],
# "chainIn": ["ARBITRUM", "MAINNET"]
# }
37 changes: 37 additions & 0 deletions bal_tools/subgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,43 @@ def get_balancer_pool_snapshots(
break
return all_pools


def query_pools_by_tvl_and_swapfee(self,
lower_boundry=0.0001,
upper_boundry=0.0003,
min_tvl=500_000,
pool_types=["STABLE", "META_STABLE", "COMPOSABLE_STABLE"],
chains=None):
if chains is None:
chains = [self.chain.upper()]
print(f"Running on {chains}")
where = {"where":
{
"minTvl": min_tvl,
"poolTypeIn": pool_types,
"chainIn": chains
}
}
print(where)
results = {}
query = self.fetch_graphql_data("apiv3", "get_swap_fees", where)
for result in query["poolGetPools"]:
if float(result["dynamicData"]["swapFee"]) < lower_boundry or float(result["dynamicData"]["swapFee"]) > upper_boundry:
pool_id = result["id"]
chain = result["chain"]
symbol = result["symbol"]
swapFee = result["dynamicData"]["swapFee"]
tvl = result["dynamicData"]["totalLiquidity"]

results[pool_id] = {
"chain": chain,
"symbol": symbol,
"swapFee": swapFee,
"tvl": tvl
}
return results


def _saETH(
self,
address: str,
Expand Down

0 comments on commit 8bb1838

Please sign in to comment.