Skip to content

Commit

Permalink
Stable ordering for SplStakePool in TwoWayPoolPair
Browse files Browse the repository at this point in the history
  • Loading branch information
Arrowana committed Feb 7, 2024
1 parent cc0f0f0 commit 00d5738
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions stakedex_sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit 00d5738

Please sign in to comment.