Skip to content

Commit

Permalink
feat: Assert no duplicate mints (#2)
Browse files Browse the repository at this point in the history
* feat: Assert no duplicate mints

* like this instead

* remove duplicates
  • Loading branch information
Arrowana authored Aug 30, 2024
1 parent 1ede820 commit 4577b2f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
14 changes: 12 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
itertools = "0.13.0"
serde = "1.0.208"
serde_json = "1.0.125"
solana-program = "2.0.6"
5 changes: 1 addition & 4 deletions dynamic_slippage_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,8 @@
"eon5tgYNk5FjJUcBUcLno49t2GfpmWZDzJHeYkbh9Zo",
"gSvP9zBJ33pX7W2finzAYJZp6Q9ipNAQ19xU9PrCirz",
"Bybit2vBJGhPF52GBdNaQfUJ6ZpThSgHBobjWZpLPb4B",
"So11111111111111111111111111111111111111112",
"5oVNBeEEQvYi1cX3ir8Dx5n1P7pdxydbGF2X4TxVusJm",
"7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj",
"mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"
"7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj"
]
},
{
Expand All @@ -134,7 +132,6 @@
"3B5wuUrMEi5yATD7on46hKfej3pfmd7t1RKgrsN3pump",
"GYKmdfcUmZVrqfcH1g579BGjuzSRijj3LBuwv79rpump",
"LMFzmYL6y1FX8HsEmZ6yNKNzercBmtmpg2ZoLwuUboU",
"DEkqHyPN7GMRJ5cArtQFAWefqbZb33Hyf6s5iCwjEonT",
"5EgzypuMLFUBDacgZqJcuL7eKtpSJuKgNu7i7Kdypump",
"63LfDmNb3MQ8mw9MtZ2To9bEA2M71kZUUGq5tiJxcqj9",
"5z3EqYQo9HiCEs3R84RCDMu2n7anpDMxRhdK8PSWmrRC",
Expand Down
14 changes: 12 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ pub fn deserialize_dynamic_slippage_config() -> Result<(DefaultSlippage, Vec<Cat

#[cfg(test)]
mod tests {
use itertools::Itertools;

use super::*;

#[test]
Expand All @@ -81,12 +83,20 @@ mod tests {
categories.iter().map(|c| &c.name).collect::<Vec<_>>(),
vec!["stable", "lst", "bluechip", "verified"]
);

assert!(categories
.iter()
.find(|c| c.name == "lst")
.unwrap()
.pair_range
.is_some())
.is_some());

// Ensure no duplicated mints, otherwise the config behaviour will be confusing
let duplicates = categories
.iter()
.flat_map(|c| &c.mints)
.duplicates()
.collect::<Vec<&Pubkey>>();

assert_eq!(duplicates, Vec::<&Pubkey>::new());
}
}

0 comments on commit 4577b2f

Please sign in to comment.