diff --git a/zrml/swaps/src/lib.rs b/zrml/swaps/src/lib.rs index 99c24987cf..c4f916b338 100644 --- a/zrml/swaps/src/lib.rs +++ b/zrml/swaps/src/lib.rs @@ -1554,6 +1554,7 @@ mod pallet { asset_amount: BalanceOf, min_pool_amount: BalanceOf, ) -> Result { + ensure!(asset_amount != Zero::zero(), Error::::MathApproximation); let pool = Pallet::::pool_by_id(pool_id)?; let pool_ref = &pool; let pool_account_id = Pallet::::pool_account_id(pool_id); diff --git a/zrml/swaps/src/tests.rs b/zrml/swaps/src/tests.rs index 37788b7903..c2644f9a6b 100644 --- a/zrml/swaps/src/tests.rs +++ b/zrml/swaps/src/tests.rs @@ -571,6 +571,18 @@ fn pool_amount_must_not_be_zero() { }); } +#[test] +fn asset_amount_must_not_be_zero() { + ExtBuilder::default().build().execute_with(|| { + create_initial_pool_with_funds_for_alice(ScoringRule::CPMM, true); + + assert_noop!( + Swaps::pool_join_with_exact_asset_amount(alice_signed(), 0, ASSET_A, 0, 0), + crate::Error::::MathApproximation + ); + }); +} + #[test] fn pool_exit_decreases_correct_pool_parameters() { ExtBuilder::default().build().execute_with(|| {