bittensor-cli 9.0.0rc4__py3-none-any.whl → 9.0.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -45,7 +45,7 @@ async def stake_list(
45
45
  coldkey_ss58=coldkey_address, block_hash=block_hash
46
46
  ),
47
47
  subtensor.get_delegate_identities(block_hash=block_hash),
48
- subtensor.all_subnets(),
48
+ subtensor.all_subnets(block_hash=block_hash),
49
49
  )
50
50
  # sub_stakes = substakes[coldkey_address]
51
51
  dynamic_info = {info.netuid: info for info in _dynamic_info}
@@ -58,7 +58,6 @@ async def stake_list(
58
58
  def define_table(
59
59
  hotkey_name: str,
60
60
  rows: list[list[str]],
61
- total_tao_ownership: Balance,
62
61
  total_tao_value: Balance,
63
62
  total_swapped_tao_value: Balance,
64
63
  live: bool = False,
@@ -130,6 +129,11 @@ async def stake_list(
130
129
  style=COLOR_PALETTE["POOLS"]["EMISSION"],
131
130
  justify="right",
132
131
  )
132
+ table.add_column(
133
+ f"[white]Emission \n({Balance.get_unit(0)}/block)",
134
+ style=COLOR_PALETTE["POOLS"]["EMISSION"],
135
+ justify="right",
136
+ )
133
137
  return table
134
138
 
135
139
  def create_table(hotkey_: str, substakes: list[StakeInfo]):
@@ -139,7 +143,6 @@ async def stake_list(
139
143
  else hotkey_
140
144
  )
141
145
  rows = []
142
- total_tao_ownership = Balance(0)
143
146
  total_tao_value = Balance(0)
144
147
  total_swapped_tao_value = Balance(0)
145
148
  root_stakes = [s for s in substakes if s.netuid == 0]
@@ -155,14 +158,6 @@ async def stake_list(
155
158
  netuid = substake_.netuid
156
159
  pool = dynamic_info[netuid]
157
160
  symbol = f"{Balance.get_unit(netuid)}\u200e"
158
- # TODO: what is this price var for?
159
- price = (
160
- "{:.4f}{}".format(
161
- pool.price.__float__(), f" τ/{Balance.get_unit(netuid)}\u200e"
162
- )
163
- if pool.is_dynamic
164
- else (f" 1.0000 τ/{symbol} ")
165
- )
166
161
 
167
162
  # Alpha value cell
168
163
  alpha_value = Balance.from_rao(int(substake_.stake.rao)).set_unit(netuid)
@@ -192,30 +187,11 @@ async def stake_list(
192
187
  else f"{swapped_tao_value} ({slippage_percentage})"
193
188
  )
194
189
 
195
- # TAO locked cell
196
- tao_locked = pool.tao_in
197
-
198
- # Issuance cell
199
- issuance = pool.alpha_out if pool.is_dynamic else tao_locked
200
-
201
190
  # Per block emission cell
202
- per_block_emission = substake_.emission.tao / pool.tempo
191
+ per_block_emission = substake_.emission.tao / (pool.tempo or 1)
192
+ per_block_tao_emission = substake_.tao_emission.tao / (pool.tempo or 1)
203
193
  # Alpha ownership and TAO ownership cells
204
194
  if alpha_value.tao > 0.00009:
205
- if issuance.tao != 0:
206
- # TODO figure out why this alpha_ownership does nothing
207
- alpha_ownership = "{:.4f}".format(
208
- (alpha_value.tao / issuance.tao) * 100
209
- )
210
- tao_ownership = Balance.from_tao(
211
- (alpha_value.tao / issuance.tao) * tao_locked.tao
212
- )
213
- total_tao_ownership += tao_ownership
214
- else:
215
- # TODO what's this var for?
216
- alpha_ownership = "0.0000"
217
- tao_ownership = Balance.from_tao(0)
218
-
219
195
  stake_value = (
220
196
  millify_tao(substake_.stake.tao)
221
197
  if not verbose
@@ -243,15 +219,14 @@ async def stake_list(
243
219
  # Removing this flag for now, TODO: Confirm correct values are here w.r.t CHKs
244
220
  # if substake_.is_registered
245
221
  # else f"[{COLOR_PALETTE['STAKE']['NOT_REGISTERED']}]N/A", # Emission(α/block)
222
+ str(Balance.from_tao(per_block_tao_emission)),
246
223
  ]
247
224
  )
248
- table = define_table(
249
- name, rows, total_tao_ownership, total_tao_value, total_swapped_tao_value
250
- )
225
+ table = define_table(name, rows, total_tao_value, total_swapped_tao_value)
251
226
  for row in rows:
252
227
  table.add_row(*row)
253
228
  console.print(table)
254
- return total_tao_ownership, total_tao_value
229
+ return total_tao_value, total_swapped_tao_value
255
230
 
256
231
  def create_live_table(
257
232
  substakes: list,
@@ -263,7 +238,6 @@ async def stake_list(
263
238
  rows = []
264
239
  current_data = {}
265
240
 
266
- total_tao_ownership = Balance(0)
267
241
  total_tao_value = Balance(0)
268
242
  total_swapped_tao_value = Balance(0)
269
243
 
@@ -319,30 +293,19 @@ async def stake_list(
319
293
  alpha_value = Balance.from_rao(int(substake.stake.rao)).set_unit(netuid)
320
294
  tao_value = pool.alpha_to_tao(alpha_value)
321
295
  total_tao_value += tao_value
322
- swapped_tao_value, slippage = pool.alpha_to_tao_with_slippage(
296
+ swapped_tao_value, slippage, slippage_pct = pool.alpha_to_tao_with_slippage(
323
297
  substake.stake
324
298
  )
325
299
  total_swapped_tao_value += swapped_tao_value
326
300
 
327
- # Calculate TAO ownership
328
- tao_locked = pool.tao_in
329
- issuance = pool.alpha_out if pool.is_dynamic else tao_locked
330
- if alpha_value.tao > 0.00009 and issuance.tao != 0:
331
- tao_ownership = Balance.from_tao(
332
- (alpha_value.tao / issuance.tao) * tao_locked.tao
333
- )
334
- total_tao_ownership += tao_ownership
335
- else:
336
- tao_ownership = Balance.from_tao(0)
337
-
338
301
  # Store current values for future delta tracking
339
302
  current_data[netuid] = {
340
303
  "stake": alpha_value.tao,
341
304
  "price": pool.price.tao,
342
305
  "tao_value": tao_value.tao,
343
306
  "swapped_value": swapped_tao_value.tao,
344
- "emission": substake.emission.tao / pool.tempo,
345
- "tao_ownership": tao_ownership.tao,
307
+ "emission": substake.emission.tao / (pool.tempo or 1),
308
+ "tao_emission": substake.tao_emission.tao / (pool.tempo or 1),
346
309
  }
347
310
 
348
311
  # Get previous values for delta tracking
@@ -376,15 +339,6 @@ async def stake_list(
376
339
  millify=True if not verbose else False,
377
340
  )
378
341
 
379
- if pool.is_dynamic:
380
- slippage_pct = (
381
- 100 * float(slippage) / float(slippage + swapped_tao_value)
382
- if slippage + swapped_tao_value != 0
383
- else 0
384
- )
385
- else:
386
- slippage_pct = 0
387
-
388
342
  if netuid != 0:
389
343
  swap_cell = (
390
344
  format_cell(
@@ -400,7 +354,7 @@ async def stake_list(
400
354
  else:
401
355
  swap_cell = f"[{COLOR_PALETTE['STAKE']['NOT_REGISTERED']}]N/A[/{COLOR_PALETTE['STAKE']['NOT_REGISTERED']}] ({slippage_pct}%)"
402
356
 
403
- emission_value = substake.emission.tao / pool.tempo
357
+ emission_value = substake.emission.tao / (pool.tempo or 1)
404
358
  emission_cell = format_cell(
405
359
  emission_value,
406
360
  prev.get("emission"),
@@ -408,6 +362,16 @@ async def stake_list(
408
362
  unit_first=unit_first,
409
363
  precision=4,
410
364
  )
365
+
366
+ tao_emission_value = substake.tao_emission.tao / (pool.tempo or 1)
367
+ tao_emission_cell = format_cell(
368
+ tao_emission_value,
369
+ prev.get("tao_emission"),
370
+ unit="τ",
371
+ unit_first=unit_first,
372
+ precision=4,
373
+ )
374
+
411
375
  subnet_name_cell = (
412
376
  f"[{COLOR_PALETTE['GENERAL']['SYMBOL']}]{symbol if netuid != 0 else 'τ'}[/{COLOR_PALETTE['GENERAL']['SYMBOL']}]"
413
377
  f" {get_subnet_name(dynamic_info[netuid])}"
@@ -425,13 +389,13 @@ async def stake_list(
425
389
  if substake.is_registered
426
390
  else f"[{COLOR_PALETTE['STAKE']['NOT_REGISTERED']}]NO", # Registration status
427
391
  emission_cell, # Emission rate
392
+ tao_emission_cell, # TAO emission rate
428
393
  ]
429
394
  )
430
395
 
431
396
  table = define_table(
432
397
  hotkey_name,
433
398
  rows,
434
- total_tao_ownership,
435
399
  total_tao_value,
436
400
  total_swapped_tao_value,
437
401
  live=True,
@@ -443,11 +407,12 @@ async def stake_list(
443
407
  return table, current_data
444
408
 
445
409
  # Main execution
410
+ block_hash = await subtensor.substrate.get_chain_head()
446
411
  (
447
412
  sub_stakes,
448
413
  registered_delegate_info,
449
414
  dynamic_info,
450
- ) = await get_stake_data()
415
+ ) = await get_stake_data(block_hash)
451
416
  balance = await subtensor.get_balance(coldkey_address)
452
417
 
453
418
  # Iterate over substakes and aggregate them by hotkey.
@@ -466,7 +431,7 @@ async def stake_list(
466
431
  raise typer.Exit()
467
432
 
468
433
  if live:
469
- # Select one hokkey for live monitoring
434
+ # Select one hotkey for live monitoring
470
435
  if len(hotkeys_to_substakes) > 1:
471
436
  console.print(
472
437
  "\n[bold]Multiple hotkeys found. Please select one for live monitoring:[/bold]"
@@ -536,7 +501,7 @@ async def stake_list(
536
501
  table, current_data = create_live_table(
537
502
  selected_stakes,
538
503
  registered_delegate_info,
539
- dynamic_info,
504
+ dynamic_info_,
540
505
  hotkey_name,
541
506
  previous_data,
542
507
  )
@@ -570,27 +535,29 @@ async def stake_list(
570
535
  # Iterate over each hotkey and make a table
571
536
  counter = 0
572
537
  num_hotkeys = len(hotkeys_to_substakes)
573
- all_hotkeys_total_global_tao = Balance(0)
574
- all_hotkeys_total_tao_value = Balance(0)
538
+ all_hks_swapped_tao_value = Balance(0)
539
+ all_hks_tao_value = Balance(0)
575
540
  for hotkey in hotkeys_to_substakes.keys():
576
541
  counter += 1
577
- stake, value = create_table(hotkey, hotkeys_to_substakes[hotkey])
578
- all_hotkeys_total_global_tao += stake
579
- all_hotkeys_total_tao_value += value
542
+ tao_value, swapped_tao_value = create_table(
543
+ hotkey, hotkeys_to_substakes[hotkey]
544
+ )
545
+ all_hks_tao_value += tao_value
546
+ all_hks_swapped_tao_value += swapped_tao_value
580
547
 
581
548
  if num_hotkeys > 1 and counter < num_hotkeys and prompt:
582
549
  console.print("\nPress Enter to continue to the next hotkey...")
583
550
  input()
584
551
 
585
552
  total_tao_value = (
586
- f"τ {millify_tao(all_hotkeys_total_tao_value.tao)}"
553
+ f"τ {millify_tao(all_hks_tao_value.tao)}"
587
554
  if not verbose
588
- else all_hotkeys_total_tao_value
555
+ else all_hks_tao_value
589
556
  )
590
- total_tao_ownership = (
591
- f"τ {millify_tao(all_hotkeys_total_global_tao.tao)}"
557
+ total_swapped_tao_value = (
558
+ f"τ {millify_tao(all_hks_swapped_tao_value.tao)}"
592
559
  if not verbose
593
- else all_hotkeys_total_global_tao
560
+ else all_hks_swapped_tao_value
594
561
  )
595
562
 
596
563
  console.print("\n\n")
@@ -598,8 +565,8 @@ async def stake_list(
598
565
  f"Wallet:\n"
599
566
  f" Coldkey SS58: [{COLOR_PALETTE['GENERAL']['COLDKEY']}]{coldkey_address}[/{COLOR_PALETTE['GENERAL']['COLDKEY']}]\n"
600
567
  f" Free Balance: [{COLOR_PALETTE['GENERAL']['BALANCE']}]{balance}[/{COLOR_PALETTE['GENERAL']['BALANCE']}]\n"
601
- f" Total TAO ({Balance.unit}): [{COLOR_PALETTE['GENERAL']['BALANCE']}]{total_tao_ownership}[/{COLOR_PALETTE['GENERAL']['BALANCE']}]\n"
602
- f" Total Value ({Balance.unit}): [{COLOR_PALETTE['GENERAL']['BALANCE']}]{total_tao_value}[/{COLOR_PALETTE['GENERAL']['BALANCE']}]"
568
+ f" Total TAO Value ({Balance.unit}): [{COLOR_PALETTE['GENERAL']['BALANCE']}]{total_tao_value}[/{COLOR_PALETTE['GENERAL']['BALANCE']}]\n"
569
+ f" Total TAO Swapped Value ({Balance.unit}): [{COLOR_PALETTE['GENERAL']['BALANCE']}]{total_swapped_tao_value}[/{COLOR_PALETTE['GENERAL']['BALANCE']}]"
603
570
  )
604
571
  if not sub_stakes:
605
572
  console.print(
@@ -812,7 +812,7 @@ async def transfer_stake(
812
812
  if not await response.is_success:
813
813
  err_console.print(
814
814
  f":cross_mark: [red]Failed[/red] with error: "
815
- f"{format_error_message(await response.error_message, subtensor.substrate)}"
815
+ f"{format_error_message(await response.error_message)}"
816
816
  )
817
817
  return False
818
818
 
@@ -905,7 +905,7 @@ async def swap_stake(
905
905
  )
906
906
 
907
907
  if swap_all:
908
- amount_to_swap = Balance.from_tao(current_stake).set_unit(origin_netuid)
908
+ amount_to_swap = current_stake.set_unit(origin_netuid)
909
909
  else:
910
910
  amount_to_swap = Balance.from_tao(amount).set_unit(origin_netuid)
911
911
 
@@ -971,7 +971,7 @@ async def swap_stake(
971
971
  if not await response.is_success:
972
972
  err_console.print(
973
973
  f":cross_mark: [red]Failed[/red] with error: "
974
- f"{format_error_message(await response.error_message, subtensor.substrate)}"
974
+ f"{format_error_message(await response.error_message)}"
975
975
  )
976
976
  return False
977
977