@@ -103,7 +103,7 @@ async fn solve_orders(solver_args: &SolverArgs) {
103
103
& tip,
104
104
gas,
105
105
all_orders,
106
- solver_args. cross_chain_solution_provider . as_ref ( ) ,
106
+ solver_args. router . as_ref ( ) ,
107
107
)
108
108
. await ;
109
109
} ;
@@ -159,36 +159,44 @@ async fn solve(
159
159
_write_client : & mut CosmWasmWriteClient ,
160
160
cosmos_query_client : & mut CosmWasmReadClient ,
161
161
// really this should query Python Blackbox
162
- cvm_contact : & String ,
162
+ cvm_contact : & Option < String > ,
163
163
order_contract : & String ,
164
164
signing_key : & cosmrs:: crypto:: secp256k1:: SigningKey ,
165
165
rpc : & CosmosChainInfo ,
166
166
tip : & Tip ,
167
167
gas : Gas ,
168
168
all_orders : Vec < OrderItem > ,
169
- router_api : & str ,
169
+ router_api : & Option < String > ,
170
170
) {
171
- let salt = crate :: cvm:: get_salt ( signing_key, tip) ;
172
171
log:: info!( target: "mantis::solver" , "Solving orders" ) ;
173
-
172
+
174
173
let cows_per_pair = mantis_node:: mantis:: solve:: find_cows ( & all_orders) ;
175
- let cvm_glt = get_cvm_glt ( cvm_contact, cosmos_query_client) . await ;
176
174
for pair_solution in cows_per_pair {
177
- let ( a, b) = mantis_node:: mantis:: solve:: IntentBankInput :: find_intent_amount (
178
- pair_solution. cows . as_ref ( ) ,
179
- & all_orders,
180
- pair_solution. optimal_price ,
181
- & cvm_glt,
182
- pair_solution. ab . clone ( ) ,
183
- ) ;
184
-
185
- let a_cvm_route = blackbox:: get_route ( router_api, a, & cvm_glt, salt. as_ref ( ) ) . await ;
186
- let b_cvm_route = blackbox:: get_route ( router_api, b, & cvm_glt, salt. as_ref ( ) ) . await ;
187
-
188
- let cvm_program = CvmProgram {
189
- tag : salt. to_vec ( ) ,
190
- instructions : [ a_cvm_route, b_cvm_route] . concat ( ) . to_vec ( ) ,
191
- } ;
175
+
176
+
177
+ let salt = crate :: cvm:: get_salt ( signing_key, tip) ;
178
+ let program = if let Some ( order_contract) = order_contract {
179
+ let cvm_glt = get_cvm_glt ( order_contract, cosmos_query_client) . await ;
180
+ let ( a, b) = mantis_node:: mantis:: solve:: IntentBankInput :: find_intent_amount (
181
+ pair_solution. cows . as_ref ( ) ,
182
+ & all_orders,
183
+ pair_solution. optimal_price ,
184
+ & cvm_glt,
185
+ pair_solution. ab . clone ( ) ,
186
+ ) ;
187
+
188
+
189
+ let a_cvm_route = blackbox:: get_route ( router_api, a, & cvm_glt, salt. as_ref ( ) ) . await ;
190
+ let b_cvm_route = blackbox:: get_route ( router_api, b, & cvm_glt, salt. as_ref ( ) ) . await ;
191
+
192
+ let cvm_program = CvmProgram {
193
+ tag : salt. to_vec ( ) ,
194
+ instructions : [ a_cvm_route, b_cvm_route] . concat ( ) . to_vec ( ) ,
195
+ } ;
196
+ }
197
+ else {
198
+ None
199
+ } ;
192
200
send_solution (
193
201
pair_solution. cows ,
194
202
cvm_program,
@@ -206,7 +214,7 @@ async fn solve(
206
214
207
215
async fn send_solution (
208
216
cows : Vec < OrderSolution > ,
209
- program : CvmProgram ,
217
+ program : Option < CvmProgram > ,
210
218
tip : & Tip ,
211
219
optimal_price : Ratio ,
212
220
signing_key : & cosmrs:: crypto:: secp256k1:: SigningKey ,
@@ -215,11 +223,9 @@ async fn send_solution(
215
223
gas : Gas ,
216
224
salt : Vec < u8 > ,
217
225
) {
218
- println ! ( "========================= settle =========================" ) ;
226
+ log :: info !( "========================= settle =========================" ) ;
219
227
// would be reasonable to do do cross chain if it solves some % of whole trade
220
- let route = if random :: < bool > ( ) {
221
- None
222
- } else {
228
+ let route = if let Some ( program) = program && random :: < bool > ( ) {
223
229
Some ( CrossChainPart {
224
230
msg : cvm_runtime:: outpost:: ExecuteProgramMsg {
225
231
salt,
@@ -229,6 +235,8 @@ async fn send_solution(
229
235
} ,
230
236
optimal_price,
231
237
} )
238
+ } else {
239
+ None
232
240
} ;
233
241
let solution = SolutionSubMsg {
234
242
cows,
0 commit comments