Skip to content

Commit 7ad2b64

Browse files
authored
Merge pull request #519 from opentensor/update/safe-staking-limits
Updates safe staking/unstaking limits
2 parents 37123e5 + 4280071 commit 7ad2b64

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

bittensor_cli/src/commands/stake/add.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,14 +342,14 @@ async def stake_extrinsic(
342342
# If we are staking safe, add price tolerance
343343
if safe_staking:
344344
if subnet_info.is_dynamic:
345-
rate = 1 / subnet_info.price.tao or 1
345+
rate = amount_to_stake.rao / received_amount.rao
346346
_rate_with_tolerance = rate * (
347347
1 + rate_tolerance
348348
) # Rate only for display
349349
rate_with_tolerance = f"{_rate_with_tolerance:.4f}"
350-
price_with_tolerance = subnet_info.price.rao * (
351-
1 + rate_tolerance
352-
) # Actual price to pass to extrinsic
350+
price_with_tolerance = Balance.from_tao(
351+
_rate_with_tolerance
352+
).rao # Actual price to pass to extrinsic
353353
else:
354354
rate_with_tolerance = "1"
355355
price_with_tolerance = Balance.from_rao(1)

bittensor_cli/src/commands/stake/remove.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,13 @@ async def unstake(
248248
# Additional fields for safe unstaking
249249
if safe_staking:
250250
if subnet_info.is_dynamic:
251-
rate = subnet_info.price.tao or 1
251+
rate = received_amount.rao / amount_to_unstake_as_balance.rao
252252
rate_with_tolerance = rate * (
253253
1 - rate_tolerance
254254
) # Rate only for display
255-
price_with_tolerance = subnet_info.price.rao * (
256-
1 - rate_tolerance
257-
) # Actual price to pass to extrinsic
255+
price_with_tolerance = Balance.from_tao(
256+
rate_with_tolerance
257+
).rao # Actual price to pass to extrinsic
258258
else:
259259
rate_with_tolerance = 1
260260
price_with_tolerance = 1

0 commit comments

Comments
 (0)