Skip to content

Commit 6b73141

Browse files
authored
Merge pull request opentensor#700 from opentensor/release/9.15.1
Release/9.15.1
2 parents ed29e71 + 1b83836 commit 6b73141

File tree

4 files changed

+88
-54
lines changed

4 files changed

+88
-54
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 9.15.1 /2025-11-04
4+
5+
* Update/Subnet list ema by @ibraheem-abe in https://github.com/opentensor/btcli/pull/699
6+
7+
**Full Changelog**: https://github.com/opentensor/btcli/compare/v9.15.0...v9.15.1
8+
39
## 9.15.0 /2025-11-04
410

511
* Stop running e2e tests on changelog branches by @thewhaleking in https://github.com/opentensor/btcli/pull/691

bittensor_cli/src/bittensor/subtensor_interface.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2231,7 +2231,7 @@ async def get_all_subnet_ema_tao_inflow(
22312231
self,
22322232
block_hash: Optional[str] = None,
22332233
page_size: int = 100,
2234-
) -> dict[int, tuple[int, float]]:
2234+
) -> dict[int, Balance]:
22352235
"""
22362236
Query EMA TAO inflow for all subnets.
22372237
@@ -2243,20 +2243,23 @@ async def get_all_subnet_ema_tao_inflow(
22432243
page_size: The page size for batch queries (default: 100).
22442244
22452245
Returns:
2246-
Dict mapping netuid -> (block_number, Balance(EMA TAO inflow)).
2246+
Dict mapping netuid -> Balance(EMA TAO inflow).
22472247
"""
22482248
query = await self.substrate.query_map(
22492249
module="SubtensorModule",
22502250
storage_function="SubnetEmaTaoFlow",
22512251
page_size=page_size,
22522252
block_hash=block_hash,
22532253
)
2254-
tao_inflow_ema = {}
2254+
ema_map = {}
22552255
async for netuid, value in query:
2256-
block_updated, _tao_ema = value
2257-
ema_value = fixed_to_float(_tao_ema)
2258-
tao_inflow_ema[netuid] = (block_updated, Balance.from_rao(ema_value))
2259-
return tao_inflow_ema
2256+
if not value:
2257+
ema_map[netuid] = Balance.from_rao(0)
2258+
else:
2259+
_, raw_ema_value = value
2260+
ema_value = fixed_to_float(raw_ema_value)
2261+
ema_map[netuid] = Balance.from_rao(ema_value)
2262+
return ema_map
22602263

