@@ -209,16 +209,12 @@ async def unstake(
209209 )
210210
211211 try :
212- received_amount , slippage_pct , slippage_pct_float = _calculate_slippage (
213- subnet_info = subnet_info ,
214- amount = amount_to_unstake_as_balance ,
215- stake_fee = stake_fee ,
216- )
212+ current_price = subnet_info .price .tao
213+ rate = current_price
214+ received_amount = amount_to_unstake_as_balance * rate
217215 except ValueError :
218216 continue
219-
220217 total_received_amount += received_amount
221- max_float_slippage = max (max_float_slippage , slippage_pct_float )
222218
223219 base_unstake_op = {
224220 "netuid" : netuid ,
@@ -229,8 +225,6 @@ async def unstake(
229225 "amount_to_unstake" : amount_to_unstake_as_balance ,
230226 "current_stake_balance" : current_stake_balance ,
231227 "received_amount" : received_amount ,
232- "slippage_pct" : slippage_pct ,
233- "slippage_pct_float" : slippage_pct_float ,
234228 "dynamic_info" : subnet_info ,
235229 }
236230
@@ -241,17 +235,15 @@ async def unstake(
241235 str (subnet_info .price .tao )
242236 + f"({ Balance .get_unit (0 )} /{ Balance .get_unit (netuid )} )" , # Rate
243237 str (stake_fee ), # Fee
244- # str(received_amount), # Received Amount
238+ str (received_amount ), # Received Amount
245239 # slippage_pct, # Slippage Percent
246240 ]
247241
248242 # Additional fields for safe unstaking
249243 if safe_staking :
250244 if subnet_info .is_dynamic :
251- rate = received_amount .rao / amount_to_unstake_as_balance .rao
252- rate_with_tolerance = rate * (
253- 1 - rate_tolerance
254- ) # Rate only for display
245+ price_with_tolerance = current_price * (1 - rate_tolerance )
246+ rate_with_tolerance = price_with_tolerance
255247 price_with_tolerance = Balance .from_tao (
256248 rate_with_tolerance
257249 ).rao # Actual price to pass to extrinsic
@@ -443,11 +435,11 @@ async def unstake_all(
443435 justify = "center" ,
444436 style = COLOR_PALETTE ["STAKE" ]["STAKE_AMOUNT" ],
445437 )
446- # table.add_column(
447- # f"Received ({Balance.unit})",
448- # justify="center",
449- # style=COLOR_PALETTE["POOLS"]["TAO_EQUIV"],
450- # )
438+ table .add_column (
439+ f"Received ({ Balance .unit } )" ,
440+ justify = "center" ,
441+ style = COLOR_PALETTE ["POOLS" ]["TAO_EQUIV" ],
442+ )
451443 # table.add_column(
452444 # "Slippage",
453445 # justify="center",
@@ -1259,12 +1251,12 @@ def _create_unstake_table(
12591251 justify = "center" ,
12601252 style = COLOR_PALETTE ["STAKE" ]["STAKE_AMOUNT" ],
12611253 )
1262- # table.add_column(
1263- # f"Received ({Balance.get_unit(0)})",
1264- # justify="center",
1265- # style=COLOR_PALETTE["POOLS"]["TAO_EQUIV"],
1266- # footer=str(total_received_amount),
1267- # )
1254+ table .add_column (
1255+ f"Received ({ Balance .get_unit (0 )} )" ,
1256+ justify = "center" ,
1257+ style = COLOR_PALETTE ["POOLS" ]["TAO_EQUIV" ],
1258+ footer = str (total_received_amount ),
1259+ )
12681260 # table.add_column(
12691261 # "Slippage", justify="center", style=COLOR_PALETTE["STAKE"]["SLIPPAGE_PERCENT"]
12701262 # )
0 commit comments