bittensor-cli 9.1.4__py3-none-any.whl → 9.3.0__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.
@@ -32,13 +32,14 @@ async def display_stake_movement_cross_subnets(
32
32
  origin_hotkey: str,
33
33
  destination_hotkey: str,
34
34
  amount_to_move: Balance,
35
+ stake_fee: Balance,
35
36
  ) -> tuple[Balance, float, str, str]:
36
37
  """Calculate and display slippage information"""
37
38
 
38
39
  if origin_netuid == destination_netuid:
39
40
  subnet = await subtensor.subnet(origin_netuid)
40
41
  received_amount_tao = subnet.alpha_to_tao(amount_to_move)
41
- received_amount_tao -= MIN_STAKE_FEE
42
+ received_amount_tao -= stake_fee
42
43
 
43
44
  if received_amount_tao < Balance.from_tao(0):
44
45
  print_error("Not enough Alpha to pay the transaction fee.")
@@ -46,7 +47,7 @@ async def display_stake_movement_cross_subnets(
46
47
 
47
48
  received_amount = subnet.tao_to_alpha(received_amount_tao)
48
49
  slippage_pct_float = (
49
- 100 * float(MIN_STAKE_FEE) / float(MIN_STAKE_FEE + received_amount_tao)
50
+ 100 * float(stake_fee) / float(stake_fee + received_amount_tao)
50
51
  if received_amount_tao != 0
51
52
  else 0
52
53
  )
@@ -67,7 +68,7 @@ async def display_stake_movement_cross_subnets(
67
68
  received_amount_tao, _, _ = dynamic_origin.alpha_to_tao_with_slippage(
68
69
  amount_to_move
69
70
  )
70
- received_amount_tao -= MIN_STAKE_FEE
71
+ received_amount_tao -= stake_fee
71
72
  received_amount, _, _ = dynamic_destination.tao_to_alpha_with_slippage(
72
73
  received_amount_tao
73
74
  )
@@ -135,6 +136,11 @@ async def display_stake_movement_cross_subnets(
135
136
  justify="center",
136
137
  style=COLOR_PALETTE["POOLS"]["TAO_EQUIV"],
137
138
  )
139
+ table.add_column(
140
+ "Fee (τ)",
141
+ justify="center",
142
+ style=COLOR_PALETTE["STAKE"]["STAKE_AMOUNT"],
143
+ )
138
144
  table.add_column(
139
145
  "slippage",
140
146
  justify="center",
@@ -149,13 +155,11 @@ async def display_stake_movement_cross_subnets(
149
155
  str(amount_to_move),
150
156
  price_str,
151
157
  str(received_amount),
158
+ str(stake_fee),
152
159
  str(slippage_pct),
153
160
  )
154
161
 
155
162
  console.print(table)
156
- # console.print(
157
- # f"[dim]A fee of {MIN_STAKE_FEE} applies.[/dim]"
158
- # )
159
163
 
160
164
  # Display slippage warning if necessary
161
165
  if slippage_pct_float > 5:
@@ -440,9 +444,10 @@ async def move_stake(
440
444
  destination_hotkey: str,
441
445
  amount: float,
442
446
  stake_all: bool,
447
+ era: int,
443
448
  interactive_selection: bool = False,
444
449
  prompt: bool = True,
445
- ):
450
+ ) -> bool:
446
451
  if interactive_selection:
447
452
  try:
448
453
  selection = await stake_move_transfer_selection(subtensor, wallet)
@@ -508,11 +513,23 @@ async def move_stake(
508
513
  if amount_to_move_as_balance > origin_stake_balance:
509
514
  err_console.print(
510
515
  f"[red]Not enough stake[/red]:\n"
511
- f" Stake balance: [{COLOR_PALETTE['STAKE']['STAKE_AMOUNT']}]{origin_stake_balance}[/{COLOR_PALETTE['STAKE']['STAKE_AMOUNT']}]"
512
- f" < Moving amount: [{COLOR_PALETTE['STAKE']['STAKE_AMOUNT']}]{amount_to_move_as_balance}[/{COLOR_PALETTE['STAKE']['STAKE_AMOUNT']}]"
516
+ f" Stake balance: [{COLOR_PALETTE['STAKE']['STAKE_AMOUNT']}]"
517
+ f"{origin_stake_balance}[/{COLOR_PALETTE['STAKE']['STAKE_AMOUNT']}]"
518
+ f" < Moving amount: [{COLOR_PALETTE['STAKE']['STAKE_AMOUNT']}]"
519
+ f"{amount_to_move_as_balance}[/{COLOR_PALETTE['STAKE']['STAKE_AMOUNT']}]"
513
520
  )
514
521
  return False
515
522
 
523
+ stake_fee = await subtensor.get_stake_fee(
524
+ origin_hotkey_ss58=origin_hotkey,
525
+ origin_netuid=origin_netuid,
526
+ origin_coldkey_ss58=wallet.coldkeypub.ss58_address,
527
+ destination_hotkey_ss58=destination_hotkey,
528
+ destination_netuid=destination_netuid,
529
+ destination_coldkey_ss58=wallet.coldkeypub.ss58_address,
530
+ amount=amount_to_move_as_balance.rao,
531
+ )
532
+
516
533
  # Slippage warning
517
534
  if prompt:
518
535
  try:
@@ -523,6 +540,7 @@ async def move_stake(
523
540
  origin_hotkey=origin_hotkey,
524
541
  destination_hotkey=destination_hotkey,
525
542
  amount_to_move=amount_to_move_as_balance,
543
+ stake_fee=stake_fee,
526
544
  )
527
545
  except ValueError:
528
546
  return False
@@ -548,7 +566,7 @@ async def move_stake(
548
566
  },
549
567
  )
550
568
  extrinsic = await subtensor.substrate.create_signed_extrinsic(
551
- call=call, keypair=wallet.coldkey
569
+ call=call, keypair=wallet.coldkey, era={"period": era}
552
570
  )
553
571
  response = await subtensor.substrate.submit_extrinsic(
554
572
  extrinsic, wait_for_inclusion=True, wait_for_finalization=False
@@ -558,13 +576,12 @@ async def move_stake(
558
576
  console.print(":white_heavy_check_mark: [green]Sent[/green]")
559
577
  return True
560
578
  else:
561
- await response.process_events()
562
579
  if not await response.is_success:
563
580
  err_console.print(
564
581
  f"\n:cross_mark: [red]Failed[/red] with error:"
565
582
  f" {format_error_message(await response.error_message)}"
566
583
  )
567
- return
584
+ return False
568
585
  else:
569
586
  console.print(
570
587
  ":white_heavy_check_mark: [dark_sea_green3]Stake moved.[/dark_sea_green3]"
@@ -596,7 +613,7 @@ async def move_stake(
596
613
  f"Destination Stake:\n [blue]{destination_stake_balance}[/blue] :arrow_right: "
597
614
  f"[{COLOR_PALETTE['STAKE']['STAKE_AMOUNT']}]{new_destination_stake_balance}"
598
615
  )
599
- return
616
+ return True
600
617
 
601
618
 
602
619
  async def transfer_stake(
@@ -607,6 +624,7 @@ async def transfer_stake(
607
624
  origin_netuid: int,
608
625
  dest_netuid: int,
609
626
  dest_coldkey_ss58: str,
627
+ era: int,
610
628
  interactive_selection: bool = False,
611
629
  stake_all: bool = False,
612
630
  prompt: bool = True,
@@ -686,6 +704,16 @@ async def transfer_stake(
686
704
  )
687
705
  return False
688
706
 
707
+ stake_fee = await subtensor.get_stake_fee(
708
+ origin_hotkey_ss58=origin_hotkey,
709
+ origin_netuid=origin_netuid,
710
+ origin_coldkey_ss58=wallet.coldkeypub.ss58_address,
711
+ destination_hotkey_ss58=origin_hotkey,
712
+ destination_netuid=dest_netuid,
713
+ destination_coldkey_ss58=dest_coldkey_ss58,
714
+ amount=amount_to_transfer.rao,
715
+ )
716
+
689
717
  # Slippage warning
690
718
  if prompt:
691
719
  try:
@@ -696,6 +724,7 @@ async def transfer_stake(
696
724
  origin_hotkey=origin_hotkey,
697
725
  destination_hotkey=origin_hotkey,
698
726
  amount_to_move=amount_to_transfer,
727
+ stake_fee=stake_fee,
699
728
  )
700
729
  except ValueError:
701
730
  return False
@@ -721,7 +750,7 @@ async def transfer_stake(
721
750
  )
722
751
 
723
752
  extrinsic = await subtensor.substrate.create_signed_extrinsic(
724
- call=call, keypair=wallet.coldkey
753
+ call=call, keypair=wallet.coldkey, era={"period": era}
725
754
  )
726
755
 
727
756
  response = await subtensor.substrate.submit_extrinsic(
@@ -732,7 +761,6 @@ async def transfer_stake(
732
761
  console.print(":white_heavy_check_mark: [green]Sent[/green]")
733
762
  return True
734
763
 
735
- await response.process_events()
736
764
  if not await response.is_success:
737
765
  err_console.print(
738
766
  f":cross_mark: [red]Failed[/red] with error: "
@@ -772,6 +800,7 @@ async def swap_stake(
772
800
  destination_netuid: int,
773
801
  amount: float,
774
802
  swap_all: bool = False,
803
+ era: int = 3,
775
804
  interactive_selection: bool = False,
776
805
  prompt: bool = True,
777
806
  wait_for_inclusion: bool = True,
@@ -844,6 +873,16 @@ async def swap_stake(
844
873
  )
845
874
  return False
846
875
 
876
+ stake_fee = await subtensor.get_stake_fee(
877
+ origin_hotkey_ss58=hotkey_ss58,
878
+ origin_netuid=origin_netuid,
879
+ origin_coldkey_ss58=wallet.coldkeypub.ss58_address,
880
+ destination_hotkey_ss58=hotkey_ss58,
881
+ destination_netuid=destination_netuid,
882
+ destination_coldkey_ss58=wallet.coldkeypub.ss58_address,
883
+ amount=amount_to_swap.rao,
884
+ )
885
+
847
886
  # Slippage warning
848
887
  if prompt:
849
888
  try:
@@ -854,6 +893,7 @@ async def swap_stake(
854
893
  origin_hotkey=hotkey_ss58,
855
894
  destination_hotkey=hotkey_ss58,
856
895
  amount_to_move=amount_to_swap,
896
+ stake_fee=stake_fee,
857
897
  )
858
898
  except ValueError:
859
899
  return False
@@ -866,7 +906,8 @@ async def swap_stake(
866
906
  return False
867
907
 
868
908
  with console.status(
869
- f"\n:satellite: Swapping stake from netuid [blue]{origin_netuid}[/blue] to netuid [blue]{destination_netuid}[/blue]..."
909
+ f"\n:satellite: Swapping stake from netuid [blue]{origin_netuid}[/blue] "
910
+ f"to netuid [blue]{destination_netuid}[/blue]..."
870
911
  ):
871
912
  call = await subtensor.substrate.compose_call(
872
913
  call_module="SubtensorModule",
@@ -880,7 +921,7 @@ async def swap_stake(
880
921
  )
881
922
 
882
923
  extrinsic = await subtensor.substrate.create_signed_extrinsic(
883
- call=call, keypair=wallet.coldkey
924
+ call=call, keypair=wallet.coldkey, era={"period": era}
884
925
  )
885
926
 
886
927
  response = await subtensor.substrate.submit_extrinsic(
@@ -893,7 +934,6 @@ async def swap_stake(
893
934
  console.print(":white_heavy_check_mark: [green]Sent[/green]")
894
935
  return True
895
936
 
896
- await response.process_events()
897
937
  if not await response.is_success:
898
938
  err_console.print(
899
939
  f":cross_mark: [red]Failed[/red] with error: "