fix: Use permutations to get token directions
- This is needed for pools which have >2 tokens.
This commit is contained in:
@@ -5,6 +5,7 @@ use figment::{
|
|||||||
providers::{Format, Yaml},
|
providers::{Format, Yaml},
|
||||||
Figment,
|
Figment,
|
||||||
};
|
};
|
||||||
|
use itertools::Itertools;
|
||||||
use miette::{miette, IntoDiagnostic, WrapErr};
|
use miette::{miette, IntoDiagnostic, WrapErr};
|
||||||
use num_bigint::BigUint;
|
use num_bigint::BigUint;
|
||||||
use num_traits::Zero;
|
use num_traits::Zero;
|
||||||
@@ -457,8 +458,12 @@ fn validate_state(
|
|||||||
// We then retrieve the amount out for 0.1%, 1% and 10%.
|
// We then retrieve the amount out for 0.1%, 1% and 10%.
|
||||||
let percentages = [0.001, 0.01, 0.1];
|
let percentages = [0.001, 0.01, 0.1];
|
||||||
|
|
||||||
// Test both swap directions
|
// Test all permutations of swap directions
|
||||||
let swap_directions = [(&tokens[0], &tokens[1]), (&tokens[1], &tokens[0])];
|
let swap_directions: Vec<_> = tokens
|
||||||
|
.iter()
|
||||||
|
.permutations(2)
|
||||||
|
.map(|perm| (perm[0], perm[1]))
|
||||||
|
.collect();
|
||||||
|
|
||||||
for (token_in, token_out) in &swap_directions {
|
for (token_in, token_out) in &swap_directions {
|
||||||
let (max_input, max_output) = state
|
let (max_input, max_output) = state
|
||||||
|
|||||||
Reference in New Issue
Block a user