diff --git a/Cargo.lock b/Cargo.lock index f2a1440b0..09a5ab98c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3831,7 +3831,7 @@ dependencies = [ [[package]] name = "hydradx-runtime" -version = "186.0.0" +version = "187.0.0" dependencies = [ "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", @@ -6911,7 +6911,7 @@ dependencies = [ [[package]] name = "pallet-lbp" -version = "4.6.16" +version = "4.7.0" dependencies = [ "frame-benchmarking", "frame-support", @@ -6923,7 +6923,6 @@ dependencies = [ "orml-traits", "parity-scale-codec", "primitive-types", - "primitives", "proptest", "rug", "scale-info", @@ -7779,7 +7778,7 @@ dependencies = [ [[package]] name = "pallet-xyk" -version = "6.3.0" +version = "6.3.1" dependencies = [ "frame-benchmarking", "frame-support", @@ -7794,7 +7793,6 @@ dependencies = [ "pallet-asset-registry", "parity-scale-codec", "primitive-types", - "primitives", "proptest", "scale-info", "serde", @@ -9467,7 +9465,7 @@ dependencies = [ [[package]] name = "primitives" -version = "5.8.5" +version = "6.0.0" dependencies = [ "frame-support", "hex-literal 0.3.4", @@ -10220,7 +10218,7 @@ dependencies = [ [[package]] name = "runtime-integration-tests" -version = "1.15.0" +version = "1.15.1" dependencies = [ "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index 663d811ec..4bdac3b87 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "runtime-integration-tests" -version = "1.15.0" +version = "1.15.1" description = "Integration tests" authors = ["GalacticCouncil"] edition = "2021" diff --git a/integration-tests/src/omnipool_init.rs b/integration-tests/src/omnipool_init.rs index da18be5c8..a363f4107 100644 --- a/integration-tests/src/omnipool_init.rs +++ b/integration-tests/src/omnipool_init.rs @@ -296,7 +296,6 @@ fn removing_token_should_work_when_no_shares_remaining() { position.shares, )); - let state = pallet_omnipool::Pallet::::load_asset_state(DOT).unwrap(); let dot_balance = hydradx_runtime::Tokens::free_balance(DOT, &bob_account); assert!(dot_balance <= dot_amount); let lrna_balance = hydradx_runtime::Tokens::free_balance(LRNA, &bob_account); diff --git a/integration-tests/src/router.rs b/integration-tests/src/router.rs index e46cd5d37..2fb234ee2 100644 --- a/integration-tests/src/router.rs +++ b/integration-tests/src/router.rs @@ -21,7 +21,6 @@ use pallet_omnipool::traits::OmnipoolHooks; use pallet_omnipool::weights::WeightInfo as OmnipoolWeights; use pallet_route_executor::AmmTradeWeights; -use primitives::asset::AssetPair; use primitives::AssetId; use frame_support::{assert_noop, assert_ok}; @@ -2237,7 +2236,7 @@ fn create_lbp_pool(accumulated_asset: u32, distributed_asset: u32) { } fn get_lbp_pair_account_id(asset_a: AssetId, asset_b: AssetId) -> AccountId { - let asset_pair = AssetPair { + let asset_pair = pallet_lbp::AssetPair { asset_in: asset_a, asset_out: asset_b, }; diff --git a/pallets/lbp/Cargo.toml b/pallets/lbp/Cargo.toml index 72c7b5861..61d072fc9 100644 --- a/pallets/lbp/Cargo.toml +++ b/pallets/lbp/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-lbp" -version = "4.6.16" +version = "4.7.0" description = "HydraDX Liquidity Bootstrapping Pool Pallet" authors = ["GalacticCouncil"] edition = "2021" @@ -23,7 +23,6 @@ serde = { features = ["derive"], optional = true, version = "1.0.136" } ## Local dependencies hydra-dx-math = { workspace = true } hydradx-traits = { workspace = true } -primitives = { workspace = true } ## ORML dependencies orml-traits = { workspace = true } @@ -63,7 +62,6 @@ std = [ "sp-runtime/std", "sp-core/std", "sp-std/std", - "primitives/std", "hydradx-traits/std", "scale-info/std", "hydra-dx-math/std", diff --git a/pallets/lbp/src/benchmarking.rs b/pallets/lbp/src/benchmarking.rs index e9bba5295..f00406ede 100644 --- a/pallets/lbp/src/benchmarking.rs +++ b/pallets/lbp/src/benchmarking.rs @@ -20,7 +20,6 @@ use super::*; use crate::Pallet as LBP; use hydradx_traits::router::{PoolType, TradeExecution}; -use primitives::AssetId; use frame_benchmarking::{account, benchmarks}; use frame_system::RawOrigin; diff --git a/pallets/lbp/src/lib.rs b/pallets/lbp/src/lib.rs index 01a551dc5..9e18755c4 100644 --- a/pallets/lbp/src/lib.rs +++ b/pallets/lbp/src/lib.rs @@ -21,6 +21,7 @@ #![allow(clippy::type_complexity)] #![allow(clippy::too_many_arguments)] +pub use crate::types::{Amount, AssetId, AssetPair, Balance}; use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::sp_runtime::{ traits::{AtLeast32BitUnsigned, BlockNumberProvider, Saturating, Zero}, @@ -36,7 +37,6 @@ use frame_system::ensure_signed; use hydra_dx_math::types::LBPWeight; use hydradx_traits::{AMMTransfer, AssetPairAccountIdFor, CanCreatePool, LockedBalance, AMM}; use orml_traits::{MultiCurrency, MultiCurrencyExtended, MultiLockableCurrency}; -use primitives::{asset::AssetPair, Amount, AssetId, Balance}; use scale_info::TypeInfo; @@ -58,7 +58,9 @@ pub mod weights; #[cfg(test)] mod invariants; + mod trade_execution; +pub mod types; use weights::WeightInfo; // Re-export pallet items so that they can be accessed from the crate namespace. diff --git a/pallets/lbp/src/mock.rs b/pallets/lbp/src/mock.rs index 6f247e052..97d27507e 100644 --- a/pallets/lbp/src/mock.rs +++ b/pallets/lbp/src/mock.rs @@ -2,12 +2,14 @@ use super::*; use crate as lbp; -use crate::{AssetPairAccountIdFor, Config}; +use crate::{ + types::{AssetId, AssetPair, Balance}, + AssetPairAccountIdFor, Config, +}; use frame_support::parameter_types; use frame_support::traits::{Everything, GenesisBuild, LockIdentifier, Nothing}; use hydradx_traits::LockedBalance; use orml_traits::parameter_type_with_key; -use primitives::constants::chain::{AssetId, Balance, CORE_ASSET_ID}; use sp_core::H256; use sp_runtime::{ testing::Header, @@ -28,7 +30,7 @@ pub const ALICE: AccountId = 1; pub const BOB: AccountId = 2; pub const CHARLIE: AccountId = 3; -pub const HDX: AssetId = CORE_ASSET_ID; +pub const HDX: AssetId = 0; pub const KUSD: AssetId = 2_000; pub const BSX: AssetId = 3_000; pub const ETH: AssetId = 4_000; @@ -151,7 +153,7 @@ impl AssetPairAccountIdFor for AssetPairAccountIdTest { } parameter_types! { - pub const NativeAssetId: AssetId = CORE_ASSET_ID; + pub const NativeAssetId: AssetId = HDX; pub const MinTradingLimit: Balance = 1_000; pub const MinPoolLiquidity: Balance = 1_000; pub const MaxInRatio: u128 = 3; diff --git a/pallets/lbp/src/tests.rs b/pallets/lbp/src/tests.rs index 2ea4b6ee4..c77bfbc9e 100644 --- a/pallets/lbp/src/tests.rs +++ b/pallets/lbp/src/tests.rs @@ -31,9 +31,6 @@ use hydradx_traits::{AMMTransfer, LockedBalance}; use sp_runtime::traits::BadOrigin; use sp_std::convert::TryInto; -use primitives::asset::AssetPair; -use primitives::constants::chain::CORE_ASSET_ID; - pub fn new_test_ext() -> sp_io::TestExternalities { let mut ext = ExtBuilder::default().build(); ext.execute_with(|| set_block_number::(1)); @@ -2317,12 +2314,12 @@ fn buy_should_work() { .into(), frame_system::Event::NewAccount { account: pool_id2 }.into(), mock::RuntimeEvent::Currency(orml_tokens::Event::Endowed { - currency_id: CORE_ASSET_ID, + currency_id: HDX, who: HDX_BSX_POOL_ID, amount: 1000000000, }), mock::RuntimeEvent::Currency(orml_tokens::Event::Transfer { - currency_id: CORE_ASSET_ID, + currency_id: HDX, from: ALICE, to: HDX_BSX_POOL_ID, amount: 1000000000, @@ -2544,12 +2541,12 @@ fn sell_should_work() { .into(), frame_system::Event::NewAccount { account: pool_id2 }.into(), mock::RuntimeEvent::Currency(orml_tokens::Event::Endowed { - currency_id: CORE_ASSET_ID, + currency_id: HDX, who: HDX_BSX_POOL_ID, amount: 1000000000, }), mock::RuntimeEvent::Currency(orml_tokens::Event::Transfer { - currency_id: CORE_ASSET_ID, + currency_id: HDX, from: ALICE, to: HDX_BSX_POOL_ID, amount: 1000000000, diff --git a/pallets/lbp/src/trade_execution.rs b/pallets/lbp/src/trade_execution.rs index 3a0bc1c07..1acaf276d 100644 --- a/pallets/lbp/src/trade_execution.rs +++ b/pallets/lbp/src/trade_execution.rs @@ -1,9 +1,7 @@ -use crate::{Config, Error, Pallet, PoolData}; +use crate::*; use hydradx_traits::router::{ExecutorError, PoolType, TradeExecution}; use hydradx_traits::AMM; use orml_traits::MultiCurrency; -use primitives::asset::AssetPair; -use primitives::{AssetId, Balance}; use sp_runtime::traits::BlockNumberProvider; use sp_runtime::DispatchError; diff --git a/primitives/src/asset.rs b/pallets/lbp/src/types.rs similarity index 94% rename from primitives/src/asset.rs rename to pallets/lbp/src/types.rs index 534be4e0c..63c51add9 100644 --- a/primitives/src/asset.rs +++ b/pallets/lbp/src/types.rs @@ -1,4 +1,4 @@ -// This file is part of Basilisk-node. +// This file is part of HydraDX-node. // Copyright (C) 2020-2022 Intergalactic, Limited (GIB). // SPDX-License-Identifier: Apache-2.0 @@ -15,13 +15,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::AssetId; +pub type AssetId = u32; +pub type Amount = i128; +pub type Balance = u128; use codec::{Decode, Encode}; - -use sp_std::vec::Vec; - use scale_info::TypeInfo; +use sp_std::vec::Vec; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; @@ -42,6 +42,7 @@ impl AssetPair { pub fn new(asset_in: AssetId, asset_out: AssetId) -> Self { Self { asset_in, asset_out } } + /// Return ordered asset tuple (A,B) where A < B /// Used in storage pub fn ordered_pair(&self) -> (AssetId, AssetId) { diff --git a/pallets/xyk/Cargo.toml b/pallets/xyk/Cargo.toml index 0bb2fac5d..f9a07717a 100644 --- a/pallets/xyk/Cargo.toml +++ b/pallets/xyk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = 'pallet-xyk' -version = "6.3.0" +version = "6.3.1" description = 'XYK automated market maker' authors = ['GalacticCouncil'] edition = '2021' @@ -23,9 +23,6 @@ log = { version = "0.4.17", default-features = false } hydra-dx-math = { workspace = true } -# Local dependencies -primitives = {path = '../../primitives', default-features = false} - # ORML dependencies orml-tokens = { workspace = true } orml-traits = { workspace = true } @@ -65,7 +62,6 @@ std = [ 'sp-core/std', 'sp-std/std', 'orml-traits/std', - 'primitives/std', "hydradx-traits/std", 'orml-tokens/std', 'frame-benchmarking/std', diff --git a/pallets/xyk/src/benchmarking.rs b/pallets/xyk/src/benchmarking.rs index 6b6acc765..f8835aa7e 100644 --- a/pallets/xyk/src/benchmarking.rs +++ b/pallets/xyk/src/benchmarking.rs @@ -25,8 +25,8 @@ use sp_std::prelude::*; use crate::Pallet as XYK; +use crate::types::{AssetId, Balance}; use hydradx_traits::router::{PoolType, TradeExecution}; -use primitives::{AssetId, Balance}; const SEED: u32 = 1; diff --git a/pallets/xyk/src/lib.rs b/pallets/xyk/src/lib.rs index a53812719..69979508f 100644 --- a/pallets/xyk/src/lib.rs +++ b/pallets/xyk/src/lib.rs @@ -37,10 +37,9 @@ use hydradx_traits::{ }; use sp_std::{vec, vec::Vec}; -use crate::types::{AssetId, AssetPair, Balance}; +use crate::types::{Amount, AssetId, AssetPair, Balance}; use hydra_dx_math::ratio::Ratio; use orml_traits::{MultiCurrency, MultiCurrencyExtended}; -use primitives::Amount; #[cfg(test)] mod tests; diff --git a/pallets/xyk/src/types.rs b/pallets/xyk/src/types.rs index acae283c6..ce20f6aa3 100644 --- a/pallets/xyk/src/types.rs +++ b/pallets/xyk/src/types.rs @@ -16,6 +16,7 @@ // limitations under the License. pub type AssetId = u32; +pub type Amount = i128; pub type Balance = u128; pub type Price = FixedU128; diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml index d775fc942..4cbb432c3 100644 --- a/primitives/Cargo.toml +++ b/primitives/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "primitives" -version = "5.8.5" +version = "6.0.0" authors = ["GalacticCouncil"] edition = "2021" repository = "https://github.com/galacticcouncil/HydraDX-node" diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index a165cbbd8..9fe493c72 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -27,7 +27,6 @@ use frame_support::sp_runtime::{ MultiSignature, }; -pub mod asset; pub mod constants; /// An index to a block. diff --git a/runtime/hydradx/Cargo.toml b/runtime/hydradx/Cargo.toml index b072057df..cb89eaa34 100644 --- a/runtime/hydradx/Cargo.toml +++ b/runtime/hydradx/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hydradx-runtime" -version = "186.0.0" +version = "187.0.0" authors = ["GalacticCouncil"] edition = "2021" license = "Apache 2.0" diff --git a/runtime/hydradx/src/lib.rs b/runtime/hydradx/src/lib.rs index 3c651f43a..9367396d9 100644 --- a/runtime/hydradx/src/lib.rs +++ b/runtime/hydradx/src/lib.rs @@ -94,7 +94,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("hydradx"), impl_name: create_runtime_str!("hydradx"), authoring_version: 1, - spec_version: 186, + spec_version: 187, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1,