diff --git a/mantis/node/src/mantis/blackbox/mod.rs b/mantis/node/src/mantis/blackbox/mod.rs index 9b2b2b93..45dd169c 100644 --- a/mantis/node/src/mantis/blackbox/mod.rs +++ b/mantis/node/src/mantis/blackbox/mod.rs @@ -3,7 +3,7 @@ use blackbox_rs::{types::*, Client}; use cvm_runtime::{ outpost::GetConfigResponse, shared::{CvmAddress, CvmFundsFilter, CvmInstruction, CvmProgram, Displayed}, - Amount, + Amount, }; use crate::solver::router::shortest_path; @@ -51,7 +51,9 @@ fn new_spawn( let in_amount: Amount = match spawn.in_asset_amount.as_ref().expect("in_asset_amount") { InAssetAmount::Variant0(x) => (*x).try_into().expect("in_asset_amount"), InAssetAmount::Variant1(x) => x.parse().expect("in_asset_amount"), - InAssetAmount::Variant2(x) => panic!("fix python not to have float or use to fixed point/fraction first"), // Amount::try_floor_f64(*x).expect("in_asset_amount"), + InAssetAmount::Variant2(x) => { + panic!("fix python not to have float or use to fixed point/fraction first") + } // Amount::try_floor_f64(*x).expect("in_asset_amount"), }; let out_asset_id = match &spawn.out_asset_id { diff --git a/mantis/node/src/mantis/cosmos/client.rs b/mantis/node/src/mantis/cosmos/client.rs index 800477bd..c6874569 100644 --- a/mantis/node/src/mantis/cosmos/client.rs +++ b/mantis/node/src/mantis/cosmos/client.rs @@ -1,8 +1,6 @@ use crate::prelude::*; -use cosmos_sdk_proto::cosmos::{ - auth::v1beta1::BaseAccount, -}; +use cosmos_sdk_proto::cosmos::auth::v1beta1::BaseAccount; use cosmrs::{ rpc::Client, tendermint::{block::Height, chain}, @@ -38,7 +36,6 @@ pub fn timeout(height: Height, delta: u32) -> u64 { pub async fn create_cosmos_query_client(rpc: &str) -> CosmosQueryClient { use cosmos_sdk_proto::cosmos::auth::v1beta1::query_client::*; - use cosmos_sdk_proto::cosmos::auth::v1beta1::*; let url = tonic::transport::Endpoint::from_str(rpc).expect("url"); QueryClient::connect(url).await.expect("connected") diff --git a/mantis/node/src/mantis/solve.rs b/mantis/node/src/mantis/solve.rs index c974aa59..6b894df9 100644 --- a/mantis/node/src/mantis/solve.rs +++ b/mantis/node/src/mantis/solve.rs @@ -1,6 +1,4 @@ use core::num; - -use cosmrs::tendermint::block::Height; use cvm_runtime::{ outpost::GetConfigResponse, shared::{CvmAddress, CvmBalanceFilter, CvmFunds, CvmFundsFilter, CvmInstruction, Displayed}, @@ -8,15 +6,13 @@ use cvm_runtime::{ }; use cw_mantis_order::{CrossChainPart, OrderAmount, OrderItem, OrderSolution, OrderSubMsg}; use mantis_cw::{DenomPair, OrderCoinPair, OrderSide, OrderedTuple2}; -use num_rational::{Ratio, Rational64}; +use num_rational::Ratio; use crate::{ prelude::*, solver::{orderbook::OrderList, solution::Solution}, }; -use super::cosmos::client::timeout; - /// input batched summarized from users for routing pub struct IntentBankInput { pub in_asset_id: AssetId, @@ -117,8 +113,6 @@ pub fn find_cows(all_orders: &[OrderItem]) -> Vec { let mut cows_per_pair = vec![]; 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| { crate::solver::types::Order::new_integer( x.given.amount.u128(), diff --git a/mantis/node/src/solver/router/shortest_path.rs b/mantis/node/src/solver/router/shortest_path.rs index 6f3c735e..dcec1c5c 100644 --- a/mantis/node/src/solver/router/shortest_path.rs +++ b/mantis/node/src/solver/router/shortest_path.rs @@ -5,9 +5,7 @@ use cvm_route::venue::VenueId; use cvm_runtime::shared::{CvmFundsFilter, CvmInstruction, CvmProgram}; use cvm_runtime::{exchange, AssetId, ExchangeId}; use petgraph::algo::bellman_ford; -use petgraph::data::FromElements; use petgraph::dot::{Config, Dot}; -use petgraph::graph::{NodeIndex, UnGraph}; use std::collections::BTreeMap; use std::ops::Deref; @@ -55,7 +53,7 @@ pub fn route( let local_venue = graph.add_edge(*from_node, *to_node, 1.0); venue_local_to_global.insert(local_venue, venue.clone()); } - Venue::Exchange(exchange_id, from, to) => { + Venue::Exchange(_exchange_id, from, to) => { let from_node = assets_global_to_local.get(&from).unwrap(); let to_node = assets_global_to_local.get(&to).unwrap(); let local_venue = graph.add_edge(*from_node, *to_node, 1.0); @@ -71,9 +69,8 @@ pub fn route( let routes = bellman_ford::bellman_ford(&graph, start_node_index).expect("bf"); let mut out_node_index = *assets_global_to_local - .get(&input.out_asset_id) - .expect("node") - ; + .get(&input.out_asset_id) + .expect("node"); let mut in_node_index = routes.predecessors[out_node_index.index()]; let mut instructions = input.order_accounts.clone(); while let Some(in_node_index_value) = in_node_index { @@ -85,7 +82,7 @@ pub fn route( .expect("venue") .clone(); match venue { - Venue::Transfer(from_asset_id, to_asset_id) => { + Venue::Transfer(from_asset_id, _to_asset_id) => { let spawn = CvmInstruction::Spawn { network_id: cvm_glt.get_network_for_asset(from_asset_id), salt: salt.to_vec(), diff --git a/mantis/node/tests/mantis.rs b/mantis/node/tests/mantis.rs index 2745e930..48d756d2 100644 --- a/mantis/node/tests/mantis.rs +++ b/mantis/node/tests/mantis.rs @@ -2,7 +2,10 @@ use cosmrs::tendermint::block::Height; use cosmwasm_std::{testing::*, Addr, Binary, Coin, MessageInfo}; use cw_mantis_order::{sv::*, OrderItem, OrderSubMsg, SolutionSubMsg}; -use mantis_node::{mantis::{simulate::randomize_order, solve::PairSolution}, prelude::*}; +use mantis_node::{ + mantis::{simulate::randomize_order, solve::PairSolution}, + prelude::*, +}; #[test] fn cows_scenarios() { @@ -228,7 +231,12 @@ fn do_solve( info: MessageInfo, ) -> Vec { let mut responses = vec![]; - for PairSolution {cows, optimal_price, ..} in cows_per_pair { + for PairSolution { + cows, + optimal_price, + .. + } in cows_per_pair + { let msg = ExecMsg::Solve { msg: SolutionSubMsg { cows,