Last active
December 3, 2020 13:46
-
-
Save rodrigosobrero/9c00bba87513d2fb7de052921e38dea2 to your computer and use it in GitHub Desktop.
Obtener precio de un token con el Subgraph oficial de Balancer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from gql import gql, Client | |
from gql.transport.aiohttp import AIOHTTPTransport | |
transport = AIOHTTPTransport(url="https://api.thegraph.com/subgraphs/name/balancer-labs/balancer") | |
client = Client(transport=transport, fetch_schema_from_transport=True) | |
# DAI | |
tokenAddress = "0x6b175474e89094c44da98b954eedeac495271d0f" | |
query = gql( | |
""" | |
query getPrice($id: ID!) { | |
tokenPrice(id: $id) { | |
price | |
} | |
} | |
""" | |
) | |
params = {"id", tokenAddress} | |
result = client.execute(query, variable_values=params) | |
print(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment