Skip to content

Commit

Permalink
Merge pull request #96 from galacticcouncil/fix/min_pool_liquidity
Browse files Browse the repository at this point in the history
fix(xyk): create_pool respects min liquidity limit
  • Loading branch information
jak-pan committed Jul 11, 2021
2 parents 7df2c39 + fb95322 commit e826631
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pallets/xyk/Cargo.toml
Expand Up @@ -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']
Expand Down
2 changes: 2 additions & 0 deletions pallets/xyk/src/lib.rs
Expand Up @@ -240,6 +240,8 @@ pub mod pallet {
.checked_mul_int(amount)
.ok_or(Error::<T>::CreatePoolAssetAmountInvalid)?;

ensure!(asset_b_amount >= MIN_POOL_LIQUIDITY, Error::<T>::InsufficientLiquidity);

let shares_added = if asset_a < asset_b { amount } else { asset_b_amount };

ensure!(
Expand Down
5 changes: 5 additions & 0 deletions pallets/xyk/src/tests.rs
Expand Up @@ -1128,6 +1128,11 @@ fn create_pool_with_insufficient_liquidity_should_not_work() {
Error::<Test>::InsufficientLiquidity
);

assert_noop!(
XYK::create_pool(Origin::signed(ALICE), ACA, HDX, 5000, Price::from_float(0.1f64)),
Error::<Test>::InsufficientLiquidity
);

assert_noop!(
XYK::create_pool(Origin::signed(ALICE), ACA, HDX, 1000, Price::from(0)),
Error::<Test>::ZeroInitialPrice
Expand Down
2 changes: 1 addition & 1 deletion runtime/Cargo.toml
Expand Up @@ -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']
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/lib.rs
Expand Up @@ -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,
Expand Down

0 comments on commit e826631

Please sign in to comment.