Skip to content

Commit d425f94

Browse files
authored
Merge branch 'staging' into changelog/981
2 parents 477964c + 73cca54 commit d425f94

File tree

4 files changed

+44
-38
lines changed

4 files changed

+44
-38
lines changed

bittensor/core/extrinsics/asyncex/staking.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -120,28 +120,31 @@ async def add_stake_extrinsic(
120120

121121
if safe_staking:
122122
pool = await subtensor.subnet(netuid=netuid)
123-
base_price = pool.price.rao
124-
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"
123+
base_price = pool.price.tao
124+
125+
if pool.netuid == 0:
126+
price_with_tolerance = base_price
127+
else:
128+
price_with_tolerance = base_price * (1 + rate_tolerance)
132129

133-
# For logging
134-
base_rate = pool.price.tao
135-
rate_with_tolerance = base_rate * (1 + rate_tolerance)
136130
logging.info(
137131
f":satellite: [magenta]Safe Staking to:[/magenta] "
138132
f"[blue]netuid: [green]{netuid}[/green], amount: [green]{staking_balance}[/green], "
139133
f"tolerance percentage: [green]{rate_tolerance * 100}%[/green], "
140-
f"price limit: [green]{rate_with_tolerance}[/green], "
141-
f"original price: [green]{base_rate}[/green], "
134+
f"price limit: [green]{price_with_tolerance}[/green], "
135+
f"original price: [green]{base_price}[/green], "
142136
f"with partial stake: [green]{allow_partial_stake}[/green] "
143137
f"on [blue]{subtensor.network}[/blue][/magenta]...[/magenta]"
144138
)
139+
140+
limit_price = Balance.from_tao(price_with_tolerance).rao
141+
call_params.update(
142+
{
143+
"limit_price": limit_price,
144+
"allow_partial": allow_partial_stake,
145+
}
146+
)
147+
call_function = "add_stake_limit"
145148
else:
146149
logging.info(
147150
f":satellite: [magenta]Staking to:[/magenta] "

bittensor/core/extrinsics/asyncex/unstaking.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,26 +107,27 @@ async def unstake_extrinsic(
107107
}
108108
if safe_staking:
109109
pool = await subtensor.subnet(netuid=netuid)
110-
base_price = pool.price.rao
111-
price_with_tolerance = base_price * (1 - rate_tolerance)
110+
base_price = pool.price.tao
112111

113-
# For logging
114-
base_rate = pool.price.tao
115-
rate_with_tolerance = base_rate * (1 - rate_tolerance)
112+
if pool.netuid == 0:
113+
price_with_tolerance = base_price
114+
else:
115+
price_with_tolerance = base_price * (1 - rate_tolerance)
116116

117117
logging.info(
118118
f":satellite: [magenta]Safe Unstaking from:[/magenta] "
119119
f"netuid: [green]{netuid}[/green], amount: [green]{unstaking_balance}[/green], "
120120
f"tolerance percentage: [green]{rate_tolerance * 100}%[/green], "
121-
f"price limit: [green]{rate_with_tolerance}[/green], "
122-
f"original price: [green]{base_rate}[/green], "
121+
f"price limit: [green]{price_with_tolerance}[/green], "
122+
f"original price: [green]{base_price}[/green], "
123123
f"with partial unstake: [green]{allow_partial_stake}[/green] "
124124
f"on [blue]{subtensor.network}[/blue][magenta]...[/magenta]"
125125
)
126126

127+
limit_price = Balance.from_tao(price_with_tolerance).rao
127128
call_params.update(
128129
{
129-
"limit_price": price_with_tolerance,
130+
"limit_price": limit_price,
130131
"allow_partial": allow_partial_stake,
131132
}
132133
)

bittensor/core/extrinsics/staking.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,26 +112,27 @@ def add_stake_extrinsic(
112112

113113
if safe_staking:
114114
pool = subtensor.subnet(netuid=netuid)
115-
base_price = pool.price.rao
116-
price_with_tolerance = base_price * (1 + rate_tolerance)
115+
base_price = pool.price.tao
117116

118-
# For logging
119-
base_rate = pool.price.tao
120-
rate_with_tolerance = base_rate * (1 + rate_tolerance)
117+
if pool.netuid == 0:
118+
price_with_tolerance = base_price
119+
else:
120+
price_with_tolerance = base_price * (1 + rate_tolerance)
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], "
126-
f"price limit: [green]{rate_with_tolerance}[/green], "
127-
f"original price: [green]{base_rate}[/green], "
126+
f"price limit: [green]{price_with_tolerance}[/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
)
131131

132+
limit_price = Balance.from_tao(price_with_tolerance).rao
132133
call_params.update(
133134
{
134-
"limit_price": price_with_tolerance,
135+
"limit_price": limit_price,
135136
"allow_partial": allow_partial_stake,
136137
}
137138
)

bittensor/core/extrinsics/unstaking.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,26 +105,27 @@ def unstake_extrinsic(
105105

106106
if safe_staking:
107107
pool = subtensor.subnet(netuid=netuid)
108-
base_price = pool.price.rao
109-
price_with_tolerance = base_price * (1 - rate_tolerance)
108+
base_price = pool.price.tao
110109

111-
# For logging
112-
base_rate = pool.price.tao
113-
rate_with_tolerance = base_rate * (1 - rate_tolerance)
110+
if pool.netuid == 0:
111+
price_with_tolerance = base_price
112+
else:
113+
price_with_tolerance = base_price * (1 - rate_tolerance)
114114

115115
logging.info(
116116
f":satellite: [magenta]Safe Unstaking from:[/magenta] "
117117
f"netuid: [green]{netuid}[/green], amount: [green]{unstaking_balance}[/green], "
118118
f"tolerance percentage: [green]{rate_tolerance * 100}%[/green], "
119-
f"price limit: [green]{rate_with_tolerance}[/green], "
120-
f"original price: [green]{base_rate}[/green], "
119+
f"price limit: [green]{price_with_tolerance}[/green], "
120+
f"original price: [green]{base_price}[/green], "
121121
f"with partial unstake: [green]{allow_partial_stake}[/green] "
122122
f"on [blue]{subtensor.network}[/blue][magenta]...[/magenta]"
123123
)
124124

125+
limit_price = Balance.from_tao(price_with_tolerance).rao
125126
call_params.update(
126127
{
127-
"limit_price": price_with_tolerance,
128+
"limit_price": limit_price,
128129
"allow_partial": allow_partial_stake,
129130
}
130131
)

0 commit comments

Comments
 (0)