From 4f32ccb12e26017fbc0e01dca8dc8e936836e421 Mon Sep 17 00:00:00 2001 From: Marcus Aurelius Date: Fri, 17 May 2024 10:03:30 -0400 Subject: [PATCH] Fix discrepancy and switch to querying hosted service subgraphs --- src/apps/treasury/pages/hud.py | 4 ++-- src/apps/treasury/util/constants.py | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/apps/treasury/pages/hud.py b/src/apps/treasury/pages/hud.py index 4b3a8df..18cc7c1 100644 --- a/src/apps/treasury/pages/hud.py +++ b/src/apps/treasury/pages/hud.py @@ -140,14 +140,14 @@ def query_last_metric(): # TODO: add logic to sum up balances until all KLIMA tokens are backed carbon_backing_usd = klima_supply * lowest_carbon_price -treasury_value -= carbon_backing_usd +total_treasury_value -= (carbon_backing_usd + treasury_usdc) # TODO: add descriptive tooltips to each label on the pie chart green_ratio_data = [ {"bucket": "Op Ex", "value": total_usdc, "target": 0.1}, {"bucket": "Carbon Forwards", "value": total_forwards, "target": 0.22}, {"bucket": "Carbon Backing", "value": carbon_backing_usd, "target": 0.2}, - {"bucket": "Treasury Holdings", "value": treasury_value, "target": 0.48} + {"bucket": "Treasury Holdings", "value": total_treasury_value, "target": 0.48} ] green_ratio_df = pd.DataFrame.from_records(green_ratio_data) order = [ diff --git a/src/apps/treasury/util/constants.py b/src/apps/treasury/util/constants.py index cb6e4ad..f708187 100644 --- a/src/apps/treasury/util/constants.py +++ b/src/apps/treasury/util/constants.py @@ -1,5 +1,15 @@ +import os + # Subgraphs -KLIMA_PROTOCOL_SUBGRAPH = 'https://api.thegraph.com/subgraphs/name/klimadao/klimadao-protocol-metrics' +GRAPH_API_KEY = os.environ.get('GRAPH_API_KEY') +GRAPH_BASE_URL = f'https://gateway-arbitrum.network.thegraph.com/api/{GRAPH_API_KEY}/subgraphs/id/' +GRAPH_DEV_BASE_URL = 'https://api.studio.thegraph.com/query/71975/' +GRAPH_VERSION_SUFFIX = '/version/latest' + +if os.environ.get('ENV') == 'production': + KLIMA_PROTOCOL_SUBGRAPH = 'https://api.studio.thegraph.com/query/71975/staging-klimadao-protocol-metrics/version/latest' +else: + KLIMA_PROTOCOL_SUBGRAPH = GRAPH_DEV_BASE_URL + 'staging-klimadao-protocol-metrics' + GRAPH_VERSION_SUFFIX BCT_ERC20_CONTRACT = '0x2f800db0fdb5223b3c3f354886d907a671414a7f' NCT_ERC20_CONTRACT = '0xD838290e877E0188a4A44700463419ED96c16107'