Skip to content

Commit

Permalink
Merge branch 'master' into dca_benchmarking
Browse files Browse the repository at this point in the history
  • Loading branch information
Roznovjak authored Oct 6, 2023
2 parents ca10249 + 725f1fc commit a8abb2b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
17 changes: 17 additions & 0 deletions integration-tests/src/call_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,23 @@ fn transfer_should_not_work_when_transfering_omnipool_assets_to_omnipool_account
});
}

#[test]
fn xyk_create_pool_with_lrna_should_be_filtered_by_call_filter() {
TestNet::reset();

Hydra::execute_with(|| {
// the values here don't need to make sense, all we need is a valid Call
let call = hydradx_runtime::RuntimeCall::XYK(pallet_xyk::Call::create_pool {
asset_a: LRNA,
amount_a: UNITS,
asset_b: DOT,
amount_b: UNITS,
});

assert!(!hydradx_runtime::CallFilter::contains(&call));
});
}

#[test]
fn calling_pallet_xcm_send_extrinsic_should_not_be_filtered_by_call_filter() {
TestNet::reset();
Expand Down
13 changes: 10 additions & 3 deletions runtime/hydradx/src/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@ impl Contains<RuntimeCall> for CallFilter {
return false;
}

let hub_asset_id = <Runtime as pallet_omnipool::Config>::HubAssetId::get();

// filter transfers of LRNA and omnipool assets to the omnipool account
if let RuntimeCall::Tokens(orml_tokens::Call::transfer { dest, currency_id, .. })
| RuntimeCall::Tokens(orml_tokens::Call::transfer_keep_alive { dest, currency_id, .. })
| RuntimeCall::Tokens(orml_tokens::Call::transfer_all { dest, currency_id, .. })
| RuntimeCall::Currencies(pallet_currencies::Call::transfer { dest, currency_id, .. }) = call
{
// Lookup::lookup() is not necessary thanks to IdentityLookup
if dest == &Omnipool::protocol_account()
&& (*currency_id == <Runtime as pallet_omnipool::Config>::HubAssetId::get()
|| Omnipool::exists(*currency_id))
if dest == &Omnipool::protocol_account() && (*currency_id == hub_asset_id || Omnipool::exists(*currency_id))
{
return false;
}
Expand All @@ -83,6 +83,13 @@ impl Contains<RuntimeCall> for CallFilter {
}
}

// XYK pools with LRNA are not allowed
if let RuntimeCall::XYK(pallet_xyk::Call::create_pool { asset_a, asset_b, .. }) = call {
if *asset_a == hub_asset_id || *asset_b == hub_asset_id {
return false;
}
}

match call {
RuntimeCall::PolkadotXcm(pallet_xcm::Call::send { .. }) => true,
RuntimeCall::PolkadotXcm(_) => false,
Expand Down

0 comments on commit a8abb2b

Please sign in to comment.