From 2d906b404912c32ccc6c5c696692aadf48bb1753 Mon Sep 17 00:00:00 2001 From: dzmitry-lahoda Date: Sun, 10 Dec 2023 20:53:58 +0000 Subject: [PATCH] rust is ugly --- mantis/node/src/solver/router.rs | 21 +++++++++++++++++++++ mantis/simulation/router.py | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/mantis/node/src/solver/router.rs b/mantis/node/src/solver/router.rs index 72f80f24..40f37bb5 100644 --- a/mantis/node/src/solver/router.rs +++ b/mantis/node/src/solver/router.rs @@ -54,4 +54,25 @@ pub fn solve( let count_cffms = all_cffms.len(); let mut current_assets = ndarray::Array1::::from_elem(count_tokens, <_>::default()); current_assets[0] = number_of_init_tokens; + + let mut problem = ProblemVariables::new(); + let mut main_expression = Expression::default(); + let mut constraints: Vec = vec![]; + + // Build variables + + let mut A: Vec> = vec![]; + for cfmm in all_cffms.iter() { + let n_i = 2; + } + + let mut deltas: Vec> = vec![]; + let mut lambdas: Vec> = vec![]; + // Binary value, indicates tx or not for given pool + let mut eta: Vec = vec![]; + for _ in all_cffms { + deltas.push(vec![variable(), variable()]); + lambdas.push(vec![variable(), variable()]); + eta.push(variable()); + } } diff --git a/mantis/simulation/router.py b/mantis/simulation/router.py index 99e495e3..b0acff50 100644 --- a/mantis/simulation/router.py +++ b/mantis/simulation/router.py @@ -59,7 +59,7 @@ def solve( count_cfmms, nonneg=True ) # Binary value, indicates tx or not for given pool - psi = cp.sum([A_i @ (L - D) for A_i, D, L in zip(A, deltas, lambdas)]) + psi = cp.sum([A_i @ (LAMBDA - DELTA) for A_i, DELTA, LAMBDA in zip(A, deltas, lambdas)]) # Objective is to trade number_of_init_tokens of asset origin_token for a maximum amount of asset objective_token obj = cp.Maximize(psi[all_tokens.index(obj_token)] - eta @ cfmm_tx_cost)