Skip to content
Merged
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 9.0.0rc4 /2025-02-12
* Adds sort option to metagraph/show
* Updates metagraph/show to use direct dividends instead of relative
* Updates subnets list to use working tao emissions

## 9.0.0rc3 /2025-02-11

## What's Changed
Expand Down
2 changes: 1 addition & 1 deletion bittensor_cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
from .cli import CLIManager


__version__ = "9.0.0rc3"
__version__ = "9.0.0rc4"

__all__ = [CLIManager, __version__]
15 changes: 12 additions & 3 deletions bittensor_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class GitError(Exception):
pass


__version__ = "9.0.0rc3"
__version__ = "9.0.0rc4"


_core_version = re.match(r"^\d+\.\d+\.\d+", __version__).group(0)
Expand Down Expand Up @@ -2919,6 +2919,7 @@ def stake_add(
subnets.show(
subtensor=self.initialize_chain(network),
netuid=netuid,
sort=False,
max_rows=12,
prompt=False,
delegate_selection=True,
Expand Down Expand Up @@ -4327,6 +4328,11 @@ def subnets_show(
self,
network: Optional[list[str]] = Options.network,
netuid: int = Options.netuid,
sort: bool = typer.Option(
False,
"--sort",
help="Sort the subnets by uid.",
),
quiet: bool = Options.quiet,
verbose: bool = Options.verbose,
prompt: bool = Options.prompt,
Expand All @@ -4342,8 +4348,11 @@ def subnets_show(
subtensor = self.initialize_chain(network)
return self._run_command(
subnets.show(
subtensor,
netuid,
subtensor=subtensor,
netuid=netuid,
sort=sort,
max_rows=None,
delegate_selection=False,
verbose=verbose,
prompt=prompt,
)
Expand Down
93 changes: 33 additions & 60 deletions bittensor_cli/src/commands/subnets/subnets.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def create_table(subnets, block_number):
if netuid == 0:
emission_tao = 0.0
else:
emission_tao = subnet.emission.tao
emission_tao = subnet.tao_in_emission.tao

alpha_in_value = (
f"{millify_tao(subnet.alpha_in.tao)}"
Expand Down Expand Up @@ -399,7 +399,7 @@ def create_table(subnets, block_number):
)

total_emissions = round(
sum(float(subnet.emission.tao) for subnet in subnets if subnet.netuid != 0),
sum(subnet.tao_in_emission.tao for subnet in subnets if subnet.netuid != 0),
4,
)
total_rate = round(
Expand Down Expand Up @@ -528,7 +528,7 @@ def format_liquidity_cell(
if netuid == 0:
emission_tao = 0.0
else:
emission_tao = subnet.emission.tao
emission_tao = subnet.tao_in_emission.tao

market_cap = (subnet.alpha_in.tao + subnet.alpha_out.tao) * subnet.price.tao
supply = subnet.alpha_in.tao + subnet.alpha_out.tao
Expand Down Expand Up @@ -657,17 +657,15 @@ def format_liquidity_cell(
# Calculate totals
total_netuids = len(subnets)
_total_emissions = sum(
float(subnet.emission.tao) for subnet in subnets if subnet.netuid != 0
subnet.tao_in_emission.tao for subnet in subnets if subnet.netuid != 0
)
total_emissions = (
f"{millify_tao(_total_emissions)}"
if not verbose
else f"{_total_emissions:,.2f}"
)

total_rate = sum(
float(subnet.price.tao) for subnet in subnets if subnet.netuid != 0
)
total_rate = sum(subnet.price.tao for subnet in subnets if subnet.netuid != 0)
total_rate = (
f"{millify_tao(total_rate)}" if not verbose else f"{total_rate:,.2f}"
)
Expand Down Expand Up @@ -804,6 +802,7 @@ def format_liquidity_cell(
async def show(
subtensor: "SubtensorInterface",
netuid: int,
sort: bool = False,
max_rows: Optional[int] = None,
delegate_selection: bool = False,
verbose: bool = False,
Expand Down Expand Up @@ -850,26 +849,13 @@ async def show_root():
)

table.add_column("[bold white]Position", style="white", justify="center")
# table.add_column(
# f"[bold white]Total Stake ({Balance.get_unit(0)})",
# style=COLOR_PALETTE["POOLS"]["ALPHA_IN"],
# justify="center",
# )
# ------- Temporary columns for testing -------
# table.add_column(
# "Alpha (τ)",
# style=COLOR_PALETTE["POOLS"]["EXTRA_2"],
# no_wrap=True,
# justify="right",
# )
table.add_column(
"Tao (τ)",
style=COLOR_PALETTE["POOLS"]["EXTRA_2"],
no_wrap=True,
justify="right",
footer=f"{tao_sum:.4f} τ" if verbose else f"{millify_tao(tao_sum)} τ",
)
# ------- End Temporary columns for testing -------
table.add_column(
f"[bold white]Emission ({Balance.get_unit(0)}/block)",
style=COLOR_PALETTE["POOLS"]["EMISSION"],
Expand Down Expand Up @@ -1075,14 +1061,6 @@ async def show_subnet(netuid_: int):
pad_edge=True,
)

# For hotkey_block_emission calculation
emission_sum = sum(
[
subnet_state.emission[idx].tao
for idx in range(len(subnet_state.emission))
]
)

# For table footers
alpha_sum = sum(
[
Expand All @@ -1102,7 +1080,16 @@ async def show_subnet(netuid_: int):
for idx in range(len(subnet_state.tao_stake))
]
)
relative_emissions_sum = 0
dividends_sum = sum(
subnet_state.dividends[idx] for idx in range(len(subnet_state.dividends))
)
emission_sum = sum(
[
subnet_state.emission[idx].tao
for idx in range(len(subnet_state.emission))
]
)

owner_hotkeys = await subtensor.get_owned_hotkeys(subnet_info.owner_coldkey)
if subnet_info.owner_hotkey not in owner_hotkeys:
owner_hotkeys.append(subnet_info.owner_hotkey)
Expand All @@ -1118,25 +1105,24 @@ async def show_subnet(netuid_: int):
sorted_indices = sorted(
range(len(subnet_state.hotkeys)),
key=lambda i: (
# Sort by owner status first
not (
subnet_state.coldkeys[i] == subnet_info.owner_coldkey
or subnet_state.hotkeys[i] in owner_hotkeys
),
# Then sort by stake amount (higher stakes first)
-subnet_state.total_stake[i].tao,
# If sort is True, sort only by UIDs
i
if sort
else (
# Otherwise
# Sort by owner status first
not (
subnet_state.coldkeys[i] == subnet_info.owner_coldkey
or subnet_state.hotkeys[i] in owner_hotkeys
),
# Then sort by stake amount (higher stakes first)
-subnet_state.total_stake[i].tao,
)
),
)

rows = []
for idx in sorted_indices:
hotkey_block_emission = (
subnet_state.emission[idx].tao / emission_sum
if emission_sum != 0
else 0
)
relative_emissions_sum += hotkey_block_emission

# Get identity for this uid
coldkey_identity = identities.get(subnet_state.coldkeys[idx], {}).get(
"name", ""
Expand Down Expand Up @@ -1175,11 +1161,9 @@ async def show_subnet(netuid_: int):
f"τ {tao_stake.tao:.4f}"
if verbose
else f"τ {millify_tao(tao_stake)}", # Tao Stake
# str(subnet_state.dividends[idx]),
f"{Balance.from_tao(hotkey_block_emission).set_unit(netuid_).tao:.5f}", # Dividends
f"{subnet_state.incentives[idx]:.4f}", # Incentive
# f"{Balance.from_tao(hotkey_block_emission).set_unit(netuid_).tao:.5f}", # Emissions relative
f"{Balance.from_tao(subnet_state.emission[idx].tao).set_unit(netuid_).tao:.5f} {subnet_info.symbol}", # Emissions
f"{subnet_state.dividends[idx]:.6f}", # Dividends
f"{subnet_state.incentives[idx]:.6f}", # Incentive
f"{Balance.from_tao(subnet_state.emission[idx].tao).set_unit(netuid_).tao:.6f} {subnet_info.symbol}", # Emissions
f"{subnet_state.hotkeys[idx][:6]}"
if not verbose
else f"{subnet_state.hotkeys[idx]}", # Hotkey
Expand All @@ -1201,7 +1185,6 @@ async def show_subnet(netuid_: int):
if verbose
else f"{millify_tao(stake_sum)} {subnet_info.symbol}",
)
# ------- Temporary columns for testing -------
table.add_column(
f"Alpha ({Balance.get_unit(netuid_)})",
style=COLOR_PALETTE["POOLS"]["EXTRA_2"],
Expand All @@ -1220,24 +1203,14 @@ async def show_subnet(netuid_: int):
if verbose
else f"{millify_tao(tao_sum)} {subnet_info.symbol}",
)
# ------- End Temporary columns for testing -------
table.add_column(
"Dividends",
style=COLOR_PALETTE["POOLS"]["EMISSION"],
no_wrap=True,
justify="center",
footer=f"{relative_emissions_sum:.3f}",
footer=f"{dividends_sum:.3f}",
)
table.add_column("Incentive", style="#5fd7ff", no_wrap=True, justify="center")

# Hiding relative emissions for now
# table.add_column(
# "Emissions",
# style="light_goldenrod2",
# no_wrap=True,
# justify="center",
# footer=f"{relative_emissions_sum:.3f}",
# )
table.add_column(
f"Emissions ({Balance.get_unit(netuid_)})",
style=COLOR_PALETTE["POOLS"]["EMISSION"],
Expand Down