Skip to content

Commit 916f83f

Browse files
Ad96elrflechtner
authored andcommitted
fix: ensure at least one currency in pool (#844)
## fixes [#3747](KILTprotocol/ticket#3747)
1 parent 9d6bab4 commit 916f83f

File tree

1 file changed

+3
-0
lines changed
  • pallets/pallet-bonded-coins/src

1 file changed

+3
-0
lines changed

pallets/pallet-bonded-coins/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,8 @@ pub mod pallet {
315315
Slippage,
316316
/// The calculated collateral is zero.
317317
ZeroCollateral,
318+
/// A pool has to contain at least one bonded currency.
319+
ZeroBondedCurrency,
318320
}
319321

320322
#[pallet::call]
@@ -372,6 +374,7 @@ pub mod pallet {
372374
let checked_curve = curve.try_into().map_err(|_| Error::<T>::InvalidInput)?;
373375

374376
let currency_length = currencies.len();
377+
ensure!(!currency_length.is_zero(), Error::<T>::ZeroBondedCurrency);
375378

376379
let currency_ids = T::NextAssetIds::try_get(currency_length.saturated_into())
377380
.map_err(|e| e.into())

0 commit comments

Comments
 (0)