From 00d573875cecb6f2fdf28825a969be940c57f146 Mon Sep 17 00:00:00 2001 From: Arrowana Date: Wed, 7 Feb 2024 22:35:55 +1100 Subject: [PATCH] Stable ordering for SplStakePool in TwoWayPoolPair --- stakedex_sdk/src/lib.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/stakedex_sdk/src/lib.rs b/stakedex_sdk/src/lib.rs index 5a178c9..cdd6aa6 100644 --- a/stakedex_sdk/src/lib.rs +++ b/stakedex_sdk/src/lib.rs @@ -470,6 +470,12 @@ impl Stakedex { for (first_stakedex, second_stakedex) in stakedexes.into_iter().tuple_combinations() { match (first_stakedex, second_stakedex) { (Stakedex::SplStakePool(p1), Stakedex::SplStakePool(p2)) => { + // To provide a stable ordering of SPL stake pools + let (p1, p2) = if p1.staked_sol_mint() < p2.staked_sol_mint() { + (p1, p2) + } else { + (p2, p1) + }; amms.push(Box::new(TwoWayPoolPair::new(p1, p2))); } match_stakedexes!(SplStakePool, Marinade, withdraw, deposit) => {