|
16 | 16 |
|
17 | 17 | dash.register_page(__name__, title="KlimaDAO Treasury Heads Up Display")
|
18 | 18 |
|
19 |
| -# TODO: add caching |
20 | 19 |
|
21 |
| -# TODO: combine repetitive queries to `last_metric` into a single DF call and unpack instead |
22 |
| -# last_metric_df = sg.query_df([last_metric.marketCap, last_metric.treasuryMarketValue, ...]) |
| 20 | +def query_last_metric(): |
| 21 | + df = sg.query_df([ |
| 22 | + last_metric.marketCap, |
| 23 | + last_metric.treasuryMarketValue, |
| 24 | + last_metric.daoBalanceUSDC, last_metric.treasuryBalanceUSDC, |
| 25 | + last_metric.treasuryMarketValue, last_metric.daoBalanceKLIMA, |
| 26 | + last_metric.klimaPrice, last_metric.totalSupply |
| 27 | + ]) |
| 28 | + |
| 29 | + df = df.rename({ |
| 30 | + c: c.replace('protocolMetrics_', '') for c in df.columns |
| 31 | + }, axis=1) |
| 32 | + |
| 33 | + return df |
| 34 | + |
| 35 | + |
| 36 | +last_metric_df = query_last_metric() |
| 37 | + |
| 38 | +mcap = last_metric_df.loc[0, 'marketCap'] |
| 39 | +mval = last_metric_df.loc[0, 'treasuryMarketValue'] |
23 | 40 |
|
24 | 41 | # Market Cap indicator
|
25 | 42 | metric_fig = go.Figure(
|
26 | 43 | go.Indicator(
|
27 | 44 | mode="number",
|
28 |
| - value=sg.query([last_metric.marketCap]), |
| 45 | + value=mcap, |
29 | 46 | number={"prefix": "$", "valueformat": ".2s", "font": {"family": "Poppins-ExtraBold"}},
|
30 | 47 | title={
|
31 | 48 | "text":
|
|
43 | 60 | # Total Treasury Market Value ($) indicator
|
44 | 61 | go.Indicator(
|
45 | 62 | mode="number",
|
46 |
| - value=sg.query([last_metric.treasuryMarketValue]), |
| 63 | + value=mval, |
47 | 64 | number={"prefix": "$", "valueformat": ".2s", "font": {"family": "Poppins-ExtraBold"}},
|
48 | 65 | title={
|
49 | 66 | "text":
|
|
81 | 98 | total_illiquid_spot = illiquid_assets[illiquid_assets.Is_Spot]["Dollars"].sum()
|
82 | 99 |
|
83 | 100 | # Pull sum of DAO and Treasury USDC holdings for OpEx
|
84 |
| -dao_usdc, treasury_usdc = sg.query([last_metric.daoBalanceUSDC, last_metric.treasuryBalanceUSDC]) |
| 101 | +dao_usdc = last_metric_df.loc[0, 'daoBalanceUSDC'] |
| 102 | +treasury_usdc = last_metric_df.loc[0, 'treasuryBalanceUSDC'] |
85 | 103 | total_usdc = dao_usdc + treasury_usdc
|
86 | 104 |
|
87 | 105 | # Total treasury market value
|
88 | 106 | # TODO: check that treasuryMarketValue field includes all assets (raw carbon, all LPs, raw KLIMA)
|
89 | 107 | # TODO: add Solid World CRISP-C LP value
|
90 | 108 | # TODO: add offchain assets (added illiquid spot tonnes, may be other assets)
|
91 |
| -(treasury_value, dao_klima, klima_price) = sg.query([ |
92 |
| - last_metric.treasuryMarketValue, last_metric.daoBalanceKLIMA, |
93 |
| - last_metric.klimaPrice |
94 |
| -]) |
| 109 | +treasury_value = last_metric_df.loc[0, 'treasuryMarketValue'] |
| 110 | +dao_klima = last_metric_df.loc[0, 'daoBalanceKLIMA'] |
| 111 | +klima_price = last_metric_df.loc[0, 'klimaPrice'] |
95 | 112 |
|
96 | 113 | # Add DAO KLIMA holdings since it is not considered part of OpEx bucket
|
97 | 114 | total_treasury_value = (
|
98 | 115 | treasury_value + (dao_klima * klima_price) + total_illiquid_spot
|
99 | 116 | )
|
100 | 117 |
|
101 |
| -# TODO: make sure treasury KLIMA is included in treasuryMarketValue |
102 |
| - |
103 | 118 | # Separate out enough lowest price carbon tonnes from total treasury value
|
104 | 119 | # to back all KLIMA supply as Carbon Backing
|
105 |
| -klima_supply = sg.query([last_metric.totalSupply]) |
| 120 | +klima_supply = last_metric_df.loc[0, 'totalSupply'] |
106 | 121 |
|
107 | 122 | # TODO: Replace hard-coded BCT with dynamic check for lowest priced tonne
|
108 | 123 | lowest_price_carbon_addr = BCT_ERC20_CONTRACT
|
|
0 commit comments