Skip to content

Commit c3363e6

Browse files
committed
fix(stableswap): enforce peg alignment at runtime and fix bench filename
1 parent c55e0c2 commit c3363e6

3 files changed

Lines changed: 15 additions & 629 deletions

File tree

pallets/stableswap/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,7 @@ pub mod pallet {
11171117
/// - `ShareAssetInPoolAssets`: If the share asset is among the pool assets.
11181118
/// - `AssetNotRegistered`: If one or more assets are not registered in the AssetRegistry.
11191119
/// - `InvalidAmplification`: If the amplification parameter is invalid.
1120+
/// - `IncorrectInitialPegs`: If the number of peg sources does not match the number of assets.
11201121
/// - `MissingTargetPegOracle`: If the target peg oracle entry is missing.
11211122
/// - `IncorrectAssetDecimals`: If the assets have different decimals.
11221123
///
@@ -2216,10 +2217,18 @@ impl<T: Config> Pallet<T> {
22162217
peg_sources.len(),
22172218
"Pool assets and peg sources must have the same length"
22182219
);
2220+
ensure!(
2221+
pool_assets.len() == peg_sources.len(),
2222+
Error::<T>::IncorrectInitialPegs
2223+
);
22192224
debug_assert!(
22202225
pool_assets.windows(2).all(|w| w[0] <= w[1]),
22212226
"pool_assets must be sorted ascending"
22222227
);
2228+
ensure!(
2229+
pool_assets.windows(2).all(|w| w[0] <= w[1]),
2230+
Error::<T>::IncorrectAssets
2231+
);
22232232

22242233
if pool_assets.is_empty() {
22252234
// Should never happen

0 commit comments

Comments
 (0)