Skip to content

Commit 4b1daf3

Browse files
committed
Fix discrepancy and switch to querying hosted service subgraphs
1 parent 87eb2da commit 4b1daf3

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/apps/treasury/pages/hud.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from src.apps.treasury.util.constants import BCT_ERC20_CONTRACT, KLIMA_GREEN
1212
from src.apps.treasury.data.protocol_metrics import \
13-
sg, last_metric, get_last_asset_price_by_address, protocol_metrics_subgraph
13+
sg, last_metric, get_last_asset_price_by_address
1414

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

@@ -140,14 +140,14 @@ def query_last_metric():
140140
# TODO: add logic to sum up balances until all KLIMA tokens are backed
141141

142142
carbon_backing_usd = klima_supply * lowest_carbon_price
143-
treasury_value -= carbon_backing_usd
143+
total_treasury_value -= (carbon_backing_usd + treasury_usdc)
144144

145145
# TODO: add descriptive tooltips to each label on the pie chart
146146
green_ratio_data = [
147147
{"bucket": "Op Ex", "value": total_usdc, "target": 0.1},
148148
{"bucket": "Carbon Forwards", "value": total_forwards, "target": 0.22},
149149
{"bucket": "Carbon Backing", "value": carbon_backing_usd, "target": 0.2},
150-
{"bucket": "Treasury Holdings", "value": treasury_value, "target": 0.48}
150+
{"bucket": "Treasury Holdings", "value": total_treasury_value, "target": 0.48}
151151
]
152152
green_ratio_df = pd.DataFrame.from_records(green_ratio_data)
153153
order = [

src/apps/treasury/util/constants.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
1+
import os
2+
13
# Subgraphs
2-
KLIMA_PROTOCOL_SUBGRAPH = 'https://api.thegraph.com/subgraphs/name/klimadao/klimadao-protocol-metrics'
4+
GRAPH_API_KEY = os.environ.get('GRAPH_API_KEY')
5+
GRAPH_BASE_URL = f'https://gateway-arbitrum.network.thegraph.com/api/{GRAPH_API_KEY}/subgraphs/id/'
6+
GRAPH_DEV_BASE_URL = 'https://api.studio.thegraph.com/query/71975/'
7+
GRAPH_VERSION_SUFFIX = '/version/latest'
8+
9+
if os.environ.get('ENV') == 'production':
10+
KLIMA_PROTOCOL_SUBGRAPH = (
11+
'https://api.studio.thegraph.com/query/71975/staging-klimadao-protocol-metrics/version/latest'
12+
)
13+
else:
14+
KLIMA_PROTOCOL_SUBGRAPH = (
15+
GRAPH_DEV_BASE_URL + 'staging-klimadao-protocol-metrics' + GRAPH_VERSION_SUFFIX
16+
)
317

418
BCT_ERC20_CONTRACT = '0x2f800db0fdb5223b3c3f354886d907a671414a7f'
519
NCT_ERC20_CONTRACT = '0xD838290e877E0188a4A44700463419ED96c16107'

0 commit comments

Comments
 (0)