22612264
async def get_subnet_ema_tao_inflow(
22622265
self,

bittensor_cli/src/commands/subnets/subnets.py

Lines changed: 71 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,11 @@ async def subnets_list(
223223

224224
async def fetch_subnet_data():
225225
block_hash = await subtensor.substrate.get_chain_head()
226-
subnets_, mechanisms, block_number_ = await asyncio.gather(
226+
subnets_, mechanisms, block_number_, ema_tao_inflow = await asyncio.gather(
227227
subtensor.all_subnets(block_hash=block_hash),
228228
subtensor.get_all_subnet_mechanisms(block_hash=block_hash),
229229
subtensor.substrate.get_block_number(block_hash=block_hash),
230+
subtensor.get_all_subnet_ema_tao_inflow(block_hash=block_hash),
230231
)
231232

232233
# Sort subnets by market cap, keeping the root subnet in the first position
@@ -237,7 +238,7 @@ async def fetch_subnet_data():
237238
reverse=True,
238239
)
239240
sorted_subnets = [root_subnet] + other_subnets
240-
return sorted_subnets, block_number_, mechanisms
241+
return sorted_subnets, block_number_, mechanisms, ema_tao_inflow
241242

242243
def calculate_emission_stats(
243244
subnets_: list, block_number_: int
@@ -259,43 +260,12 @@ def calculate_emission_stats(
259260
)
260261
return total_tao_emitted, percentage_string
261262

262-
def format_ema_tao_value(value: float, verbose: bool = False) -> str:
263-
"""
264-
Format EMA TAO inflow value with adaptive precision.
265-
"""
266-
import math
267-
268-
abs_value = abs(value)
269-
if abs_value == 0:
270-
return "0.00"
271-
elif abs_value >= 1.0:
272-
# Large values: 2-4 decimal places
273-
return f"{abs_value:,.4f}" if verbose else f"{abs_value:,.2f}"
274-
elif abs_value >= 0.01:
275-
# Medium values: 4 decimal places
276-
return f"{abs_value:.4f}"
277-
else:
278-
# Low values: upto 12 decimal places
279-
decimal_places = -int(math.floor(math.log10(abs_value))) + 2
280-
decimal_places = min(decimal_places, 12)
281-
return f"{abs_value:.{decimal_places}f}"
282-
283-
def format_ema_flow_cell(ema_value: float) -> tuple[str, str]:
284-
"""
285-
Format EMA TAO inflow value with adaptive precision.
286-
"""
287-
if ema_value > 0:
288-
return "pale_green3", "+"
289-
elif ema_value < 0:
290-
return "hot_pink3", "-"
291-
else:
292-
return "blue", ""
293-
294263
def define_table(
295264
total_emissions: float,
296265
total_rate: float,
297266
total_netuids: int,
298267
tao_emission_percentage: str,
268+
total_tao_flow_ema: float,
299269
):
300270
defined_table = Table(
301271
title=f"\n[{COLOR_PALETTE['GENERAL']['HEADER']}]Subnets"
@@ -334,6 +304,12 @@ def define_table(
334304
justify="left",
335305
footer=f"τ {total_emissions}",
336306
)
307+
defined_table.add_column(
308+
f"[bold white]Net Inflow EMA ({Balance.get_unit(0)})",
309+
style=COLOR_PALETTE["POOLS"]["ALPHA_OUT"],
310+
justify="left",
311+
footer=f"τ {total_tao_flow_ema}",
312+
)
337313
defined_table.add_column(
338314
f"[bold white]P ({Balance.get_unit(0)}_in, {Balance.get_unit(1)}_in)",
339315
style=COLOR_PALETTE["STAKE"]["TAO"],
@@ -365,7 +341,7 @@ def define_table(
365341
return defined_table
366342

367343
# Non-live mode
368-
def _create_table(subnets_, block_number_, mechanisms):
344+
def _create_table(subnets_, block_number_, mechanisms, ema_tao_inflow):
369345
rows = []
370346
_, percentage_string = calculate_emission_stats(subnets_, block_number_)
371347

@@ -432,6 +408,12 @@ def _create_table(subnets_, block_number_, mechanisms):
432408
)
433409
emission_cell = f"τ {emission_tao:,.4f}"
434410

411+
if netuid in ema_tao_inflow:
412+
ema_value = ema_tao_inflow[netuid].tao
413+
else:
414+
ema_value = 0.0
415+
ema_flow_cell = f"τ {ema_value:,.4f}"
416+
435417
price_cell = f"{price_value} τ/{symbol}"
436418
alpha_out_cell = (
437419
f"{alpha_out_value} {symbol}"
@@ -455,6 +437,7 @@ def _create_table(subnets_, block_number_, mechanisms):
455437
price_cell, # Rate τ_in/α_in
456438
market_cap_cell, # Market Cap
457439
emission_cell, # Emission (τ)
440+
ema_flow_cell, # EMA TAO Inflow (τ)
458441
liquidity_cell, # Liquidity (t_in, a_in)
459442
alpha_out_cell, # Stake α_out
460443
supply_cell, # Supply
@@ -469,22 +452,30 @@ def _create_table(subnets_, block_number_, mechanisms):
469452
),
470453
4,
471454
)
455+
total_tao_flow_ema = round(
456+
sum(inflow.tao for inflow in ema_tao_inflow.values()), 4
457+
)
472458
total_rate = round(
473459
sum(float(subnet.price.tao) for subnet in subnets_ if subnet.netuid != 0), 4
474460
)
475461
total_netuids = len(subnets_)
476462
defined_table = define_table(
477-
total_emissions, total_rate, total_netuids, percentage_string
463+
total_emissions,
464+
total_rate,
465+
total_netuids,
466+
percentage_string,
467+
total_tao_flow_ema,
478468
)
479469

480470
for row in rows:
481471
defined_table.add_row(*row)
482472
return defined_table
483473

484-
def dict_table(subnets_, block_number_, mechanisms) -> dict:
474+
def dict_table(subnets_, block_number_, mechanisms, ema_tao_inflow) -> dict:
485475
subnet_rows = {}
486476
total_tao_emitted, _ = calculate_emission_stats(subnets_, block_number_)
487477
total_emissions = 0.0
478+
total_tao_flow_ema = 0.0
488479
total_rate = 0.0
489480
total_netuids = len(subnets_)
490481
emission_percentage = (total_tao_emitted / block_number_) * 100
@@ -511,12 +502,17 @@ def dict_table(subnets_, block_number_, mechanisms) -> dict:
511502
),
512503
"sn_tempo": (subnet.tempo if netuid != 0 else None),
513504
}
505+
tao_flow_ema = None
506+
if netuid in ema_tao_inflow:
507+
tao_flow_ema = ema_tao_inflow[netuid].tao
508+
total_tao_flow_ema += tao_flow_ema.tao
514509
subnet_rows[netuid] = {
515510
"netuid": netuid,
516511
"subnet_name": subnet_name,
517512
"price": price_value,
518513
"market_cap": market_cap,
519514
"emission": emission_tao,
515+
"tao_flow_ema": tao_flow_ema,
520516
"liquidity": {"tao_in": tao_in, "alpha_in": alpha_in},
521517
"alpha_out": alpha_out,
522518
"supply": supply,
@@ -529,12 +525,15 @@ def dict_table(subnets_, block_number_, mechanisms) -> dict:
529525
"total_rate": total_rate,
530526
"total_netuids": total_netuids,
531527
"emission_percentage": emission_percentage,
528+
"total_tao_flow_ema": total_tao_flow_ema,
532529
"subnets": subnet_rows,
533530
}
534531
return output
535532

536533
# Live mode
537-
def create_table_live(subnets_, previous_data_, block_number_, mechanisms):
534+
def create_table_live(
535+
subnets_, previous_data_, block_number_, mechanisms, ema_tao_inflow
536+
):
538537
def format_cell(
539538
value, previous_value, unit="", unit_first=False, precision=4, millify=False
540539
):
@@ -652,10 +651,15 @@ def format_liquidity_cell(
652651
market_cap = (subnet.alpha_in.tao + subnet.alpha_out.tao) * subnet.price.tao
653652
supply = subnet.alpha_in.tao + subnet.alpha_out.tao
654653

654+
tao_flow_ema = 0.0
655+
if netuid in ema_tao_inflow:
656+
tao_flow_ema = ema_tao_inflow[netuid].tao
657+
655658
# Store current values for comparison
656659
current_data[netuid] = {
657660
"market_cap": market_cap,
658661
"emission_tao": emission_tao,
662+
"tao_flow_ema": tao_flow_ema,
659663
"alpha_out": subnet.alpha_out.tao,
660664
"tao_in": subnet.tao_in.tao,
661665
"alpha_in": subnet.alpha_in.tao,
@@ -684,6 +688,14 @@ def format_liquidity_cell(
684688
precision=4,
685689
)
686690

691+
tao_flow_ema_cell = format_cell(
692+
tao_flow_ema,
693+
prev.get("tao_flow_ema"),
694+
unit="τ",
695+
unit_first=True,
696+
precision=4,
697+
)
698+
687699
price_cell = format_cell(
688700
subnet.price.tao,
689701
prev.get("price"),
@@ -767,6 +779,7 @@ def format_liquidity_cell(
767779
price_cell, # Rate τ_in/α_in
768780
market_cap_cell, # Market Cap
769781
emission_cell, # Emission (τ)
782+
tao_flow_ema_cell, # EMA TAO Inflow (τ)
770783
liquidity_cell, # Liquidity (t_in, a_in)
771784
alpha_out_cell, # Stake α_out
772785
supply_cell, # Supply
@@ -785,13 +798,22 @@ def format_liquidity_cell(
785798
if not verbose
786799
else f"{_total_emissions:,.2f}"
787800
)
788-
801+
_total_tao_flow_ema = sum(inflow.tao for inflow in ema_tao_inflow.values())
802+
total_tao_flow_ema = (
803+
f"{millify_tao(_total_tao_flow_ema)}"
804+
if not verbose
805+
else f"{_total_tao_flow_ema:,.2f}"
806+
)
789807
total_rate = sum(subnet.price.tao for subnet in subnets_ if subnet.netuid != 0)
790808
total_rate = (
791809
f"{millify_tao(total_rate)}" if not verbose else f"{total_rate:,.2f}"
792810
)
793811
table = define_table(
794-
total_emissions, total_rate, total_netuids, percentage_string
812+
total_emissions,
813+
total_rate,
814+
total_netuids,
815+
percentage_string,
816+
total_tao_flow_ema,
795817
)
796818

797819
for row in rows:
@@ -822,6 +844,7 @@ def format_liquidity_cell(
822844
subnets,
823845
block_number,
824846
mechanisms,
847+
ema_tao_inflow,
825848
) = await fetch_subnet_data()
826849

827850
# Update block numbers
@@ -834,7 +857,7 @@ def format_liquidity_cell(
834857
)
835858

836859
table, current_data = create_table_live(
837-
subnets, previous_data, block_number, mechanisms
860+
subnets, previous_data, block_number, mechanisms, ema_tao_inflow
838861
)
839862
previous_data = current_data
840863
progress.reset(progress_task)
@@ -860,13 +883,15 @@ def format_liquidity_cell(
860883
pass # Ctrl + C
861884
else:
862885
# Non-live mode
863-
subnets, block_number, mechanisms = await fetch_subnet_data()
886+
subnets, block_number, mechanisms, ema_tao_inflow = await fetch_subnet_data()
864887
if json_output:
865888
json_console.print(
866-
json.dumps(dict_table(subnets, block_number, mechanisms))
889+
json.dumps(
890+
dict_table(subnets, block_number, mechanisms, ema_tao_inflow)
891+
)
867892
)
868893
else:
869-
table = _create_table(subnets, block_number, mechanisms)
894+
table = _create_table(subnets, block_number, mechanisms, ema_tao_inflow)
870895
console.print(table)
871896

872897
return
@@ -1490,8 +1515,8 @@ async def show_subnet(
14901515
f"{total_mech_line}"
14911516
f"\n Owner: [{COLOR_PALETTE['GENERAL']['COLDKEY']}]{subnet_info.owner_coldkey}{' (' + owner_identity + ')' if owner_identity else ''}[/{COLOR_PALETTE['GENERAL']['COLDKEY']}]"
14921517
f"\n Rate: [{COLOR_PALETTE['GENERAL']['HOTKEY']}]{subnet_info.price.tao:.4f} τ/{subnet_info.symbol}[/{COLOR_PALETTE['GENERAL']['HOTKEY']}]"
1493-
f"\n EMA TAO Inflow: [{COLOR_PALETTE['STAKE']['TAO']}{ema_tao_inflow.tao}[/{COLOR_PALETTE['STAKE']['TAO']}]"
1494-
f"\n Emission: [{COLOR_PALETTE['GENERAL']['HOTKEY']}{subnet_info.emission.tao:,.4f}[/{COLOR_PALETTE['GENERAL']['HOTKEY']}]"
1518+
f"\n EMA TAO Inflow: [{COLOR_PALETTE['STAKE']['TAO']}{ema_tao_inflow.tao:.4f}[/{COLOR_PALETTE['STAKE']['TAO']}]"
1519+
f"\n Emission: [{COLOR_PALETTE['GENERAL']['HOTKEY']}{subnet_info.tao_in_emission.tao:,.4f}[/{COLOR_PALETTE['GENERAL']['HOTKEY']}]"
14951520
f"\n TAO Pool: [{COLOR_PALETTE['POOLS']['ALPHA_IN']}{tao_pool}[/{COLOR_PALETTE['POOLS']['ALPHA_IN']}]"
14961521
f"\n Alpha Pool: [{COLOR_PALETTE['POOLS']['ALPHA_IN']}]{alpha_pool} {subnet_info.symbol}[/{COLOR_PALETTE['POOLS']['ALPHA_IN']}]"
14971522
# f"\n Stake: [{COLOR_PALETTE['STAKE']['STAKE_ALPHA']}]{subnet_info.alpha_out.tao:,.5f} {subnet_info.symbol}[/{COLOR_PALETTE['STAKE']['STAKE_ALPHA']}]"

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "bittensor-cli"
7-
version = "9.15.0"
7+
version = "9.15.1"
88
description = "Bittensor CLI"
99
readme = "README.md"
1010
authors = [

0 commit comments

Comments
 (0)