Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: registry traits consolidation #701

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
354768a
asset-registry: implemented new Registry traits
martinfridrich Nov 8, 2023
928b5e4
pallet-xyk: refactor to use new Registry traits
martinfridrich Nov 8, 2023
537e6f8
pallet-stableswap: refactor to use latest registry traits
martinfridrich Nov 9, 2023
a9e016f
pallet-bonds: refactor to use latest registry traits
martinfridrich Nov 9, 2023
e04940d
pallet-omnipool: refactor to use latest registry traits
martinfridrich Nov 9, 2023
c14a4e1
pallet-dca: refactor to use latest registry traits
martinfridrich Nov 9, 2023
b51cd6d
pallet-liquidity-minin: refactor to use latest registry traits
martinfridrich Nov 9, 2023
4280f1c
pallet-otc: refactor to use latest registry traits
martinfridrich Nov 9, 2023
a2f0f3f
pallet-omnipool-liquidity-mining: refactor to use latest registry traits
martinfridrich Nov 9, 2023
ff08f1d
fix integration-tests and missing AssetLocation to runtime configs
martinfridrich Nov 9, 2023
92b940f
refactor benchmarks to use use latest registry traits
martinfridrich Nov 10, 2023
85039ed
pallet-otc: fixed benchmarks
martinfridrich Nov 10, 2023
decf0a4
pallet-omnipool-liquidity-mining: fix benchmarks and make clippy happy
martinfridrich Nov 13, 2023
b4a19e3
traits: remove deprecated registry traits
martinfridrich Nov 13, 2023
3ddb972
traits: make location associated type of Inspect trait + update all n…
martinfridrich Nov 14, 2023
aa4b6a9
fix PR comments
martinfridrich Nov 14, 2023
bf2e99c
Merge branch 'feat/permissionless-asset-registry' into refactor/regis…
martinfridrich Nov 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions Cargo.lock

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

30 changes: 22 additions & 8 deletions integration-tests/src/bonds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::polkadot_test_net::*;
use frame_support::storage::with_transaction;
use frame_support::{assert_noop, assert_ok};
use frame_system::RawOrigin;
use hydradx_traits::CreateRegistry;
use hydradx_traits::registry::{AssetKind, Create};
use orml_traits::MultiCurrency;
use sp_runtime::{DispatchResult, TransactionOutcome};
use xcm_emulator::TestExt;
Expand Down Expand Up @@ -65,10 +65,15 @@ fn issue_bonds_should_work_when_issued_for_share_asset() {
let maturity = NOW + MONTH;

let name = b"SHARED".to_vec();
let share_asset_id = AssetRegistry::create_asset(
&name,
pallet_asset_registry::AssetType::PoolShare(HDX, DOT).into(),
1_000,
let share_asset_id = AssetRegistry::register_insufficient_asset(
None,
Some(&name),
AssetKind::XYK,
Some(1_000),
None,
None,
None,
None,
)
.unwrap();
assert_ok!(Currencies::deposit(share_asset_id, &ALICE.into(), amount,));
Expand Down Expand Up @@ -119,9 +124,18 @@ fn issue_bonds_should_not_work_when_issued_for_bond_asset() {
let maturity = NOW + MONTH;

let name = b"BOND".to_vec();
let underlying_asset_id =
AssetRegistry::create_asset(&name, pallet_asset_registry::AssetType::<AssetId>::Bond.into(), 1_000)
.unwrap();
let underlying_asset_id = AssetRegistry::register_insufficient_asset(
None,
Some(&name),
AssetKind::Bond,
Some(1_000),
None,
None,
None,
None,
)
.unwrap();

assert_ok!(Currencies::deposit(underlying_asset_id, &ALICE.into(), amount,));

// Act & Assert
Expand Down
22 changes: 14 additions & 8 deletions integration-tests/src/dca.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ use hydradx_runtime::{
AssetRegistry, Balances, Currencies, Omnipool, Router, Runtime, RuntimeEvent, RuntimeOrigin, Stableswap, Tokens,
Treasury, DCA,
};
use hydradx_traits::registry::{AssetKind, Create};
use hydradx_traits::router::{PoolType, Trade};
use hydradx_traits::{
registry::{AssetKind, Create},
Registry,
};
use orml_traits::MultiCurrency;
use orml_traits::MultiReservableCurrency;
use pallet_dca::types::{Order, Schedule};
Expand Down Expand Up @@ -2314,7 +2311,7 @@ pub fn init_stableswap() -> Result<(AssetId, AssetId, AssetId), DispatchError> {
None,
Some(name.as_ref()),
AssetKind::Token,
Some(1u128),
1u128,
Some(b"xDUM".as_ref()),
Some(18u8),
None,
Expand All @@ -2335,7 +2332,7 @@ pub fn init_stableswap() -> Result<(AssetId, AssetId, AssetId), DispatchError> {
None,
Some(b"pool".as_ref()),
AssetKind::Token,
Some(1u128),
1u128,
None,
None,
None,
Expand Down Expand Up @@ -2372,7 +2369,7 @@ pub fn init_stableswap_with_three_assets_having_different_decimals(
None,
Some(name.as_ref()),
AssetKind::Token,
Some(1u128),
1u128,
Some(b"xDUM".as_ref()),
Some(decimals_for_each_asset[idx as usize]),
None,
Expand All @@ -2395,7 +2392,16 @@ pub fn init_stableswap_with_three_assets_having_different_decimals(
initial.push(AssetAmount::new(asset_id, initial_liquidity));
added_liquidity.push(AssetAmount::new(asset_id, liquidity_added));
}
let pool_id = AssetRegistry::create_asset(&b"pool".to_vec(), 1u128)?;
let pool_id = AssetRegistry::register_insufficient_asset(
None,
Some(&b"pool".to_vec()),
AssetKind::Token,
Some(1u128),
None,
None,
None,
None,
)?;

let amplification = 100u16;
let fee = Permill::from_percent(1);
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2314,7 +2314,7 @@ pub fn init_stableswap() -> Result<(AssetId, AssetId, AssetId), DispatchError> {
None,
Some(name.as_ref()),
AssetKind::Token,
Some(1u128),
1u128,
Some(b"xDUM".as_ref()),
Some(18u8),
None,
Expand Down Expand Up @@ -2342,7 +2342,7 @@ pub fn init_stableswap() -> Result<(AssetId, AssetId, AssetId), DispatchError> {
None,
Some(b"pool".as_ref()),
AssetKind::Token,
Some(1u128),
1u128,
None,
None,
None,
Expand Down
2 changes: 1 addition & 1 deletion pallets/asset-registry/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ benchmarks! {
let _ = Pallet::<T>::register(RawOrigin::Root.into(), Some(asset_id), Some(name), AssetType::Token, Some(ed), Some(symbol), Some(decimals), Some(location), Some(xcm_rate_limit), is_sufficient);

let new_name= vec![98u8; T::StringLimit::get() as usize];
let new_type = AssetType::PoolShare(T::AssetId::from(10u8),T::AssetId::from(20u8));
let new_type = AssetType::XYK;
let new_ed = 1_000_000_u128;
let new_xcm_rate_limit = 1_000_u128;
let new_is_sufficient = false;
Expand Down
Loading
Loading