@@ -97,47 +97,51 @@ def add_stake_extrinsic(
97
97
return False
98
98
99
99
try :
100
+ call_params = {
101
+ "hotkey" : hotkey_ss58 ,
102
+ "netuid" : netuid ,
103
+ "amount_staked" : staking_balance .rao ,
104
+ }
105
+
100
106
if safe_staking :
101
107
pool = subtensor .subnet (netuid = netuid )
102
108
base_price = pool .price .rao
103
109
price_with_tolerance = base_price * (1 + rate_threshold )
104
110
105
- # For logging purposes
111
+ # For logging
106
112
base_rate = pool .price .tao
107
113
rate_with_tolerance = base_rate * (1 + rate_threshold )
108
114
109
115
logging .info (
110
116
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]"
114
123
)
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
+ {
122
127
"limit_price" : price_with_tolerance ,
123
128
"allow_partial" : allow_partial_stake ,
124
- },
129
+ }
125
130
)
131
+ call_function = "add_stake_limit"
126
132
else :
127
133
logging .info (
128
134
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]"
140
137
)
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
+ )
141
145
142
146
staking_response , err_msg = subtensor .sign_and_send_extrinsic (
143
147
call ,
0 commit comments