Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions bittensor/core/extrinsics/asyncex/staking.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,28 +120,31 @@ async def add_stake_extrinsic(

if safe_staking:
pool = await subtensor.subnet(netuid=netuid)
base_price = pool.price.rao
price_with_tolerance = base_price * (1 + rate_tolerance)
call_params.update(
{
"limit_price": price_with_tolerance,
"allow_partial": allow_partial_stake,
}
)
call_function = "add_stake_limit"
base_price = pool.price.tao

if pool.netuid == 0:
price_with_tolerance = base_price * (1 + rate_tolerance)
else:
price_with_tolerance = base_price

# For logging
base_rate = pool.price.tao
rate_with_tolerance = base_rate * (1 + rate_tolerance)
logging.info(
f":satellite: [magenta]Safe Staking to:[/magenta] "
f"[blue]netuid: [green]{netuid}[/green], amount: [green]{staking_balance}[/green], "
f"tolerance percentage: [green]{rate_tolerance * 100}%[/green], "
f"price limit: [green]{rate_with_tolerance}[/green], "
f"original price: [green]{base_rate}[/green], "
f"price limit: [green]{price_with_tolerance}[/green], "
f"original price: [green]{base_price}[/green], "
f"with partial stake: [green]{allow_partial_stake}[/green] "
f"on [blue]{subtensor.network}[/blue][/magenta]...[/magenta]"
)

limit_price = Balance.from_tao(price_with_tolerance).rao
call_params.update(
{
"limit_price": limit_price,
"allow_partial": allow_partial_stake,
}
)
call_function = "add_stake_limit"
else:
logging.info(
f":satellite: [magenta]Staking to:[/magenta] "
Expand Down
17 changes: 9 additions & 8 deletions bittensor/core/extrinsics/asyncex/unstaking.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,26 +107,27 @@ async def unstake_extrinsic(
}
if safe_staking:
pool = await subtensor.subnet(netuid=netuid)
base_price = pool.price.rao
price_with_tolerance = base_price * (1 - rate_tolerance)
base_price = pool.price.tao

# For logging
base_rate = pool.price.tao
rate_with_tolerance = base_rate * (1 - rate_tolerance)
if pool.netuid == 0:
price_with_tolerance = base_price * (1 - rate_tolerance)
else:
price_with_tolerance = base_price

logging.info(
f":satellite: [magenta]Safe Unstaking from:[/magenta] "
f"netuid: [green]{netuid}[/green], amount: [green]{unstaking_balance}[/green], "
f"tolerance percentage: [green]{rate_tolerance * 100}%[/green], "
f"price limit: [green]{rate_with_tolerance}[/green], "
f"original price: [green]{base_rate}[/green], "
f"price limit: [green]{price_with_tolerance}[/green], "
f"original price: [green]{base_price}[/green], "
f"with partial unstake: [green]{allow_partial_stake}[/green] "
f"on [blue]{subtensor.network}[/blue][magenta]...[/magenta]"
)

limit_price = Balance.from_tao(price_with_tolerance).rao
call_params.update(
{
"limit_price": price_with_tolerance,
"limit_price": limit_price,
"allow_partial": allow_partial_stake,
}
)
Expand Down
17 changes: 9 additions & 8 deletions bittensor/core/extrinsics/staking.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,26 +112,27 @@ def add_stake_extrinsic(

if safe_staking:
pool = subtensor.subnet(netuid=netuid)
base_price = pool.price.rao
price_with_tolerance = base_price * (1 + rate_tolerance)
base_price = pool.price.tao

# For logging
base_rate = pool.price.tao
rate_with_tolerance = base_rate * (1 + rate_tolerance)
if pool.netuid == 0:
price_with_tolerance = base_price * (1 + rate_tolerance)
else:
price_with_tolerance = base_price

logging.info(
f":satellite: [magenta]Safe Staking to:[/magenta] "
f"[blue]netuid: [green]{netuid}[/green], amount: [green]{staking_balance}[/green], "
f"tolerance percentage: [green]{rate_tolerance * 100}%[/green], "
f"price limit: [green]{rate_with_tolerance}[/green], "
f"original price: [green]{base_rate}[/green], "
f"price limit: [green]{price_with_tolerance}[/green], "
f"original price: [green]{base_price}[/green], "
f"with partial stake: [green]{allow_partial_stake}[/green] "
f"on [blue]{subtensor.network}[/blue][/magenta]...[/magenta]"
)

limit_price = Balance.from_tao(price_with_tolerance).rao
call_params.update(
{
"limit_price": price_with_tolerance,
"limit_price": limit_price,
"allow_partial": allow_partial_stake,
}
)
Expand Down
17 changes: 9 additions & 8 deletions bittensor/core/extrinsics/unstaking.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,26 +105,27 @@ def unstake_extrinsic(

if safe_staking:
pool = subtensor.subnet(netuid=netuid)
base_price = pool.price.rao
price_with_tolerance = base_price * (1 - rate_tolerance)
base_price = pool.price.tao

# For logging
base_rate = pool.price.tao
rate_with_tolerance = base_rate * (1 - rate_tolerance)
if pool.netuid == 0:
price_with_tolerance = base_price * (1 - rate_tolerance)
else:
price_with_tolerance = base_price

logging.info(
f":satellite: [magenta]Safe Unstaking from:[/magenta] "
f"netuid: [green]{netuid}[/green], amount: [green]{unstaking_balance}[/green], "
f"tolerance percentage: [green]{rate_tolerance * 100}%[/green], "
f"price limit: [green]{rate_with_tolerance}[/green], "
f"original price: [green]{base_rate}[/green], "
f"price limit: [green]{price_with_tolerance}[/green], "
f"original price: [green]{base_price}[/green], "
f"with partial unstake: [green]{allow_partial_stake}[/green] "
f"on [blue]{subtensor.network}[/blue][magenta]...[/magenta]"
)

limit_price = Balance.from_tao(price_with_tolerance).rao
call_params.update(
{
"limit_price": price_with_tolerance,
"limit_price": limit_price,
"allow_partial": allow_partial_stake,
}
)
Expand Down
Loading