From 9062262b0b0af2a7ec274b3cefaea94f83ce950c Mon Sep 17 00:00:00 2001 From: dzmitry-lahoda Date: Sat, 6 Apr 2024 19:00:25 +0100 Subject: [PATCH] Bypes --- contracts/cosmwasm/order/src/lib.rs | 2 +- contracts/cosmwasm/order/src/simulator.rs | 12 ++++++------ mantis/node/src/bin/mantis.rs | 16 ++++++++-------- mantis/node/src/mantis/simulate.rs | 4 ++-- mantis/node/src/mantis/solve.rs | 9 +++++---- 5 files changed, 22 insertions(+), 21 deletions(-) diff --git a/contracts/cosmwasm/order/src/lib.rs b/contracts/cosmwasm/order/src/lib.rs index 3e5dbf36..0ef75f95 100644 --- a/contracts/cosmwasm/order/src/lib.rs +++ b/contracts/cosmwasm/order/src/lib.rs @@ -537,7 +537,7 @@ impl OrderContract<'_> { fn pre_fill_remotely<'a>( &self, ctx: ExecCtx<'a>, - optimal_price: Ratio, + _optimal_price: Ratio, solver_address: String, solution_id: SolutionHash, solver_orders: Vec, diff --git a/contracts/cosmwasm/order/src/simulator.rs b/contracts/cosmwasm/order/src/simulator.rs index 333391cf..fc138df5 100644 --- a/contracts/cosmwasm/order/src/simulator.rs +++ b/contracts/cosmwasm/order/src/simulator.rs @@ -13,7 +13,7 @@ use crate::SolvedOrder; /// return filling amounts for all orders from program, which may or may not lead to full fill pub fn verify( route: CvmProgram, - in_asset: &AssetItem, + _in_asset: &AssetItem, out_asset: &AssetItem, predicted_out_amount: u128, orders: Vec, @@ -80,11 +80,11 @@ pub fn simulate_cows_via_bank( /// Solve only larger CVM for in volume, assuming other solution will be for other side sent. /// Produces remaining each order will receive proportional to what is given. pub fn simulate_route( - storage: &mut dyn Storage, - route: CvmProgram, - token_a_remaining: Coin, - token_b_remaining: Coin, - orders: Vec, + _storage: &mut dyn Storage, + _route: CvmProgram, + _token_a_remaining: Coin, + _token_b_remaining: Coin, + _orders: Vec, ) -> Result<(), StdError> { todo!() } diff --git a/mantis/node/src/bin/mantis.rs b/mantis/node/src/bin/mantis.rs index e979be03..8d55c38d 100644 --- a/mantis/node/src/bin/mantis.rs +++ b/mantis/node/src/bin/mantis.rs @@ -29,7 +29,7 @@ use mantis_node::{ *, }, indexer::{get_all_orders, get_cvm_glt}, - simulate, + simulate, solve::PairSolution, }, prelude::*, solver::{orderbook::OrderList, solution::Solution}, @@ -64,7 +64,7 @@ async fn main() { async fn solve_orders(solver_args: &SolverArgs) { let args = &solver_args.shared; - let mut wasm_read_client = create_wasm_query_client(&args.grpc_centauri).await; + let wasm_read_client = create_wasm_query_client(&args.grpc_centauri).await; let signer = mantis_node::mantis::cosmos::signer::from_mnemonic( args.wallet.as_str(), @@ -187,16 +187,16 @@ async fn solve( let salt = crate::cvm::get_salt(signing_key, tip); log::info!(target: "mantis::solver", "Solving orders"); - let cows_per_pair = mantis_node::mantis::solve::find_cows(all_orders); + let cows_per_pair = mantis_node::mantis::solve::find_cows(&all_orders); let cvm_glt = get_cvm_glt(cvm_contact, cosmos_query_client).await; - for (cows, optimal_price) in cows_per_pair {); - let (a, b) = mantis_node::mantis::solve::IntentBankInput::find_intent_amount(cows.as_ref(), &all_orders, optimal_price, &cvm_glt, cvm_glt.pair.clone()); - let cvm_route = blackbox::get_route(router_api, bank, &cvm_glt, salt.as_ref()).await; + for pair_solution in cows_per_pair {; + let (a, b) = mantis_node::mantis::solve::IntentBankInput::find_intent_amount(pair_solution.cows.as_ref(), &all_orders, pair_solution.optimal_price, &cvm_glt, pair_solution.ab.clone()); + let cvm_route = panic!(); //blackbox::get_route(router_api, bank, &cvm_glt, salt.as_ref()).await; send_solution( - cows, + pair_solution.cows, cvm_route, tip, - optimal_price, + pair_solution.optimal_price, signing_key, order_contract, rpc, diff --git a/mantis/node/src/mantis/simulate.rs b/mantis/node/src/mantis/simulate.rs index 0d6c64f0..8fcea92a 100644 --- a/mantis/node/src/mantis/simulate.rs +++ b/mantis/node/src/mantis/simulate.rs @@ -63,8 +63,8 @@ pub fn randomize_coin(coin_0_amount: u128) -> u128 { /// /// Also calls `timeout` so old orders are cleaned. pub async fn simulate_order( - write_client: &mut CosmWasmWriteClient, - cosmos_query_client: &mut CosmosQueryClient, + _write_client: &mut CosmWasmWriteClient, + _cosmos_query_client: &mut CosmosQueryClient, order_contract: String, coins_pair: &String, signing_key: &cosmrs::crypto::secp256k1::SigningKey, diff --git a/mantis/node/src/mantis/solve.rs b/mantis/node/src/mantis/solve.rs index 168bfc99..2fd8d63f 100644 --- a/mantis/node/src/mantis/solve.rs +++ b/mantis/node/src/mantis/solve.rs @@ -46,6 +46,7 @@ impl IntentBankInput { orders: &[OrderItem], optimal_ratio: Ratio, cvm_glt: &GetConfigResponse, + pair: DenomPair, ) -> (IntentBankInput, IntentBankInput) { // native calculations let mut pair = OrderCoinPair::zero(pair.a, pair.b); @@ -111,17 +112,17 @@ pub struct PairSolution { pub optimal_price: Ratio, } -pub fn find_cows(all_orders: Vec) -> Vec { +pub fn find_cows(all_orders: &[OrderItem]) -> Vec { let all_orders = all_orders.into_iter().group_by(|x| { x.pair() }); let mut cows_per_pair = vec![]; - for ((a, b), orders) in all_orders.into_iter() { + for (ab, orders) in all_orders.into_iter() { let orders = orders.collect::>(); use crate::solver::cows::*; use crate::solver::types::*; let orders = orders.iter().map(|x| { - let side = if x.given.denom == a { + let side = if x.given.denom == ab.a { OrderType::Buy } else { OrderType::Sell @@ -160,7 +161,7 @@ pub fn find_cows(all_orders: Vec) -> Vec { println!("cows: {:?}", cows); if !cows.is_empty() { let pair_solution = PairSolution { - ab: DenomPair::new(a, b), + ab, cows, optimal_price, };