Skip to content

Commit 8d408b6

Browse files
committed
update unstake logic
1 parent 1002b12 commit 8d408b6

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

bittensor/core/extrinsics/asyncex/unstaking.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,19 +107,19 @@ async def unstake_extrinsic(
107107
}
108108
if safe_staking:
109109
pool = await subtensor.subnet(netuid=netuid)
110-
received_amount, _ = pool.alpha_to_tao_with_slippage(unstaking_balance)
111-
base_price = unstaking_balance.rao / received_amount.rao
112-
price_with_tolerance = base_price * (1 - rate_tolerance)
110+
base_price = pool.price.tao
113111

114-
# For logging
115-
base_rate = pool.price.tao
112+
if pool.is_dynamic:
113+
price_with_tolerance = base_price * (1 - rate_tolerance)
114+
else:
115+
price_with_tolerance = base_price
116116

117117
logging.info(
118118
f":satellite: [magenta]Safe Unstaking from:[/magenta] "
119119
f"netuid: [green]{netuid}[/green], amount: [green]{unstaking_balance}[/green], "
120120
f"tolerance percentage: [green]{rate_tolerance * 100}%[/green], "
121121
f"price limit: [green]{price_with_tolerance}[/green], "
122-
f"original price: [green]{base_rate}[/green], "
122+
f"original price: [green]{base_price}[/green], "
123123
f"with partial unstake: [green]{allow_partial_stake}[/green] "
124124
f"on [blue]{subtensor.network}[/blue][magenta]...[/magenta]"
125125
)

bittensor/core/extrinsics/unstaking.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,19 +105,19 @@ def unstake_extrinsic(
105105

106106
if safe_staking:
107107
pool = subtensor.subnet(netuid=netuid)
108-
received_amount, _ = pool.alpha_to_tao_with_slippage(unstaking_balance)
109-
base_price = unstaking_balance.rao / received_amount.rao
110-
price_with_tolerance = base_price * (1 - rate_tolerance)
108+
base_price = pool.price.tao
111109

112-
# For logging
113-
base_rate = pool.price.tao
110+
if pool.is_dynamic:
111+
price_with_tolerance = base_price * (1 - rate_tolerance)
112+
else:
113+
price_with_tolerance = base_price
114114

115115
logging.info(
116116
f":satellite: [magenta]Safe Unstaking from:[/magenta] "
117117
f"netuid: [green]{netuid}[/green], amount: [green]{unstaking_balance}[/green], "
118118
f"tolerance percentage: [green]{rate_tolerance * 100}%[/green], "
119119
f"price limit: [green]{price_with_tolerance}[/green], "
120-
f"original price: [green]{base_rate}[/green], "
120+
f"original price: [green]{base_price}[/green], "
121121
f"with partial unstake: [green]{allow_partial_stake}[/green] "
122122
f"on [blue]{subtensor.network}[/blue][magenta]...[/magenta]"
123123
)

0 commit comments

Comments
 (0)