Skip to content

Commit

Permalink
Fix discrepancy and switch to querying hosted service subgraphs
Browse files Browse the repository at this point in the history
  • Loading branch information
0xAurelius committed May 17, 2024
1 parent 87eb2da commit 4b1daf3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/apps/treasury/pages/hud.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from src.apps.treasury.util.constants import BCT_ERC20_CONTRACT, KLIMA_GREEN
from src.apps.treasury.data.protocol_metrics import \
sg, last_metric, get_last_asset_price_by_address, protocol_metrics_subgraph
sg, last_metric, get_last_asset_price_by_address

ILLIQUID_ASSETS_GSHEET = 'https://docs.google.com/spreadsheets/d/1beNgV2Aemu01I-iyTsfOvHDTSevb0dj8GWXqo5KDShk'

Expand Down Expand Up @@ -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 = [
Expand Down
16 changes: 15 additions & 1 deletion src/apps/treasury/util/constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
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'
Expand Down

0 comments on commit 4b1daf3

Please sign in to comment.