Skip to content

Commit b816140

Browse files
committed
update stake logic
1 parent 8d408b6 commit b816140

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

bittensor/core/extrinsics/asyncex/staking.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,19 +120,19 @@ async def add_stake_extrinsic(
120120

121121
if safe_staking:
122122
pool = await subtensor.subnet(netuid=netuid)
123-
received_amount, _ = pool.tao_to_alpha_with_slippage(staking_balance)
124-
base_price = received_amount.rao / staking_balance.rao
125-
price_with_tolerance = base_price * (1 + rate_tolerance)
123+
base_price = pool.price.tao
126124

127-
# For logging
128-
base_rate = pool.price.tao
125+
if pool.is_dynamic:
126+
price_with_tolerance = base_price * (1 + rate_tolerance)
127+
else:
128+
price_with_tolerance = base_price
129129

130130
logging.info(
131131
f":satellite: [magenta]Safe Staking to:[/magenta] "
132132
f"[blue]netuid: [green]{netuid}[/green], amount: [green]{staking_balance}[/green], "
133133
f"tolerance percentage: [green]{rate_tolerance * 100}%[/green], "
134134
f"price limit: [green]{price_with_tolerance}[/green], "
135-
f"original price: [green]{base_rate}[/green], "
135+
f"original price: [green]{base_price}[/green], "
136136
f"with partial stake: [green]{allow_partial_stake}[/green] "
137137
f"on [blue]{subtensor.network}[/blue][/magenta]...[/magenta]"
138138
)

bittensor/core/extrinsics/staking.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,19 +112,19 @@ def add_stake_extrinsic(
112112

113113
if safe_staking:
114114
pool = subtensor.subnet(netuid=netuid)
115-
received_amount, _ = pool.tao_to_alpha_with_slippage(staking_balance)
116-
base_price = received_amount.rao / staking_balance.rao
117-
price_with_tolerance = base_price * (1 + rate_tolerance)
115+
base_price = pool.price.tao
118116

119-
# For logging
120-
base_rate = pool.price.tao
117+
if pool.is_dynamic:
118+
price_with_tolerance = base_price * (1 + rate_tolerance)
119+
else:
120+
price_with_tolerance = base_price
121121

122122
logging.info(
123123
f":satellite: [magenta]Safe Staking to:[/magenta] "
124124
f"[blue]netuid: [green]{netuid}[/green], amount: [green]{staking_balance}[/green], "
125125
f"tolerance percentage: [green]{rate_tolerance * 100}%[/green], "
126126
f"price limit: [green]{price_with_tolerance}[/green], "
127-
f"original price: [green]{base_rate}[/green], "
127+
f"original price: [green]{base_price}[/green], "
128128
f"with partial stake: [green]{allow_partial_stake}[/green] "
129129
f"on [blue]{subtensor.network}[/blue][/magenta]...[/magenta]"
130130
)

0 commit comments

Comments
 (0)