Skip to content

Commit 4f4272b

Browse files
committed
feat: change method of validating pool assets
1 parent 5f04123 commit 4f4272b

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/implementations/osmosis/osmosis_math.rs

+14-4
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,27 @@ pub fn osmosis_calculate_join_pool_shares(
2020

2121
// Validate that sent assets are in the pool
2222
// TODO: Need to check if there are duplicates in the assets list?
23+
let mut valid: bool = false;
2324
assets
2425
.iter()
2526
.map(|a| {
26-
if pool_state.assets.contains(a) {
27-
Ok(())
28-
} else {
29-
Err(StdError::generic_err(format!("Asset {} is not in the pool {}", a, pool_id)))
27+
for asset in &pool_state.assets {
28+
if asset.denom == a.denom {
29+
valid = true;
30+
return Ok(());
31+
}
3032
}
33+
Ok(())
3134
})
3235
.collect::<StdResult<Vec<_>>>()?;
3336

37+
if valid == false {
38+
return Err(StdError::generic_err(format!(
39+
"Assets {:?} are not in the pool {}, expected: {:?}",
40+
assets, pool_id, pool_state.assets
41+
)));
42+
}
43+
3444
if assets.len() == 2 {
3545
let shares_out_amount = calc_join_pool_shares_double_sided(
3646
assets,

0 commit comments

Comments
 (0)