@@ -24,6 +24,7 @@ def unstake_extrinsic(
24
24
allow_partial_stake : bool = False ,
25
25
rate_tolerance : float = 0.005 ,
26
26
period : Optional [int ] = None ,
27
+ unstake_all : bool = False ,
27
28
) -> bool :
28
29
"""Removes stake into the wallet coldkey from the specified hotkey ``uid``.
29
30
@@ -44,11 +45,15 @@ def unstake_extrinsic(
44
45
period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted.
45
46
If the transaction is not included in a block within that number of blocks, it will expire and be rejected.
46
47
You can think of it as an expiration date for the transaction.
48
+ unstake_all: If true, unstakes all tokens. Default is ``False``.
47
49
48
50
Returns:
49
51
success (bool): Flag is ``True`` if extrinsic was finalized or included in the block. If we did not wait for
50
52
finalization / inclusion, the response is ``True``.
51
53
"""
54
+ if amount and unstake_all :
55
+ raise ValueError ("Cannot specify both `amount` and `unstake_all`." )
56
+
52
57
# Decrypt keys,
53
58
if not (unlock := unlock_key (wallet )).success :
54
59
logging .error (unlock .message )
@@ -102,16 +107,12 @@ def unstake_extrinsic(
102
107
base_price = pool .price .rao
103
108
price_with_tolerance = base_price * (1 - rate_tolerance )
104
109
105
- # For logging
106
- base_rate = pool .price .tao
107
- rate_with_tolerance = base_rate * (1 - rate_tolerance )
108
-
109
110
logging .info (
110
111
f":satellite: [magenta]Safe Unstaking from:[/magenta] "
111
112
f"netuid: [green]{ netuid } [/green], amount: [green]{ unstaking_balance } [/green], "
112
113
f"tolerance percentage: [green]{ rate_tolerance * 100 } %[/green], "
113
- f"price limit: [green]{ rate_with_tolerance } [/green], "
114
- f"original price: [green]{ base_rate } [/green], "
114
+ f"price limit: [green]{ price_with_tolerance } [/green], "
115
+ f"original price: [green]{ base_price } [/green], "
115
116
f"with partial unstake: [green]{ allow_partial_stake } [/green] "
116
117
f"on [blue]{ subtensor .network } [/blue][magenta]...[/magenta]"
117
118
)
@@ -201,6 +202,7 @@ def unstake_multiple_extrinsic(
201
202
wait_for_inclusion : bool = True ,
202
203
wait_for_finalization : bool = False ,
203
204
period : Optional [int ] = None ,
205
+ unstake_all : bool = False ,
204
206
) -> bool :
205
207
"""Removes stake from each ``hotkey_ss58`` in the list, using each amount, to a common coldkey.
206
208
@@ -217,11 +219,14 @@ def unstake_multiple_extrinsic(
217
219
period (Optional[int]): The number of blocks during which the transaction will remain valid after it's submitted.
218
220
If the transaction is not included in a block within that number of blocks, it will expire and be rejected.
219
221
You can think of it as an expiration date for the transaction.
222
+ unstake_all: If true, unstakes all tokens. Default is ``False``.
220
223
221
224
Returns:
222
225
success (bool): Flag is ``True`` if extrinsic was finalized or included in the block. Flag is ``True`` if any
223
226
wallet was unstaked. If we did not wait for finalization / inclusion, the response is ``True``.
224
227
"""
228
+ if amounts and unstake_all :
229
+ raise ValueError ("Cannot specify both `amounts` and `unstake_all`." )
225
230
226
231
if not isinstance (hotkey_ss58s , list ) or not all (
227
232
isinstance (hotkey_ss58 , str ) for hotkey_ss58 in hotkey_ss58s
0 commit comments