Skip to content

Commit

Permalink
rename disallow struct
Browse files Browse the repository at this point in the history
  • Loading branch information
enthusiastmartin committed Nov 23, 2021
1 parent ba3f0f1 commit cd2961f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions pallets/lbp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -997,9 +997,9 @@ impl<T: Config> AMM<T::AccountId, AssetId, AssetPair, BalanceOf<T>> for Pallet<T
}
}

pub struct DisallowLBPRunningPool<T>(sp_std::marker::PhantomData<T>);
pub struct DisallowWhenLBPPoolRunning<T>(sp_std::marker::PhantomData<T>);

impl<T: Config> CanCreatePool<AssetId> for DisallowLBPRunningPool<T> {
impl<T: Config> CanCreatePool<AssetId> for DisallowWhenLBPPoolRunning<T> {
fn can_create(asset_a: AssetId, asset_b: AssetId) -> bool {
let pool_id = Pallet::<T>::pair_account_from_assets(asset_a, asset_b);
let now = T::BlockNumberProvider::current_block_number();
Expand Down
12 changes: 6 additions & 6 deletions pallets/lbp/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2750,7 +2750,7 @@ fn can_create_should_work() {
new_test_ext().execute_with(|| {
let asset_pair = AssetPair{ asset_in: ACA, asset_out: DOT };
// pool doesn't exist
assert!(DisallowLBPRunningPool::<Test>::can_create(asset_pair.asset_in, asset_pair.asset_out));
assert!(DisallowWhenLBPPoolRunning::<Test>::can_create(asset_pair.asset_in, asset_pair.asset_out));

assert_ok!(LBPPallet::create_pool(
Origin::root(),
Expand All @@ -2766,7 +2766,7 @@ fn can_create_should_work() {
CHARLIE,
));
// pool is not initialized
assert!(!DisallowLBPRunningPool::<Test>::can_create(asset_pair.asset_in, asset_pair.asset_out));
assert!(!DisallowWhenLBPPoolRunning::<Test>::can_create(asset_pair.asset_in, asset_pair.asset_out));

assert_ok!(LBPPallet::update_pool_data(
Origin::signed(ALICE),
Expand All @@ -2780,18 +2780,18 @@ fn can_create_should_work() {
None
));
// pool is initialized but is not running
assert!(!DisallowLBPRunningPool::<Test>::can_create(asset_pair.asset_in, asset_pair.asset_out));
assert!(!DisallowWhenLBPPoolRunning::<Test>::can_create(asset_pair.asset_in, asset_pair.asset_out));

run_to_block::<Test>(15);
// pool is running
assert!(!DisallowLBPRunningPool::<Test>::can_create(asset_pair.asset_in, asset_pair.asset_out));
assert!(!DisallowWhenLBPPoolRunning::<Test>::can_create(asset_pair.asset_in, asset_pair.asset_out));

run_to_block::<Test>(30);
// sale ended
assert!(DisallowLBPRunningPool::<Test>::can_create(asset_pair.asset_in, asset_pair.asset_out));
assert!(DisallowWhenLBPPoolRunning::<Test>::can_create(asset_pair.asset_in, asset_pair.asset_out));

assert_ok!(LBPPallet::remove_liquidity(Origin::signed(ALICE), ACA_DOT_POOL_ID,));
// pool was destroyed
assert!(DisallowLBPRunningPool::<Test>::can_create(asset_pair.asset_in, asset_pair.asset_out));
assert!(DisallowWhenLBPPoolRunning::<Test>::can_create(asset_pair.asset_in, asset_pair.asset_out));
});
}
2 changes: 1 addition & 1 deletion runtime/basilisk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ impl pallet_xyk::Config for Runtime {
type MinPoolLiquidity = MinPoolLiquidity;
type MaxInRatio = MaxInRatio;
type MaxOutRatio = MaxOutRatio;
type CanCreatePool = pallet_lbp::DisallowLBPRunningPool<Runtime>;
type CanCreatePool = pallet_lbp::DisallowWhenLBPPoolRunning<Runtime>;
}

impl pallet_exchange::Config for Runtime {
Expand Down
2 changes: 1 addition & 1 deletion runtime/testing-basilisk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ impl pallet_xyk::Config for Runtime {
type MinPoolLiquidity = MinPoolLiquidity;
type MaxInRatio = MaxInRatio;
type MaxOutRatio = MaxOutRatio;
type CanCreatePool = pallet_lbp::DisallowLBPRunningPool<Runtime>;
type CanCreatePool = pallet_lbp::DisallowWhenLBPPoolRunning<Runtime>;
}

impl pallet_exchange::Config for Runtime {
Expand Down

0 comments on commit cd2961f

Please sign in to comment.