Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds Tao emissions to stake list #300

Open
wants to merge 1 commit into
base: rao-games/pools
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion bittensor_cli/src/bittensor/chain_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ class StakeInfo(InfoBase):
stake: Balance # Stake for the hotkey-coldkey pair
locked: Balance # Stake which is locked.
emission: Balance # Emission for the hotkey-coldkey pair
tao_emission: Balance # TAO emission for the hotkey-coldkey pair
drain: int
is_registered: bool

Expand All @@ -208,11 +209,20 @@ def _fix_decoded(cls, decoded: Any) -> "StakeInfo":
stake = Balance.from_rao(decoded.get("stake")).set_unit(netuid)
locked = Balance.from_rao(decoded.get("locked")).set_unit(netuid)
emission = Balance.from_rao(decoded.get("emission")).set_unit(netuid)
tao_emission = Balance.from_rao(decoded.get("tao_emission"))
drain = int(decoded.get("drain"))
is_registered = bool(decoded.get("is_registered"))

return StakeInfo(
hotkey, coldkey, netuid, stake, locked, emission, drain, is_registered
hotkey,
coldkey,
netuid,
stake,
locked,
emission,
tao_emission,
drain,
is_registered,
)


Expand Down
19 changes: 19 additions & 0 deletions bittensor_cli/src/commands/stake/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ def define_table(
style=COLOR_PALETTE["POOLS"]["EMISSION"],
justify="right",
)
table.add_column(
f"[white]Emission \n({Balance.get_unit(0)}/block)",
style=COLOR_PALETTE["POOLS"]["EMISSION"],
justify="right",
)
return table

def create_table(hotkey_: str, substakes: list[StakeInfo]):
Expand Down Expand Up @@ -200,6 +205,7 @@ def create_table(hotkey_: str, substakes: list[StakeInfo]):

# Per block emission cell
per_block_emission = substake_.emission.tao / pool.tempo
per_block_tao_emission = substake_.tao_emission.tao / pool.tempo
# Alpha ownership and TAO ownership cells
if alpha_value.tao > 0.00009:
if issuance.tao != 0:
Expand Down Expand Up @@ -243,6 +249,7 @@ def create_table(hotkey_: str, substakes: list[StakeInfo]):
# Removing this flag for now, TODO: Confirm correct values are here w.r.t CHKs
# if substake_.is_registered
# else f"[{COLOR_PALETTE['STAKE']['NOT_REGISTERED']}]N/A", # Emission(α/block)
str(Balance.from_tao(per_block_tao_emission)),
]
)
table = define_table(
Expand Down Expand Up @@ -343,6 +350,7 @@ def format_cell(
"swapped_value": swapped_tao_value.tao,
"emission": substake.emission.tao / pool.tempo,
"tao_ownership": tao_ownership.tao,
"tao_emission": substake.tao_emission.tao / pool.tempo,
}

# Get previous values for delta tracking
Expand Down Expand Up @@ -408,6 +416,16 @@ def format_cell(
unit_first=unit_first,
precision=4,
)

tao_emission_value = substake.tao_emission.tao / pool.tempo
tao_emission_cell = format_cell(
tao_emission_value,
prev.get("tao_emission"),
unit="τ",
unit_first=unit_first,
precision=4,
)

subnet_name_cell = (
f"[{COLOR_PALETTE['GENERAL']['SYMBOL']}]{symbol if netuid != 0 else 'τ'}[/{COLOR_PALETTE['GENERAL']['SYMBOL']}]"
f" {get_subnet_name(dynamic_info[netuid])}"
Expand All @@ -425,6 +443,7 @@ def format_cell(
if substake.is_registered
else f"[{COLOR_PALETTE['STAKE']['NOT_REGISTERED']}]NO", # Registration status
emission_cell, # Emission rate
tao_emission_cell, # TAO emission rate
]
)

Expand Down