Skip to content

Commit 2f2e366

Browse files
authored
Merge pull request #300 from opentensor/feat/add-tao-dividends-stake-list
Adds Tao emissions to stake list
2 parents 8477eb8 + 44e124f commit 2f2e366

File tree

2 files changed

+37
-7
lines changed

2 files changed

+37
-7
lines changed

bittensor_cli/src/bittensor/chain_data.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ class SubnetHyperparameters(InfoBase):
156156
def _fix_decoded(
157157
cls, decoded: Union[dict, "SubnetHyperparameters"]
158158
) -> "SubnetHyperparameters":
159-
return SubnetHyperparameters(
159+
return cls(
160160
rho=decoded.get("rho"),
161161
kappa=decoded.get("kappa"),
162162
immunity_period=decoded.get("immunity_period"),
@@ -197,6 +197,7 @@ class StakeInfo(InfoBase):
197197
stake: Balance # Stake for the hotkey-coldkey pair
198198
locked: Balance # Stake which is locked.
199199
emission: Balance # Emission for the hotkey-coldkey pair
200+
tao_emission: Balance # TAO emission for the hotkey-coldkey pair
200201
drain: int
201202
is_registered: bool
202203

@@ -208,11 +209,20 @@ def _fix_decoded(cls, decoded: Any) -> "StakeInfo":
208209
stake = Balance.from_rao(decoded.get("stake")).set_unit(netuid)
209210
locked = Balance.from_rao(decoded.get("locked")).set_unit(netuid)
210211
emission = Balance.from_rao(decoded.get("emission")).set_unit(netuid)
212+
tao_emission = Balance.from_rao(decoded.get("tao_emission"))
211213
drain = int(decoded.get("drain"))
212214
is_registered = bool(decoded.get("is_registered"))
213215

214-
return StakeInfo(
215-
hotkey, coldkey, netuid, stake, locked, emission, drain, is_registered
216+
return cls(
217+
hotkey,
218+
coldkey,
219+
netuid,
220+
stake,
221+
locked,
222+
emission,
223+
tao_emission,
224+
drain,
225+
is_registered,
216226
)
217227

218228

@@ -293,7 +303,7 @@ def _fix_decoded(cls, decoded: Any) -> "NeuronInfo":
293303
axon_info = decoded.get("axon_info", {})
294304
coldkey = decode_account_id(decoded.get("coldkey"))
295305
hotkey = decode_account_id(decoded.get("hotkey"))
296-
return NeuronInfo(
306+
return cls(
297307
hotkey=hotkey,
298308
coldkey=coldkey,
299309
uid=decoded.get("uid"),
@@ -555,7 +565,7 @@ class SubnetInfo(InfoBase):
555565

556566
@classmethod
557567
def _fix_decoded(cls, decoded: "SubnetInfo") -> "SubnetInfo":
558-
return SubnetInfo(
568+
return cls(
559569
netuid=decoded.get("netuid"),
560570
rho=decoded.get("rho"),
561571
kappa=decoded.get("kappa"),
@@ -594,7 +604,7 @@ class SubnetIdentity(InfoBase):
594604

595605
@classmethod
596606
def _fix_decoded(cls, decoded: dict) -> "SubnetIdentity":
597-
return SubnetIdentity(
607+
return cls(
598608
subnet_name=bytes(decoded["subnet_name"]).decode(),
599609
github_repo=bytes(decoded["github_repo"]).decode(),
600610
subnet_contact=bytes(decoded["subnet_contact"]).decode(),
@@ -828,7 +838,7 @@ class SubnetState(InfoBase):
828838
@classmethod
829839
def _fix_decoded(cls, decoded: Any) -> "SubnetState":
830840
netuid = decoded.get("netuid")
831-
return SubnetState(
841+
return cls(
832842
netuid=netuid,
833843
hotkeys=[decode_account_id(val) for val in decoded.get("hotkeys")],
834844
coldkeys=[decode_account_id(val) for val in decoded.get("coldkeys")],

bittensor_cli/src/commands/stake/list.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import asyncio
22

33
from typing import TYPE_CHECKING, Optional
4+
from bittensor_cli.src.commands.stake.remove import unstake
45
import typer
56

67
from bittensor_wallet import Wallet
@@ -130,6 +131,11 @@ def define_table(
130131
style=COLOR_PALETTE["POOLS"]["EMISSION"],
131132
justify="right",
132133
)
134+
table.add_column(
135+
f"[white]Emission \n({Balance.get_unit(0)}/block)",
136+
style=COLOR_PALETTE["POOLS"]["EMISSION"],
137+
justify="right",
138+
)
133139
return table
134140

135141
def create_table(hotkey_: str, substakes: list[StakeInfo]):
@@ -200,6 +206,7 @@ def create_table(hotkey_: str, substakes: list[StakeInfo]):
200206

201207
# Per block emission cell
202208
per_block_emission = substake_.emission.tao / (pool.tempo or 1)
209+
per_block_tao_emission = substake_.tao_emission.tao / (pool.tempo or 1)
203210
# Alpha ownership and TAO ownership cells
204211
if alpha_value.tao > 0.00009:
205212
if issuance.tao != 0:
@@ -243,6 +250,7 @@ def create_table(hotkey_: str, substakes: list[StakeInfo]):
243250
# Removing this flag for now, TODO: Confirm correct values are here w.r.t CHKs
244251
# if substake_.is_registered
245252
# else f"[{COLOR_PALETTE['STAKE']['NOT_REGISTERED']}]N/A", # Emission(α/block)
253+
str(Balance.from_tao(per_block_tao_emission)),
246254
]
247255
)
248256
table = define_table(
@@ -343,6 +351,7 @@ def format_cell(
343351
"swapped_value": swapped_tao_value.tao,
344352
"emission": substake.emission.tao / (pool.tempo or 1),
345353
"tao_ownership": tao_ownership.tao,
354+
"tao_emission": substake.tao_emission.tao (pool.tempo or 1),
346355
}
347356

348357
# Get previous values for delta tracking
@@ -408,6 +417,16 @@ def format_cell(
408417
unit_first=unit_first,
409418
precision=4,
410419
)
420+
421+
tao_emission_value = substake.tao_emission.tao / (pool.tempo or 1)
422+
tao_emission_cell = format_cell(
423+
tao_emission_value,
424+
prev.get("tao_emission"),
425+
unit="τ",
426+
unit_first=unit_first,
427+
precision=4,
428+
)
429+
411430
subnet_name_cell = (
412431
f"[{COLOR_PALETTE['GENERAL']['SYMBOL']}]{symbol if netuid != 0 else 'τ'}[/{COLOR_PALETTE['GENERAL']['SYMBOL']}]"
413432
f" {get_subnet_name(dynamic_info[netuid])}"
@@ -425,6 +444,7 @@ def format_cell(
425444
if substake.is_registered
426445
else f"[{COLOR_PALETTE['STAKE']['NOT_REGISTERED']}]NO", # Registration status
427446
emission_cell, # Emission rate
447+
tao_emission_cell, # TAO emission rate
428448
]
429449
)
430450

0 commit comments

Comments
 (0)