Skip to content

Commit

Permalink
rust is ugly
Browse files Browse the repository at this point in the history
  • Loading branch information
dzmitry-lahoda committed Dec 10, 2023
1 parent 7883663 commit 2d906b4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions mantis/node/src/solver/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,25 @@ pub fn solve(
let count_cffms = all_cffms.len();
let mut current_assets = ndarray::Array1::<f64>::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<Constraint> = vec![];

// Build variables

let mut A: Vec<Vec<f64>> = vec![];
for cfmm in all_cffms.iter() {
let n_i = 2;
}

let mut deltas: Vec<Vec<VariableDefinition>> = vec![];
let mut lambdas: Vec<Vec<VariableDefinition>> = vec![];
// Binary value, indicates tx or not for given pool
let mut eta: Vec<VariableDefinition> = vec![];
for _ in all_cffms {
deltas.push(vec![variable(), variable()]);
lambdas.push(vec![variable(), variable()]);
eta.push(variable());
}
}
2 changes: 1 addition & 1 deletion mantis/simulation/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2d906b4

Please sign in to comment.