diff --git a/mantis/node/src/bin/optimal-routing.rs b/mantis/node/src/bin/optimal-routing.rs index 28e06bdd..c631732b 100644 --- a/mantis/node/src/bin/optimal-routing.rs +++ b/mantis/node/src/bin/optimal-routing.rs @@ -1,6 +1,7 @@ use itertools::*; use mantis_node::solver::router::*; use std::collections::HashMap; +use tuples::TupleCloned; fn main() { let center_node = "CENTAURI"; @@ -24,16 +25,60 @@ fn main() { let mut cfmm_tx_cost = vec![]; for (other_chain, other_tokens) in chains.clone() { all_tokens.extend(other_tokens.clone()); - let cfmms = other_tokens.clone().into_iter().combinations(2); + let cfmms = other_tokens + .clone() + .into_iter() + .combinations(2) + .map(|x| (x[0].clone(), x[1].clone())); all_cfmms.extend(cfmms); } use rand::prelude::*; let tx_costs_random = rand_distr::Uniform::new(0, 20); let reserves_radom = rand_distr::Uniform::new(9500, 10051); - for cfmm in all_cfmms { - let value = reserves_radom.sample(&mut rand::thread_rng()); - reserves.push(value); + for cfmm in all_cfmms.iter() { + let a = reserves_radom.sample(&mut rand::thread_rng()); + let b = reserves_radom.sample(&mut rand::thread_rng()); + reserves.push((a, b)); let value = tx_costs_random.sample(&mut rand::thread_rng()); cfmm_tx_cost.push(value); } + + let mut ibc_pools = 0u32; + let tx_costs_random = rand_distr::Uniform::new(0, 20); + let reserves_random = rand_distr::Uniform::new(10000, 11000); + for token_on_center in chains.get(center_node).unwrap() { + for (other_chain, other_tokens) in chains.iter() { + if other_chain != center_node { + for other_token in other_tokens { + if token_on_center.contains(other_token) + || other_token.contains(token_on_center) + { + all_cfmms.push((token_on_center.to_owned(), other_token.to_owned())); + let a = reserves_random.sample(&mut rand::thread_rng()); + let b = reserves_random.sample(&mut rand::thread_rng()); + reserves.push((a, b)); + cfmm_tx_cost.push(tx_costs_random.sample(&mut rand::thread_rng())); + ibc_pools += 1; + } + } + } + } + } + + let mut fees = vec![]; + let fees_random = rand_distr::Uniform::new(0.97, 0.999); + for cfmm in 0..all_cfmms.len() { + let value = fees_random.sample(&mut rand::thread_rng()); + fees.push(value); + } + + println!("{:?}", reserves); + + for item in all_tokens.iter().enumerate() { + println!("{:?}", item); + } + + for item in all_cfmms.iter().enumerate() { + println!("{:?}", item); + } } diff --git a/mantis/simulation/optimal-routing.py b/mantis/simulation/optimal-routing.py index 0875c119..ae696859 100644 --- a/mantis/simulation/optimal-routing.py +++ b/mantis/simulation/optimal-routing.py @@ -42,7 +42,7 @@ for other_chain, other_tokens in chains.items(): if other_chain != CENTER_NODE: for other_token in other_tokens: - # Check wether the chain has the token in centuri, or the other way around + # Check wether the chain has the token in center, or the other way around # Could cause problems if chainName == tokensName (for example OSMOSIS) if other_token in token_on_center or token_on_center in other_token: all_cfmms.append((token_on_center, other_token)) @@ -53,7 +53,7 @@ # simulate random fees fees.extend(np.random.uniform(0.97, 0.999) for _ in range(len(all_cfmms))) -print(chains) +print(reserves) for i, token in enumerate(all_tokens): print(i, token)