@@ -120,28 +120,30 @@ async def add_stake_extrinsic(
120
120
121
121
if safe_staking :
122
122
pool = await subtensor .subnet (netuid = netuid )
123
- base_price = pool .price .rao
123
+ received_amount , _ = pool .tao_to_alpha_with_slippage (staking_balance )
124
+ base_price = received_amount .rao / staking_balance .rao
124
125
price_with_tolerance = base_price * (1 + rate_tolerance )
125
- call_params .update (
126
- {
127
- "limit_price" : price_with_tolerance ,
128
- "allow_partial" : allow_partial_stake ,
129
- }
130
- )
131
- call_function = "add_stake_limit"
132
126
133
127
# For logging
134
128
base_rate = pool .price .tao
135
- rate_with_tolerance = base_rate * ( 1 + rate_tolerance )
129
+
136
130
logging .info (
137
131
f":satellite: [magenta]Safe Staking to:[/magenta] "
138
132
f"[blue]netuid: [green]{ netuid } [/green], amount: [green]{ staking_balance } [/green], "
139
133
f"tolerance percentage: [green]{ rate_tolerance * 100 } %[/green], "
140
- f"price limit: [green]{ rate_with_tolerance } [/green], "
134
+ f"price limit: [green]{ price_with_tolerance } [/green], "
141
135
f"original price: [green]{ base_rate } [/green], "
142
136
f"with partial stake: [green]{ allow_partial_stake } [/green] "
143
137
f"on [blue]{ subtensor .network } [/blue][/magenta]...[/magenta]"
144
138
)
139
+
140
+ call_params .update (
141
+ {
142
+ "limit_price" : price_with_tolerance ,
143
+ "allow_partial" : allow_partial_stake ,
144
+ }
145
+ )
146
+ call_function = "add_stake_limit"
145
147
else :
146
148
logging .info (
147
149
f":satellite: [magenta]Staking to:[/magenta] "
0 commit comments