Skip to content

Commit

Permalink
combinations
Browse files Browse the repository at this point in the history
  • Loading branch information
dzmitry-lahoda committed Dec 10, 2023
1 parent 38c11a3 commit ebaa07e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
12 changes: 10 additions & 2 deletions mantis/node/src/bin/optimal-routing.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::HashMap;

use itertools::*;
use mantis_node::solver::router::*;
use std::collections::HashMap;
fn main() {
let center_node = "CENTAURI";

Expand All @@ -17,4 +17,12 @@ fn main() {

populate_chain_dict(&mut chains, center_node.to_owned());
println!("{:?}", chains);

let mut all_tokens = vec![];
let mut all_cfmms = vec![];
for (other_chain, other_tokens) in chains.clone() {
all_tokens.extend(other_tokens.clone());
let cfmms = other_tokens.clone().into_iter().combinations(2);
all_cfmms.extend(cfmms);
}
}
7 changes: 4 additions & 3 deletions mantis/node/src/solver/router.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const MIN_RESERVE: f64 = 05000.0;
const MAX_RESERVE: f64 = 15000.0;

use std::collections::HashMap;
use std::{collections::HashMap, ops::Index};

use cosmrs::tendermint::chain;
use good_lp::*;
Expand Down Expand Up @@ -46,11 +46,12 @@ pub fn solve(
fees: Vec<f64>,
ibc_pools: u16,
origin_token: String,
number_of_init_tokens: u128,
number_of_init_tokens: f64,
obj_token: String,
force_eta: Vec<f64>,
) {
let count_tokens = all_tokens.len();
let count_cffms = all_cffms.len();
let current_assets = ndarray::Array1::<f64>::from_elem(count_tokens, <_>::default());
let mut current_assets = ndarray::Array1::<f64>::from_elem(count_tokens, <_>::default());
current_assets[0] = number_of_init_tokens;
}
5 changes: 4 additions & 1 deletion mantis/simulation/optimal-routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

print("=============== chains and tokens ========================")
print(chains)
exit()

# simulate in chain CFMMS
for other_chain, other_tokens in chains.items():
Expand Down Expand Up @@ -62,6 +61,9 @@
for i, cfmm in enumerate(all_cfmms):
print(i, cfmm)

print("=============== solving ========================")

exit()
d, l, p, n = solve(
all_tokens,
all_cfmms,
Expand All @@ -74,6 +76,7 @@
OBJ_TOKEN
)


to_look_n: list[float] = []
for i in range(len(all_cfmms)):
to_look_n.append(n[i].value)
Expand Down
2 changes: 1 addition & 1 deletion mantis/simulation/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def solve(
fees: list[float],
ibc_pools: int,
origin_token: str,
number_of_init_tokens: int,
number_of_init_tokens: float,
obj_token: str,
force_eta: list[float] = None,
):
Expand Down

0 comments on commit ebaa07e

Please sign in to comment.