@@ -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']}]"
0 commit comments