From e80ec1b13c3efcdd85d10e96ec073e00a2901558 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Fri, 9 Jul 2021 17:26:32 +0200 Subject: [PATCH 1/2] create pool if both amounts are greater than min_pool_liquidity --- pallets/xyk/src/lib.rs | 2 ++ pallets/xyk/src/tests.rs | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/pallets/xyk/src/lib.rs b/pallets/xyk/src/lib.rs index a195ab20cf5..0087959b8e8 100644 --- a/pallets/xyk/src/lib.rs +++ b/pallets/xyk/src/lib.rs @@ -240,6 +240,8 @@ pub mod pallet { .checked_mul_int(amount) .ok_or(Error::::CreatePoolAssetAmountInvalid)?; + ensure!(asset_b_amount >= MIN_POOL_LIQUIDITY, Error::::InsufficientLiquidity); + let shares_added = if asset_a < asset_b { amount } else { asset_b_amount }; ensure!( diff --git a/pallets/xyk/src/tests.rs b/pallets/xyk/src/tests.rs index dbf35c10e4d..955c0b4b80b 100644 --- a/pallets/xyk/src/tests.rs +++ b/pallets/xyk/src/tests.rs @@ -1128,6 +1128,11 @@ fn create_pool_with_insufficient_liquidity_should_not_work() { Error::::InsufficientLiquidity ); + assert_noop!( + XYK::create_pool(Origin::signed(ALICE), ACA, HDX, 5000, Price::from_float(0.1f64)), + Error::::InsufficientLiquidity + ); + assert_noop!( XYK::create_pool(Origin::signed(ALICE), ACA, HDX, 1000, Price::from(0)), Error::::ZeroInitialPrice From fb953220de7ba0b89b5595fbd059b57ea53049a9 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Fri, 9 Jul 2021 17:33:50 +0200 Subject: [PATCH 2/2] bump xyk and runtime version --- Cargo.lock | 4 ++-- pallets/xyk/Cargo.toml | 2 +- runtime/Cargo.toml | 2 +- runtime/src/lib.rs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c28eb44123e..a3be033618c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -511,7 +511,7 @@ dependencies = [ [[package]] name = "basilisk-runtime" -version = "10.0.0" +version = "11.0.0" dependencies = [ "cumulus-pallet-aura-ext", "cumulus-pallet-parachain-system", @@ -5888,7 +5888,7 @@ dependencies = [ [[package]] name = "pallet-xyk" -version = "1.2.0" +version = "1.3.0" dependencies = [ "frame-benchmarking", "frame-support", diff --git a/pallets/xyk/Cargo.toml b/pallets/xyk/Cargo.toml index e1ea85c353e..5876023ee1d 100644 --- a/pallets/xyk/Cargo.toml +++ b/pallets/xyk/Cargo.toml @@ -6,7 +6,7 @@ homepage = 'https://github.com/galacticcouncil/basilisk-node' license = 'Apache 2.0' name = 'pallet-xyk' repository = 'https://github.com/galacticcouncil/basilisk-node' -version = '1.2.0' +version = '1.3.0' [package.metadata.docs.rs] targets = ['x86_64-unknown-linux-gnu'] diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 7b70469b94d..d4d67164806 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -5,7 +5,7 @@ homepage = 'https://github.com/galacticcouncil/Basilisk-node' license = 'Apache 2.0' name = 'basilisk-runtime' repository = 'https://github.com/galacticcouncil/Basilisk-node' -version = '10.0.0' +version = '11.0.0' [package.metadata.docs.rs] targets = ['x86_64-unknown-linux-gnu'] diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 4a7fe00b4da..c84af28d52a 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -117,7 +117,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("basilisk"), impl_name: create_runtime_str!("basilisk"), authoring_version: 1, - spec_version: 10, + spec_version: 11, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1,