beta_load_subgraphs
Fetch data from multiple subgraphs
beta_load_subgraphs(defs)
Parameters
defs (List[SubgraphDef])
SubgraphDef
is a wrapper class of parameters ofbeta_load_subgraph
:
url (str)
query (str)
progressCallback=None
useBigDecimal=False
Returns
{
<Subgraph_url>:{
<Entity_name>: <DataFrame_of_items_from_the_graph>
}
...
}
Examples
From 2021-01-01 to 2021-01-10, fetch all deposits and earliest 3 flash loans from AAVE v2 subgraph, and all mintEvents from Compound V2 subgraph
url_aave_subgraph = 'https://api.thegraph.com/subgraphs/name/aave/protocol-v2'
query_aave = """
{
deposits(
where:{timestamp_gte:1609459200, timestamp_lt:1610236800}
orderBy: timestamp
orderDirection: desc
bypassPagination: true
) {
reserve {
symbol,
decimals
}
amount
timestamp
}
flashLoans(
orderBy: timestamp
orderDirection: asc
first:3
){
amount
timestamp
}
}
"""
url_compoundv2_subgraph = 'https://api.thegraph.com/subgraphs/name/graphprotocol/compound-v2'
query_compoundv2 = """
{
mintEvents(
where:{blockTime_gte:1609459200, blockTime_lt:1610236800}
bypassPagination: true
) {
cTokenSymbol
amount
underlyingAmount
blockTime
}
}
"""
data = bubbletea.beta_load_subgraphs([
bubbletea.SubgraphDef(url=url_aave_subgraph, query=query_aave),
bubbletea.SubgraphDef(url=url_compoundv2_subgraph, query=query_compoundv2)
])
df_aave_deposits = data[url_aave_subgraph]['deposits']
df_aave_flashloans = data[url_aave_subgraph]['flashLoans']
df_compound_mints = data[url_compoundv2_subgraph]['mintEvents']
print(df_aave_deposits)
print(df_aave_deposits.dtypes)
print(df_compound_mints)
print(df_compound_mints.dtypes)
Last updated
Was this helpful?