Skip to content

Commit 0dc6191

Browse files
committed
update add_stake
1 parent 40127cd commit 0dc6191

File tree

1 file changed

+27
-23
lines changed

1 file changed

+27
-23
lines changed

bittensor/core/extrinsics/staking.py

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -97,47 +97,51 @@ def add_stake_extrinsic(
9797
return False
9898

9999
try:
100+
call_params = {
101+
"hotkey": hotkey_ss58,
102+
"netuid": netuid,
103+
"amount_staked": staking_balance.rao,
104+
}
105+
100106
if safe_staking:
101107
pool = subtensor.subnet(netuid=netuid)
102108
base_price = pool.price.rao
103109
price_with_tolerance = base_price * (1 + rate_threshold)
104110

105-
# For logging purposes
111+
# For logging
106112
base_rate = pool.price.tao
107113
rate_with_tolerance = base_rate * (1 + rate_threshold)
108114

109115
logging.info(
110116
f":satellite: [magenta]Safe Staking to:[/magenta] "
111-
f"[blue]netuid: {netuid}, amount: {staking_balance}, tolerance percentage: {rate_threshold*100}%, "
112-
f"price limit: {rate_with_tolerance}, original price: {base_rate}, with partial stake: {allow_partial_stake} "
113-
f"on {subtensor.network}[/blue] [magenta]...[/magenta]"
117+
f"[blue]netuid: [yellow]{netuid}[/yellow], amount: [green]{staking_balance}[/green], "
118+
f"tolerance percentage: [yellow]{rate_threshold*100}%[/yellow], "
119+
f"price limit: [yellow]{rate_with_tolerance}[/yellow], "
120+
f"original price: [green]{base_rate}[/green], "
121+
f"with partial stake: [yellow]{allow_partial_stake}[/yellow] "
122+
f"on [blue]{subtensor.network}[/blue][/magenta]...[/magenta]"
114123
)
115-
call = subtensor.substrate.compose_call(
116-
call_module="SubtensorModule",
117-
call_function="add_stake_limit",
118-
call_params={
119-
"hotkey": hotkey_ss58,
120-
"netuid": netuid,
121-
"amount_staked": staking_balance.rao,
124+
125+
call_params.update(
126+
{
122127
"limit_price": price_with_tolerance,
123128
"allow_partial": allow_partial_stake,
124-
},
129+
}
125130
)
131+
call_function = "add_stake_limit"
126132
else:
127133
logging.info(
128134
f":satellite: [magenta]Staking to:[/magenta] "
129-
f"[blue]netuid: {netuid}, amount: {staking_balance} "
130-
f"on {subtensor.network}[/blue] [magenta]...[/magenta]"
131-
)
132-
call = subtensor.substrate.compose_call(
133-
call_module="SubtensorModule",
134-
call_function="add_stake",
135-
call_params={
136-
"hotkey": hotkey_ss58,
137-
"amount_staked": staking_balance.rao,
138-
"netuid": netuid,
139-
},
135+
f"[blue]netuid: [yellow]{netuid}[/yellow], amount: [green]{staking_balance}[/green] "
136+
f"on [blue]{subtensor.network}[/blue][magenta]...[/magenta]"
140137
)
138+
call_function = "add_stake"
139+
140+
call = subtensor.substrate.compose_call(
141+
call_module="SubtensorModule",
142+
call_function=call_function,
143+
call_params=call_params,
144+
)
141145

142146
staking_response, err_msg = subtensor.sign_and_send_extrinsic(
143147
call,

0 commit comments

Comments
 (0)