From 6cfc1cd34201227be6ad5117ddd73ea5aba00e6c Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Fri, 20 Sep 2024 14:41:49 +0200 Subject: [PATCH 001/142] initial implementation --- Cargo.lock | 36 +- Cargo.toml | 2 + pallets/lbp/Cargo.toml | 6 +- pallets/lbp/src/lib.rs | 56 ++- pallets/lbp/src/mock.rs | 5 + pallets/lbp/src/trade_execution.rs | 20 +- pallets/omnipool/Cargo.toml | 16 +- pallets/omnipool/src/lib.rs | 451 +++++++++++++--------- pallets/omnipool/src/router_execution.rs | 6 +- pallets/omnipool/src/tests/mock.rs | 5 + pallets/otc/Cargo.toml | 12 +- pallets/otc/src/lib.rs | 42 +- pallets/otc/src/tests/mock.rs | 5 + pallets/route-executor/Cargo.toml | 12 +- pallets/route-executor/src/lib.rs | 7 + pallets/stableswap/Cargo.toml | 10 +- pallets/stableswap/src/lib.rs | 152 +++++--- pallets/stableswap/src/tests/mock.rs | 5 + pallets/stableswap/src/trade_execution.rs | 7 +- pallets/trade-event/Cargo.toml | 37 ++ pallets/trade-event/README.md | 3 + pallets/trade-event/src/lib.rs | 111 ++++++ pallets/xyk-liquidity-mining/src/lib.rs | 2 +- pallets/xyk/Cargo.toml | 4 +- pallets/xyk/src/lib.rs | 53 ++- pallets/xyk/src/tests/mock.rs | 5 + pallets/xyk/src/trade_execution.rs | 19 +- primitives/src/lib.rs | 3 + runtime/hydradx/Cargo.toml | 5 +- runtime/hydradx/src/assets.rs | 13 + runtime/hydradx/src/lib.rs | 3 +- traits/src/lib.rs | 18 +- traits/src/router.rs | 19 +- 33 files changed, 845 insertions(+), 305 deletions(-) create mode 100644 pallets/trade-event/Cargo.toml create mode 100644 pallets/trade-event/README.md create mode 100644 pallets/trade-event/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index d9baf8680..f69edad15 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4938,7 +4938,7 @@ dependencies = [ [[package]] name = "hydradx-runtime" -version = "256.0.0" +version = "257.0.0" dependencies = [ "cumulus-pallet-aura-ext", "cumulus-pallet-parachain-system", @@ -5028,6 +5028,7 @@ dependencies = [ "pallet-state-trie-migration", "pallet-timestamp", "pallet-tips", + "pallet-trade-event", "pallet-transaction-multi-payment", "pallet-transaction-pause", "pallet-transaction-payment", @@ -8444,7 +8445,7 @@ dependencies = [ [[package]] name = "pallet-lbp" -version = "4.8.4" +version = "4.9.0" dependencies = [ "frame-benchmarking", "frame-support", @@ -8453,6 +8454,7 @@ dependencies = [ "hydradx-traits", "orml-tokens", "orml-traits", + "pallet-trade-event", "parity-scale-codec", "primitive-types", "proptest", @@ -8692,7 +8694,7 @@ dependencies = [ [[package]] name = "pallet-omnipool" -version = "4.3.2" +version = "4.4.0" dependencies = [ "bitflags 1.3.2", "frame-benchmarking", @@ -8705,6 +8707,7 @@ dependencies = [ "orml-tokens", "orml-traits", "pallet-balances", + "pallet-trade-event", "parity-scale-codec", "pretty_assertions", "primitive-types", @@ -8746,7 +8749,7 @@ dependencies = [ [[package]] name = "pallet-otc" -version = "2.0.1" +version = "2.1.0" dependencies = [ "frame-benchmarking", "frame-support", @@ -8754,6 +8757,7 @@ dependencies = [ "hydradx-traits", "orml-tokens", "orml-traits", + "pallet-trade-event", "parity-scale-codec", "pretty_assertions", "proptest", @@ -8936,7 +8940,7 @@ dependencies = [ [[package]] name = "pallet-route-executor" -version = "2.6.0" +version = "2.7.0" dependencies = [ "frame-benchmarking", "frame-support", @@ -8948,8 +8952,10 @@ dependencies = [ "orml-traits", "pallet-balances", "pallet-currencies", + "pallet-trade-event", "parity-scale-codec", "pretty_assertions", + "primitives", "scale-info", "serde", "sp-core", @@ -9036,7 +9042,7 @@ dependencies = [ [[package]] name = "pallet-stableswap" -version = "3.6.4" +version = "3.7.0" dependencies = [ "bitflags 1.3.2", "frame-benchmarking", @@ -9046,6 +9052,7 @@ dependencies = [ "hydradx-traits", "orml-tokens", "orml-traits", + "pallet-trade-event", "parity-scale-codec", "proptest", "scale-info", @@ -9208,6 +9215,20 @@ dependencies = [ "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", ] +[[package]] +name = "pallet-trade-event" +version = "1.0.0" +dependencies = [ + "frame-support", + "frame-system", + "hydradx-traits", + "parity-scale-codec", + "primitives", + "scale-info", + "sp-api", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", +] + [[package]] name = "pallet-transaction-multi-payment" version = "10.0.4" @@ -9424,7 +9445,7 @@ dependencies = [ [[package]] name = "pallet-xyk" -version = "6.4.4" +version = "6.5.0" dependencies = [ "frame-benchmarking", "frame-support", @@ -9435,6 +9456,7 @@ dependencies = [ "orml-tokens", "orml-traits", "pallet-asset-registry", + "pallet-trade-event", "parity-scale-codec", "primitive-types", "proptest", diff --git a/Cargo.toml b/Cargo.toml index f2af9f50e..5c064f8fc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,6 +41,7 @@ members = [ 'pallets/evm-accounts', 'pallets/dynamic-evm-fee', 'pallets/xyk-liquidity-mining', + 'pallets/trade-event', 'precompiles/call-permit', 'runtime-mock' ] @@ -104,6 +105,7 @@ pallet-xyk-liquidity-mining = { path = "pallets/xyk-liquidity-mining", default-f pallet-referrals = { path = "pallets/referrals", default-features = false} pallet-evm-accounts = { path = "pallets/evm-accounts", default-features = false} pallet-evm-accounts-rpc-runtime-api = { path = "pallets/evm-accounts/rpc/runtime-api", default-features = false} +pallet-trade-event = { path = "pallets/trade-event", default-features = false} hydra-dx-build-script-utils = { path = "utils/build-script-utils", default-features = false } scraper = { path = "scraper", default-features = false } diff --git a/pallets/lbp/Cargo.toml b/pallets/lbp/Cargo.toml index 14263533f..3db919325 100644 --- a/pallets/lbp/Cargo.toml +++ b/pallets/lbp/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-lbp" -version = "4.8.4" +version = "4.9.0" description = "HydraDX Liquidity Bootstrapping Pool Pallet" authors = ["GalacticCouncil"] edition = "2021" @@ -20,9 +20,10 @@ scale-info = { version = "2.3.1", default-features = false, features = ["derive" primitive-types = { default-features = false, version = "0.12.0" } serde = { features = ["derive"], optional = true, version = "1.0.136" } -## Local dependencies +# HydraDX dependencies hydra-dx-math = { workspace = true } hydradx-traits = { workspace = true } +pallet-trade-event = { workspace = true } ## ORML dependencies orml-traits = { workspace = true } @@ -66,5 +67,6 @@ std = [ 'frame-benchmarking/std', "scale-info/std", "hydra-dx-math/std", + "pallet-trade-event/std", ] try-runtime = ["frame-support/try-runtime"] diff --git a/pallets/lbp/src/lib.rs b/pallets/lbp/src/lib.rs index 96e159c53..84fdb1e83 100644 --- a/pallets/lbp/src/lib.rs +++ b/pallets/lbp/src/lib.rs @@ -37,6 +37,7 @@ use frame_system::ensure_signed; use frame_system::pallet_prelude::BlockNumberFor; use hydra_dx_math::types::LBPWeight; use hydradx_traits::{AMMTransfer, AssetPairAccountIdFor, CanCreatePool, LockedBalance, AMM}; +use pallet_trade_event::IncrementalIdType; use orml_traits::{MultiCurrency, MultiCurrencyExtended, MultiLockableCurrency}; use scale_info::TypeInfo; @@ -183,7 +184,7 @@ pub mod pallet { pub struct Pallet(_); #[pallet::config] - pub trait Config: frame_system::Config { + pub trait Config: frame_system::Config + pallet_trade_event::Config { type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Multi currency for transfer of currencies @@ -341,6 +342,7 @@ pub mod pallet { }, /// Sale executed. + /// Deprecated. Replaced by pallet_trade_event::Swapped SellExecuted { who: T::AccountId, asset_in: AssetId, @@ -352,6 +354,7 @@ pub mod pallet { }, /// Purchase executed. + /// Deprecated. Replaced by pallet_trade_event::Swapped BuyExecuted { who: T::AccountId, asset_out: AssetId, @@ -717,7 +720,7 @@ pub mod pallet { /// - `amount`: The amount of `asset_in` /// - `max_limit`: minimum amount of `asset_out` / amount of asset_out to be obtained from the pool in exchange for `asset_in`. /// - /// Emits `SellExecuted` when successful. + /// Emits `pallet_trade_event::Swapped` when successful. #[pallet::call_index(4)] #[pallet::weight(::WeightInfo::sell())] pub fn sell( @@ -729,7 +732,14 @@ pub mod pallet { ) -> DispatchResult { let who = ensure_signed(origin)?; - >::sell(&who, AssetPair { asset_in, asset_out }, amount, max_limit, false)?; + >::sell( + &who, + AssetPair { asset_in, asset_out }, + amount, + max_limit, + false, + None, + )?; Ok(()) } @@ -747,7 +757,7 @@ pub mod pallet { /// - `amount`: The amount of `asset_out`. /// - `max_limit`: maximum amount of `asset_in` to be sold in exchange for `asset_out`. /// - /// Emits `BuyExecuted` when successful. + /// Emits `pallet_trade_event::Swapped` when successful. #[pallet::call_index(5)] #[pallet::weight(::WeightInfo::buy())] pub fn buy( @@ -759,7 +769,7 @@ pub mod pallet { ) -> DispatchResult { let who = ensure_signed(origin)?; - >::buy(&who, AssetPair { asset_in, asset_out }, amount, max_limit, false)?; + >::buy(&who, AssetPair { asset_in, asset_out }, amount, max_limit, false)?; Ok(()) } @@ -930,7 +940,9 @@ impl Pallet { } } -impl AMM> for Pallet { +impl AMM, IncrementalIdType> + for Pallet +{ fn exists(assets: AssetPair) -> bool { let pair_account = Self::pair_account_from_assets(assets.asset_in, assets.asset_out); >::contains_key(&pair_account) @@ -1098,9 +1110,13 @@ impl AMM> for Pallet) -> DispatchResult { + fn execute_sell( + transfer: &AMMTransfer, + batch_id: Option, + ) -> DispatchResult { Self::execute_trade(transfer)?; + // TODO: Deprecated, remove when ready Self::deposit_event(Event::::SellExecuted { who: transfer.origin.clone(), asset_in: transfer.assets.asset_in, @@ -1111,6 +1127,18 @@ impl AMM> for Pallet::deposit_trade_event( + transfer.origin.clone(), + pallet_trade_event::PoolType::LBP, + pallet_trade_event::TradeOperation::Sell, + transfer.assets.asset_in, + transfer.assets.asset_out, + transfer.amount, + transfer.amount_b, + vec![transfer.fee], + batch_id, + ); + Ok(()) } @@ -1235,6 +1263,7 @@ impl AMM> for Pallet>) -> DispatchResult { Self::execute_trade(transfer)?; + // TODO: Deprecated, remove when ready Self::deposit_event(Event::::BuyExecuted { who: transfer.origin.clone(), asset_out: transfer.assets.asset_out, @@ -1244,6 +1273,19 @@ impl AMM> for Pallet::deposit_trade_event( + transfer.origin.clone(), + pallet_trade_event::PoolType::LBP, + pallet_trade_event::TradeOperation::Buy, + transfer.assets.asset_in, + transfer.assets.asset_out, + transfer.amount, + transfer.amount_b, + vec![transfer.fee], + None, + ); + Ok(()) } diff --git a/pallets/lbp/src/mock.rs b/pallets/lbp/src/mock.rs index c685d6dc8..6eb4f8cd6 100644 --- a/pallets/lbp/src/mock.rs +++ b/pallets/lbp/src/mock.rs @@ -75,6 +75,7 @@ frame_support::construct_runtime!( System: frame_system, LBPPallet: lbp, Currency: orml_tokens, + TradeEvent: pallet_trade_event, } ); @@ -170,6 +171,10 @@ impl LockedBalance for MultiLockedBalance { } } +impl pallet_trade_event::Config for Test { + type RuntimeEvent = RuntimeEvent; +} + impl Config for Test { type RuntimeEvent = RuntimeEvent; type MultiCurrency = Currency; diff --git a/pallets/lbp/src/trade_execution.rs b/pallets/lbp/src/trade_execution.rs index 0846640cb..50ae89e48 100644 --- a/pallets/lbp/src/trade_execution.rs +++ b/pallets/lbp/src/trade_execution.rs @@ -2,10 +2,12 @@ use crate::*; use hydradx_traits::router::{ExecutorError, PoolType, TradeExecution}; use hydradx_traits::AMM; use orml_traits::MultiCurrency; +use pallet_trade_event::IncrementalIdType; use sp_runtime::traits::BlockNumberProvider; use sp_runtime::DispatchError::Corruption; use sp_runtime::{ArithmeticError, DispatchError, FixedPointNumber, FixedU128}; -impl TradeExecution for Pallet { + +impl TradeExecution for Pallet { type Error = DispatchError; fn calculate_sell( @@ -110,12 +112,26 @@ impl TradeExecution asset_out: AssetId, amount_in: Balance, min_limit: Balance, + batch_id: Option, ) -> Result<(), ExecutorError> { if pool_type != PoolType::LBP { return Err(ExecutorError::NotSupported); } - Self::sell(who, asset_in, asset_out, amount_in, min_limit).map_err(ExecutorError::Error) + let who = crate::ensure_signed(who).map_err(|e| ExecutorError::Error(e.into()))?; + + >::sell( + &who, + AssetPair { asset_in, asset_out }, + amount_in, + min_limit, + false, + batch_id, + ) + .map_err(ExecutorError::Error)?; + + Ok(()) + // Self::sell(who, asset_in, asset_out, amount_in, min_limit).map_err(ExecutorError::Error) } fn execute_buy( diff --git a/pallets/omnipool/Cargo.toml b/pallets/omnipool/Cargo.toml index ec37db74f..d960a91b2 100644 --- a/pallets/omnipool/Cargo.toml +++ b/pallets/omnipool/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-omnipool" -version = "4.3.2" +version = "4.4.0" authors = ['GalacticCouncil'] edition = "2021" license = "Apache-2.0" @@ -17,6 +17,11 @@ targets = ["x86_64-unknown-linux-gnu"] scale-info = { version = "2.3.1", default-features = false, features = ["derive"] } codec = { default-features = false, features = ["derive"], package = "parity-scale-codec", version = "3.4.0" } +# HydraDX dependencies +hydradx-traits = { workspace = true } +hydra-dx-math = { workspace = true } +pallet-trade-event = { workspace = true } + # primitives sp-runtime = { workspace = true } sp-std = { workspace = true } @@ -28,11 +33,6 @@ frame-system = { workspace = true } # ORML orml-traits = { workspace = true } -# Warehouse -hydradx-traits = { workspace = true } - -hydra-dx-math = { workspace = true } - # third party primitive-types = { version = "0.12.0", default-features = false } bitflags = "1.3.2" @@ -69,6 +69,10 @@ std = [ "pallet-balances/std", "orml-tokens/std", "frame-benchmarking/std", + "pallet-trade-event/std", + 'hydradx-traits/std', + 'hydra-dx-math/std', + 'orml-traits/std', ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/pallets/omnipool/src/lib.rs b/pallets/omnipool/src/lib.rs index 245e458dc..71ca34111 100644 --- a/pallets/omnipool/src/lib.rs +++ b/pallets/omnipool/src/lib.rs @@ -114,6 +114,7 @@ pub mod weights; use crate::traits::{AssetInfo, OmnipoolHooks}; use crate::types::{AssetReserveState, AssetState, Balance, Position, SimpleImbalance, Tradability}; pub use pallet::*; +use pallet_trade_event::IncrementalIdType; pub use weights::WeightInfo; /// NFT class id type of provided nft implementation @@ -138,7 +139,7 @@ pub mod pallet { pub struct Pallet(_); #[pallet::config] - pub trait Config: frame_system::Config { + pub trait Config: frame_system::Config + pallet_trade_event::Config { /// The overarching event type. type RuntimeEvent: From> + IsType<::RuntimeEvent>; @@ -151,7 +152,8 @@ pub mod pallet { + HasCompact + MaybeSerializeDeserialize + MaxEncodedLen - + TypeInfo; + + TypeInfo + + Into; /// Multi currency mechanism type Currency: MultiCurrency; @@ -301,6 +303,7 @@ pub mod pallet { shares_removed: Balance, }, /// Sell trade executed. + /// Deprecated. Replaced by pallet_trade_event::Swapped SellExecuted { who: T::AccountId, asset_in: T::AssetId, @@ -313,6 +316,7 @@ pub mod pallet { protocol_fee_amount: Balance, }, /// Buy trade executed. + /// Deprecated. Replaced by pallet_trade_event::Swapped BuyExecuted { who: T::AccountId, asset_in: T::AssetId, @@ -359,6 +363,12 @@ pub mod pallet { /// Asset's weight cap has been updated. AssetWeightCapUpdated { asset_id: T::AssetId, cap: Permill }, + + /// Amount of the Hub asset has been updated. + HubAmountUpdated { + hub_amount_in: Balance, + hub_amount_out: Balance, + }, } #[pallet::error] @@ -1016,7 +1026,7 @@ pub mod pallet { /// - `amount`: Amount of asset sold /// - `min_buy_amount`: Minimum amount required to receive /// - /// Emits `SellExecuted` event when successful. + /// Emits `pallet_trade_event::Swapped` event when successful. /// #[pallet::call_index(5)] #[pallet::weight(::WeightInfo::sell() @@ -1031,185 +1041,7 @@ pub mod pallet { amount: Balance, min_buy_amount: Balance, ) -> DispatchResult { - let who = ensure_signed(origin.clone())?; - - ensure!(asset_in != asset_out, Error::::SameAssetTradeNotAllowed); - - ensure!( - amount >= T::MinimumTradingLimit::get(), - Error::::InsufficientTradingAmount - ); - - ensure!( - T::Currency::ensure_can_withdraw(asset_in, &who, amount).is_ok(), - Error::::InsufficientBalance - ); - - // Special handling when one of the asset is Hub Asset - // Math is simplified and asset_in is actually part of asset_out state in this case - if asset_in == T::HubAssetId::get() { - return Self::sell_hub_asset(origin, &who, asset_out, amount, min_buy_amount); - } - - if asset_out == T::HubAssetId::get() { - return Self::sell_asset_for_hub_asset(&who, asset_in, amount, min_buy_amount); - } - - let asset_in_state = Self::load_asset_state(asset_in)?; - let asset_out_state = Self::load_asset_state(asset_out)?; - - ensure!( - Self::allow_assets(&asset_in_state, &asset_out_state), - Error::::NotAllowed - ); - - ensure!( - amount - <= asset_in_state - .reserve - .checked_div(T::MaxInRatio::get()) - .ok_or(ArithmeticError::DivisionByZero)?, // Note: this can only fail if MaxInRatio is zero. - Error::::MaxInRatioExceeded - ); - - let current_imbalance = >::get(); - - let (asset_fee, _) = T::Fee::get(&asset_out); - let (_, protocol_fee) = T::Fee::get(&asset_in); - - let state_changes = hydra_dx_math::omnipool::calculate_sell_state_changes( - &(&asset_in_state).into(), - &(&asset_out_state).into(), - amount, - asset_fee, - protocol_fee, - current_imbalance.value, - ) - .ok_or(ArithmeticError::Overflow)?; - - ensure!( - *state_changes.asset_out.delta_reserve > Balance::zero(), - Error::::ZeroAmountOut - ); - - ensure!( - *state_changes.asset_out.delta_reserve >= min_buy_amount, - Error::::BuyLimitNotReached - ); - - ensure!( - *state_changes.asset_out.delta_reserve - <= asset_out_state - .reserve - .checked_div(T::MaxOutRatio::get()) - .ok_or(ArithmeticError::DivisionByZero)?, // Note: let's be safe. this can only fail if MaxOutRatio is zero. - Error::::MaxOutRatioExceeded - ); - - let new_asset_in_state = asset_in_state - .delta_update(&state_changes.asset_in) - .ok_or(ArithmeticError::Overflow)?; - let new_asset_out_state = asset_out_state - .delta_update(&state_changes.asset_out) - .ok_or(ArithmeticError::Overflow)?; - - debug_assert_eq!( - *state_changes.asset_in.delta_reserve, amount, - "delta_reserve_in is not equal to given amount in" - ); - - T::Currency::transfer( - asset_in, - &who, - &Self::protocol_account(), - *state_changes.asset_in.delta_reserve, - )?; - T::Currency::transfer( - asset_out, - &Self::protocol_account(), - &who, - *state_changes.asset_out.delta_reserve, - )?; - - // Hub liquidity update - work out difference between in and amount so only one update is needed. - let delta_hub_asset = state_changes - .asset_in - .delta_hub_reserve - .merge( - state_changes - .asset_out - .delta_hub_reserve - .merge(BalanceUpdate::Increase(state_changes.hdx_hub_amount)) - .ok_or(ArithmeticError::Overflow)?, - ) - .ok_or(ArithmeticError::Overflow)?; - - match delta_hub_asset { - BalanceUpdate::Increase(val) if val == Balance::zero() => { - // nothing to do if zero. - } - BalanceUpdate::Increase(_) => { - // trade can only burn some. This would be a bug. - return Err(Error::::HubAssetUpdateError.into()); - } - BalanceUpdate::Decrease(amount) => { - T::Currency::withdraw(T::HubAssetId::get(), &Self::protocol_account(), amount)?; - } - }; - - // Callback hook info - let info_in: AssetInfo = AssetInfo::new( - asset_in, - &asset_in_state, - &new_asset_in_state, - &state_changes.asset_in, - false, - ); - - let info_out: AssetInfo = AssetInfo::new( - asset_out, - &asset_out_state, - &new_asset_out_state, - &state_changes.asset_out, - false, - ); - - Self::update_imbalance(state_changes.delta_imbalance)?; - - Self::set_asset_state(asset_in, new_asset_in_state); - Self::set_asset_state(asset_out, new_asset_out_state); - - T::OmnipoolHooks::on_trade(origin.clone(), info_in, info_out)?; - - Self::update_hdx_subpool_hub_asset(origin, state_changes.hdx_hub_amount)?; - - Self::process_trade_fee(&who, asset_out, state_changes.fee.asset_fee)?; - - debug_assert!(*state_changes.asset_in.delta_hub_reserve >= *state_changes.asset_out.delta_hub_reserve); - debug_assert_eq!( - *state_changes.asset_in.delta_hub_reserve - *state_changes.asset_out.delta_hub_reserve, - state_changes.fee.protocol_fee - ); - - Self::deposit_event(Event::SellExecuted { - who, - asset_in, - asset_out, - amount_in: amount, - amount_out: *state_changes.asset_out.delta_reserve, - hub_amount_in: *state_changes.asset_in.delta_hub_reserve, - hub_amount_out: *state_changes.asset_out.delta_hub_reserve, - asset_fee_amount: state_changes.fee.asset_fee, - protocol_fee_amount: state_changes.fee.protocol_fee, - }); - - #[cfg(feature = "try-runtime")] - Self::ensure_trade_invariant( - (asset_in, asset_in_state, new_asset_in_state), - (asset_out, asset_out_state, new_asset_out_state), - ); - - Ok(()) + Self::do_sell(origin, asset_in, asset_out, amount, min_buy_amount, None) } /// Execute a swap of `asset_out` for `asset_in`. @@ -1226,7 +1058,7 @@ pub mod pallet { /// - `amount`: Amount of asset sold /// - `max_sell_amount`: Maximum amount to be sold. /// - /// Emits `BuyExecuted` event when successful. + /// Emits `pallet_trade_event::Swapped` event when successful. /// #[pallet::call_index(6)] #[pallet::weight(::WeightInfo::buy() @@ -1395,8 +1227,9 @@ pub mod pallet { state_changes.fee.protocol_fee ); + // TODO: Deprecated, remove when ready Self::deposit_event(Event::BuyExecuted { - who, + who: who.clone(), asset_in, asset_out, amount_in: *state_changes.asset_in.delta_reserve, @@ -1407,6 +1240,23 @@ pub mod pallet { protocol_fee_amount: state_changes.fee.protocol_fee, }); + Self::deposit_event(Event::HubAmountUpdated { + hub_amount_in: *state_changes.asset_in.delta_hub_reserve, + hub_amount_out: *state_changes.asset_out.delta_hub_reserve, + }); + + pallet_trade_event::Pallet::::deposit_trade_event( + who.clone(), + pallet_trade_event::PoolType::Omnipool, + pallet_trade_event::TradeOperation::Buy, + asset_in.into(), + asset_out.into(), + *state_changes.asset_in.delta_reserve, + *state_changes.asset_out.delta_reserve, + vec![], // TODO + None, + ); + #[cfg(feature = "try-runtime")] Self::ensure_trade_invariant( (asset_in, asset_in_state, new_asset_in_state), @@ -1822,6 +1672,213 @@ impl Pallet { asset_in.tradable.contains(Tradability::SELL) && asset_out.tradable.contains(Tradability::BUY) } + fn do_sell( + origin: frame_system::pallet_prelude::OriginFor, + asset_in: T::AssetId, + asset_out: T::AssetId, + amount: Balance, + min_buy_amount: Balance, + batch_id: Option, + ) -> DispatchResult { + let who = frame_system::ensure_signed(origin.clone())?; + + ensure!(asset_in != asset_out, Error::::SameAssetTradeNotAllowed); + + ensure!( + amount >= T::MinimumTradingLimit::get(), + Error::::InsufficientTradingAmount + ); + + ensure!( + T::Currency::ensure_can_withdraw(asset_in, &who, amount).is_ok(), + Error::::InsufficientBalance + ); + + // Special handling when one of the asset is Hub Asset + // Math is simplified and asset_in is actually part of asset_out state in this case + if asset_in == T::HubAssetId::get() { + return Self::sell_hub_asset(origin, &who, asset_out, amount, min_buy_amount); + } + + if asset_out == T::HubAssetId::get() { + return Self::sell_asset_for_hub_asset(&who, asset_in, amount, min_buy_amount); + } + + let asset_in_state = Self::load_asset_state(asset_in)?; + let asset_out_state = Self::load_asset_state(asset_out)?; + + ensure!( + Self::allow_assets(&asset_in_state, &asset_out_state), + Error::::NotAllowed + ); + + ensure!( + amount + <= asset_in_state + .reserve + .checked_div(T::MaxInRatio::get()) + .ok_or(ArithmeticError::DivisionByZero)?, // Note: this can only fail if MaxInRatio is zero. + Error::::MaxInRatioExceeded + ); + + let current_imbalance = >::get(); + + let (asset_fee, _) = T::Fee::get(&asset_out); + let (_, protocol_fee) = T::Fee::get(&asset_in); + + let state_changes = hydra_dx_math::omnipool::calculate_sell_state_changes( + &(&asset_in_state).into(), + &(&asset_out_state).into(), + amount, + asset_fee, + protocol_fee, + current_imbalance.value, + ) + .ok_or(ArithmeticError::Overflow)?; + + ensure!( + *state_changes.asset_out.delta_reserve > Balance::zero(), + Error::::ZeroAmountOut + ); + + ensure!( + *state_changes.asset_out.delta_reserve >= min_buy_amount, + Error::::BuyLimitNotReached + ); + + ensure!( + *state_changes.asset_out.delta_reserve + <= asset_out_state + .reserve + .checked_div(T::MaxOutRatio::get()) + .ok_or(ArithmeticError::DivisionByZero)?, // Note: let's be safe. this can only fail if MaxOutRatio is zero. + Error::::MaxOutRatioExceeded + ); + + let new_asset_in_state = asset_in_state + .delta_update(&state_changes.asset_in) + .ok_or(ArithmeticError::Overflow)?; + let new_asset_out_state = asset_out_state + .delta_update(&state_changes.asset_out) + .ok_or(ArithmeticError::Overflow)?; + + debug_assert_eq!( + *state_changes.asset_in.delta_reserve, amount, + "delta_reserve_in is not equal to given amount in" + ); + + T::Currency::transfer( + asset_in, + &who, + &Self::protocol_account(), + *state_changes.asset_in.delta_reserve, + )?; + T::Currency::transfer( + asset_out, + &Self::protocol_account(), + &who, + *state_changes.asset_out.delta_reserve, + )?; + + // Hub liquidity update - work out difference between in and amount so only one update is needed. + let delta_hub_asset = state_changes + .asset_in + .delta_hub_reserve + .merge( + state_changes + .asset_out + .delta_hub_reserve + .merge(BalanceUpdate::Increase(state_changes.hdx_hub_amount)) + .ok_or(ArithmeticError::Overflow)?, + ) + .ok_or(ArithmeticError::Overflow)?; + + match delta_hub_asset { + BalanceUpdate::Increase(val) if val == Balance::zero() => { + // nothing to do if zero. + } + BalanceUpdate::Increase(_) => { + // trade can only burn some. This would be a bug. + return Err(Error::::HubAssetUpdateError.into()); + } + BalanceUpdate::Decrease(amount) => { + T::Currency::withdraw(T::HubAssetId::get(), &Self::protocol_account(), amount)?; + } + }; + + // Callback hook info + let info_in: AssetInfo = AssetInfo::new( + asset_in, + &asset_in_state, + &new_asset_in_state, + &state_changes.asset_in, + false, + ); + + let info_out: AssetInfo = AssetInfo::new( + asset_out, + &asset_out_state, + &new_asset_out_state, + &state_changes.asset_out, + false, + ); + + Self::update_imbalance(state_changes.delta_imbalance)?; + + Self::set_asset_state(asset_in, new_asset_in_state); + Self::set_asset_state(asset_out, new_asset_out_state); + + T::OmnipoolHooks::on_trade(origin.clone(), info_in, info_out)?; + + Self::update_hdx_subpool_hub_asset(origin, state_changes.hdx_hub_amount)?; + + Self::process_trade_fee(&who, asset_out, state_changes.fee.asset_fee)?; + + debug_assert!(*state_changes.asset_in.delta_hub_reserve >= *state_changes.asset_out.delta_hub_reserve); + debug_assert_eq!( + *state_changes.asset_in.delta_hub_reserve - *state_changes.asset_out.delta_hub_reserve, + state_changes.fee.protocol_fee + ); + + // TODO: Deprecated, remove when ready + Self::deposit_event(Event::SellExecuted { + who: who.clone(), + asset_in, + asset_out, + amount_in: amount, + amount_out: *state_changes.asset_out.delta_reserve, + hub_amount_in: *state_changes.asset_in.delta_hub_reserve, + hub_amount_out: *state_changes.asset_out.delta_hub_reserve, + asset_fee_amount: state_changes.fee.asset_fee, + protocol_fee_amount: state_changes.fee.protocol_fee, + }); + + Self::deposit_event(Event::HubAmountUpdated { + hub_amount_in: *state_changes.asset_in.delta_hub_reserve, + hub_amount_out: *state_changes.asset_out.delta_hub_reserve, + }); + + pallet_trade_event::Pallet::::deposit_trade_event( + who.clone(), + pallet_trade_event::PoolType::Omnipool, + pallet_trade_event::TradeOperation::Sell, + asset_in.into(), + asset_out.into(), + amount, + *state_changes.asset_out.delta_reserve, + vec![], // TODO + batch_id, + ); + + #[cfg(feature = "try-runtime")] + Self::ensure_trade_invariant( + (asset_in, asset_in_state, new_asset_in_state), + (asset_out, asset_out_state, new_asset_out_state), + ); + + Ok(()) + } + /// Swap hub asset for asset_out. /// Special handling of sell trade where asset in is Hub Asset. fn sell_hub_asset( @@ -1912,6 +1969,7 @@ impl Pallet { Self::process_trade_fee(who, asset_out, state_changes.fee.asset_fee)?; + // TODO: Deprecated, remove when ready Self::deposit_event(Event::SellExecuted { who: who.clone(), asset_in: T::HubAssetId::get(), @@ -1924,6 +1982,18 @@ impl Pallet { protocol_fee_amount: state_changes.fee.protocol_fee, }); + pallet_trade_event::Pallet::::deposit_trade_event( + who.clone(), + pallet_trade_event::PoolType::Omnipool, + pallet_trade_event::TradeOperation::Sell, + T::HubAssetId::get().into(), + asset_out.into(), + *state_changes.asset.delta_hub_reserve, + *state_changes.asset.delta_reserve, + vec![], // TODO + None, + ); + T::OmnipoolHooks::on_hub_asset_trade(origin, info)?; Ok(()) @@ -2019,6 +2089,7 @@ impl Pallet { Self::process_trade_fee(who, asset_out, state_changes.fee.asset_fee)?; + // TODO: Deprecated, remove when ready Self::deposit_event(Event::BuyExecuted { who: who.clone(), asset_in: T::HubAssetId::get(), @@ -2031,6 +2102,18 @@ impl Pallet { protocol_fee_amount: state_changes.fee.protocol_fee, }); + pallet_trade_event::Pallet::::deposit_trade_event( + who.clone(), + pallet_trade_event::PoolType::Omnipool, + pallet_trade_event::TradeOperation::Buy, + T::HubAssetId::get().into(), + asset_out.into(), + *state_changes.asset.delta_hub_reserve, + *state_changes.asset.delta_reserve, + vec![], // TODO + None, + ); + T::OmnipoolHooks::on_hub_asset_trade(origin, info)?; Ok(()) diff --git a/pallets/omnipool/src/router_execution.rs b/pallets/omnipool/src/router_execution.rs index 7ff3e9df0..356249a37 100644 --- a/pallets/omnipool/src/router_execution.rs +++ b/pallets/omnipool/src/router_execution.rs @@ -5,13 +5,14 @@ use hydra_dx_math::omnipool::types::I129; use hydradx_traits::router::{ExecutorError, PoolType, TradeExecution}; use orml_traits::{GetByKey, MultiCurrency}; +use pallet_trade_event::IncrementalIdType; use sp_runtime::traits::Get; use sp_runtime::DispatchError::Corruption; use sp_runtime::{ArithmeticError, DispatchError, FixedPointNumber, FixedU128}; // dev note: The code is calculate sell and buy is copied from the corresponding functions. // This is not ideal and should be refactored to avoid code duplication. -impl TradeExecution, T::AccountId, T::AssetId, Balance> for Pallet { +impl TradeExecution, T::AccountId, T::AssetId, Balance, IncrementalIdType> for Pallet { type Error = DispatchError; fn calculate_sell( @@ -131,12 +132,13 @@ impl TradeExecution, T::AccountId, T::AssetId, Balance> asset_out: T::AssetId, amount_in: Balance, min_limit: Balance, + batch_id: Option, ) -> Result<(), ExecutorError> { if pool_type != PoolType::Omnipool { return Err(ExecutorError::NotSupported); } - Self::sell(who, asset_in, asset_out, amount_in, min_limit).map_err(ExecutorError::Error) + Self::do_sell(who, asset_in, asset_out, amount_in, min_limit, batch_id).map_err(ExecutorError::Error) } fn execute_buy( diff --git a/pallets/omnipool/src/tests/mock.rs b/pallets/omnipool/src/tests/mock.rs index 6d7dfe5a8..b4b7aa195 100644 --- a/pallets/omnipool/src/tests/mock.rs +++ b/pallets/omnipool/src/tests/mock.rs @@ -86,6 +86,7 @@ construct_runtime!( Balances: pallet_balances, Omnipool: pallet_omnipool, Tokens: orml_tokens, + TradeEvent: pallet_trade_event, } ); @@ -175,6 +176,10 @@ parameter_types! { pub MinWithdrawFee: Permill = WITHDRAWAL_FEE.with(|v| *v.borrow()); } +impl pallet_trade_event::Config for Test { + type RuntimeEvent = RuntimeEvent; +} + impl Config for Test { type RuntimeEvent = RuntimeEvent; type AssetId = AssetId; diff --git a/pallets/otc/Cargo.toml b/pallets/otc/Cargo.toml index 97633fbdf..da91daea7 100644 --- a/pallets/otc/Cargo.toml +++ b/pallets/otc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = 'pallet-otc' -version = '2.0.1' +version = '2.1.0' description = 'A pallet for trustless over-the-counter trading' authors = ['GalacticCouncil'] edition = '2021' @@ -12,6 +12,10 @@ repository = "https://github.com/galacticcouncil/Hydradx-node" codec = { package = "parity-scale-codec", version = "3.4.0", features = ["derive", "max-encoded-len"], default-features = false } scale-info = { version = "2.1.2", default-features = false, features = ["derive"] } +# HydraDX dependencies +hydradx-traits = { workspace = true } +pallet-trade-event = { workspace = true } + # primitives sp-runtime = { workspace = true } sp-std = { workspace = true } @@ -21,9 +25,6 @@ sp-core = { workspace = true } frame-support = { workspace = true } frame-system = { workspace = true } -# HydraDX dependencies -hydradx-traits = { workspace = true } - # ORML dependencies orml-traits = { workspace = true } @@ -52,7 +53,8 @@ std = [ 'orml-tokens/std', 'orml-traits/std', 'hydradx-traits/std', - 'frame-benchmarking/std' + 'frame-benchmarking/std', + "pallet-trade-event/std", ] runtime-benchmarks = [ diff --git a/pallets/otc/src/lib.rs b/pallets/otc/src/lib.rs index a4604329d..e33a8672a 100644 --- a/pallets/otc/src/lib.rs +++ b/pallets/otc/src/lib.rs @@ -81,9 +81,9 @@ pub mod pallet { pub struct Pallet(_); #[pallet::config] - pub trait Config: frame_system::Config { + pub trait Config: frame_system::Config + pallet_trade_event::Config { /// Identifier for the class of asset. - type AssetId: Member + Parameter + Copy + HasCompact + MaybeSerializeDeserialize + MaxEncodedLen; + type AssetId: Member + Parameter + Copy + HasCompact + MaybeSerializeDeserialize + MaxEncodedLen + Into; /// Asset Registry mechanism - used to check if asset is correctly registered in asset registry. type AssetRegistry: Inspect; @@ -124,6 +124,7 @@ pub mod pallet { /// An Order has been cancelled Cancelled { order_id: OrderId }, /// An Order has been completely filled + /// Deprecated. Replaced by pallet_trade_event::Swapped Filled { order_id: OrderId, who: T::AccountId, @@ -132,6 +133,7 @@ pub mod pallet { fee: Balance, }, /// An Order has been partially filled + /// Deprecated. Replaced by pallet_trade_event::Swapped PartiallyFilled { order_id: OrderId, who: T::AccountId, @@ -266,7 +268,7 @@ pub mod pallet { /// of asset_out multiplied by ExistentialDepositMultiplier /// /// Events: - /// `PartiallyFilled` event when successful. + /// `pallet_trade_event::Swapped` event when successful. #[pallet::call_index(1)] #[pallet::weight(::WeightInfo::partial_fill_order())] pub fn partial_fill_order(origin: OriginFor, order_id: OrderId, amount_in: Balance) -> DispatchResult { @@ -296,13 +298,27 @@ pub mod pallet { Self::execute_order(order, &who, amount_in, amount_out, fee)?; + // TODO: Deprecated, remove when ready Self::deposit_event(Event::PartiallyFilled { order_id, - who, + who: who.clone(), amount_in, amount_out, fee, }); + + pallet_trade_event::Pallet::::deposit_trade_event( + who, + pallet_trade_event::PoolType::OTC(order_id), + pallet_trade_event::TradeOperation::Sell, + order.asset_in.into(), + order.asset_out.into(), + order.amount_in, + order.amount_out, + vec![(order.asset_out.into(), fee)], + None, + ); + Ok(()) }) } @@ -313,7 +329,7 @@ pub mod pallet { /// - `order_id`: ID of the order /// /// Events: - /// `Filled` event when successful. + /// `pallet_trade_event::Swapped` event when successful. #[pallet::call_index(2)] #[pallet::weight(::WeightInfo::fill_order())] pub fn fill_order(origin: OriginFor, order_id: OrderId) -> DispatchResult { @@ -325,13 +341,27 @@ pub mod pallet { Self::execute_order(&order, &who, order.amount_in, order.amount_out, fee)?; >::remove(order_id); + // TODO: Deprecated, remove when ready Self::deposit_event(Event::Filled { order_id, - who, + who: who.clone(), amount_in: order.amount_in, amount_out: order.amount_out, fee, }); + + pallet_trade_event::Pallet::::deposit_trade_event( + who, + pallet_trade_event::PoolType::OTC(order_id), + pallet_trade_event::TradeOperation::Sell, + order.asset_in.into(), + order.asset_out.into(), + order.amount_in, + order.amount_out, + vec![(order.asset_out.into(), fee)], + None, + ); + Ok(()) } diff --git a/pallets/otc/src/tests/mock.rs b/pallets/otc/src/tests/mock.rs index e314193d6..1438c14a3 100644 --- a/pallets/otc/src/tests/mock.rs +++ b/pallets/otc/src/tests/mock.rs @@ -57,6 +57,7 @@ frame_support::construct_runtime!( System: frame_system, OTC: otc, Tokens: orml_tokens, + TradeEvent: pallet_trade_event, } ); @@ -139,6 +140,10 @@ impl orml_tokens::Config for Test { type CurrencyHooks = (); } +impl pallet_trade_event::Config for Test { + type RuntimeEvent = RuntimeEvent; +} + pub struct DummyRegistry(sp_std::marker::PhantomData); impl Inspect for DummyRegistry { diff --git a/pallets/route-executor/Cargo.toml b/pallets/route-executor/Cargo.toml index 16894edfd..2a6730ddf 100644 --- a/pallets/route-executor/Cargo.toml +++ b/pallets/route-executor/Cargo.toml @@ -1,6 +1,6 @@ [package] name = 'pallet-route-executor' -version = '2.6.0' +version = '2.7.0' description = 'A pallet to execute a route containing a sequence of trades' authors = ['GalacticCouncil'] edition = '2021' @@ -15,6 +15,8 @@ serde = { features = ["derive"], optional = true, version = "1.0.137" } # HydraDX dependencies hydradx-traits = { workspace = true } hydra-dx-math = { workspace = true } +pallet-trade-event = { workspace = true } +primitives = { workspace = true } # ORML dependencies orml-traits = { workspace = true } @@ -46,11 +48,19 @@ runtime-benchmarks = [ std = [ 'serde/std', 'codec/std', + 'scale-info/std', 'sp-std/std', 'frame-support/std', 'frame-system/std', 'orml-tokens/std', + 'orml-traits/std', "hydradx-adapters/std", "pallet-balances/std", + "pallet-trade-event/std", + 'hydradx-traits/std', + 'hydra-dx-math/std', + 'frame-benchmarking/std', + 'sp-core/std', + 'sp-runtime/std', ] try-runtime = ["frame-support/try-runtime"] diff --git a/pallets/route-executor/src/lib.rs b/pallets/route-executor/src/lib.rs index ac64928dd..1bd07318b 100644 --- a/pallets/route-executor/src/lib.rs +++ b/pallets/route-executor/src/lib.rs @@ -37,7 +37,9 @@ use hydradx_traits::router::{inverse_route, AssetPair, RefundEdCalculator, Route pub use hydradx_traits::router::{ AmmTradeWeights, AmountInAndOut, ExecutorError, PoolType, RouterT, Trade, TradeExecution, }; +use hydradx_traits::IncrementalIdProvider; use orml_traits::arithmetic::{CheckedAdd, CheckedSub}; +use primitives::IncrementalId; use sp_core::U512; use sp_runtime::traits::{AccountIdConversion, CheckedDiv}; use sp_runtime::{ArithmeticError, DispatchError, FixedPointNumber, FixedU128, Saturating, TransactionOutcome}; @@ -107,6 +109,7 @@ pub mod pallet { Self::AccountId, Self::AssetId, Self::Balance, + IncrementalId, Error = DispatchError, >; @@ -126,6 +129,7 @@ pub mod pallet { /// Origin able to set route without validation type TechnicalOrigin: EnsureOrigin; + type BatchIdProvider: IncrementalIdProvider; /// Weight information for the extrinsics. type WeightInfo: AmmTradeWeights>; } @@ -490,6 +494,7 @@ impl Pallet { let user_balance_of_asset_in_before_trade = T::Currency::reducible_balance(trade.asset_in, &who, Preservation::Expendable, Fortitude::Polite); + let next_batch_id = T::BatchIdProvider::next_id(); let execution_result = T::AMM::execute_sell( origin.clone(), trade.pool, @@ -497,6 +502,7 @@ impl Pallet { trade.asset_out, trade_amount.amount_in, trade_amount.amount_out, + Some(next_batch_id), ); handle_execution_error!(execution_result); @@ -687,6 +693,7 @@ impl Pallet { PoolType::Stableswap(pool_id) => pool_id, PoolType::XYK => first_route.asset_out, PoolType::LBP => first_route.asset_out, + _ => return Err(Error::::PoolNotSupported.into()), }; let asset_in_liquidity = T::AMM::get_liquidity_depth(first_route.pool, first_route.asset_in, asset_b); diff --git a/pallets/stableswap/Cargo.toml b/pallets/stableswap/Cargo.toml index 462c072f5..c2cece27e 100644 --- a/pallets/stableswap/Cargo.toml +++ b/pallets/stableswap/Cargo.toml @@ -1,6 +1,6 @@ [package] name = 'pallet-stableswap' -version = '3.6.4' +version = '3.7.0' description = 'AMM for correlated assets' authors = ['GalacticCouncil'] edition = '2021' @@ -19,6 +19,10 @@ scale-info = { version = "2.1.2", default-features = false, features = ["derive" codec = { default-features = false, features = ["derive"], package = "parity-scale-codec", version = "3.4.0" } serde = { features = ["derive"], optional = true, version = "1.0.137" } +# HydraDX dependencies +hydradx-traits = { workspace = true } +pallet-trade-event = { workspace = true } + # primitives sp-runtime = { workspace = true } sp-std = { workspace = true } @@ -32,9 +36,6 @@ frame-system = { workspace = true } # Math hydra-dx-math = { workspace = true } -# HydraDX dependencies -hydradx-traits = { workspace = true } - # ORML dependencies orml-traits = { workspace = true } @@ -70,5 +71,6 @@ std = [ "frame-benchmarking/std", 'orml-traits/std', "hydra-dx-math/std", + "pallet-trade-event/std", ] try-runtime = ["frame-support/try-runtime"] diff --git a/pallets/stableswap/src/lib.rs b/pallets/stableswap/src/lib.rs index 13cf9caeb..ac4509200 100644 --- a/pallets/stableswap/src/lib.rs +++ b/pallets/stableswap/src/lib.rs @@ -72,6 +72,7 @@ use crate::types::{AssetAmount, Balance, PoolInfo, PoolState, StableswapHooks, T use hydra_dx_math::stableswap::types::AssetReserve; use hydradx_traits::pools::DustRemovalAccountWhitelist; use orml_traits::MultiCurrency; +use pallet_trade_event::IncrementalIdType; use sp_std::collections::btree_map::BTreeMap; pub use weights::WeightInfo; @@ -110,7 +111,7 @@ pub mod pallet { pub struct Pallet(_); #[pallet::config] - pub trait Config: frame_system::Config { + pub trait Config: frame_system::Config + pallet_trade_event::Config { /// The overarching event type. type RuntimeEvent: From> + IsType<::RuntimeEvent>; @@ -126,7 +127,8 @@ pub mod pallet { + HasCompact + MaybeSerializeDeserialize + MaxEncodedLen - + TypeInfo; + + TypeInfo + + Into; /// Multi currency mechanism type Currency: MultiCurrency; @@ -204,6 +206,7 @@ pub mod pallet { fee: Balance, }, /// Sell trade executed. Trade fee paid in asset leaving the pool (already subtracted from amount_out). + /// Deprecated. Replaced by pallet_trade_event::Swapped SellExecuted { who: T::AccountId, pool_id: T::AssetId, @@ -214,6 +217,7 @@ pub mod pallet { fee: Balance, }, /// Buy trade executed. Trade fee paid in asset entering the pool (already included in amount_in). + /// Deprecated. Replaced by pallet_trade_event::Swapped BuyExecuted { who: T::AccountId, pool_id: T::AssetId, @@ -709,7 +713,7 @@ pub mod pallet { /// - `amount_in`: Amount of asset to be sold to the pool /// - `min_buy_amount`: Minimum amount required to receive /// - /// Emits `SellExecuted` event when successful. + /// Emits `pallet_trade_event::Swapped` event when successful. /// #[pallet::call_index(7)] #[pallet::weight(::WeightInfo::sell() @@ -723,55 +727,7 @@ pub mod pallet { amount_in: Balance, min_buy_amount: Balance, ) -> DispatchResult { - let who = ensure_signed(origin)?; - - ensure!(asset_in != asset_out, Error::::NotAllowed); - - ensure!( - Self::is_asset_allowed(pool_id, asset_in, Tradability::SELL) - && Self::is_asset_allowed(pool_id, asset_out, Tradability::BUY), - Error::::NotAllowed - ); - - ensure!( - amount_in >= T::MinTradingLimit::get(), - Error::::InsufficientTradingAmount - ); - - ensure!( - T::Currency::free_balance(asset_in, &who) >= amount_in, - Error::::InsufficientBalance - ); - - let pool = Pools::::get(pool_id).ok_or(Error::::PoolNotFound)?; - let pool_account = Self::pool_account(pool_id); - let initial_reserves = pool - .reserves_with_decimals::(&pool_account) - .ok_or(Error::::UnknownDecimals)?; - - let (amount_out, fee_amount) = Self::calculate_out_amount(pool_id, asset_in, asset_out, amount_in)?; - ensure!(amount_out >= min_buy_amount, Error::::BuyLimitNotReached); - - T::Currency::transfer(asset_in, &who, &pool_account, amount_in)?; - T::Currency::transfer(asset_out, &pool_account, &who, amount_out)?; - - //All done and updated. Let's call on_trade hook. - Self::call_on_trade_hook(pool_id, asset_in, asset_out, &initial_reserves)?; - - Self::deposit_event(Event::SellExecuted { - who, - pool_id, - asset_in, - asset_out, - amount_in, - amount_out, - fee: fee_amount, - }); - - #[cfg(feature = "try-runtime")] - Self::ensure_trade_invariant(pool_id, &initial_reserves, pool.fee); - - Ok(()) + Self::do_sell(origin, pool_id, asset_in, asset_out, amount_in, min_buy_amount, None) } /// Execute a swap of `asset_in` for `asset_out`. @@ -784,7 +740,7 @@ pub mod pallet { /// - `amount_out`: Amount of asset to receive from the pool /// - `max_sell_amount`: Maximum amount allowed to be sold /// - /// Emits `BuyExecuted` event when successful. + /// Emits `pallet_trade_event::Swapped` event when successful. /// #[pallet::call_index(8)] #[pallet::weight(::WeightInfo::buy() @@ -836,8 +792,9 @@ pub mod pallet { //All done and updated. Let's call on_trade_hook. Self::call_on_trade_hook(pool_id, asset_in, asset_out, &initial_reserves)?; + // TODO: Deprecated, remove when ready Self::deposit_event(Event::BuyExecuted { - who, + who: who.clone(), pool_id, asset_in, asset_out, @@ -846,6 +803,18 @@ pub mod pallet { fee: fee_amount, }); + pallet_trade_event::Pallet::::deposit_trade_event( + who, + pallet_trade_event::PoolType::Stableswap(pool_id.into()), + pallet_trade_event::TradeOperation::Buy, + asset_in.into(), + asset_out.into(), + amount_in, + amount_out, + vec![(asset_in.into(), fee_amount)], + None, + ); + #[cfg(feature = "try-runtime")] Self::ensure_trade_invariant(pool_id, &initial_reserves, pool.fee); @@ -890,6 +859,79 @@ impl Pallet { PalletId(*b"stblpool").into_account_truncating() } + fn do_sell( + origin: frame_system::pallet_prelude::OriginFor, + pool_id: T::AssetId, + asset_in: T::AssetId, + asset_out: T::AssetId, + amount_in: Balance, + min_buy_amount: Balance, + batch_id: Option, + ) -> DispatchResult { + let who = frame_system::ensure_signed(origin)?; + + ensure!(asset_in != asset_out, Error::::NotAllowed); + + ensure!( + Self::is_asset_allowed(pool_id, asset_in, Tradability::SELL) + && Self::is_asset_allowed(pool_id, asset_out, Tradability::BUY), + Error::::NotAllowed + ); + + ensure!( + amount_in >= T::MinTradingLimit::get(), + Error::::InsufficientTradingAmount + ); + + ensure!( + T::Currency::free_balance(asset_in, &who) >= amount_in, + Error::::InsufficientBalance + ); + + let pool = Pools::::get(pool_id).ok_or(Error::::PoolNotFound)?; + let pool_account = Self::pool_account(pool_id); + let initial_reserves = pool + .reserves_with_decimals::(&pool_account) + .ok_or(Error::::UnknownDecimals)?; + + let (amount_out, fee_amount) = Self::calculate_out_amount(pool_id, asset_in, asset_out, amount_in)?; + ensure!(amount_out >= min_buy_amount, Error::::BuyLimitNotReached); + + T::Currency::transfer(asset_in, &who, &pool_account, amount_in)?; + T::Currency::transfer(asset_out, &pool_account, &who, amount_out)?; + + //All done and updated. Let's call on_trade hook. + Self::call_on_trade_hook(pool_id, asset_in, asset_out, &initial_reserves)?; + + // TODO: Deprecated, remove when ready + Self::deposit_event(Event::SellExecuted { + who: who.clone(), + pool_id, + asset_in, + asset_out, + amount_in, + amount_out, + fee: fee_amount, + }); + + pallet_trade_event::Pallet::::deposit_trade_event( + who, + pallet_trade_event::PoolType::Stableswap(pool_id.into()), + pallet_trade_event::TradeOperation::Sell, + asset_in.into(), + asset_out.into(), + amount_in, + amount_out, + vec![(asset_out.into(), fee_amount)], + batch_id, + ); + + #[cfg(feature = "try-runtime")] + Self::ensure_trade_invariant(pool_id, &initial_reserves, pool.fee); + + Ok(()) + } + /// Calculates out amount given in amount. /// Returns (out_amount, fee_amount) on success. Note that fee amount is already subtracted from the out amount. fn calculate_out_amount( @@ -1178,9 +1220,7 @@ impl Pallet { pub(crate) fn retrieve_decimals(asset_id: T::AssetId) -> Option { T::AssetInspection::decimals(asset_id) } -} -impl Pallet { fn calculate_shares(pool_id: T::AssetId, assets: &[AssetAmount]) -> Result { let pool = Pools::::get(pool_id).ok_or(Error::::PoolNotFound)?; let pool_account = Self::pool_account(pool_id); diff --git a/pallets/stableswap/src/tests/mock.rs b/pallets/stableswap/src/tests/mock.rs index 079938ce3..b94ff1f63 100644 --- a/pallets/stableswap/src/tests/mock.rs +++ b/pallets/stableswap/src/tests/mock.rs @@ -81,6 +81,7 @@ construct_runtime!( System: frame_system, Tokens: orml_tokens, Stableswap: pallet_stableswap, + TradeEvent: pallet_trade_event, } ); @@ -167,6 +168,10 @@ impl DustRemovalAccountWhitelist for Whitelist { } } +impl pallet_trade_event::Config for Test { + type RuntimeEvent = RuntimeEvent; +} + impl Config for Test { type RuntimeEvent = RuntimeEvent; type AssetId = AssetId; diff --git a/pallets/stableswap/src/trade_execution.rs b/pallets/stableswap/src/trade_execution.rs index 53d54e25a..4795efb42 100644 --- a/pallets/stableswap/src/trade_execution.rs +++ b/pallets/stableswap/src/trade_execution.rs @@ -3,11 +3,12 @@ use crate::{Balance, Config, Error, Pallet, Pools, D_ITERATIONS, Y_ITERATIONS}; use hydra_dx_math::stableswap::types::AssetReserve; use hydradx_traits::router::{ExecutorError, PoolType, TradeExecution}; use orml_traits::MultiCurrency; +use pallet_trade_event::IncrementalIdType; use sp_core::Get; use sp_runtime::{ArithmeticError, DispatchError, FixedU128}; use sp_std::vec; -impl TradeExecution for Pallet +impl TradeExecution for Pallet where u32: sp_std::convert::From, sp_std::vec::Vec<(u32, AssetReserve)>: FromIterator<(T::AssetId, AssetReserve)>, @@ -142,6 +143,7 @@ where asset_out: T::AssetId, amount_in: Balance, min_limit: Balance, + batch_id: Option, ) -> Result<(), ExecutorError> { match pool_type { PoolType::Stableswap(pool_id) => { @@ -159,7 +161,8 @@ where ) .map_err(ExecutorError::Error) } else { - Self::sell(who, pool_id, asset_in, asset_out, amount_in, min_limit).map_err(ExecutorError::Error) + Self::do_sell(who, pool_id, asset_in, asset_out, amount_in, min_limit, batch_id) + .map_err(ExecutorError::Error) } } _ => Err(ExecutorError::NotSupported), diff --git a/pallets/trade-event/Cargo.toml b/pallets/trade-event/Cargo.toml new file mode 100644 index 000000000..6e2d70549 --- /dev/null +++ b/pallets/trade-event/Cargo.toml @@ -0,0 +1,37 @@ +[package] +name = "pallet-trade-event" +version = "1.0.0" +authors = ["GalacticCouncil"] +edition = "2021" +license = "Apache 2.0" +homepage = 'https://github.com/galacticcouncil/hydration-node' +repository = 'https://github.com/galacticcouncil/hydration-node' +description = "Trade event pallet provides unified event for AMMs" +readme = "README.md" + +[dependencies] +codec = { default-features = false, features = ["derive"], package = "parity-scale-codec", version = "3.4.0" } +scale-info = { version = "2.1.2", default-features = false, features = ["derive"] } + +# HydraDX dependencies +hydradx-traits = { workspace = true } +primitives = { workspace = true } + +# Substrate dependencies +sp-std = { workspace = true } +sp-api = { workspace = true } +frame-support = { workspace = true } +frame-system = { workspace = true } + +[features] +default = ["std"] +std = [ + "codec/std", + "scale-info/std", + "frame-support/std", + "frame-system/std", + "sp-std/std", + "sp-api/std", + "primitives/std", +] +try-runtime = ["frame-support/try-runtime"] diff --git a/pallets/trade-event/README.md b/pallets/trade-event/README.md new file mode 100644 index 000000000..625b66c14 --- /dev/null +++ b/pallets/trade-event/README.md @@ -0,0 +1,3 @@ +# Trade event pallet + +Support pallet for AMMs. Includes the unified event that is emitted by all AMM pallets. diff --git a/pallets/trade-event/src/lib.rs b/pallets/trade-event/src/lib.rs new file mode 100644 index 000000000..469285976 --- /dev/null +++ b/pallets/trade-event/src/lib.rs @@ -0,0 +1,111 @@ +// This file is part of hydration-node. + +// Copyright (C) 2020-2022 Intergalactic, Limited (GIB). +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#![cfg_attr(not(feature = "std"), no_std)] + +type AssetId = u32; +type Balance = u128; + +pub use hydradx_traits::{ + router::{PoolType, TradeOperation}, + IncrementalIdProvider, +}; +pub use primitives::IncrementalId as IncrementalIdType; + +// Re-export pallet items so that they can be accessed from the crate namespace. +pub use pallet::*; + +#[frame_support::pallet] +pub mod pallet { + use super::*; + use frame_support::pallet_prelude::*; + + #[pallet::pallet] + pub struct Pallet(_); + + #[pallet::config] + pub trait Config: frame_system::Config { + type RuntimeEvent: From> + IsType<::RuntimeEvent>; + } + + #[pallet::storage] + /// Incremental ID + #[pallet::getter(fn incremental_id)] + pub(super) type IncrementalId = StorageValue<_, IncrementalIdType, ValueQuery>; + + #[pallet::error] + pub enum Error {} + + #[pallet::event] + #[pallet::generate_deposit(pub(crate) fn deposit_event)] + pub enum Event { + /// Trade executed. + Swapped { + who: T::AccountId, + pool: PoolType, + operation: TradeOperation, + asset_in: AssetId, + asset_out: AssetId, + amount_in: Balance, + amount_out: Balance, + fees: Vec<(AssetId, Balance)>, + batch_id: Option, + }, + } + + #[pallet::call] + impl Pallet {} +} + +impl Pallet { + pub fn next_incremental_id() -> IncrementalIdType { + let next_incremental_id = Self::incremental_id(); + >::set(next_incremental_id + 1); // TODO: checked math + next_incremental_id + } + + #[allow(clippy::too_many_arguments)] + pub fn deposit_trade_event( + who: T::AccountId, + pool: PoolType, + operation: TradeOperation, + asset_in: AssetId, + asset_out: AssetId, + amount_in: Balance, + amount_out: Balance, + fees: Vec<(AssetId, Balance)>, + batch_id: Option, + ) { + Self::deposit_event(Event::::Swapped { + who, + pool, + operation, + asset_in, + asset_out, + amount_in, + amount_out, + fees, + batch_id, + }); + } +} + +impl IncrementalIdProvider for Pallet { + fn next_id() -> IncrementalIdType { + Self::next_incremental_id() + } +} diff --git a/pallets/xyk-liquidity-mining/src/lib.rs b/pallets/xyk-liquidity-mining/src/lib.rs index 4ae443483..5bc81871e 100644 --- a/pallets/xyk-liquidity-mining/src/lib.rs +++ b/pallets/xyk-liquidity-mining/src/lib.rs @@ -112,7 +112,7 @@ pub mod pallet { type Currencies: MultiCurrency; /// AMM helper functions. - type AMM: AMM + type AMM: AMM + AMMPosition; /// The origin account that can create new liquidity mining program. diff --git a/pallets/xyk/Cargo.toml b/pallets/xyk/Cargo.toml index 99c415ede..8289099e4 100644 --- a/pallets/xyk/Cargo.toml +++ b/pallets/xyk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = 'pallet-xyk' -version = "6.4.4" +version = "6.5.0" description = 'XYK automated market maker' authors = ['GalacticCouncil'] edition = '2021' @@ -29,6 +29,7 @@ orml-traits = { workspace = true } # HydraDX dependencies hydradx-traits = { workspace = true } +pallet-trade-event = { workspace = true } # Substrate dependencies frame-benchmarking = { workspace = true, optional = true } @@ -65,5 +66,6 @@ std = [ 'frame-benchmarking/std', "scale-info/std", "pallet-asset-registry/std", + "pallet-trade-event/std", ] try-runtime = ["frame-support/try-runtime"] diff --git a/pallets/xyk/src/lib.rs b/pallets/xyk/src/lib.rs index 0090e2c8c..d0f929e78 100644 --- a/pallets/xyk/src/lib.rs +++ b/pallets/xyk/src/lib.rs @@ -40,6 +40,7 @@ use sp_std::{vec, vec::Vec}; use crate::types::{Amount, AssetId, AssetPair, Balance}; use hydra_dx_math::ratio::Ratio; +use pallet_trade_event::IncrementalIdType; use orml_traits::{MultiCurrency, MultiCurrencyExtended}; #[cfg(test)] @@ -75,7 +76,7 @@ pub mod pallet { impl Hooks> for Pallet {} #[pallet::config] - pub trait Config: frame_system::Config { + pub trait Config: frame_system::Config + pallet_trade_event::Config { type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Registry support @@ -249,6 +250,7 @@ pub mod pallet { }, /// Asset sale executed. + /// Deprecated. Replaced by pallet_trade_event::Swapped SellExecuted { who: T::AccountId, asset_in: AssetId, @@ -261,6 +263,7 @@ pub mod pallet { }, /// Asset purchase executed. + /// Deprecated. Replaced by pallet_trade_event::Swapped BuyExecuted { who: T::AccountId, asset_out: AssetId, @@ -627,7 +630,7 @@ pub mod pallet { /// /// `max_limit` - minimum amount of `asset_out` / amount of asset_out to be obtained from the pool in exchange for `asset_in`. /// - /// Emits `SellExecuted` when successful. + /// Emits `pallet_trade_event::Swapped` when successful. #[pallet::call_index(3)] #[pallet::weight(::WeightInfo::sell() + ::AMMHandler::on_trade_weight())] pub fn sell( @@ -640,7 +643,14 @@ pub mod pallet { ) -> DispatchResult { let who = ensure_signed(origin)?; - >::sell(&who, AssetPair { asset_in, asset_out }, amount, max_limit, discount)?; + >::sell( + &who, + AssetPair { asset_in, asset_out }, + amount, + max_limit, + discount, + None, + )?; Ok(()) } @@ -651,7 +661,7 @@ pub mod pallet { /// /// `max_limit` - maximum amount of `asset_in` to be sold in exchange for `asset_out`. /// - /// Emits `BuyExecuted` when successful. + /// Emits `pallet_trade_event::Swapped` when successful. #[pallet::call_index(4)] #[pallet::weight(::WeightInfo::buy() + ::AMMHandler::on_trade_weight())] pub fn buy( @@ -664,7 +674,7 @@ pub mod pallet { ) -> DispatchResult { let who = ensure_signed(origin)?; - >::buy(&who, AssetPair { asset_in, asset_out }, amount, max_limit, discount)?; + >::buy(&who, AssetPair { asset_in, asset_out }, amount, max_limit, discount)?; Ok(()) } @@ -705,7 +715,7 @@ impl Pallet { } // Implementation of AMM API which makes possible to plug the AMM pool into the exchange pallet. -impl AMM for Pallet { +impl AMM for Pallet { fn exists(assets: AssetPair) -> bool { >::contains_key(&Self::get_pair_id(assets)) } @@ -854,7 +864,10 @@ impl AMM for Pallet { /// Perform necessary storage/state changes. /// Note : the execution should not return error as everything was previously verified and validated. #[transactional] - fn execute_sell(transfer: &AMMTransfer) -> DispatchResult { + fn execute_sell( + transfer: &AMMTransfer, + batch_id: Option, + ) -> DispatchResult { let pair_account = Self::get_pair_id(transfer.assets); if transfer.discount && transfer.discount_amount > 0u128 { @@ -889,6 +902,7 @@ impl AMM for Pallet { ) .map_err(|(_w, e)| e)?; + // TODO: Deprecated, remove when ready Self::deposit_event(Event::::SellExecuted { who: transfer.origin.clone(), asset_in: transfer.assets.asset_in, @@ -900,6 +914,18 @@ impl AMM for Pallet { pool: pair_account, }); + pallet_trade_event::Pallet::::deposit_trade_event( + transfer.origin.clone(), + pallet_trade_event::PoolType::XYK, + pallet_trade_event::TradeOperation::Sell, + transfer.assets.asset_in, + transfer.assets.asset_out, + transfer.amount, + transfer.amount_b, + vec![transfer.fee], + batch_id, + ); + Ok(()) } @@ -1051,6 +1077,7 @@ impl AMM for Pallet { ) .map_err(|(_w, e)| e)?; + // TODO: Deprecated, remove when ready Self::deposit_event(Event::::BuyExecuted { who: transfer.origin.clone(), asset_out: transfer.assets.asset_out, @@ -1062,6 +1089,18 @@ impl AMM for Pallet { pool: pair_account, }); + pallet_trade_event::Pallet::::deposit_trade_event( + transfer.origin.clone(), + pallet_trade_event::PoolType::XYK, + pallet_trade_event::TradeOperation::Buy, + transfer.assets.asset_in, + transfer.assets.asset_out, + transfer.amount, + transfer.amount_b, + vec![transfer.fee], + None, + ); + Ok(()) } diff --git a/pallets/xyk/src/tests/mock.rs b/pallets/xyk/src/tests/mock.rs index 00aaa71bb..180c6bb14 100644 --- a/pallets/xyk/src/tests/mock.rs +++ b/pallets/xyk/src/tests/mock.rs @@ -61,6 +61,7 @@ frame_support::construct_runtime!( XYK: xyk, Currency: orml_tokens, AssetRegistry: pallet_asset_registry, + TradeEvent: pallet_trade_event, } ); @@ -197,6 +198,10 @@ impl CanCreatePool for Disallow10_10Pool { } } +impl pallet_trade_event::Config for Test { + type RuntimeEvent = RuntimeEvent; +} + impl xyk::Config for Test { type RuntimeEvent = RuntimeEvent; type AssetRegistry = AssetRegistry; diff --git a/pallets/xyk/src/trade_execution.rs b/pallets/xyk/src/trade_execution.rs index 3cdb2f22b..3cbd7e955 100644 --- a/pallets/xyk/src/trade_execution.rs +++ b/pallets/xyk/src/trade_execution.rs @@ -5,10 +5,11 @@ use frame_support::traits::Get; use hydradx_traits::router::{ExecutorError, PoolType, TradeExecution}; use hydradx_traits::AMM; use orml_traits::MultiCurrency; +use pallet_trade_event::IncrementalIdType; use sp_runtime::DispatchError::Corruption; use sp_runtime::{ArithmeticError, DispatchError, FixedPointNumber, FixedU128}; -impl TradeExecution for Pallet { +impl TradeExecution for Pallet { type Error = DispatchError; fn calculate_sell( @@ -100,12 +101,26 @@ impl TradeExecution asset_out: AssetId, amount_in: Balance, min_limit: Balance, + batch_id: Option, ) -> Result<(), ExecutorError> { if pool_type != PoolType::XYK { return Err(ExecutorError::NotSupported); } - Self::sell(who, asset_in, asset_out, amount_in, min_limit, false).map_err(ExecutorError::Error) + let who = crate::ensure_signed(who).map_err(|e| ExecutorError::Error(e.into()))?; + + >::sell( + &who, + AssetPair { asset_in, asset_out }, + amount_in, + min_limit, + false, + batch_id, + ) + .map_err(ExecutorError::Error)?; + + Ok(()) + // Self::sell(who, asset_in, asset_out, amount_in, min_limit, false).map_err(ExecutorError::Error) } fn execute_buy( diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index 9fe493c72..584cb775e 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -75,3 +75,6 @@ pub type Header = generic::Header; /// Block type. pub type Block = generic::Block; + +/// Incremental ID type +pub type IncrementalId = u32; diff --git a/runtime/hydradx/Cargo.toml b/runtime/hydradx/Cargo.toml index 285bfed06..b0dc7c684 100644 --- a/runtime/hydradx/Cargo.toml +++ b/runtime/hydradx/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hydradx-runtime" -version = "256.0.0" +version = "257.0.0" authors = ["GalacticCouncil"] edition = "2021" license = "Apache 2.0" @@ -38,6 +38,7 @@ pallet-bonds = { workspace = true } pallet-lbp = { workspace = true } pallet-xyk = { workspace = true } pallet-referrals = { workspace = true } +pallet-trade-event = { workspace = true } pallet-evm-accounts = { workspace = true } pallet-evm-accounts-rpc-runtime-api = { workspace = true } pallet-xyk-liquidity-mining = { workspace = true } @@ -323,6 +324,7 @@ std = [ "parachains-common/std", "polkadot-runtime-common/std", "pallet-state-trie-migration/std", + "pallet-trade-event/std", ] try-runtime = [ "frame-try-runtime", @@ -394,6 +396,7 @@ try-runtime = [ "pallet-xyk-liquidity-mining/try-runtime", "pallet-message-queue/try-runtime", "pallet-state-trie-migration/try-runtime", + "pallet-trade-event/try-runtime", ] metadata-hash = [ diff --git a/runtime/hydradx/src/assets.rs b/runtime/hydradx/src/assets.rs index 1aa98f746..566b8975e 100644 --- a/runtime/hydradx/src/assets.rs +++ b/runtime/hydradx/src/assets.rs @@ -920,6 +920,7 @@ impl AmmTradeWeights> for RouterWeightInfo { } PoolType::XYK => weights::pallet_xyk::HydraWeight::::router_execution_sell(c, e) .saturating_add(::AMMHandler::on_trade_weight()), + _ => Weight::MAX, }; weight.saturating_accrue(amm_weight); } @@ -968,6 +969,7 @@ impl AmmTradeWeights> for RouterWeightInfo { } PoolType::XYK => weights::pallet_xyk::HydraWeight::::router_execution_buy(c, e) .saturating_add(::AMMHandler::on_trade_weight()), + _ => Weight::MAX, }; weight.saturating_accrue(amm_weight); } @@ -1000,6 +1002,7 @@ impl AmmTradeWeights> for RouterWeightInfo { } PoolType::XYK => weights::pallet_xyk::HydraWeight::::router_execution_buy(c, e) .saturating_add(::AMMHandler::on_trade_weight()), + _ => Weight::MAX, }; weight.saturating_accrue(amm_weight); } @@ -1024,6 +1027,7 @@ impl AmmTradeWeights> for RouterWeightInfo { } PoolType::XYK => weights::pallet_xyk::HydraWeight::::router_execution_sell(c, e) .saturating_add(::AMMHandler::on_trade_weight()), + _ => Weight::MAX, }; weight.saturating_accrue(amm_weight); } @@ -1048,6 +1052,7 @@ impl AmmTradeWeights> for RouterWeightInfo { } PoolType::XYK => weights::pallet_xyk::HydraWeight::::router_execution_buy(c, e) .saturating_add(::AMMHandler::on_trade_weight()), + _ => Weight::MAX, }; weight.saturating_accrue(amm_weight); } @@ -1080,6 +1085,7 @@ impl AmmTradeWeights> for RouterWeightInfo { weights::pallet_stableswap::HydraWeight::::router_execution_sell(1, 0) } PoolType::XYK => weights::pallet_xyk::HydraWeight::::router_execution_sell(1, 0), + _ => Weight::MAX, }; weight.saturating_accrue(amm_weight); } @@ -1093,6 +1099,7 @@ impl AmmTradeWeights> for RouterWeightInfo { weights::pallet_stableswap::HydraWeight::::router_execution_sell(1, 0) } PoolType::XYK => weights::pallet_xyk::HydraWeight::::router_execution_sell(1, 0), + _ => Weight::MAX, }; weight.saturating_accrue(amm_weight); } @@ -1125,6 +1132,7 @@ impl AmmTradeWeights> for RouterWeightInfo { weights::pallet_stableswap::HydraWeight::::calculate_spot_price_with_fee() } PoolType::XYK => weights::pallet_xyk::HydraWeight::::calculate_spot_price_with_fee(), + _ => Weight::MAX, }; weight.saturating_accrue(amm_weight); } @@ -1156,6 +1164,7 @@ impl pallet_route_executor::Config for Runtime { type TechnicalOrigin = SuperMajorityTechCommittee; type EdToRefundCalculator = RefundAndLockedEdCalculator; type OraclePriceProvider = hydradx_adapters::OraclePriceProvider; + type BatchIdProvider = TradeEvent; type OraclePeriod = RouteValidationOraclePeriod; } @@ -1525,6 +1534,10 @@ impl pallet_referrals::Config for Runtime { type BenchmarkHelper = ReferralsBenchmarkHelper; } +impl pallet_trade_event::Config for Runtime { + type RuntimeEvent = RuntimeEvent; +} + pub struct ConvertViaOmnipool(PhantomData); impl Convert for ConvertViaOmnipool where diff --git a/runtime/hydradx/src/lib.rs b/runtime/hydradx/src/lib.rs index 8e5c13482..c0a200646 100644 --- a/runtime/hydradx/src/lib.rs +++ b/runtime/hydradx/src/lib.rs @@ -113,7 +113,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("hydradx"), impl_name: create_runtime_str!("hydradx"), authoring_version: 1, - spec_version: 256, + spec_version: 257, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, @@ -185,6 +185,7 @@ construct_runtime!( LBP: pallet_lbp = 73, XYK: pallet_xyk = 74, Referrals: pallet_referrals = 75, + TradeEvent: pallet_trade_event = 76, // ORML related modules Tokens: orml_tokens = 77, diff --git a/traits/src/lib.rs b/traits/src/lib.rs index 3078695ca..c67bb3c9b 100644 --- a/traits/src/lib.rs +++ b/traits/src/lib.rs @@ -53,7 +53,7 @@ pub struct AMMTransfer { } /// Traits for handling AMM Pool trades. -pub trait AMM { +pub trait AMM { /// Check if both assets exist in a pool. fn exists(assets: AssetPair) -> bool; @@ -80,7 +80,10 @@ pub trait AMM { ) -> Result, frame_support::sp_runtime::DispatchError>; /// Execute buy for given validated transfer. - fn execute_sell(transfer: &AMMTransfer) -> dispatch::DispatchResult; + fn execute_sell( + transfer: &AMMTransfer, + batch_id: Option, + ) -> dispatch::DispatchResult; /// Perform asset swap. /// Call execute following the validation. @@ -90,8 +93,13 @@ pub trait AMM { amount: Amount, min_bought: Amount, discount: bool, + batch_id: Option, ) -> dispatch::DispatchResult { - Self::execute_sell(&Self::validate_sell(origin, assets, amount, min_bought, discount)?)?; + Self::execute_sell( + &Self::validate_sell(origin, assets, amount, min_bought, discount)?, + batch_id, + )?; + Ok(()) } @@ -268,3 +276,7 @@ pub trait AccountFeeCurrencyBalanceInCurrency { type Output; fn get_balance_in_currency(to_currency: AssetId, account: &AccountId) -> Self::Output; } + +pub trait IncrementalIdProvider { + fn next_id() -> IncrementalId; +} diff --git a/traits/src/router.rs b/traits/src/router.rs index e8d6d615b..2ebab2aac 100644 --- a/traits/src/router.rs +++ b/traits/src/router.rs @@ -60,12 +60,19 @@ pub trait RouteProvider { } } +#[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] +pub enum TradeOperation { + Sell, + Buy, +} + #[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] pub enum PoolType { XYK, LBP, Stableswap(AssetId), Omnipool, + OTC(u32), } #[derive(Debug, PartialEq, Eq)] @@ -143,7 +150,7 @@ pub trait RouterT { } /// All AMMs used in the router are required to implement this trait. -pub trait TradeExecution { +pub trait TradeExecution { type Error; fn calculate_sell( @@ -167,6 +174,7 @@ pub trait TradeExecution { asset_out: AssetId, amount_in: Balance, min_limit: Balance, + batch_id: Option, ) -> Result<(), ExecutorError>; fn execute_buy( @@ -193,10 +201,10 @@ pub trait TradeExecution { #[allow(clippy::redundant_clone)] //Needed as it complains about redundant clone, but clone is needed as Origin is moved and it is not copy type. #[impl_trait_for_tuples::impl_for_tuples(1, 5)] -impl - TradeExecution for Tuple +impl + TradeExecution for Tuple { - for_tuples!( where #(Tuple: TradeExecution)*); + for_tuples!( where #(Tuple: TradeExecution)*); type Error = E; fn calculate_sell( @@ -242,10 +250,11 @@ impl asset_out: AssetId, amount_in: Balance, min_limit: Balance, + batch_id: Option, ) -> Result<(), ExecutorError> { for_tuples!( #( - let value = match Tuple::execute_sell(who.clone(),pool_type, asset_in, asset_out, amount_in, min_limit) { + let value = match Tuple::execute_sell(who.clone(),pool_type, asset_in, asset_out, amount_in, min_limit, batch_id) { Ok(result) => return Ok(result), Err(v) if v == ExecutorError::NotSupported => v, Err(v) => return Err(v), From 2935f9047f4ef774face503e0e6d5dc7155964c6 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Fri, 20 Sep 2024 15:03:17 +0200 Subject: [PATCH 002/142] revert removed comments about emitted events --- pallets/lbp/src/lib.rs | 2 ++ pallets/omnipool/src/lib.rs | 2 ++ pallets/otc/src/lib.rs | 2 ++ pallets/stableswap/src/lib.rs | 2 ++ pallets/xyk/src/lib.rs | 3 ++- 5 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pallets/lbp/src/lib.rs b/pallets/lbp/src/lib.rs index 84fdb1e83..7bc23b621 100644 --- a/pallets/lbp/src/lib.rs +++ b/pallets/lbp/src/lib.rs @@ -720,6 +720,7 @@ pub mod pallet { /// - `amount`: The amount of `asset_in` /// - `max_limit`: minimum amount of `asset_out` / amount of asset_out to be obtained from the pool in exchange for `asset_in`. /// + /// Emits `SellExecuted` when successful. Deprecated. /// Emits `pallet_trade_event::Swapped` when successful. #[pallet::call_index(4)] #[pallet::weight(::WeightInfo::sell())] @@ -757,6 +758,7 @@ pub mod pallet { /// - `amount`: The amount of `asset_out`. /// - `max_limit`: maximum amount of `asset_in` to be sold in exchange for `asset_out`. /// + /// Emits `BuyExecuted` when successful. Deprecated. /// Emits `pallet_trade_event::Swapped` when successful. #[pallet::call_index(5)] #[pallet::weight(::WeightInfo::buy())] diff --git a/pallets/omnipool/src/lib.rs b/pallets/omnipool/src/lib.rs index 71ca34111..fb68f1fe0 100644 --- a/pallets/omnipool/src/lib.rs +++ b/pallets/omnipool/src/lib.rs @@ -1026,6 +1026,7 @@ pub mod pallet { /// - `amount`: Amount of asset sold /// - `min_buy_amount`: Minimum amount required to receive /// + /// Emits `SellExecuted` event when successful. Deprecated. /// Emits `pallet_trade_event::Swapped` event when successful. /// #[pallet::call_index(5)] @@ -1058,6 +1059,7 @@ pub mod pallet { /// - `amount`: Amount of asset sold /// - `max_sell_amount`: Maximum amount to be sold. /// + /// Emits `BuyExecuted` event when successful. Deprecated. /// Emits `pallet_trade_event::Swapped` event when successful. /// #[pallet::call_index(6)] diff --git a/pallets/otc/src/lib.rs b/pallets/otc/src/lib.rs index e33a8672a..113855905 100644 --- a/pallets/otc/src/lib.rs +++ b/pallets/otc/src/lib.rs @@ -268,6 +268,7 @@ pub mod pallet { /// of asset_out multiplied by ExistentialDepositMultiplier /// /// Events: + /// `PartiallyFilled` event when successful. Deprecated. /// `pallet_trade_event::Swapped` event when successful. #[pallet::call_index(1)] #[pallet::weight(::WeightInfo::partial_fill_order())] @@ -329,6 +330,7 @@ pub mod pallet { /// - `order_id`: ID of the order /// /// Events: + /// `Filled` event when successful. Deprecated. /// `pallet_trade_event::Swapped` event when successful. #[pallet::call_index(2)] #[pallet::weight(::WeightInfo::fill_order())] diff --git a/pallets/stableswap/src/lib.rs b/pallets/stableswap/src/lib.rs index ac4509200..c0bf70169 100644 --- a/pallets/stableswap/src/lib.rs +++ b/pallets/stableswap/src/lib.rs @@ -713,6 +713,7 @@ pub mod pallet { /// - `amount_in`: Amount of asset to be sold to the pool /// - `min_buy_amount`: Minimum amount required to receive /// + /// Emits `SellExecuted` event when successful. Deprecated. /// Emits `pallet_trade_event::Swapped` event when successful. /// #[pallet::call_index(7)] @@ -740,6 +741,7 @@ pub mod pallet { /// - `amount_out`: Amount of asset to receive from the pool /// - `max_sell_amount`: Maximum amount allowed to be sold /// + /// Emits `BuyExecuted` event when successful. Deprecated. /// Emits `pallet_trade_event::Swapped` event when successful. /// #[pallet::call_index(8)] diff --git a/pallets/xyk/src/lib.rs b/pallets/xyk/src/lib.rs index d0f929e78..dd31bf78e 100644 --- a/pallets/xyk/src/lib.rs +++ b/pallets/xyk/src/lib.rs @@ -630,6 +630,7 @@ pub mod pallet { /// /// `max_limit` - minimum amount of `asset_out` / amount of asset_out to be obtained from the pool in exchange for `asset_in`. /// + /// Emits `SellExecuted` when successful. Deprecated. /// Emits `pallet_trade_event::Swapped` when successful. #[pallet::call_index(3)] #[pallet::weight(::WeightInfo::sell() + ::AMMHandler::on_trade_weight())] @@ -660,7 +661,7 @@ pub mod pallet { /// Executes a swap of `asset_in` for `asset_out`. Price is determined by the liquidity pool. /// /// `max_limit` - maximum amount of `asset_in` to be sold in exchange for `asset_out`. - /// + /// Emits `BuyExecuted` when successful. Deprecated. /// Emits `pallet_trade_event::Swapped` when successful. #[pallet::call_index(4)] #[pallet::weight(::WeightInfo::buy() + ::AMMHandler::on_trade_weight())] From d01eab33e6c9dd00968ac35131f04a696a358e2a Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Wed, 25 Sep 2024 13:34:18 +0200 Subject: [PATCH 003/142] formatting --- pallets/lbp/src/lib.rs | 6 ++---- pallets/xyk/src/lib.rs | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/pallets/lbp/src/lib.rs b/pallets/lbp/src/lib.rs index 9f704ee4e..ef5c63a3e 100644 --- a/pallets/lbp/src/lib.rs +++ b/pallets/lbp/src/lib.rs @@ -38,8 +38,8 @@ use frame_system::ensure_signed; use frame_system::pallet_prelude::BlockNumberFor; use hydra_dx_math::types::LBPWeight; use hydradx_traits::{AMMTransfer, AssetPairAccountIdFor, CanCreatePool, LockedBalance, AMM}; -use pallet_trade_event::IncrementalIdType; use orml_traits::{MultiCurrency, MultiCurrencyExtended, MultiLockableCurrency}; +use pallet_trade_event::IncrementalIdType; use scale_info::TypeInfo; @@ -943,9 +943,7 @@ impl Pallet { } } -impl AMM, IncrementalIdType> - for Pallet -{ +impl AMM, IncrementalIdType> for Pallet { fn exists(assets: AssetPair) -> bool { let pair_account = Self::pair_account_from_assets(assets.asset_in, assets.asset_out); >::contains_key(&pair_account) diff --git a/pallets/xyk/src/lib.rs b/pallets/xyk/src/lib.rs index 90645480c..213e66a90 100644 --- a/pallets/xyk/src/lib.rs +++ b/pallets/xyk/src/lib.rs @@ -40,8 +40,8 @@ use sp_std::{vec, vec::Vec}; use crate::types::{Amount, AssetId, AssetPair, Balance}; use hydra_dx_math::ratio::Ratio; -use pallet_trade_event::IncrementalIdType; use orml_traits::{MultiCurrency, MultiCurrencyExtended}; +use pallet_trade_event::IncrementalIdType; #[cfg(test)] mod tests; From 5bb6696c11b89f4ce0aed12b1d8351948b1e45a7 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Wed, 25 Sep 2024 18:48:29 +0200 Subject: [PATCH 004/142] additional implementation --- Cargo.lock | 6 + pallets/circuit-breaker/Cargo.toml | 1 + pallets/circuit-breaker/src/tests/mock.rs | 5 + pallets/dca/Cargo.toml | 1 + pallets/dca/src/tests/mock.rs | 17 +- pallets/lbp/src/lib.rs | 5 +- pallets/lbp/src/trade_execution.rs | 16 +- pallets/liquidity-mining/Cargo.toml | 1 + pallets/liquidity-mining/src/tests/mock.rs | 5 +- pallets/omnipool-liquidity-mining/Cargo.toml | 1 + .../src/tests/mock.rs | 5 + pallets/omnipool/src/lib.rs | 394 +++++++++--------- pallets/omnipool/src/router_execution.rs | 3 +- pallets/otc-settlements/Cargo.toml | 1 + pallets/otc-settlements/src/mock.rs | 6 + pallets/route-executor/src/lib.rs | 4 +- pallets/route-executor/src/tests/mock.rs | 11 +- pallets/stableswap/src/lib.rs | 148 ++++--- pallets/stableswap/src/trade_execution.rs | 4 +- .../xyk-liquidity-mining/src/tests/mock.rs | 6 +- pallets/xyk/src/lib.rs | 12 +- pallets/xyk/src/trade_execution.rs | 16 +- runtime/adapters/Cargo.toml | 1 + runtime/adapters/src/tests/mock.rs | 6 + traits/src/lib.rs | 10 +- traits/src/router.rs | 4 +- 26 files changed, 411 insertions(+), 278 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8c8e5567a..b0c1c352f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4918,6 +4918,7 @@ dependencies = [ "pallet-route-executor", "pallet-stableswap", "pallet-staking 3.1.1", + "pallet-trade-event", "pallet-transaction-multi-payment", "pallet-uniques", "pallet-xyk", @@ -7806,6 +7807,7 @@ dependencies = [ "orml-traits", "pallet-balances", "pallet-omnipool", + "pallet-trade-event", "parity-scale-codec", "pretty_assertions", "scale-info", @@ -7958,6 +7960,7 @@ dependencies = [ "pallet-ema-oracle", "pallet-omnipool", "pallet-route-executor", + "pallet-trade-event", "pallet-xyk", "parity-scale-codec", "pretty_assertions", @@ -8484,6 +8487,7 @@ dependencies = [ "pallet-balances", "parity-scale-codec", "pretty_assertions", + "primitives", "proptest", "rand", "scale-info", @@ -8737,6 +8741,7 @@ dependencies = [ "pallet-ema-oracle", "pallet-liquidity-mining", "pallet-omnipool", + "pallet-trade-event", "parity-scale-codec", "pretty_assertions", "primitive-types", @@ -8789,6 +8794,7 @@ dependencies = [ "pallet-omnipool", "pallet-otc", "pallet-route-executor", + "pallet-trade-event", "parity-scale-codec", "parking_lot 0.12.1", "pretty_assertions", diff --git a/pallets/circuit-breaker/Cargo.toml b/pallets/circuit-breaker/Cargo.toml index 5ea64546b..44b5ee9b6 100644 --- a/pallets/circuit-breaker/Cargo.toml +++ b/pallets/circuit-breaker/Cargo.toml @@ -31,6 +31,7 @@ hydradx-traits = { workspace = true } [dev-dependencies] pallet-omnipool = { workspace = true } +pallet-trade-event = { workspace = true } pallet-balances = { workspace = true } orml-tokens = { workspace = true } orml-traits = { workspace = true } diff --git a/pallets/circuit-breaker/src/tests/mock.rs b/pallets/circuit-breaker/src/tests/mock.rs index a28a2ac92..98cc8e358 100644 --- a/pallets/circuit-breaker/src/tests/mock.rs +++ b/pallets/circuit-breaker/src/tests/mock.rs @@ -86,6 +86,7 @@ frame_support::construct_runtime!( Omnipool: pallet_omnipool, Tokens: orml_tokens, CircuitBreaker: pallet_circuit_breaker, + TradeEvent: pallet_trade_event, } ); @@ -226,6 +227,10 @@ impl pallet_omnipool::Config for Test { type Fee = FeeProvider; } +impl pallet_trade_event::Config for Test { + type RuntimeEvent = RuntimeEvent; +} + pub struct CircuitBreakerHooks(PhantomData); impl OmnipoolHooks for CircuitBreakerHooks diff --git a/pallets/dca/Cargo.toml b/pallets/dca/Cargo.toml index 694279c18..fe0d60cca 100644 --- a/pallets/dca/Cargo.toml +++ b/pallets/dca/Cargo.toml @@ -52,6 +52,7 @@ primitives = { path = "../../primitives", default-features = false } pallet-route-executor = { workspace = true } smallvec = "1.9.0" pallet-balances = { workspace = true } +pallet-trade-event = { workspace = true } pallet-currencies = { workspace = true } lazy_static = { features = ["spin_no_std"], version = "1.4.0", default-features = false } sp-api = { workspace = true } diff --git a/pallets/dca/src/tests/mock.rs b/pallets/dca/src/tests/mock.rs index 71387cf76..fe5719cdf 100644 --- a/pallets/dca/src/tests/mock.rs +++ b/pallets/dca/src/tests/mock.rs @@ -23,6 +23,7 @@ use frame_support::weights::constants::ExtrinsicBaseWeight; use frame_support::weights::WeightToFeeCoefficient; use frame_support::weights::{IdentityFee, Weight}; use frame_support::PalletId; +use primitives::IncrementalId; use frame_support::BoundedVec; use frame_support::{assert_ok, parameter_types}; @@ -79,6 +80,7 @@ frame_support::construct_runtime!( Balances: pallet_balances, Currencies: pallet_currencies, EmaOracle: pallet_ema_oracle, + TradeEvent: pallet_trade_event, } ); @@ -350,6 +352,10 @@ parameter_types! { } +impl pallet_trade_event::Config for Test { + type RuntimeEvent = RuntimeEvent; +} + type Pools = (OmniPool, Xyk); impl pallet_route_executor::Config for Test { @@ -361,11 +367,12 @@ impl pallet_route_executor::Config for Test { type AMM = Pools; type InspectRegistry = DummyRegistry; type DefaultRoutePoolType = DefaultRoutePoolType; - type WeightInfo = (); type TechnicalOrigin = EnsureRoot; type EdToRefundCalculator = MockedEdCalculator; type OraclePriceProvider = PriceProviderMock; type OraclePeriod = RouteValidationOraclePeriod; + type BatchIdProvider = TradeEvent; + type WeightInfo = (); } pub struct MockedEdCalculator; @@ -396,7 +403,7 @@ pub const CALCULATED_AMOUNT_IN_FOR_OMNIPOOL_BUY: Balance = 10 * ONE; pub struct OmniPool; pub struct Xyk; -impl TradeExecution for OmniPool { +impl TradeExecution for OmniPool { type Error = DispatchError; fn calculate_sell( @@ -441,6 +448,7 @@ impl TradeExecution for OmniPool asset_out: AssetId, amount_in: Balance, min_limit: Balance, + _batch_id: Option, ) -> Result<(), ExecutorError> { if !matches!(pool_type, PoolType::Omnipool) { return Err(ExecutorError::NotSupported); @@ -480,6 +488,7 @@ impl TradeExecution for OmniPool asset_out: AssetId, amount_out: Balance, max_limit: Balance, + _batch_id: Option, ) -> Result<(), ExecutorError> { if !matches!(pool_type, PoolType::Omnipool) { return Err(ExecutorError::NotSupported); @@ -528,7 +537,7 @@ impl TradeExecution for OmniPool pub const XYK_SELL_CALCULATION_RESULT: Balance = ONE * 5 / 4; pub const XYK_BUY_CALCULATION_RESULT: Balance = ONE / 3; -impl TradeExecution for Xyk { +impl TradeExecution for Xyk { type Error = DispatchError; fn calculate_sell( @@ -564,6 +573,7 @@ impl TradeExecution for Xyk { asset_out: AssetId, amount_in: Balance, min_limit: Balance, + _batch_id: Option, ) -> Result<(), ExecutorError> { if !matches!(pool_type, PoolType::XYK) { return Err(ExecutorError::NotSupported); @@ -596,6 +606,7 @@ impl TradeExecution for Xyk { asset_out: AssetId, amount_out: Balance, max_limit: Balance, + _batch_id: Option, ) -> Result<(), ExecutorError> { if !matches!(pool_type, PoolType::XYK) { return Err(ExecutorError::NotSupported); diff --git a/pallets/lbp/src/lib.rs b/pallets/lbp/src/lib.rs index ef5c63a3e..23e8849f5 100644 --- a/pallets/lbp/src/lib.rs +++ b/pallets/lbp/src/lib.rs @@ -772,7 +772,7 @@ pub mod pallet { ) -> DispatchResult { let who = ensure_signed(origin)?; - >::buy(&who, AssetPair { asset_in, asset_out }, amount, max_limit, false)?; + >::buy(&who, AssetPair { asset_in, asset_out }, amount, max_limit, false, None)?; Ok(()) } @@ -1264,6 +1264,7 @@ impl AMM, IncrementalI fn execute_buy( transfer: &AMMTransfer>, _destination: Option<&T::AccountId>, + batch_id: Option, ) -> dispatch::DispatchResult { Self::execute_trade(transfer)?; @@ -1287,7 +1288,7 @@ impl AMM, IncrementalI transfer.amount, transfer.amount_b, vec![transfer.fee], - None, + batch_id, ); Ok(()) diff --git a/pallets/lbp/src/trade_execution.rs b/pallets/lbp/src/trade_execution.rs index 50ae89e48..c21d71eda 100644 --- a/pallets/lbp/src/trade_execution.rs +++ b/pallets/lbp/src/trade_execution.rs @@ -131,7 +131,6 @@ impl TradeExecution TradeExecution, ) -> Result<(), ExecutorError> { if pool_type != PoolType::LBP { return Err(ExecutorError::NotSupported); } - Self::buy(who, asset_out, asset_in, amount_out, max_limit).map_err(ExecutorError::Error) + let who = crate::ensure_signed(who).map_err(|e| ExecutorError::Error(e.into()))?; + + >::buy( + &who, + AssetPair { asset_in, asset_out }, + amount_out, + max_limit, + false, + batch_id, + ) + .map_err(ExecutorError::Error)?; + + Ok(()) } fn get_liquidity_depth( diff --git a/pallets/liquidity-mining/Cargo.toml b/pallets/liquidity-mining/Cargo.toml index cb103dd88..ba8d3db46 100644 --- a/pallets/liquidity-mining/Cargo.toml +++ b/pallets/liquidity-mining/Cargo.toml @@ -34,6 +34,7 @@ test-utils = { workspace = true } sp-io = { workspace = true } sp-core = { workspace = true } orml-tokens = { workspace = true } +primitives = { workspace = true } pallet-balances = { workspace = true } # This can be updated to lates after rust update(>=1.61) fixed = { version = "=1.15.0", default-features = false } diff --git a/pallets/liquidity-mining/src/tests/mock.rs b/pallets/liquidity-mining/src/tests/mock.rs index f0a270d6d..bad062a8a 100644 --- a/pallets/liquidity-mining/src/tests/mock.rs +++ b/pallets/liquidity-mining/src/tests/mock.rs @@ -24,6 +24,7 @@ use frame_support::{dispatch, parameter_types, traits::Contains, traits::Everyth use frame_system as system; use hydradx_traits::{pools::DustRemovalAccountWhitelist, registry::Inspect, AMMTransfer, AssetKind, AMM}; use orml_traits::GetByKey; +use primitives::IncrementalId; use sp_core::H256; use sp_runtime::{ traits::{BlakeTwo256, BlockNumberProvider, IdentityLookup}, @@ -172,7 +173,7 @@ thread_local! { pub static DUSTER_WHITELIST: RefCell> = RefCell::new(Vec::new()); } -impl AMM for Amm { +impl AMM for Amm { fn get_max_out_ratio() -> u128 { 0_u32.into() } @@ -209,12 +210,14 @@ impl AMM for Amm { fn execute_buy( _transfer: &AMMTransfer, _destination: Option<&AccountId>, + _batch_id: Option, ) -> dispatch::DispatchResult { Err(sp_runtime::DispatchError::Other("NotImplemented")) } fn execute_sell( _transfer: &hydradx_traits::AMMTransfer, + _batch_id: Option, ) -> frame_support::dispatch::DispatchResult { Err(sp_runtime::DispatchError::Other("NotImplemented")) } diff --git a/pallets/omnipool-liquidity-mining/Cargo.toml b/pallets/omnipool-liquidity-mining/Cargo.toml index e90e2ac97..dbe97ea2b 100644 --- a/pallets/omnipool-liquidity-mining/Cargo.toml +++ b/pallets/omnipool-liquidity-mining/Cargo.toml @@ -51,6 +51,7 @@ sp-io = { workspace = true, optional = true } [dev-dependencies] sp-io = { workspace = true } sp-core = { workspace = true } +pallet-trade-event = { workspace = true } orml-tokens = { workspace = true } pretty_assertions = "1.2.1" diff --git a/pallets/omnipool-liquidity-mining/src/tests/mock.rs b/pallets/omnipool-liquidity-mining/src/tests/mock.rs index a04e8cfd1..f2fc7b7c2 100644 --- a/pallets/omnipool-liquidity-mining/src/tests/mock.rs +++ b/pallets/omnipool-liquidity-mining/src/tests/mock.rs @@ -110,6 +110,7 @@ construct_runtime!( WarehouseLM: warehouse_liquidity_mining::, OmnipoolMining: omnipool_liquidity_mining, EmaOracle: pallet_ema_oracle, + TradeEvent: pallet_trade_event, } ); @@ -301,6 +302,10 @@ impl pallet_omnipool::Config for Test { type Fee = FeeProvider; } +impl pallet_trade_event::Config for Test { + type RuntimeEvent = RuntimeEvent; +} + pub struct ExtBuilder { endowed_accounts: Vec<(AccountId, AssetId, Balance)>, registered_assets: Vec, diff --git a/pallets/omnipool/src/lib.rs b/pallets/omnipool/src/lib.rs index fb68f1fe0..526efe3c6 100644 --- a/pallets/omnipool/src/lib.rs +++ b/pallets/omnipool/src/lib.rs @@ -88,6 +88,7 @@ use frame_support::pallet_prelude::{DispatchResult, Get}; use frame_support::require_transactional; use frame_support::PalletId; use frame_support::{ensure, transactional}; +use frame_system::{ensure_signed, pallet_prelude::OriginFor}; use sp_runtime::traits::{AccountIdConversion, AtLeast32BitUnsigned, One}; use sp_runtime::traits::{CheckedAdd, CheckedSub, Zero}; use sp_std::ops::{Add, Sub}; @@ -1075,197 +1076,7 @@ pub mod pallet { amount: Balance, max_sell_amount: Balance, ) -> DispatchResult { - let who = ensure_signed(origin.clone())?; - - ensure!(asset_in != asset_out, Error::::SameAssetTradeNotAllowed); - - ensure!( - amount >= T::MinimumTradingLimit::get(), - Error::::InsufficientTradingAmount - ); - - // Special handling when one of the asset is Hub Asset - if asset_out == T::HubAssetId::get() { - return Self::buy_hub_asset(&who, asset_in, amount, max_sell_amount); - } - - if asset_in == T::HubAssetId::get() { - return Self::buy_asset_for_hub_asset(origin, &who, asset_out, amount, max_sell_amount); - } - - let asset_in_state = Self::load_asset_state(asset_in)?; - let asset_out_state = Self::load_asset_state(asset_out)?; - - ensure!( - Self::allow_assets(&asset_in_state, &asset_out_state), - Error::::NotAllowed - ); - - ensure!(asset_out_state.reserve >= amount, Error::::InsufficientLiquidity); - - ensure!( - amount - <= asset_out_state - .reserve - .checked_div(T::MaxOutRatio::get()) - .ok_or(ArithmeticError::DivisionByZero)?, // Note: Let's be safe. this can only fail if MaxOutRatio is zero. - Error::::MaxOutRatioExceeded - ); - - let current_imbalance = >::get(); - - let (asset_fee, _) = T::Fee::get(&asset_out); - let (_, protocol_fee) = T::Fee::get(&asset_in); - let state_changes = hydra_dx_math::omnipool::calculate_buy_state_changes( - &(&asset_in_state).into(), - &(&asset_out_state).into(), - amount, - asset_fee, - protocol_fee, - current_imbalance.value, - ) - .ok_or(ArithmeticError::Overflow)?; - - ensure!( - T::Currency::ensure_can_withdraw(asset_in, &who, *state_changes.asset_in.delta_reserve).is_ok(), - Error::::InsufficientBalance - ); - - ensure!( - *state_changes.asset_in.delta_reserve <= max_sell_amount, - Error::::SellLimitExceeded - ); - - ensure!( - *state_changes.asset_in.delta_reserve - <= asset_in_state - .reserve - .checked_div(T::MaxInRatio::get()) - .ok_or(ArithmeticError::DivisionByZero)?, // Note: this can only fail if MaxInRatio is zero. - Error::::MaxInRatioExceeded - ); - - let new_asset_in_state = asset_in_state - .delta_update(&state_changes.asset_in) - .ok_or(ArithmeticError::Overflow)?; - let new_asset_out_state = asset_out_state - .delta_update(&state_changes.asset_out) - .ok_or(ArithmeticError::Overflow)?; - - debug_assert_eq!( - *state_changes.asset_out.delta_reserve, amount, - "delta_reserve_out is not equal to given amount out" - ); - - T::Currency::transfer( - asset_in, - &who, - &Self::protocol_account(), - *state_changes.asset_in.delta_reserve, - )?; - T::Currency::transfer( - asset_out, - &Self::protocol_account(), - &who, - *state_changes.asset_out.delta_reserve, - )?; - - // Hub liquidity update - work out difference between in and amount so only one update is needed. - let delta_hub_asset = state_changes - .asset_in - .delta_hub_reserve - .merge( - state_changes - .asset_out - .delta_hub_reserve - .merge(BalanceUpdate::Increase(state_changes.hdx_hub_amount)) - .ok_or(ArithmeticError::Overflow)?, - ) - .ok_or(ArithmeticError::Overflow)?; - - match delta_hub_asset { - BalanceUpdate::Increase(val) if val == Balance::zero() => { - // nothing to do if zero. - } - BalanceUpdate::Increase(_) => { - // trade can only burn some. This would be a bug. - return Err(Error::::HubAssetUpdateError.into()); - } - BalanceUpdate::Decrease(amount) => { - T::Currency::withdraw(T::HubAssetId::get(), &Self::protocol_account(), amount)?; - } - }; - - // Callback hook info - let info_in: AssetInfo = AssetInfo::new( - asset_in, - &asset_in_state, - &new_asset_in_state, - &state_changes.asset_in, - false, - ); - - let info_out: AssetInfo = AssetInfo::new( - asset_out, - &asset_out_state, - &new_asset_out_state, - &state_changes.asset_out, - false, - ); - - Self::update_imbalance(state_changes.delta_imbalance)?; - Self::set_asset_state(asset_in, new_asset_in_state); - Self::set_asset_state(asset_out, new_asset_out_state); - - T::OmnipoolHooks::on_trade(origin.clone(), info_in, info_out)?; - - Self::update_hdx_subpool_hub_asset(origin, state_changes.hdx_hub_amount)?; - - Self::process_trade_fee(&who, asset_out, state_changes.fee.asset_fee)?; - - debug_assert!(*state_changes.asset_in.delta_hub_reserve >= *state_changes.asset_out.delta_hub_reserve); - debug_assert_eq!( - *state_changes.asset_in.delta_hub_reserve - *state_changes.asset_out.delta_hub_reserve, - state_changes.fee.protocol_fee - ); - - // TODO: Deprecated, remove when ready - Self::deposit_event(Event::BuyExecuted { - who: who.clone(), - asset_in, - asset_out, - amount_in: *state_changes.asset_in.delta_reserve, - amount_out: *state_changes.asset_out.delta_reserve, - hub_amount_in: *state_changes.asset_in.delta_hub_reserve, - hub_amount_out: *state_changes.asset_out.delta_hub_reserve, - asset_fee_amount: state_changes.fee.asset_fee, - protocol_fee_amount: state_changes.fee.protocol_fee, - }); - - Self::deposit_event(Event::HubAmountUpdated { - hub_amount_in: *state_changes.asset_in.delta_hub_reserve, - hub_amount_out: *state_changes.asset_out.delta_hub_reserve, - }); - - pallet_trade_event::Pallet::::deposit_trade_event( - who.clone(), - pallet_trade_event::PoolType::Omnipool, - pallet_trade_event::TradeOperation::Buy, - asset_in.into(), - asset_out.into(), - *state_changes.asset_in.delta_reserve, - *state_changes.asset_out.delta_reserve, - vec![], // TODO - None, - ); - - #[cfg(feature = "try-runtime")] - Self::ensure_trade_invariant( - (asset_in, asset_in_state, new_asset_in_state), - (asset_out, asset_out_state, new_asset_out_state), - ); - - Ok(()) + Self::do_buy(origin, asset_out, asset_in, amount, max_sell_amount, None) } /// Update asset's tradable state. @@ -1881,6 +1692,207 @@ impl Pallet { Ok(()) } + fn do_buy( + origin: OriginFor, + asset_out: T::AssetId, + asset_in: T::AssetId, + amount: Balance, + max_sell_amount: Balance, + batch_id: Option, + ) -> DispatchResult { + let who = ensure_signed(origin.clone())?; + + ensure!(asset_in != asset_out, Error::::SameAssetTradeNotAllowed); + + ensure!( + amount >= T::MinimumTradingLimit::get(), + Error::::InsufficientTradingAmount + ); + + // Special handling when one of the asset is Hub Asset + if asset_out == T::HubAssetId::get() { + return Self::buy_hub_asset(&who, asset_in, amount, max_sell_amount); + } + + if asset_in == T::HubAssetId::get() { + return Self::buy_asset_for_hub_asset(origin, &who, asset_out, amount, max_sell_amount); + } + + let asset_in_state = Self::load_asset_state(asset_in)?; + let asset_out_state = Self::load_asset_state(asset_out)?; + + ensure!( + Self::allow_assets(&asset_in_state, &asset_out_state), + Error::::NotAllowed + ); + + ensure!(asset_out_state.reserve >= amount, Error::::InsufficientLiquidity); + + ensure!( + amount + <= asset_out_state + .reserve + .checked_div(T::MaxOutRatio::get()) + .ok_or(ArithmeticError::DivisionByZero)?, // Note: Let's be safe. this can only fail if MaxOutRatio is zero. + Error::::MaxOutRatioExceeded + ); + + let current_imbalance = >::get(); + + let (asset_fee, _) = T::Fee::get(&asset_out); + let (_, protocol_fee) = T::Fee::get(&asset_in); + let state_changes = hydra_dx_math::omnipool::calculate_buy_state_changes( + &(&asset_in_state).into(), + &(&asset_out_state).into(), + amount, + asset_fee, + protocol_fee, + current_imbalance.value, + ) + .ok_or(ArithmeticError::Overflow)?; + + ensure!( + T::Currency::ensure_can_withdraw(asset_in, &who, *state_changes.asset_in.delta_reserve).is_ok(), + Error::::InsufficientBalance + ); + + ensure!( + *state_changes.asset_in.delta_reserve <= max_sell_amount, + Error::::SellLimitExceeded + ); + + ensure!( + *state_changes.asset_in.delta_reserve + <= asset_in_state + .reserve + .checked_div(T::MaxInRatio::get()) + .ok_or(ArithmeticError::DivisionByZero)?, // Note: this can only fail if MaxInRatio is zero. + Error::::MaxInRatioExceeded + ); + + let new_asset_in_state = asset_in_state + .delta_update(&state_changes.asset_in) + .ok_or(ArithmeticError::Overflow)?; + let new_asset_out_state = asset_out_state + .delta_update(&state_changes.asset_out) + .ok_or(ArithmeticError::Overflow)?; + + debug_assert_eq!( + *state_changes.asset_out.delta_reserve, amount, + "delta_reserve_out is not equal to given amount out" + ); + + T::Currency::transfer( + asset_in, + &who, + &Self::protocol_account(), + *state_changes.asset_in.delta_reserve, + )?; + T::Currency::transfer( + asset_out, + &Self::protocol_account(), + &who, + *state_changes.asset_out.delta_reserve, + )?; + + // Hub liquidity update - work out difference between in and amount so only one update is needed. + let delta_hub_asset = state_changes + .asset_in + .delta_hub_reserve + .merge( + state_changes + .asset_out + .delta_hub_reserve + .merge(BalanceUpdate::Increase(state_changes.hdx_hub_amount)) + .ok_or(ArithmeticError::Overflow)?, + ) + .ok_or(ArithmeticError::Overflow)?; + + match delta_hub_asset { + BalanceUpdate::Increase(val) if val == Balance::zero() => { + // nothing to do if zero. + } + BalanceUpdate::Increase(_) => { + // trade can only burn some. This would be a bug. + return Err(Error::::HubAssetUpdateError.into()); + } + BalanceUpdate::Decrease(amount) => { + T::Currency::withdraw(T::HubAssetId::get(), &Self::protocol_account(), amount)?; + } + }; + + // Callback hook info + let info_in: AssetInfo = AssetInfo::new( + asset_in, + &asset_in_state, + &new_asset_in_state, + &state_changes.asset_in, + false, + ); + + let info_out: AssetInfo = AssetInfo::new( + asset_out, + &asset_out_state, + &new_asset_out_state, + &state_changes.asset_out, + false, + ); + + Self::update_imbalance(state_changes.delta_imbalance)?; + Self::set_asset_state(asset_in, new_asset_in_state); + Self::set_asset_state(asset_out, new_asset_out_state); + + T::OmnipoolHooks::on_trade(origin.clone(), info_in, info_out)?; + + Self::update_hdx_subpool_hub_asset(origin, state_changes.hdx_hub_amount)?; + + Self::process_trade_fee(&who, asset_out, state_changes.fee.asset_fee)?; + + debug_assert!(*state_changes.asset_in.delta_hub_reserve >= *state_changes.asset_out.delta_hub_reserve); + debug_assert_eq!( + *state_changes.asset_in.delta_hub_reserve - *state_changes.asset_out.delta_hub_reserve, + state_changes.fee.protocol_fee + ); + + // TODO: Deprecated, remove when ready + Self::deposit_event(Event::BuyExecuted { + who: who.clone(), + asset_in, + asset_out, + amount_in: *state_changes.asset_in.delta_reserve, + amount_out: *state_changes.asset_out.delta_reserve, + hub_amount_in: *state_changes.asset_in.delta_hub_reserve, + hub_amount_out: *state_changes.asset_out.delta_hub_reserve, + asset_fee_amount: state_changes.fee.asset_fee, + protocol_fee_amount: state_changes.fee.protocol_fee, + }); + + Self::deposit_event(Event::HubAmountUpdated { + hub_amount_in: *state_changes.asset_in.delta_hub_reserve, + hub_amount_out: *state_changes.asset_out.delta_hub_reserve, + }); + + pallet_trade_event::Pallet::::deposit_trade_event( + who.clone(), + pallet_trade_event::PoolType::Omnipool, + pallet_trade_event::TradeOperation::Buy, + asset_in.into(), + asset_out.into(), + *state_changes.asset_in.delta_reserve, + *state_changes.asset_out.delta_reserve, + vec![], // TODO + batch_id, + ); + + #[cfg(feature = "try-runtime")] + Self::ensure_trade_invariant( + (asset_in, asset_in_state, new_asset_in_state), + (asset_out, asset_out_state, new_asset_out_state), + ); + + Ok(()) + } + /// Swap hub asset for asset_out. /// Special handling of sell trade where asset in is Hub Asset. fn sell_hub_asset( diff --git a/pallets/omnipool/src/router_execution.rs b/pallets/omnipool/src/router_execution.rs index 356249a37..6767504fa 100644 --- a/pallets/omnipool/src/router_execution.rs +++ b/pallets/omnipool/src/router_execution.rs @@ -148,12 +148,13 @@ impl TradeExecution, T::AccountId, T::AssetId, Balance, asset_out: T::AssetId, amount_out: Balance, max_limit: Balance, + batch_id: Option, ) -> Result<(), ExecutorError> { if pool_type != PoolType::Omnipool { return Err(ExecutorError::NotSupported); } - Self::buy(who, asset_out, asset_in, amount_out, max_limit).map_err(ExecutorError::Error) + Self::do_buy(who, asset_out, asset_in, amount_out, max_limit, batch_id).map_err(ExecutorError::Error) } fn get_liquidity_depth( diff --git a/pallets/otc-settlements/Cargo.toml b/pallets/otc-settlements/Cargo.toml index 24e23f5d2..e1bc659dc 100644 --- a/pallets/otc-settlements/Cargo.toml +++ b/pallets/otc-settlements/Cargo.toml @@ -39,6 +39,7 @@ pallet-asset-registry = { workspace = true } pallet-route-executor = { workspace = true } pallet-balances = { workspace = true } pallet-currencies = { workspace = true } +pallet-trade-event = { workspace = true } sp-api = { workspace = true } orml-traits = { workspace = true } orml-tokens = { workspace = true, features=["std"] } diff --git a/pallets/otc-settlements/src/mock.rs b/pallets/otc-settlements/src/mock.rs index 0fb3789c9..113db5834 100644 --- a/pallets/otc-settlements/src/mock.rs +++ b/pallets/otc-settlements/src/mock.rs @@ -74,6 +74,7 @@ frame_support::construct_runtime!( Omnipool: pallet_omnipool, Router: pallet_route_executor, OtcSettlements: pallet_otc_settlements, + TradeEvent: pallet_trade_event, } ); @@ -156,6 +157,7 @@ impl pallet_route_executor::Config for Test { type OraclePeriod = RouteValidationOraclePeriod; type DefaultRoutePoolType = DefaultRoutePoolType; type TechnicalOrigin = EnsureRoot; + type BatchIdProvider = TradeEvent; type WeightInfo = (); } @@ -251,6 +253,10 @@ impl pallet_currencies::Config for Test { type WeightInfo = (); } +impl pallet_trade_event::Config for Test { + type RuntimeEvent = RuntimeEvent; +} + parameter_types! { pub const MinTradingLimit: Balance = 1_000; pub const MinPoolLiquidity: Balance = 1_000; diff --git a/pallets/route-executor/src/lib.rs b/pallets/route-executor/src/lib.rs index 1bd07318b..d87fa8183 100644 --- a/pallets/route-executor/src/lib.rs +++ b/pallets/route-executor/src/lib.rs @@ -258,6 +258,7 @@ pub mod pallet { ensure!(first_trade.amount_in <= max_amount_in, Error::::TradingLimitReached); let route_length = route.len(); + let next_batch_id = T::BatchIdProvider::next_id(); for (trade_index, (trade_amount, trade)) in trade_amounts.iter().rev().zip(route).enumerate() { Self::disable_ed_handling_for_insufficient_assets(route_length, trade_index, trade); let user_balance_of_asset_out_before_trade = @@ -269,6 +270,7 @@ pub mod pallet { trade.asset_out, trade_amount.amount_out, trade_amount.amount_in, + Some(next_batch_id), ); handle_execution_error!(execution_result); @@ -488,13 +490,13 @@ impl Pallet { ); let route_length = route.len(); + let next_batch_id = T::BatchIdProvider::next_id(); for (trade_index, (trade_amount, trade)) in trade_amounts.iter().zip(route.clone()).enumerate() { Self::disable_ed_handling_for_insufficient_assets(route_length, trade_index, trade); let user_balance_of_asset_in_before_trade = T::Currency::reducible_balance(trade.asset_in, &who, Preservation::Expendable, Fortitude::Polite); - let next_batch_id = T::BatchIdProvider::next_id(); let execution_result = T::AMM::execute_sell( origin.clone(), trade.pool, diff --git a/pallets/route-executor/src/tests/mock.rs b/pallets/route-executor/src/tests/mock.rs index 0363cf739..d28655a55 100644 --- a/pallets/route-executor/src/tests/mock.rs +++ b/pallets/route-executor/src/tests/mock.rs @@ -28,6 +28,7 @@ use hydradx_traits::router::{ExecutorError, PoolType, RefundEdCalculator, TradeE use orml_traits::parameter_type_with_key; use pallet_currencies::{fungibles::FungibleCurrencies, BasicCurrencyAdapter}; use pretty_assertions::assert_eq; +use primitives::IncrementalId; use sp_core::H256; use sp_runtime::FixedU128; use sp_runtime::{ @@ -50,6 +51,7 @@ frame_support::construct_runtime!( Tokens: orml_tokens, Balances: pallet_balances, Currencies: pallet_currencies, + TradeEvent: pallet_trade_event, } ); @@ -136,6 +138,10 @@ impl pallet_currencies::Config for Test { type WeightInfo = (); } +impl pallet_trade_event::Config for Test { + type RuntimeEvent = RuntimeEvent; +} + type Pools = (XYK, StableSwap, OmniPool, LBP); parameter_types! { @@ -158,6 +164,7 @@ impl Config for Test { type OraclePeriod = RouteValidationOraclePeriod; type DefaultRoutePoolType = DefaultRoutePoolType; type TechnicalOrigin = EnsureRoot; + type BatchIdProvider = TradeEvent; type WeightInfo = (); } @@ -332,7 +339,7 @@ type OriginForRuntime = OriginFor; macro_rules! impl_fake_executor { ($pool_struct:ident, $pool_type: pat, $sell_calculation_result: expr, $buy_calculation_result: expr) => { - impl TradeExecution for $pool_struct { + impl TradeExecution for $pool_struct { type Error = DispatchError; fn calculate_sell( @@ -376,6 +383,7 @@ macro_rules! impl_fake_executor { asset_out: AssetId, amount_in: Balance, _min_limit: Balance, + _batch_id: Option, ) -> Result<(), ExecutorError> { let who = ensure_signed(who).map_err(|_| ExecutorError::Error(DispatchError::Other("Wrong origin")))?; if !matches!(pool_type, $pool_type) { @@ -414,6 +422,7 @@ macro_rules! impl_fake_executor { asset_out: AssetId, amount_out: Balance, _max_limit: Balance, + _batch_id: Option, ) -> Result<(), ExecutorError> { let who = ensure_signed(who).map_err(|_| ExecutorError::Error(DispatchError::Other("Wrong origin")))?; diff --git a/pallets/stableswap/src/lib.rs b/pallets/stableswap/src/lib.rs index c0bf70169..13f90fb73 100644 --- a/pallets/stableswap/src/lib.rs +++ b/pallets/stableswap/src/lib.rs @@ -55,7 +55,10 @@ extern crate core; use frame_support::pallet_prelude::{DispatchResult, Get}; use frame_support::{ensure, require_transactional, transactional, PalletId}; -use frame_system::pallet_prelude::BlockNumberFor; +use frame_system::{ + ensure_signed, + pallet_prelude::{BlockNumberFor, OriginFor}, +}; use hydradx_traits::{registry::Inspect, AccountIdFor}; pub use pallet::*; use sp_runtime::traits::{AccountIdConversion, BlockNumberProvider, Zero}; @@ -100,7 +103,6 @@ pub mod pallet { use codec::HasCompact; use core::ops::RangeInclusive; use frame_support::pallet_prelude::*; - use frame_system::pallet_prelude::*; use hydradx_traits::pools::DustRemovalAccountWhitelist; use sp_runtime::traits::{BlockNumberProvider, Zero}; use sp_runtime::ArithmeticError; @@ -756,71 +758,7 @@ pub mod pallet { amount_out: Balance, max_sell_amount: Balance, ) -> DispatchResult { - let who = ensure_signed(origin)?; - - ensure!(asset_in != asset_out, Error::::NotAllowed); - - ensure!( - Self::is_asset_allowed(pool_id, asset_in, Tradability::SELL) - && Self::is_asset_allowed(pool_id, asset_out, Tradability::BUY), - Error::::NotAllowed - ); - - ensure!( - amount_out >= T::MinTradingLimit::get(), - Error::::InsufficientTradingAmount - ); - - let pool = Pools::::get(pool_id).ok_or(Error::::PoolNotFound)?; - let pool_account = Self::pool_account(pool_id); - let initial_reserves = pool - .reserves_with_decimals::(&pool_account) - .ok_or(Error::::UnknownDecimals)?; - - let (amount_in, fee_amount) = Self::calculate_in_amount(pool_id, asset_in, asset_out, amount_out)?; - - let pool_account = Self::pool_account(pool_id); - - ensure!(amount_in <= max_sell_amount, Error::::SellLimitExceeded); - - ensure!( - T::Currency::free_balance(asset_in, &who) >= amount_in, - Error::::InsufficientBalance - ); - - T::Currency::transfer(asset_in, &who, &pool_account, amount_in)?; - T::Currency::transfer(asset_out, &pool_account, &who, amount_out)?; - - //All done and updated. Let's call on_trade_hook. - Self::call_on_trade_hook(pool_id, asset_in, asset_out, &initial_reserves)?; - - // TODO: Deprecated, remove when ready - Self::deposit_event(Event::BuyExecuted { - who: who.clone(), - pool_id, - asset_in, - asset_out, - amount_in, - amount_out, - fee: fee_amount, - }); - - pallet_trade_event::Pallet::::deposit_trade_event( - who, - pallet_trade_event::PoolType::Stableswap(pool_id.into()), - pallet_trade_event::TradeOperation::Buy, - asset_in.into(), - asset_out.into(), - amount_in, - amount_out, - vec![(asset_in.into(), fee_amount)], - None, - ); - - #[cfg(feature = "try-runtime")] - Self::ensure_trade_invariant(pool_id, &initial_reserves, pool.fee); - - Ok(()) + Self::do_buy(origin, pool_id, asset_out, asset_in, amount_out, max_sell_amount, None) } #[pallet::call_index(9)] @@ -934,6 +872,82 @@ impl Pallet { Ok(()) } + fn do_buy( + origin: OriginFor, + pool_id: T::AssetId, + asset_out: T::AssetId, + asset_in: T::AssetId, + amount_out: Balance, + max_sell_amount: Balance, + batch_id: Option, + ) -> DispatchResult { + let who = ensure_signed(origin)?; + + ensure!(asset_in != asset_out, Error::::NotAllowed); + + ensure!( + Self::is_asset_allowed(pool_id, asset_in, Tradability::SELL) + && Self::is_asset_allowed(pool_id, asset_out, Tradability::BUY), + Error::::NotAllowed + ); + + ensure!( + amount_out >= T::MinTradingLimit::get(), + Error::::InsufficientTradingAmount + ); + + let pool = Pools::::get(pool_id).ok_or(Error::::PoolNotFound)?; + let pool_account = Self::pool_account(pool_id); + let initial_reserves = pool + .reserves_with_decimals::(&pool_account) + .ok_or(Error::::UnknownDecimals)?; + + let (amount_in, fee_amount) = Self::calculate_in_amount(pool_id, asset_in, asset_out, amount_out)?; + + let pool_account = Self::pool_account(pool_id); + + ensure!(amount_in <= max_sell_amount, Error::::SellLimitExceeded); + + ensure!( + T::Currency::free_balance(asset_in, &who) >= amount_in, + Error::::InsufficientBalance + ); + + T::Currency::transfer(asset_in, &who, &pool_account, amount_in)?; + T::Currency::transfer(asset_out, &pool_account, &who, amount_out)?; + + //All done and updated. Let's call on_trade_hook. + Self::call_on_trade_hook(pool_id, asset_in, asset_out, &initial_reserves)?; + + // TODO: Deprecated, remove when ready + Self::deposit_event(Event::BuyExecuted { + who: who.clone(), + pool_id, + asset_in, + asset_out, + amount_in, + amount_out, + fee: fee_amount, + }); + + pallet_trade_event::Pallet::::deposit_trade_event( + who, + pallet_trade_event::PoolType::Stableswap(pool_id.into()), + pallet_trade_event::TradeOperation::Buy, + asset_in.into(), + asset_out.into(), + amount_in, + amount_out, + vec![(asset_in.into(), fee_amount)], + batch_id, + ); + + #[cfg(feature = "try-runtime")] + Self::ensure_trade_invariant(pool_id, &initial_reserves, pool.fee); + + Ok(()) + } + /// Calculates out amount given in amount. /// Returns (out_amount, fee_amount) on success. Note that fee amount is already subtracted from the out amount. fn calculate_out_amount( diff --git a/pallets/stableswap/src/trade_execution.rs b/pallets/stableswap/src/trade_execution.rs index 4795efb42..19d8affb7 100644 --- a/pallets/stableswap/src/trade_execution.rs +++ b/pallets/stableswap/src/trade_execution.rs @@ -176,6 +176,7 @@ where asset_out: T::AssetId, amount_out: Balance, max_limit: Balance, + batch_id: Option, ) -> Result<(), ExecutorError> { match pool_type { PoolType::Stableswap(pool_id) => { @@ -186,7 +187,8 @@ where Self::withdraw_asset_amount(who, pool_id, asset_out, amount_out, max_limit) .map_err(ExecutorError::Error) } else { - Self::buy(who, pool_id, asset_out, asset_in, amount_out, max_limit).map_err(ExecutorError::Error) + Self::do_buy(who, pool_id, asset_out, asset_in, amount_out, max_limit, batch_id) + .map_err(ExecutorError::Error) } } _ => Err(ExecutorError::NotSupported), diff --git a/pallets/xyk-liquidity-mining/src/tests/mock.rs b/pallets/xyk-liquidity-mining/src/tests/mock.rs index c8d8b3939..7f95249ae 100644 --- a/pallets/xyk-liquidity-mining/src/tests/mock.rs +++ b/pallets/xyk-liquidity-mining/src/tests/mock.rs @@ -31,7 +31,7 @@ use hydradx_traits::{pools::DustRemovalAccountWhitelist, AMMPosition, AMMTransfe use orml_traits::parameter_type_with_key; use pallet_liquidity_mining::{FarmMultiplier, YieldFarmId}; use pallet_xyk::types::{AssetId, AssetPair, Balance}; -use primitives::{Amount, ItemId}; +use primitives::{Amount, IncrementalId, ItemId}; use sp_core::H256; use sp_runtime::{ traits::{BlakeTwo256, BlockNumberProvider, IdentityLookup}, @@ -198,7 +198,7 @@ pub struct DummyFarmEntry { pub struct DummyAMM; -impl AMM for DummyAMM { +impl AMM for DummyAMM { fn get_max_out_ratio() -> u128 { 0_u32.into() } @@ -238,12 +238,14 @@ impl AMM for DummyAMM { fn execute_buy( _transfer: &AMMTransfer, _destination: Option<&AccountId>, + _batch_id: Option, ) -> dispatch::DispatchResult { Err(sp_runtime::DispatchError::Other("NotImplemented")) } fn execute_sell( _transfer: &hydradx_traits::AMMTransfer, + _batch_id: Option, ) -> frame_support::dispatch::DispatchResult { Err(sp_runtime::DispatchError::Other("NotImplemented")) } diff --git a/pallets/xyk/src/lib.rs b/pallets/xyk/src/lib.rs index 213e66a90..a04f0546b 100644 --- a/pallets/xyk/src/lib.rs +++ b/pallets/xyk/src/lib.rs @@ -675,7 +675,14 @@ pub mod pallet { ) -> DispatchResult { let who = ensure_signed(origin)?; - >::buy(&who, AssetPair { asset_in, asset_out }, amount, max_limit, discount)?; + >::buy( + &who, + AssetPair { asset_in, asset_out }, + amount, + max_limit, + discount, + None, + )?; Ok(()) } @@ -1046,6 +1053,7 @@ impl AMM, destination: Option<&T::AccountId>, + batch_id: Option, ) -> DispatchResult { let pair_account = Self::get_pair_id(transfer.assets); @@ -1102,7 +1110,7 @@ impl AMM TradeExecution TradeExecution, ) -> Result<(), ExecutorError> { if pool_type != PoolType::XYK { return Err(ExecutorError::NotSupported); } - Self::buy(who, asset_out, asset_in, amount_out, max_limit, false).map_err(ExecutorError::Error) + let who = crate::ensure_signed(who).map_err(|e| ExecutorError::Error(e.into()))?; + + >::buy( + &who, + AssetPair { asset_in, asset_out }, + amount_out, + max_limit, + false, + batch_id, + ) + .map_err(ExecutorError::Error)?; + + Ok(()) } fn get_liquidity_depth( diff --git a/runtime/adapters/Cargo.toml b/runtime/adapters/Cargo.toml index d6ca4836a..58f6d8d4b 100644 --- a/runtime/adapters/Cargo.toml +++ b/runtime/adapters/Cargo.toml @@ -66,6 +66,7 @@ pallet-balances = { workspace = true } lazy_static = { features = ["spin_no_std"], version = "1.4.0" } pretty_assertions = "1.4.0" pallet-xyk = { workspace = true } +pallet-trade-event = { workspace = true } [features] default = ["std"] diff --git a/runtime/adapters/src/tests/mock.rs b/runtime/adapters/src/tests/mock.rs index 149ef9140..85f0752d2 100644 --- a/runtime/adapters/src/tests/mock.rs +++ b/runtime/adapters/src/tests/mock.rs @@ -101,6 +101,7 @@ construct_runtime!( RouteExecutor: pallet_route_executor, Currencies: pallet_currencies, XYK: pallet_xyk, + TradeEvent: pallet_trade_event, } ); @@ -257,6 +258,10 @@ impl pallet_xyk::Config for Test { type NonDustableWhitelistHandler = DummyDuster; } +impl pallet_trade_event::Config for Test { + type RuntimeEvent = RuntimeEvent; +} + pub struct Whitelist; impl Contains for Whitelist { @@ -335,6 +340,7 @@ impl pallet_route_executor::Config for Test { type DefaultRoutePoolType = DefaultRoutePoolType; type TechnicalOrigin = EnsureRoot; type OraclePeriod = RouteValidationOraclePeriod; + type BatchIdProvider = TradeEvent; type WeightInfo = (); } diff --git a/traits/src/lib.rs b/traits/src/lib.rs index 97c3323e6..8eee05a3e 100644 --- a/traits/src/lib.rs +++ b/traits/src/lib.rs @@ -118,6 +118,7 @@ pub trait AMM { fn execute_buy( transfer: &AMMTransfer, destination: Option<&AccountId>, + batch_id: Option, ) -> dispatch::DispatchResult; /// Perform asset swap. @@ -127,8 +128,14 @@ pub trait AMM { amount: Amount, max_limit: Amount, discount: bool, + batch_id: Option, ) -> dispatch::DispatchResult { - Self::execute_buy(&Self::validate_buy(origin, assets, amount, max_limit, discount)?, None)?; + Self::execute_buy( + &Self::validate_buy(origin, assets, amount, max_limit, discount)?, + None, + batch_id, + )?; + Ok(()) } @@ -144,6 +151,7 @@ pub trait AMM { Self::execute_buy( &Self::validate_buy(origin, assets, amount, max_limit, discount)?, Some(dest), + None, )?; Ok(()) } diff --git a/traits/src/router.rs b/traits/src/router.rs index 2ebab2aac..db67a32c9 100644 --- a/traits/src/router.rs +++ b/traits/src/router.rs @@ -184,6 +184,7 @@ pub trait TradeExecution { asset_out: AssetId, amount_out: Balance, max_limit: Balance, + batch_id: Option, ) -> Result<(), ExecutorError>; fn get_liquidity_depth( @@ -271,10 +272,11 @@ impl, ) -> Result<(), ExecutorError> { for_tuples!( #( - let value = match Tuple::execute_buy(who.clone(), pool_type,asset_in, asset_out, amount_out, max_limit) { + let value = match Tuple::execute_buy(who.clone(), pool_type,asset_in, asset_out, amount_out, max_limit, batch_id) { Ok(result) => return Ok(result), Err(v) if v == ExecutorError::NotSupported => v, Err(v) => return Err(v), From 3ad68ab5c56c1361dedc1cbc51fa1ac7f6d781a5 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Wed, 25 Sep 2024 19:38:03 +0200 Subject: [PATCH 005/142] rename batch_id to event_id --- pallets/dca/src/tests/mock.rs | 8 ++++---- pallets/lbp/src/lib.rs | 8 ++++---- pallets/lbp/src/trade_execution.rs | 8 ++++---- pallets/liquidity-mining/src/tests/mock.rs | 4 ++-- pallets/omnipool/src/lib.rs | 8 ++++---- pallets/omnipool/src/router_execution.rs | 8 ++++---- pallets/route-executor/src/lib.rs | 8 ++++---- pallets/route-executor/src/tests/mock.rs | 4 ++-- pallets/stableswap/src/lib.rs | 8 ++++---- pallets/stableswap/src/trade_execution.rs | 8 ++++---- pallets/trade-event/src/lib.rs | 6 +++--- pallets/xyk-liquidity-mining/src/tests/mock.rs | 4 ++-- pallets/xyk/src/lib.rs | 8 ++++---- pallets/xyk/src/trade_execution.rs | 8 ++++---- traits/src/lib.rs | 12 ++++++------ traits/src/router.rs | 12 ++++++------ 16 files changed, 61 insertions(+), 61 deletions(-) diff --git a/pallets/dca/src/tests/mock.rs b/pallets/dca/src/tests/mock.rs index fe5719cdf..8a48fb2c5 100644 --- a/pallets/dca/src/tests/mock.rs +++ b/pallets/dca/src/tests/mock.rs @@ -448,7 +448,7 @@ impl TradeExecution, + _event_id: Option, ) -> Result<(), ExecutorError> { if !matches!(pool_type, PoolType::Omnipool) { return Err(ExecutorError::NotSupported); @@ -488,7 +488,7 @@ impl TradeExecution, + _event_id: Option, ) -> Result<(), ExecutorError> { if !matches!(pool_type, PoolType::Omnipool) { return Err(ExecutorError::NotSupported); @@ -573,7 +573,7 @@ impl TradeExecution, + _event_id: Option, ) -> Result<(), ExecutorError> { if !matches!(pool_type, PoolType::XYK) { return Err(ExecutorError::NotSupported); @@ -606,7 +606,7 @@ impl TradeExecution, + _event_id: Option, ) -> Result<(), ExecutorError> { if !matches!(pool_type, PoolType::XYK) { return Err(ExecutorError::NotSupported); diff --git a/pallets/lbp/src/lib.rs b/pallets/lbp/src/lib.rs index 23e8849f5..8ba38d86a 100644 --- a/pallets/lbp/src/lib.rs +++ b/pallets/lbp/src/lib.rs @@ -1113,7 +1113,7 @@ impl AMM, IncrementalI fn execute_sell( transfer: &AMMTransfer, - batch_id: Option, + event_id: Option, ) -> DispatchResult { Self::execute_trade(transfer)?; @@ -1137,7 +1137,7 @@ impl AMM, IncrementalI transfer.amount, transfer.amount_b, vec![transfer.fee], - batch_id, + event_id, ); Ok(()) @@ -1264,7 +1264,7 @@ impl AMM, IncrementalI fn execute_buy( transfer: &AMMTransfer>, _destination: Option<&T::AccountId>, - batch_id: Option, + event_id: Option, ) -> dispatch::DispatchResult { Self::execute_trade(transfer)?; @@ -1288,7 +1288,7 @@ impl AMM, IncrementalI transfer.amount, transfer.amount_b, vec![transfer.fee], - batch_id, + event_id, ); Ok(()) diff --git a/pallets/lbp/src/trade_execution.rs b/pallets/lbp/src/trade_execution.rs index c21d71eda..094dd4435 100644 --- a/pallets/lbp/src/trade_execution.rs +++ b/pallets/lbp/src/trade_execution.rs @@ -112,7 +112,7 @@ impl TradeExecution, + event_id: Option, ) -> Result<(), ExecutorError> { if pool_type != PoolType::LBP { return Err(ExecutorError::NotSupported); @@ -126,7 +126,7 @@ impl TradeExecution TradeExecution, + event_id: Option, ) -> Result<(), ExecutorError> { if pool_type != PoolType::LBP { return Err(ExecutorError::NotSupported); @@ -154,7 +154,7 @@ impl TradeExecution for Amm { fn execute_buy( _transfer: &AMMTransfer, _destination: Option<&AccountId>, - _batch_id: Option, + _event_id: Option, ) -> dispatch::DispatchResult { Err(sp_runtime::DispatchError::Other("NotImplemented")) } fn execute_sell( _transfer: &hydradx_traits::AMMTransfer, - _batch_id: Option, + _event_id: Option, ) -> frame_support::dispatch::DispatchResult { Err(sp_runtime::DispatchError::Other("NotImplemented")) } diff --git a/pallets/omnipool/src/lib.rs b/pallets/omnipool/src/lib.rs index 526efe3c6..68da20414 100644 --- a/pallets/omnipool/src/lib.rs +++ b/pallets/omnipool/src/lib.rs @@ -1491,7 +1491,7 @@ impl Pallet { asset_out: T::AssetId, amount: Balance, min_buy_amount: Balance, - batch_id: Option, + event_id: Option, ) -> DispatchResult { let who = frame_system::ensure_signed(origin.clone())?; @@ -1680,7 +1680,7 @@ impl Pallet { amount, *state_changes.asset_out.delta_reserve, vec![], // TODO - batch_id, + event_id, ); #[cfg(feature = "try-runtime")] @@ -1698,7 +1698,7 @@ impl Pallet { asset_in: T::AssetId, amount: Balance, max_sell_amount: Balance, - batch_id: Option, + event_id: Option, ) -> DispatchResult { let who = ensure_signed(origin.clone())?; @@ -1881,7 +1881,7 @@ impl Pallet { *state_changes.asset_in.delta_reserve, *state_changes.asset_out.delta_reserve, vec![], // TODO - batch_id, + event_id, ); #[cfg(feature = "try-runtime")] diff --git a/pallets/omnipool/src/router_execution.rs b/pallets/omnipool/src/router_execution.rs index 6767504fa..ed8327a8a 100644 --- a/pallets/omnipool/src/router_execution.rs +++ b/pallets/omnipool/src/router_execution.rs @@ -132,13 +132,13 @@ impl TradeExecution, T::AccountId, T::AssetId, Balance, asset_out: T::AssetId, amount_in: Balance, min_limit: Balance, - batch_id: Option, + event_id: Option, ) -> Result<(), ExecutorError> { if pool_type != PoolType::Omnipool { return Err(ExecutorError::NotSupported); } - Self::do_sell(who, asset_in, asset_out, amount_in, min_limit, batch_id).map_err(ExecutorError::Error) + Self::do_sell(who, asset_in, asset_out, amount_in, min_limit, event_id).map_err(ExecutorError::Error) } fn execute_buy( @@ -148,13 +148,13 @@ impl TradeExecution, T::AccountId, T::AssetId, Balance, asset_out: T::AssetId, amount_out: Balance, max_limit: Balance, - batch_id: Option, + event_id: Option, ) -> Result<(), ExecutorError> { if pool_type != PoolType::Omnipool { return Err(ExecutorError::NotSupported); } - Self::do_buy(who, asset_out, asset_in, amount_out, max_limit, batch_id).map_err(ExecutorError::Error) + Self::do_buy(who, asset_out, asset_in, amount_out, max_limit, event_id).map_err(ExecutorError::Error) } fn get_liquidity_depth( diff --git a/pallets/route-executor/src/lib.rs b/pallets/route-executor/src/lib.rs index d87fa8183..0948bfa65 100644 --- a/pallets/route-executor/src/lib.rs +++ b/pallets/route-executor/src/lib.rs @@ -258,7 +258,7 @@ pub mod pallet { ensure!(first_trade.amount_in <= max_amount_in, Error::::TradingLimitReached); let route_length = route.len(); - let next_batch_id = T::BatchIdProvider::next_id(); + let next_event_id = T::BatchIdProvider::next_id(); for (trade_index, (trade_amount, trade)) in trade_amounts.iter().rev().zip(route).enumerate() { Self::disable_ed_handling_for_insufficient_assets(route_length, trade_index, trade); let user_balance_of_asset_out_before_trade = @@ -270,7 +270,7 @@ pub mod pallet { trade.asset_out, trade_amount.amount_out, trade_amount.amount_in, - Some(next_batch_id), + Some(next_event_id), ); handle_execution_error!(execution_result); @@ -490,7 +490,7 @@ impl Pallet { ); let route_length = route.len(); - let next_batch_id = T::BatchIdProvider::next_id(); + let next_event_id = T::BatchIdProvider::next_id(); for (trade_index, (trade_amount, trade)) in trade_amounts.iter().zip(route.clone()).enumerate() { Self::disable_ed_handling_for_insufficient_assets(route_length, trade_index, trade); @@ -504,7 +504,7 @@ impl Pallet { trade.asset_out, trade_amount.amount_in, trade_amount.amount_out, - Some(next_batch_id), + Some(next_event_id), ); handle_execution_error!(execution_result); diff --git a/pallets/route-executor/src/tests/mock.rs b/pallets/route-executor/src/tests/mock.rs index d28655a55..28c016346 100644 --- a/pallets/route-executor/src/tests/mock.rs +++ b/pallets/route-executor/src/tests/mock.rs @@ -383,7 +383,7 @@ macro_rules! impl_fake_executor { asset_out: AssetId, amount_in: Balance, _min_limit: Balance, - _batch_id: Option, + _event_id: Option, ) -> Result<(), ExecutorError> { let who = ensure_signed(who).map_err(|_| ExecutorError::Error(DispatchError::Other("Wrong origin")))?; if !matches!(pool_type, $pool_type) { @@ -422,7 +422,7 @@ macro_rules! impl_fake_executor { asset_out: AssetId, amount_out: Balance, _max_limit: Balance, - _batch_id: Option, + _event_id: Option, ) -> Result<(), ExecutorError> { let who = ensure_signed(who).map_err(|_| ExecutorError::Error(DispatchError::Other("Wrong origin")))?; diff --git a/pallets/stableswap/src/lib.rs b/pallets/stableswap/src/lib.rs index 13f90fb73..6fda0df4d 100644 --- a/pallets/stableswap/src/lib.rs +++ b/pallets/stableswap/src/lib.rs @@ -806,7 +806,7 @@ impl Pallet { asset_out: T::AssetId, amount_in: Balance, min_buy_amount: Balance, - batch_id: Option, + event_id: Option, ) -> DispatchResult { let who = frame_system::ensure_signed(origin)?; @@ -863,7 +863,7 @@ impl Pallet { amount_in, amount_out, vec![(asset_out.into(), fee_amount)], - batch_id, + event_id, ); #[cfg(feature = "try-runtime")] @@ -879,7 +879,7 @@ impl Pallet { asset_in: T::AssetId, amount_out: Balance, max_sell_amount: Balance, - batch_id: Option, + event_id: Option, ) -> DispatchResult { let who = ensure_signed(origin)?; @@ -939,7 +939,7 @@ impl Pallet { amount_in, amount_out, vec![(asset_in.into(), fee_amount)], - batch_id, + event_id, ); #[cfg(feature = "try-runtime")] diff --git a/pallets/stableswap/src/trade_execution.rs b/pallets/stableswap/src/trade_execution.rs index 19d8affb7..cd632269f 100644 --- a/pallets/stableswap/src/trade_execution.rs +++ b/pallets/stableswap/src/trade_execution.rs @@ -143,7 +143,7 @@ where asset_out: T::AssetId, amount_in: Balance, min_limit: Balance, - batch_id: Option, + event_id: Option, ) -> Result<(), ExecutorError> { match pool_type { PoolType::Stableswap(pool_id) => { @@ -161,7 +161,7 @@ where ) .map_err(ExecutorError::Error) } else { - Self::do_sell(who, pool_id, asset_in, asset_out, amount_in, min_limit, batch_id) + Self::do_sell(who, pool_id, asset_in, asset_out, amount_in, min_limit, event_id) .map_err(ExecutorError::Error) } } @@ -176,7 +176,7 @@ where asset_out: T::AssetId, amount_out: Balance, max_limit: Balance, - batch_id: Option, + event_id: Option, ) -> Result<(), ExecutorError> { match pool_type { PoolType::Stableswap(pool_id) => { @@ -187,7 +187,7 @@ where Self::withdraw_asset_amount(who, pool_id, asset_out, amount_out, max_limit) .map_err(ExecutorError::Error) } else { - Self::do_buy(who, pool_id, asset_out, asset_in, amount_out, max_limit, batch_id) + Self::do_buy(who, pool_id, asset_out, asset_in, amount_out, max_limit, event_id) .map_err(ExecutorError::Error) } } diff --git a/pallets/trade-event/src/lib.rs b/pallets/trade-event/src/lib.rs index 469285976..846e4e7c7 100644 --- a/pallets/trade-event/src/lib.rs +++ b/pallets/trade-event/src/lib.rs @@ -63,7 +63,7 @@ pub mod pallet { amount_in: Balance, amount_out: Balance, fees: Vec<(AssetId, Balance)>, - batch_id: Option, + event_id: Option, }, } @@ -88,7 +88,7 @@ impl Pallet { amount_in: Balance, amount_out: Balance, fees: Vec<(AssetId, Balance)>, - batch_id: Option, + event_id: Option, ) { Self::deposit_event(Event::::Swapped { who, @@ -99,7 +99,7 @@ impl Pallet { amount_in, amount_out, fees, - batch_id, + event_id: event_id, }); } } diff --git a/pallets/xyk-liquidity-mining/src/tests/mock.rs b/pallets/xyk-liquidity-mining/src/tests/mock.rs index 7f95249ae..fcddf9bd5 100644 --- a/pallets/xyk-liquidity-mining/src/tests/mock.rs +++ b/pallets/xyk-liquidity-mining/src/tests/mock.rs @@ -238,14 +238,14 @@ impl AMM for DummyAMM { fn execute_buy( _transfer: &AMMTransfer, _destination: Option<&AccountId>, - _batch_id: Option, + _event_id: Option, ) -> dispatch::DispatchResult { Err(sp_runtime::DispatchError::Other("NotImplemented")) } fn execute_sell( _transfer: &hydradx_traits::AMMTransfer, - _batch_id: Option, + _event_id: Option, ) -> frame_support::dispatch::DispatchResult { Err(sp_runtime::DispatchError::Other("NotImplemented")) } diff --git a/pallets/xyk/src/lib.rs b/pallets/xyk/src/lib.rs index a04f0546b..985a3254e 100644 --- a/pallets/xyk/src/lib.rs +++ b/pallets/xyk/src/lib.rs @@ -874,7 +874,7 @@ impl AMM, - batch_id: Option, + event_id: Option, ) -> DispatchResult { let pair_account = Self::get_pair_id(transfer.assets); @@ -931,7 +931,7 @@ impl AMM AMM, destination: Option<&T::AccountId>, - batch_id: Option, + event_id: Option, ) -> DispatchResult { let pair_account = Self::get_pair_id(transfer.assets); @@ -1110,7 +1110,7 @@ impl AMM TradeExecution, + event_id: Option, ) -> Result<(), ExecutorError> { if pool_type != PoolType::XYK { return Err(ExecutorError::NotSupported); @@ -115,7 +115,7 @@ impl TradeExecution TradeExecution, + event_id: Option, ) -> Result<(), ExecutorError> { if pool_type != PoolType::XYK { return Err(ExecutorError::NotSupported); @@ -143,7 +143,7 @@ impl TradeExecution { /// Execute buy for given validated transfer. fn execute_sell( transfer: &AMMTransfer, - batch_id: Option, + event_id: Option, ) -> dispatch::DispatchResult; /// Perform asset swap. @@ -94,11 +94,11 @@ pub trait AMM { amount: Amount, min_bought: Amount, discount: bool, - batch_id: Option, + event_id: Option, ) -> dispatch::DispatchResult { Self::execute_sell( &Self::validate_sell(origin, assets, amount, min_bought, discount)?, - batch_id, + event_id, )?; Ok(()) @@ -118,7 +118,7 @@ pub trait AMM { fn execute_buy( transfer: &AMMTransfer, destination: Option<&AccountId>, - batch_id: Option, + event_id: Option, ) -> dispatch::DispatchResult; /// Perform asset swap. @@ -128,12 +128,12 @@ pub trait AMM { amount: Amount, max_limit: Amount, discount: bool, - batch_id: Option, + event_id: Option, ) -> dispatch::DispatchResult { Self::execute_buy( &Self::validate_buy(origin, assets, amount, max_limit, discount)?, None, - batch_id, + event_id, )?; Ok(()) diff --git a/traits/src/router.rs b/traits/src/router.rs index db67a32c9..06b2a3469 100644 --- a/traits/src/router.rs +++ b/traits/src/router.rs @@ -174,7 +174,7 @@ pub trait TradeExecution { asset_out: AssetId, amount_in: Balance, min_limit: Balance, - batch_id: Option, + event_id: Option, ) -> Result<(), ExecutorError>; fn execute_buy( @@ -184,7 +184,7 @@ pub trait TradeExecution { asset_out: AssetId, amount_out: Balance, max_limit: Balance, - batch_id: Option, + event_id: Option, ) -> Result<(), ExecutorError>; fn get_liquidity_depth( @@ -251,11 +251,11 @@ impl, + event_id: Option, ) -> Result<(), ExecutorError> { for_tuples!( #( - let value = match Tuple::execute_sell(who.clone(),pool_type, asset_in, asset_out, amount_in, min_limit, batch_id) { + let value = match Tuple::execute_sell(who.clone(),pool_type, asset_in, asset_out, amount_in, min_limit, event_id) { Ok(result) => return Ok(result), Err(v) if v == ExecutorError::NotSupported => v, Err(v) => return Err(v), @@ -272,11 +272,11 @@ impl, + event_id: Option, ) -> Result<(), ExecutorError> { for_tuples!( #( - let value = match Tuple::execute_buy(who.clone(), pool_type,asset_in, asset_out, amount_out, max_limit, batch_id) { + let value = match Tuple::execute_buy(who.clone(), pool_type,asset_in, asset_out, amount_out, max_limit, event_id) { Ok(result) => return Ok(result), Err(v) if v == ExecutorError::NotSupported => v, Err(v) => return Err(v), From 4ac8adc092f69e9a89578ab9b3913be41a70efb1 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Wed, 25 Sep 2024 19:50:04 +0200 Subject: [PATCH 006/142] rename pallet_trade_event to pallet_amm_support --- Cargo.lock | 52 +++++++++---------- Cargo.toml | 4 +- .../{trade-event => amm-support}/Cargo.toml | 4 +- .../{trade-event => amm-support}/README.md | 2 +- .../{trade-event => amm-support}/src/lib.rs | 0 pallets/circuit-breaker/Cargo.toml | 2 +- pallets/circuit-breaker/src/tests/mock.rs | 4 +- pallets/dca/Cargo.toml | 2 +- pallets/dca/src/tests/mock.rs | 4 +- pallets/lbp/Cargo.toml | 4 +- pallets/lbp/src/lib.rs | 24 ++++----- pallets/lbp/src/mock.rs | 4 +- pallets/lbp/src/trade_execution.rs | 2 +- pallets/omnipool-liquidity-mining/Cargo.toml | 2 +- .../src/tests/mock.rs | 4 +- pallets/omnipool/Cargo.toml | 4 +- pallets/omnipool/src/lib.rs | 36 ++++++------- pallets/omnipool/src/router_execution.rs | 2 +- pallets/omnipool/src/tests/mock.rs | 4 +- pallets/otc-settlements/Cargo.toml | 2 +- pallets/otc-settlements/src/mock.rs | 4 +- pallets/otc/Cargo.toml | 4 +- pallets/otc/src/lib.rs | 22 ++++---- pallets/otc/src/tests/mock.rs | 4 +- pallets/route-executor/Cargo.toml | 4 +- pallets/route-executor/src/tests/mock.rs | 4 +- pallets/stableswap/Cargo.toml | 4 +- pallets/stableswap/src/lib.rs | 24 ++++----- pallets/stableswap/src/tests/mock.rs | 4 +- pallets/stableswap/src/trade_execution.rs | 2 +- pallets/xyk/Cargo.toml | 4 +- pallets/xyk/src/lib.rs | 24 ++++----- pallets/xyk/src/tests/mock.rs | 4 +- pallets/xyk/src/trade_execution.rs | 2 +- runtime/adapters/Cargo.toml | 2 +- runtime/adapters/src/tests/mock.rs | 4 +- runtime/hydradx/Cargo.toml | 6 +-- runtime/hydradx/src/assets.rs | 2 +- runtime/hydradx/src/lib.rs | 2 +- 39 files changed, 144 insertions(+), 144 deletions(-) rename pallets/{trade-event => amm-support}/Cargo.toml (90%) rename pallets/{trade-event => amm-support}/README.md (80%) rename pallets/{trade-event => amm-support}/src/lib.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index b0c1c352f..066428f3b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4903,6 +4903,7 @@ dependencies = [ "orml-utilities", "orml-vesting", "orml-xcm-support", + "pallet-amm-support", "pallet-asset-registry", "pallet-balances", "pallet-bonds", @@ -4918,7 +4919,6 @@ dependencies = [ "pallet-route-executor", "pallet-stableswap", "pallet-staking 3.1.1", - "pallet-trade-event", "pallet-transaction-multi-payment", "pallet-uniques", "pallet-xyk", @@ -4977,6 +4977,7 @@ dependencies = [ "orml-xcm", "orml-xcm-support", "orml-xtokens", + "pallet-amm-support", "pallet-asset-registry", "pallet-aura", "pallet-authorship", @@ -5029,7 +5030,6 @@ dependencies = [ "pallet-state-trie-migration", "pallet-timestamp", "pallet-tips", - "pallet-trade-event", "pallet-transaction-multi-payment", "pallet-transaction-pause", "pallet-transaction-payment", @@ -7468,6 +7468,20 @@ version = "6.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1" +[[package]] +name = "pallet-amm-support" +version = "1.0.0" +dependencies = [ + "frame-support", + "frame-system", + "hydradx-traits", + "parity-scale-codec", + "primitives", + "scale-info", + "sp-api", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", +] + [[package]] name = "pallet-asset-conversion" version = "10.0.0" @@ -7805,9 +7819,9 @@ dependencies = [ "hydradx-traits", "orml-tokens", "orml-traits", + "pallet-amm-support", "pallet-balances", "pallet-omnipool", - "pallet-trade-event", "parity-scale-codec", "pretty_assertions", "scale-info", @@ -7955,12 +7969,12 @@ dependencies = [ "log", "orml-tokens", "orml-traits", + "pallet-amm-support", "pallet-balances", "pallet-currencies", "pallet-ema-oracle", "pallet-omnipool", "pallet-route-executor", - "pallet-trade-event", "pallet-xyk", "parity-scale-codec", "pretty_assertions", @@ -8458,7 +8472,7 @@ dependencies = [ "hydradx-traits", "orml-tokens", "orml-traits", - "pallet-trade-event", + "pallet-amm-support", "parity-scale-codec", "primitive-types", "proptest", @@ -8711,8 +8725,8 @@ dependencies = [ "log", "orml-tokens", "orml-traits", + "pallet-amm-support", "pallet-balances", - "pallet-trade-event", "parity-scale-codec", "pretty_assertions", "primitive-types", @@ -8737,11 +8751,11 @@ dependencies = [ "log", "orml-tokens", "orml-traits", + "pallet-amm-support", "pallet-balances", "pallet-ema-oracle", "pallet-liquidity-mining", "pallet-omnipool", - "pallet-trade-event", "parity-scale-codec", "pretty_assertions", "primitive-types", @@ -8763,7 +8777,7 @@ dependencies = [ "hydradx-traits", "orml-tokens", "orml-traits", - "pallet-trade-event", + "pallet-amm-support", "parity-scale-codec", "pretty_assertions", "proptest", @@ -8788,13 +8802,13 @@ dependencies = [ "log", "orml-tokens", "orml-traits", + "pallet-amm-support", "pallet-asset-registry", "pallet-balances", "pallet-currencies", "pallet-omnipool", "pallet-otc", "pallet-route-executor", - "pallet-trade-event", "parity-scale-codec", "parking_lot 0.12.1", "pretty_assertions", @@ -8957,9 +8971,9 @@ dependencies = [ "hydradx-traits", "orml-tokens", "orml-traits", + "pallet-amm-support", "pallet-balances", "pallet-currencies", - "pallet-trade-event", "parity-scale-codec", "pretty_assertions", "primitives", @@ -9059,7 +9073,7 @@ dependencies = [ "hydradx-traits", "orml-tokens", "orml-traits", - "pallet-trade-event", + "pallet-amm-support", "parity-scale-codec", "proptest", "scale-info", @@ -9222,20 +9236,6 @@ dependencies = [ "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", ] -[[package]] -name = "pallet-trade-event" -version = "1.0.0" -dependencies = [ - "frame-support", - "frame-system", - "hydradx-traits", - "parity-scale-codec", - "primitives", - "scale-info", - "sp-api", - "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", -] - [[package]] name = "pallet-transaction-multi-payment" version = "10.1.0" @@ -9463,8 +9463,8 @@ dependencies = [ "log", "orml-tokens", "orml-traits", + "pallet-amm-support", "pallet-asset-registry", - "pallet-trade-event", "parity-scale-codec", "primitive-types", "proptest", diff --git a/Cargo.toml b/Cargo.toml index 5c064f8fc..f4adeb73b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,7 +41,7 @@ members = [ 'pallets/evm-accounts', 'pallets/dynamic-evm-fee', 'pallets/xyk-liquidity-mining', - 'pallets/trade-event', + 'pallets/amm-support', 'precompiles/call-permit', 'runtime-mock' ] @@ -105,7 +105,7 @@ pallet-xyk-liquidity-mining = { path = "pallets/xyk-liquidity-mining", default-f pallet-referrals = { path = "pallets/referrals", default-features = false} pallet-evm-accounts = { path = "pallets/evm-accounts", default-features = false} pallet-evm-accounts-rpc-runtime-api = { path = "pallets/evm-accounts/rpc/runtime-api", default-features = false} -pallet-trade-event = { path = "pallets/trade-event", default-features = false} +pallet-amm-support = { path = "pallets/amm-support", default-features = false} hydra-dx-build-script-utils = { path = "utils/build-script-utils", default-features = false } scraper = { path = "scraper", default-features = false } diff --git a/pallets/trade-event/Cargo.toml b/pallets/amm-support/Cargo.toml similarity index 90% rename from pallets/trade-event/Cargo.toml rename to pallets/amm-support/Cargo.toml index 6e2d70549..a851f8144 100644 --- a/pallets/trade-event/Cargo.toml +++ b/pallets/amm-support/Cargo.toml @@ -1,12 +1,12 @@ [package] -name = "pallet-trade-event" +name = "pallet-amm-support" version = "1.0.0" authors = ["GalacticCouncil"] edition = "2021" license = "Apache 2.0" homepage = 'https://github.com/galacticcouncil/hydration-node' repository = 'https://github.com/galacticcouncil/hydration-node' -description = "Trade event pallet provides unified event for AMMs" +description = "Support for AMMs" readme = "README.md" [dependencies] diff --git a/pallets/trade-event/README.md b/pallets/amm-support/README.md similarity index 80% rename from pallets/trade-event/README.md rename to pallets/amm-support/README.md index 625b66c14..702f20c02 100644 --- a/pallets/trade-event/README.md +++ b/pallets/amm-support/README.md @@ -1,3 +1,3 @@ -# Trade event pallet +# AMM support pallet Support pallet for AMMs. Includes the unified event that is emitted by all AMM pallets. diff --git a/pallets/trade-event/src/lib.rs b/pallets/amm-support/src/lib.rs similarity index 100% rename from pallets/trade-event/src/lib.rs rename to pallets/amm-support/src/lib.rs diff --git a/pallets/circuit-breaker/Cargo.toml b/pallets/circuit-breaker/Cargo.toml index 44b5ee9b6..9da29041f 100644 --- a/pallets/circuit-breaker/Cargo.toml +++ b/pallets/circuit-breaker/Cargo.toml @@ -31,7 +31,7 @@ hydradx-traits = { workspace = true } [dev-dependencies] pallet-omnipool = { workspace = true } -pallet-trade-event = { workspace = true } +pallet-amm-support = { workspace = true } pallet-balances = { workspace = true } orml-tokens = { workspace = true } orml-traits = { workspace = true } diff --git a/pallets/circuit-breaker/src/tests/mock.rs b/pallets/circuit-breaker/src/tests/mock.rs index 98cc8e358..8ff3b4307 100644 --- a/pallets/circuit-breaker/src/tests/mock.rs +++ b/pallets/circuit-breaker/src/tests/mock.rs @@ -86,7 +86,7 @@ frame_support::construct_runtime!( Omnipool: pallet_omnipool, Tokens: orml_tokens, CircuitBreaker: pallet_circuit_breaker, - TradeEvent: pallet_trade_event, + TradeEvent: pallet_amm_support, } ); @@ -227,7 +227,7 @@ impl pallet_omnipool::Config for Test { type Fee = FeeProvider; } -impl pallet_trade_event::Config for Test { +impl pallet_amm_support::Config for Test { type RuntimeEvent = RuntimeEvent; } diff --git a/pallets/dca/Cargo.toml b/pallets/dca/Cargo.toml index fe0d60cca..1395f9753 100644 --- a/pallets/dca/Cargo.toml +++ b/pallets/dca/Cargo.toml @@ -52,7 +52,7 @@ primitives = { path = "../../primitives", default-features = false } pallet-route-executor = { workspace = true } smallvec = "1.9.0" pallet-balances = { workspace = true } -pallet-trade-event = { workspace = true } +pallet-amm-support = { workspace = true } pallet-currencies = { workspace = true } lazy_static = { features = ["spin_no_std"], version = "1.4.0", default-features = false } sp-api = { workspace = true } diff --git a/pallets/dca/src/tests/mock.rs b/pallets/dca/src/tests/mock.rs index 8a48fb2c5..27dd45dc2 100644 --- a/pallets/dca/src/tests/mock.rs +++ b/pallets/dca/src/tests/mock.rs @@ -80,7 +80,7 @@ frame_support::construct_runtime!( Balances: pallet_balances, Currencies: pallet_currencies, EmaOracle: pallet_ema_oracle, - TradeEvent: pallet_trade_event, + TradeEvent: pallet_amm_support, } ); @@ -352,7 +352,7 @@ parameter_types! { } -impl pallet_trade_event::Config for Test { +impl pallet_amm_support::Config for Test { type RuntimeEvent = RuntimeEvent; } diff --git a/pallets/lbp/Cargo.toml b/pallets/lbp/Cargo.toml index 3db919325..2082fce78 100644 --- a/pallets/lbp/Cargo.toml +++ b/pallets/lbp/Cargo.toml @@ -23,7 +23,7 @@ serde = { features = ["derive"], optional = true, version = "1.0.136" } # HydraDX dependencies hydra-dx-math = { workspace = true } hydradx-traits = { workspace = true } -pallet-trade-event = { workspace = true } +pallet-amm-support = { workspace = true } ## ORML dependencies orml-traits = { workspace = true } @@ -67,6 +67,6 @@ std = [ 'frame-benchmarking/std', "scale-info/std", "hydra-dx-math/std", - "pallet-trade-event/std", + "pallet-amm-support/std", ] try-runtime = ["frame-support/try-runtime"] diff --git a/pallets/lbp/src/lib.rs b/pallets/lbp/src/lib.rs index 8ba38d86a..e5f9ea46c 100644 --- a/pallets/lbp/src/lib.rs +++ b/pallets/lbp/src/lib.rs @@ -39,7 +39,7 @@ use frame_system::pallet_prelude::BlockNumberFor; use hydra_dx_math::types::LBPWeight; use hydradx_traits::{AMMTransfer, AssetPairAccountIdFor, CanCreatePool, LockedBalance, AMM}; use orml_traits::{MultiCurrency, MultiCurrencyExtended, MultiLockableCurrency}; -use pallet_trade_event::IncrementalIdType; +use pallet_amm_support::IncrementalIdType; use scale_info::TypeInfo; @@ -185,7 +185,7 @@ pub mod pallet { pub struct Pallet(_); #[pallet::config] - pub trait Config: frame_system::Config + pallet_trade_event::Config { + pub trait Config: frame_system::Config + pallet_amm_support::Config { type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Multi currency for transfer of currencies @@ -343,7 +343,7 @@ pub mod pallet { }, /// Sale executed. - /// Deprecated. Replaced by pallet_trade_event::Swapped + /// Deprecated. Replaced by pallet_amm_support::Swapped SellExecuted { who: T::AccountId, asset_in: AssetId, @@ -355,7 +355,7 @@ pub mod pallet { }, /// Purchase executed. - /// Deprecated. Replaced by pallet_trade_event::Swapped + /// Deprecated. Replaced by pallet_amm_support::Swapped BuyExecuted { who: T::AccountId, asset_out: AssetId, @@ -722,7 +722,7 @@ pub mod pallet { /// - `max_limit`: minimum amount of `asset_out` / amount of asset_out to be obtained from the pool in exchange for `asset_in`. /// /// Emits `SellExecuted` when successful. Deprecated. - /// Emits `pallet_trade_event::Swapped` when successful. + /// Emits `pallet_amm_support::Swapped` when successful. #[pallet::call_index(4)] #[pallet::weight(::WeightInfo::sell())] pub fn sell( @@ -760,7 +760,7 @@ pub mod pallet { /// - `max_limit`: maximum amount of `asset_in` to be sold in exchange for `asset_out`. /// /// Emits `BuyExecuted` when successful. Deprecated. - /// Emits `pallet_trade_event::Swapped` when successful. + /// Emits `pallet_amm_support::Swapped` when successful. #[pallet::call_index(5)] #[pallet::weight(::WeightInfo::buy())] pub fn buy( @@ -1128,10 +1128,10 @@ impl AMM, IncrementalI fee_amount: transfer.fee.1, }); - pallet_trade_event::Pallet::::deposit_trade_event( + pallet_amm_support::Pallet::::deposit_trade_event( transfer.origin.clone(), - pallet_trade_event::PoolType::LBP, - pallet_trade_event::TradeOperation::Sell, + pallet_amm_support::PoolType::LBP, + pallet_amm_support::TradeOperation::Sell, transfer.assets.asset_in, transfer.assets.asset_out, transfer.amount, @@ -1279,10 +1279,10 @@ impl AMM, IncrementalI fee_amount: transfer.fee.1, }); - pallet_trade_event::Pallet::::deposit_trade_event( + pallet_amm_support::Pallet::::deposit_trade_event( transfer.origin.clone(), - pallet_trade_event::PoolType::LBP, - pallet_trade_event::TradeOperation::Buy, + pallet_amm_support::PoolType::LBP, + pallet_amm_support::TradeOperation::Buy, transfer.assets.asset_in, transfer.assets.asset_out, transfer.amount, diff --git a/pallets/lbp/src/mock.rs b/pallets/lbp/src/mock.rs index 6eb4f8cd6..09b20fc12 100644 --- a/pallets/lbp/src/mock.rs +++ b/pallets/lbp/src/mock.rs @@ -75,7 +75,7 @@ frame_support::construct_runtime!( System: frame_system, LBPPallet: lbp, Currency: orml_tokens, - TradeEvent: pallet_trade_event, + TradeEvent: pallet_amm_support, } ); @@ -171,7 +171,7 @@ impl LockedBalance for MultiLockedBalance { } } -impl pallet_trade_event::Config for Test { +impl pallet_amm_support::Config for Test { type RuntimeEvent = RuntimeEvent; } diff --git a/pallets/lbp/src/trade_execution.rs b/pallets/lbp/src/trade_execution.rs index 094dd4435..bb113d276 100644 --- a/pallets/lbp/src/trade_execution.rs +++ b/pallets/lbp/src/trade_execution.rs @@ -2,7 +2,7 @@ use crate::*; use hydradx_traits::router::{ExecutorError, PoolType, TradeExecution}; use hydradx_traits::AMM; use orml_traits::MultiCurrency; -use pallet_trade_event::IncrementalIdType; +use pallet_amm_support::IncrementalIdType; use sp_runtime::traits::BlockNumberProvider; use sp_runtime::DispatchError::Corruption; use sp_runtime::{ArithmeticError, DispatchError, FixedPointNumber, FixedU128}; diff --git a/pallets/omnipool-liquidity-mining/Cargo.toml b/pallets/omnipool-liquidity-mining/Cargo.toml index dbe97ea2b..e448c2cbc 100644 --- a/pallets/omnipool-liquidity-mining/Cargo.toml +++ b/pallets/omnipool-liquidity-mining/Cargo.toml @@ -51,7 +51,7 @@ sp-io = { workspace = true, optional = true } [dev-dependencies] sp-io = { workspace = true } sp-core = { workspace = true } -pallet-trade-event = { workspace = true } +pallet-amm-support = { workspace = true } orml-tokens = { workspace = true } pretty_assertions = "1.2.1" diff --git a/pallets/omnipool-liquidity-mining/src/tests/mock.rs b/pallets/omnipool-liquidity-mining/src/tests/mock.rs index f2fc7b7c2..d5a0dd65c 100644 --- a/pallets/omnipool-liquidity-mining/src/tests/mock.rs +++ b/pallets/omnipool-liquidity-mining/src/tests/mock.rs @@ -110,7 +110,7 @@ construct_runtime!( WarehouseLM: warehouse_liquidity_mining::, OmnipoolMining: omnipool_liquidity_mining, EmaOracle: pallet_ema_oracle, - TradeEvent: pallet_trade_event, + TradeEvent: pallet_amm_support, } ); @@ -302,7 +302,7 @@ impl pallet_omnipool::Config for Test { type Fee = FeeProvider; } -impl pallet_trade_event::Config for Test { +impl pallet_amm_support::Config for Test { type RuntimeEvent = RuntimeEvent; } diff --git a/pallets/omnipool/Cargo.toml b/pallets/omnipool/Cargo.toml index d960a91b2..400412481 100644 --- a/pallets/omnipool/Cargo.toml +++ b/pallets/omnipool/Cargo.toml @@ -20,7 +20,7 @@ codec = { default-features = false, features = ["derive"], package = "parity-sca # HydraDX dependencies hydradx-traits = { workspace = true } hydra-dx-math = { workspace = true } -pallet-trade-event = { workspace = true } +pallet-amm-support = { workspace = true } # primitives sp-runtime = { workspace = true } @@ -69,7 +69,7 @@ std = [ "pallet-balances/std", "orml-tokens/std", "frame-benchmarking/std", - "pallet-trade-event/std", + "pallet-amm-support/std", 'hydradx-traits/std', 'hydra-dx-math/std', 'orml-traits/std', diff --git a/pallets/omnipool/src/lib.rs b/pallets/omnipool/src/lib.rs index 68da20414..2704f2f4a 100644 --- a/pallets/omnipool/src/lib.rs +++ b/pallets/omnipool/src/lib.rs @@ -115,7 +115,7 @@ pub mod weights; use crate::traits::{AssetInfo, OmnipoolHooks}; use crate::types::{AssetReserveState, AssetState, Balance, Position, SimpleImbalance, Tradability}; pub use pallet::*; -use pallet_trade_event::IncrementalIdType; +use pallet_amm_support::IncrementalIdType; pub use weights::WeightInfo; /// NFT class id type of provided nft implementation @@ -140,7 +140,7 @@ pub mod pallet { pub struct Pallet(_); #[pallet::config] - pub trait Config: frame_system::Config + pallet_trade_event::Config { + pub trait Config: frame_system::Config + pallet_amm_support::Config { /// The overarching event type. type RuntimeEvent: From> + IsType<::RuntimeEvent>; @@ -304,7 +304,7 @@ pub mod pallet { shares_removed: Balance, }, /// Sell trade executed. - /// Deprecated. Replaced by pallet_trade_event::Swapped + /// Deprecated. Replaced by pallet_amm_support::Swapped SellExecuted { who: T::AccountId, asset_in: T::AssetId, @@ -317,7 +317,7 @@ pub mod pallet { protocol_fee_amount: Balance, }, /// Buy trade executed. - /// Deprecated. Replaced by pallet_trade_event::Swapped + /// Deprecated. Replaced by pallet_amm_support::Swapped BuyExecuted { who: T::AccountId, asset_in: T::AssetId, @@ -1028,7 +1028,7 @@ pub mod pallet { /// - `min_buy_amount`: Minimum amount required to receive /// /// Emits `SellExecuted` event when successful. Deprecated. - /// Emits `pallet_trade_event::Swapped` event when successful. + /// Emits `pallet_amm_support::Swapped` event when successful. /// #[pallet::call_index(5)] #[pallet::weight(::WeightInfo::sell() @@ -1061,7 +1061,7 @@ pub mod pallet { /// - `max_sell_amount`: Maximum amount to be sold. /// /// Emits `BuyExecuted` event when successful. Deprecated. - /// Emits `pallet_trade_event::Swapped` event when successful. + /// Emits `pallet_amm_support::Swapped` event when successful. /// #[pallet::call_index(6)] #[pallet::weight(::WeightInfo::buy() @@ -1671,10 +1671,10 @@ impl Pallet { hub_amount_out: *state_changes.asset_out.delta_hub_reserve, }); - pallet_trade_event::Pallet::::deposit_trade_event( + pallet_amm_support::Pallet::::deposit_trade_event( who.clone(), - pallet_trade_event::PoolType::Omnipool, - pallet_trade_event::TradeOperation::Sell, + pallet_amm_support::PoolType::Omnipool, + pallet_amm_support::TradeOperation::Sell, asset_in.into(), asset_out.into(), amount, @@ -1872,10 +1872,10 @@ impl Pallet { hub_amount_out: *state_changes.asset_out.delta_hub_reserve, }); - pallet_trade_event::Pallet::::deposit_trade_event( + pallet_amm_support::Pallet::::deposit_trade_event( who.clone(), - pallet_trade_event::PoolType::Omnipool, - pallet_trade_event::TradeOperation::Buy, + pallet_amm_support::PoolType::Omnipool, + pallet_amm_support::TradeOperation::Buy, asset_in.into(), asset_out.into(), *state_changes.asset_in.delta_reserve, @@ -1996,10 +1996,10 @@ impl Pallet { protocol_fee_amount: state_changes.fee.protocol_fee, }); - pallet_trade_event::Pallet::::deposit_trade_event( + pallet_amm_support::Pallet::::deposit_trade_event( who.clone(), - pallet_trade_event::PoolType::Omnipool, - pallet_trade_event::TradeOperation::Sell, + pallet_amm_support::PoolType::Omnipool, + pallet_amm_support::TradeOperation::Sell, T::HubAssetId::get().into(), asset_out.into(), *state_changes.asset.delta_hub_reserve, @@ -2116,10 +2116,10 @@ impl Pallet { protocol_fee_amount: state_changes.fee.protocol_fee, }); - pallet_trade_event::Pallet::::deposit_trade_event( + pallet_amm_support::Pallet::::deposit_trade_event( who.clone(), - pallet_trade_event::PoolType::Omnipool, - pallet_trade_event::TradeOperation::Buy, + pallet_amm_support::PoolType::Omnipool, + pallet_amm_support::TradeOperation::Buy, T::HubAssetId::get().into(), asset_out.into(), *state_changes.asset.delta_hub_reserve, diff --git a/pallets/omnipool/src/router_execution.rs b/pallets/omnipool/src/router_execution.rs index ed8327a8a..2298bf06b 100644 --- a/pallets/omnipool/src/router_execution.rs +++ b/pallets/omnipool/src/router_execution.rs @@ -5,7 +5,7 @@ use hydra_dx_math::omnipool::types::I129; use hydradx_traits::router::{ExecutorError, PoolType, TradeExecution}; use orml_traits::{GetByKey, MultiCurrency}; -use pallet_trade_event::IncrementalIdType; +use pallet_amm_support::IncrementalIdType; use sp_runtime::traits::Get; use sp_runtime::DispatchError::Corruption; use sp_runtime::{ArithmeticError, DispatchError, FixedPointNumber, FixedU128}; diff --git a/pallets/omnipool/src/tests/mock.rs b/pallets/omnipool/src/tests/mock.rs index b4b7aa195..3cbd0c81f 100644 --- a/pallets/omnipool/src/tests/mock.rs +++ b/pallets/omnipool/src/tests/mock.rs @@ -86,7 +86,7 @@ construct_runtime!( Balances: pallet_balances, Omnipool: pallet_omnipool, Tokens: orml_tokens, - TradeEvent: pallet_trade_event, + TradeEvent: pallet_amm_support, } ); @@ -176,7 +176,7 @@ parameter_types! { pub MinWithdrawFee: Permill = WITHDRAWAL_FEE.with(|v| *v.borrow()); } -impl pallet_trade_event::Config for Test { +impl pallet_amm_support::Config for Test { type RuntimeEvent = RuntimeEvent; } diff --git a/pallets/otc-settlements/Cargo.toml b/pallets/otc-settlements/Cargo.toml index e1bc659dc..7cdeb8c87 100644 --- a/pallets/otc-settlements/Cargo.toml +++ b/pallets/otc-settlements/Cargo.toml @@ -39,7 +39,7 @@ pallet-asset-registry = { workspace = true } pallet-route-executor = { workspace = true } pallet-balances = { workspace = true } pallet-currencies = { workspace = true } -pallet-trade-event = { workspace = true } +pallet-amm-support = { workspace = true } sp-api = { workspace = true } orml-traits = { workspace = true } orml-tokens = { workspace = true, features=["std"] } diff --git a/pallets/otc-settlements/src/mock.rs b/pallets/otc-settlements/src/mock.rs index 113db5834..740d655c8 100644 --- a/pallets/otc-settlements/src/mock.rs +++ b/pallets/otc-settlements/src/mock.rs @@ -74,7 +74,7 @@ frame_support::construct_runtime!( Omnipool: pallet_omnipool, Router: pallet_route_executor, OtcSettlements: pallet_otc_settlements, - TradeEvent: pallet_trade_event, + TradeEvent: pallet_amm_support, } ); @@ -253,7 +253,7 @@ impl pallet_currencies::Config for Test { type WeightInfo = (); } -impl pallet_trade_event::Config for Test { +impl pallet_amm_support::Config for Test { type RuntimeEvent = RuntimeEvent; } diff --git a/pallets/otc/Cargo.toml b/pallets/otc/Cargo.toml index da91daea7..83a303d3e 100644 --- a/pallets/otc/Cargo.toml +++ b/pallets/otc/Cargo.toml @@ -14,7 +14,7 @@ scale-info = { version = "2.1.2", default-features = false, features = ["derive" # HydraDX dependencies hydradx-traits = { workspace = true } -pallet-trade-event = { workspace = true } +pallet-amm-support = { workspace = true } # primitives sp-runtime = { workspace = true } @@ -54,7 +54,7 @@ std = [ 'orml-traits/std', 'hydradx-traits/std', 'frame-benchmarking/std', - "pallet-trade-event/std", + "pallet-amm-support/std", ] runtime-benchmarks = [ diff --git a/pallets/otc/src/lib.rs b/pallets/otc/src/lib.rs index 113855905..e90c89254 100644 --- a/pallets/otc/src/lib.rs +++ b/pallets/otc/src/lib.rs @@ -81,7 +81,7 @@ pub mod pallet { pub struct Pallet(_); #[pallet::config] - pub trait Config: frame_system::Config + pallet_trade_event::Config { + pub trait Config: frame_system::Config + pallet_amm_support::Config { /// Identifier for the class of asset. type AssetId: Member + Parameter + Copy + HasCompact + MaybeSerializeDeserialize + MaxEncodedLen + Into; @@ -124,7 +124,7 @@ pub mod pallet { /// An Order has been cancelled Cancelled { order_id: OrderId }, /// An Order has been completely filled - /// Deprecated. Replaced by pallet_trade_event::Swapped + /// Deprecated. Replaced by pallet_amm_support::Swapped Filled { order_id: OrderId, who: T::AccountId, @@ -133,7 +133,7 @@ pub mod pallet { fee: Balance, }, /// An Order has been partially filled - /// Deprecated. Replaced by pallet_trade_event::Swapped + /// Deprecated. Replaced by pallet_amm_support::Swapped PartiallyFilled { order_id: OrderId, who: T::AccountId, @@ -269,7 +269,7 @@ pub mod pallet { /// /// Events: /// `PartiallyFilled` event when successful. Deprecated. - /// `pallet_trade_event::Swapped` event when successful. + /// `pallet_amm_support::Swapped` event when successful. #[pallet::call_index(1)] #[pallet::weight(::WeightInfo::partial_fill_order())] pub fn partial_fill_order(origin: OriginFor, order_id: OrderId, amount_in: Balance) -> DispatchResult { @@ -308,10 +308,10 @@ pub mod pallet { fee, }); - pallet_trade_event::Pallet::::deposit_trade_event( + pallet_amm_support::Pallet::::deposit_trade_event( who, - pallet_trade_event::PoolType::OTC(order_id), - pallet_trade_event::TradeOperation::Sell, + pallet_amm_support::PoolType::OTC(order_id), + pallet_amm_support::TradeOperation::Sell, order.asset_in.into(), order.asset_out.into(), order.amount_in, @@ -331,7 +331,7 @@ pub mod pallet { /// /// Events: /// `Filled` event when successful. Deprecated. - /// `pallet_trade_event::Swapped` event when successful. + /// `pallet_amm_support::Swapped` event when successful. #[pallet::call_index(2)] #[pallet::weight(::WeightInfo::fill_order())] pub fn fill_order(origin: OriginFor, order_id: OrderId) -> DispatchResult { @@ -352,10 +352,10 @@ pub mod pallet { fee, }); - pallet_trade_event::Pallet::::deposit_trade_event( + pallet_amm_support::Pallet::::deposit_trade_event( who, - pallet_trade_event::PoolType::OTC(order_id), - pallet_trade_event::TradeOperation::Sell, + pallet_amm_support::PoolType::OTC(order_id), + pallet_amm_support::TradeOperation::Sell, order.asset_in.into(), order.asset_out.into(), order.amount_in, diff --git a/pallets/otc/src/tests/mock.rs b/pallets/otc/src/tests/mock.rs index 1438c14a3..d76841a9c 100644 --- a/pallets/otc/src/tests/mock.rs +++ b/pallets/otc/src/tests/mock.rs @@ -57,7 +57,7 @@ frame_support::construct_runtime!( System: frame_system, OTC: otc, Tokens: orml_tokens, - TradeEvent: pallet_trade_event, + TradeEvent: pallet_amm_support, } ); @@ -140,7 +140,7 @@ impl orml_tokens::Config for Test { type CurrencyHooks = (); } -impl pallet_trade_event::Config for Test { +impl pallet_amm_support::Config for Test { type RuntimeEvent = RuntimeEvent; } diff --git a/pallets/route-executor/Cargo.toml b/pallets/route-executor/Cargo.toml index 2a6730ddf..b4dd9ba49 100644 --- a/pallets/route-executor/Cargo.toml +++ b/pallets/route-executor/Cargo.toml @@ -15,7 +15,7 @@ serde = { features = ["derive"], optional = true, version = "1.0.137" } # HydraDX dependencies hydradx-traits = { workspace = true } hydra-dx-math = { workspace = true } -pallet-trade-event = { workspace = true } +pallet-amm-support = { workspace = true } primitives = { workspace = true } # ORML dependencies @@ -56,7 +56,7 @@ std = [ 'orml-traits/std', "hydradx-adapters/std", "pallet-balances/std", - "pallet-trade-event/std", + "pallet-amm-support/std", 'hydradx-traits/std', 'hydra-dx-math/std', 'frame-benchmarking/std', diff --git a/pallets/route-executor/src/tests/mock.rs b/pallets/route-executor/src/tests/mock.rs index 28c016346..98f8daccb 100644 --- a/pallets/route-executor/src/tests/mock.rs +++ b/pallets/route-executor/src/tests/mock.rs @@ -51,7 +51,7 @@ frame_support::construct_runtime!( Tokens: orml_tokens, Balances: pallet_balances, Currencies: pallet_currencies, - TradeEvent: pallet_trade_event, + TradeEvent: pallet_amm_support, } ); @@ -138,7 +138,7 @@ impl pallet_currencies::Config for Test { type WeightInfo = (); } -impl pallet_trade_event::Config for Test { +impl pallet_amm_support::Config for Test { type RuntimeEvent = RuntimeEvent; } diff --git a/pallets/stableswap/Cargo.toml b/pallets/stableswap/Cargo.toml index c2cece27e..e1a1d09c8 100644 --- a/pallets/stableswap/Cargo.toml +++ b/pallets/stableswap/Cargo.toml @@ -21,7 +21,7 @@ serde = { features = ["derive"], optional = true, version = "1.0.137" } # HydraDX dependencies hydradx-traits = { workspace = true } -pallet-trade-event = { workspace = true } +pallet-amm-support = { workspace = true } # primitives sp-runtime = { workspace = true } @@ -71,6 +71,6 @@ std = [ "frame-benchmarking/std", 'orml-traits/std', "hydra-dx-math/std", - "pallet-trade-event/std", + "pallet-amm-support/std", ] try-runtime = ["frame-support/try-runtime"] diff --git a/pallets/stableswap/src/lib.rs b/pallets/stableswap/src/lib.rs index 6fda0df4d..a6749ba74 100644 --- a/pallets/stableswap/src/lib.rs +++ b/pallets/stableswap/src/lib.rs @@ -75,7 +75,7 @@ use crate::types::{AssetAmount, Balance, PoolInfo, PoolState, StableswapHooks, T use hydra_dx_math::stableswap::types::AssetReserve; use hydradx_traits::pools::DustRemovalAccountWhitelist; use orml_traits::MultiCurrency; -use pallet_trade_event::IncrementalIdType; +use pallet_amm_support::IncrementalIdType; use sp_std::collections::btree_map::BTreeMap; pub use weights::WeightInfo; @@ -113,7 +113,7 @@ pub mod pallet { pub struct Pallet(_); #[pallet::config] - pub trait Config: frame_system::Config + pallet_trade_event::Config { + pub trait Config: frame_system::Config + pallet_amm_support::Config { /// The overarching event type. type RuntimeEvent: From> + IsType<::RuntimeEvent>; @@ -208,7 +208,7 @@ pub mod pallet { fee: Balance, }, /// Sell trade executed. Trade fee paid in asset leaving the pool (already subtracted from amount_out). - /// Deprecated. Replaced by pallet_trade_event::Swapped + /// Deprecated. Replaced by pallet_amm_support::Swapped SellExecuted { who: T::AccountId, pool_id: T::AssetId, @@ -219,7 +219,7 @@ pub mod pallet { fee: Balance, }, /// Buy trade executed. Trade fee paid in asset entering the pool (already included in amount_in). - /// Deprecated. Replaced by pallet_trade_event::Swapped + /// Deprecated. Replaced by pallet_amm_support::Swapped BuyExecuted { who: T::AccountId, pool_id: T::AssetId, @@ -716,7 +716,7 @@ pub mod pallet { /// - `min_buy_amount`: Minimum amount required to receive /// /// Emits `SellExecuted` event when successful. Deprecated. - /// Emits `pallet_trade_event::Swapped` event when successful. + /// Emits `pallet_amm_support::Swapped` event when successful. /// #[pallet::call_index(7)] #[pallet::weight(::WeightInfo::sell() @@ -744,7 +744,7 @@ pub mod pallet { /// - `max_sell_amount`: Maximum amount allowed to be sold /// /// Emits `BuyExecuted` event when successful. Deprecated. - /// Emits `pallet_trade_event::Swapped` event when successful. + /// Emits `pallet_amm_support::Swapped` event when successful. /// #[pallet::call_index(8)] #[pallet::weight(::WeightInfo::buy() @@ -854,10 +854,10 @@ impl Pallet { fee: fee_amount, }); - pallet_trade_event::Pallet::::deposit_trade_event( + pallet_amm_support::Pallet::::deposit_trade_event( who, - pallet_trade_event::PoolType::Stableswap(pool_id.into()), - pallet_trade_event::TradeOperation::Sell, + pallet_amm_support::PoolType::Stableswap(pool_id.into()), + pallet_amm_support::TradeOperation::Sell, asset_in.into(), asset_out.into(), amount_in, @@ -930,10 +930,10 @@ impl Pallet { fee: fee_amount, }); - pallet_trade_event::Pallet::::deposit_trade_event( + pallet_amm_support::Pallet::::deposit_trade_event( who, - pallet_trade_event::PoolType::Stableswap(pool_id.into()), - pallet_trade_event::TradeOperation::Buy, + pallet_amm_support::PoolType::Stableswap(pool_id.into()), + pallet_amm_support::TradeOperation::Buy, asset_in.into(), asset_out.into(), amount_in, diff --git a/pallets/stableswap/src/tests/mock.rs b/pallets/stableswap/src/tests/mock.rs index b94ff1f63..b7637c241 100644 --- a/pallets/stableswap/src/tests/mock.rs +++ b/pallets/stableswap/src/tests/mock.rs @@ -81,7 +81,7 @@ construct_runtime!( System: frame_system, Tokens: orml_tokens, Stableswap: pallet_stableswap, - TradeEvent: pallet_trade_event, + TradeEvent: pallet_amm_support, } ); @@ -168,7 +168,7 @@ impl DustRemovalAccountWhitelist for Whitelist { } } -impl pallet_trade_event::Config for Test { +impl pallet_amm_support::Config for Test { type RuntimeEvent = RuntimeEvent; } diff --git a/pallets/stableswap/src/trade_execution.rs b/pallets/stableswap/src/trade_execution.rs index cd632269f..7dbf6142c 100644 --- a/pallets/stableswap/src/trade_execution.rs +++ b/pallets/stableswap/src/trade_execution.rs @@ -3,7 +3,7 @@ use crate::{Balance, Config, Error, Pallet, Pools, D_ITERATIONS, Y_ITERATIONS}; use hydra_dx_math::stableswap::types::AssetReserve; use hydradx_traits::router::{ExecutorError, PoolType, TradeExecution}; use orml_traits::MultiCurrency; -use pallet_trade_event::IncrementalIdType; +use pallet_amm_support::IncrementalIdType; use sp_core::Get; use sp_runtime::{ArithmeticError, DispatchError, FixedU128}; use sp_std::vec; diff --git a/pallets/xyk/Cargo.toml b/pallets/xyk/Cargo.toml index 68535415e..3f8affe69 100644 --- a/pallets/xyk/Cargo.toml +++ b/pallets/xyk/Cargo.toml @@ -29,7 +29,7 @@ orml-traits = { workspace = true } # HydraDX dependencies hydradx-traits = { workspace = true } -pallet-trade-event = { workspace = true } +pallet-amm-support = { workspace = true } # Substrate dependencies frame-benchmarking = { workspace = true, optional = true } @@ -66,6 +66,6 @@ std = [ 'frame-benchmarking/std', "scale-info/std", "pallet-asset-registry/std", - "pallet-trade-event/std", + "pallet-amm-support/std", ] try-runtime = ["frame-support/try-runtime"] diff --git a/pallets/xyk/src/lib.rs b/pallets/xyk/src/lib.rs index 985a3254e..8f4c33ed0 100644 --- a/pallets/xyk/src/lib.rs +++ b/pallets/xyk/src/lib.rs @@ -41,7 +41,7 @@ use sp_std::{vec, vec::Vec}; use crate::types::{Amount, AssetId, AssetPair, Balance}; use hydra_dx_math::ratio::Ratio; use orml_traits::{MultiCurrency, MultiCurrencyExtended}; -use pallet_trade_event::IncrementalIdType; +use pallet_amm_support::IncrementalIdType; #[cfg(test)] mod tests; @@ -76,7 +76,7 @@ pub mod pallet { impl Hooks> for Pallet {} #[pallet::config] - pub trait Config: frame_system::Config + pallet_trade_event::Config { + pub trait Config: frame_system::Config + pallet_amm_support::Config { type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Registry support @@ -250,7 +250,7 @@ pub mod pallet { }, /// Asset sale executed. - /// Deprecated. Replaced by pallet_trade_event::Swapped + /// Deprecated. Replaced by pallet_amm_support::Swapped SellExecuted { who: T::AccountId, asset_in: AssetId, @@ -263,7 +263,7 @@ pub mod pallet { }, /// Asset purchase executed. - /// Deprecated. Replaced by pallet_trade_event::Swapped + /// Deprecated. Replaced by pallet_amm_support::Swapped BuyExecuted { who: T::AccountId, asset_out: AssetId, @@ -631,7 +631,7 @@ pub mod pallet { /// `max_limit` - minimum amount of `asset_out` / amount of asset_out to be obtained from the pool in exchange for `asset_in`. /// /// Emits `SellExecuted` when successful. Deprecated. - /// Emits `pallet_trade_event::Swapped` when successful. + /// Emits `pallet_amm_support::Swapped` when successful. #[pallet::call_index(3)] #[pallet::weight(::WeightInfo::sell() + ::AMMHandler::on_trade_weight())] pub fn sell( @@ -662,7 +662,7 @@ pub mod pallet { /// /// `max_limit` - maximum amount of `asset_in` to be sold in exchange for `asset_out`. /// Emits `BuyExecuted` when successful. Deprecated. - /// Emits `pallet_trade_event::Swapped` when successful. + /// Emits `pallet_amm_support::Swapped` when successful. #[pallet::call_index(4)] #[pallet::weight(::WeightInfo::buy() + ::AMMHandler::on_trade_weight())] pub fn buy( @@ -922,10 +922,10 @@ impl AMM::deposit_trade_event( + pallet_amm_support::Pallet::::deposit_trade_event( transfer.origin.clone(), - pallet_trade_event::PoolType::XYK, - pallet_trade_event::TradeOperation::Sell, + pallet_amm_support::PoolType::XYK, + pallet_amm_support::TradeOperation::Sell, transfer.assets.asset_in, transfer.assets.asset_out, transfer.amount, @@ -1101,10 +1101,10 @@ impl AMM::deposit_trade_event( + pallet_amm_support::Pallet::::deposit_trade_event( transfer.origin.clone(), - pallet_trade_event::PoolType::XYK, - pallet_trade_event::TradeOperation::Buy, + pallet_amm_support::PoolType::XYK, + pallet_amm_support::TradeOperation::Buy, transfer.assets.asset_in, transfer.assets.asset_out, transfer.amount, diff --git a/pallets/xyk/src/tests/mock.rs b/pallets/xyk/src/tests/mock.rs index 180c6bb14..3d2fcf51c 100644 --- a/pallets/xyk/src/tests/mock.rs +++ b/pallets/xyk/src/tests/mock.rs @@ -61,7 +61,7 @@ frame_support::construct_runtime!( XYK: xyk, Currency: orml_tokens, AssetRegistry: pallet_asset_registry, - TradeEvent: pallet_trade_event, + TradeEvent: pallet_amm_support, } ); @@ -198,7 +198,7 @@ impl CanCreatePool for Disallow10_10Pool { } } -impl pallet_trade_event::Config for Test { +impl pallet_amm_support::Config for Test { type RuntimeEvent = RuntimeEvent; } diff --git a/pallets/xyk/src/trade_execution.rs b/pallets/xyk/src/trade_execution.rs index 6dede19c0..967ad8a8c 100644 --- a/pallets/xyk/src/trade_execution.rs +++ b/pallets/xyk/src/trade_execution.rs @@ -5,7 +5,7 @@ use frame_support::traits::Get; use hydradx_traits::router::{ExecutorError, PoolType, TradeExecution}; use hydradx_traits::AMM; use orml_traits::MultiCurrency; -use pallet_trade_event::IncrementalIdType; +use pallet_amm_support::IncrementalIdType; use sp_runtime::DispatchError::Corruption; use sp_runtime::{ArithmeticError, DispatchError, FixedPointNumber, FixedU128}; diff --git a/runtime/adapters/Cargo.toml b/runtime/adapters/Cargo.toml index 58f6d8d4b..ce5ef1121 100644 --- a/runtime/adapters/Cargo.toml +++ b/runtime/adapters/Cargo.toml @@ -66,7 +66,7 @@ pallet-balances = { workspace = true } lazy_static = { features = ["spin_no_std"], version = "1.4.0" } pretty_assertions = "1.4.0" pallet-xyk = { workspace = true } -pallet-trade-event = { workspace = true } +pallet-amm-support = { workspace = true } [features] default = ["std"] diff --git a/runtime/adapters/src/tests/mock.rs b/runtime/adapters/src/tests/mock.rs index 85f0752d2..22785b712 100644 --- a/runtime/adapters/src/tests/mock.rs +++ b/runtime/adapters/src/tests/mock.rs @@ -101,7 +101,7 @@ construct_runtime!( RouteExecutor: pallet_route_executor, Currencies: pallet_currencies, XYK: pallet_xyk, - TradeEvent: pallet_trade_event, + TradeEvent: pallet_amm_support, } ); @@ -258,7 +258,7 @@ impl pallet_xyk::Config for Test { type NonDustableWhitelistHandler = DummyDuster; } -impl pallet_trade_event::Config for Test { +impl pallet_amm_support::Config for Test { type RuntimeEvent = RuntimeEvent; } diff --git a/runtime/hydradx/Cargo.toml b/runtime/hydradx/Cargo.toml index 1bb049665..0336bbc60 100644 --- a/runtime/hydradx/Cargo.toml +++ b/runtime/hydradx/Cargo.toml @@ -38,7 +38,7 @@ pallet-bonds = { workspace = true } pallet-lbp = { workspace = true } pallet-xyk = { workspace = true } pallet-referrals = { workspace = true } -pallet-trade-event = { workspace = true } +pallet-amm-support = { workspace = true } pallet-evm-accounts = { workspace = true } pallet-evm-accounts-rpc-runtime-api = { workspace = true } pallet-xyk-liquidity-mining = { workspace = true } @@ -324,7 +324,7 @@ std = [ "parachains-common/std", "polkadot-runtime-common/std", "pallet-state-trie-migration/std", - "pallet-trade-event/std", + "pallet-amm-support/std", ] try-runtime = [ "frame-try-runtime", @@ -396,7 +396,7 @@ try-runtime = [ "pallet-xyk-liquidity-mining/try-runtime", "pallet-message-queue/try-runtime", "pallet-state-trie-migration/try-runtime", - "pallet-trade-event/try-runtime", + "pallet-amm-support/try-runtime", ] metadata-hash = [ diff --git a/runtime/hydradx/src/assets.rs b/runtime/hydradx/src/assets.rs index bd77f97fe..1b212f5a4 100644 --- a/runtime/hydradx/src/assets.rs +++ b/runtime/hydradx/src/assets.rs @@ -1584,7 +1584,7 @@ impl pallet_referrals::Config for Runtime { type BenchmarkHelper = ReferralsBenchmarkHelper; } -impl pallet_trade_event::Config for Runtime { +impl pallet_amm_support::Config for Runtime { type RuntimeEvent = RuntimeEvent; } diff --git a/runtime/hydradx/src/lib.rs b/runtime/hydradx/src/lib.rs index 4fbdd7ece..c5302d718 100644 --- a/runtime/hydradx/src/lib.rs +++ b/runtime/hydradx/src/lib.rs @@ -185,7 +185,7 @@ construct_runtime!( LBP: pallet_lbp = 73, XYK: pallet_xyk = 74, Referrals: pallet_referrals = 75, - TradeEvent: pallet_trade_event = 76, + TradeEvent: pallet_amm_support = 76, // ORML related modules Tokens: orml_tokens = 77, From 87bd9484ee9fd6cd333e152fec151ac3b4cd15eb Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Fri, 27 Sep 2024 15:10:47 +0200 Subject: [PATCH 007/142] fix some tests --- pallets/lbp/src/tests.rs | 14 +++++++------- pallets/otc-settlements/src/mock.rs | 6 +++--- .../stableswap/src/tests/calculate_spot_price.rs | 9 +++++++++ traits/src/router.rs | 1 + 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/pallets/lbp/src/tests.rs b/pallets/lbp/src/tests.rs index 16632ba64..73c301915 100644 --- a/pallets/lbp/src/tests.rs +++ b/pallets/lbp/src/tests.rs @@ -1829,7 +1829,7 @@ fn execute_sell_should_work() { assert_eq!(Currency::free_balance(asset_in, &pool_id), 1_000_000_000); assert_eq!(Currency::free_balance(asset_out, &pool_id), 2_000_000_000); - assert_ok!(LBPPallet::execute_sell(&t)); + assert_ok!(LBPPallet::execute_sell(&t, None)); expect_events(vec![Event::SellExecuted { who: ALICE, @@ -1886,7 +1886,7 @@ fn execute_sell_should_not_work() { assert_eq!(Currency::free_balance(KUSD, &KUSD_BSX_POOL_ID), 1_000_000_000); assert_eq!(Currency::free_balance(BSX, &KUSD_BSX_POOL_ID), 2_000_000_000); - assert_noop!(LBPPallet::execute_sell(&t), orml_tokens::Error::::BalanceTooLow); + assert_noop!(LBPPallet::execute_sell(&t, None), orml_tokens::Error::::BalanceTooLow); assert_eq!(Currency::free_balance(KUSD, &ALICE), 999_999_000_000_000); assert_eq!(Currency::free_balance(BSX, &ALICE), 999_998_000_000_000); @@ -1961,7 +1961,7 @@ fn execute_buy_should_work() { assert_eq!(Currency::free_balance(asset_in, &pool_id), 1_000_000_000); assert_eq!(Currency::free_balance(asset_out, &pool_id), 2_000_000_000); - assert_ok!(LBPPallet::execute_buy(&t, None)); + assert_ok!(LBPPallet::execute_buy(&t, None, None)); assert_eq!(Currency::free_balance(asset_in, &ALICE), 999_998_991_999_000); assert_eq!(Currency::free_balance(asset_out, &ALICE), 999_998_020_000_000); @@ -2012,7 +2012,7 @@ fn execute_buy_should_not_work() { assert_eq!(Currency::free_balance(asset_out, &pool_id), 2_000_000_000); assert_noop!( - LBPPallet::execute_buy(&t, None), + LBPPallet::execute_buy(&t, None, None), orml_tokens::Error::::BalanceTooLow ); @@ -3692,7 +3692,7 @@ fn collected_fees_should_be_locked_and_unlocked_after_liquidity_is_removed() { run_to_sale_start(); let Pool { fee_collector, .. } = LBPPallet::pool_data(KUSD_BSX_POOL_ID).unwrap(); let (fee_asset, fee_amount) = SAMPLE_AMM_TRANSFER.fee; - assert_ok!(LBPPallet::execute_buy(&SAMPLE_AMM_TRANSFER, None)); + assert_ok!(LBPPallet::execute_buy(&SAMPLE_AMM_TRANSFER, None, None)); // collector receives locked fee assert_eq!(Currency::free_balance(fee_asset, &fee_collector), fee_amount); @@ -3723,8 +3723,8 @@ fn collected_fees_are_continually_locked() { run_to_sale_start(); let Pool { fee_collector, .. } = LBPPallet::pool_data(KUSD_BSX_POOL_ID).unwrap(); let (fee_asset, fee_amount) = SAMPLE_AMM_TRANSFER.fee; - assert_ok!(LBPPallet::execute_buy(&SAMPLE_AMM_TRANSFER, None)); - assert_ok!(LBPPallet::execute_buy(&SAMPLE_AMM_TRANSFER, None)); + assert_ok!(LBPPallet::execute_buy(&SAMPLE_AMM_TRANSFER, None, None)); + assert_ok!(LBPPallet::execute_buy(&SAMPLE_AMM_TRANSFER, None, None)); let total = 2 * fee_amount; assert_eq!(Currency::free_balance(fee_asset, &fee_collector), total); assert_eq!( diff --git a/pallets/otc-settlements/src/mock.rs b/pallets/otc-settlements/src/mock.rs index 740d655c8..20e79195b 100644 --- a/pallets/otc-settlements/src/mock.rs +++ b/pallets/otc-settlements/src/mock.rs @@ -92,17 +92,17 @@ parameter_type_with_key! { }; } -impl pallet_otc_settlements::Config for Test { - type Currency = pallet_currencies::fungibles::FungibleCurrencies; +impl Config for Test { type RuntimeEvent = RuntimeEvent; + type Currency = FungibleCurrencies; type Router = Router; type ProfitReceiver = TreasuryAccount; type MinProfitPercentage = MinProfitPercentage; type PricePrecision = PricePrecision; type MinTradingLimit = MinTradingLimit; type MaxIterations = ConstU32<40>; - type WeightInfo = (); type RouterWeightInfo = (); + type WeightInfo = (); } impl pallet_otc::Config for Test { diff --git a/pallets/stableswap/src/tests/calculate_spot_price.rs b/pallets/stableswap/src/tests/calculate_spot_price.rs index d28553512..00b26f43f 100644 --- a/pallets/stableswap/src/tests/calculate_spot_price.rs +++ b/pallets/stableswap/src/tests/calculate_spot_price.rs @@ -57,6 +57,7 @@ fn spot_price_calculation_should_work_when_asset_in_is_share_with_6_decimals() { asset_b, sell_amount, 0, + None, )); let expected = 9; @@ -129,6 +130,7 @@ fn spot_price_calculation_should_work_when_asset_in_is_share_with_12_decimals() asset_b, sell_amount, 0, + None, )); let expected = 994999; @@ -205,6 +207,7 @@ fn spot_price_calculation_should_work_when_asset_in_is_share_with_18_decimals() asset_b, sell_amount, 0, + None, )); let expected = 991; @@ -290,6 +293,7 @@ fn spot_price_calculation_should_work_when_asset_out_is_share_with_12_decimals() pool_id, sell_amount, 0, + None, )); let expected = 986999999; @@ -365,6 +369,7 @@ fn spot_price_calculation_should_work_when_asset_out_is_share_with_18_decimals() pool_id, sell_amount, 0, + None, )); let expected = 984938537439245; @@ -431,6 +436,7 @@ fn spot_price_calculation_should_work_for_two_stableassets() { asset_b, sell_amount, 0, + None, )); let expected = 989999901; @@ -506,6 +512,7 @@ fn spot_price_calculation_should_work_for_two_stableassets_on_different_position asset_b, sell_amount, 0, + None, )); let expected = 968488820; @@ -592,6 +599,7 @@ mod invariants { asset_b, sell_amount, 0, + None, )); assert_balance!(BOB, pool_id, bob_share_balance - sell_amount); @@ -659,6 +667,7 @@ mod invariants { pool_id, sell_amount, 0, + None, )); diff --git a/traits/src/router.rs b/traits/src/router.rs index 06b2a3469..225255a41 100644 --- a/traits/src/router.rs +++ b/traits/src/router.rs @@ -73,6 +73,7 @@ pub enum PoolType { Stableswap(AssetId), Omnipool, OTC(u32), + ICE, } #[derive(Debug, PartialEq, Eq)] From ac008a377412df7b9ac6597e2cd94a0e4cbf4647 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Fri, 27 Sep 2024 15:11:05 +0200 Subject: [PATCH 008/142] update the event structure --- integration-tests/src/fee_calculation.rs | 13 +---------- integration-tests/src/router.rs | 28 ++++++++++++++++++++++++ pallets/amm-support/src/lib.rs | 21 ++++++++++-------- pallets/lbp/src/lib.rs | 8 +++++-- pallets/lbp/src/tests.rs | 5 ++++- pallets/omnipool/src/lib.rs | 12 ++++++---- pallets/otc/src/lib.rs | 8 +++++-- pallets/route-executor/src/lib.rs | 5 ++++- pallets/stableswap/src/lib.rs | 6 +++-- pallets/xyk/src/lib.rs | 10 +++++---- runtime/hydradx/src/assets.rs | 8 ------- traits/src/router.rs | 10 ++++++++- 12 files changed, 88 insertions(+), 46 deletions(-) diff --git a/integration-tests/src/fee_calculation.rs b/integration-tests/src/fee_calculation.rs index 1938f8664..8d3eb203e 100644 --- a/integration-tests/src/fee_calculation.rs +++ b/integration-tests/src/fee_calculation.rs @@ -4,12 +4,11 @@ use crate::{oracle::hydradx_run_to_block, polkadot_test_net::*}; use frame_support::assert_ok; use frame_support::dispatch::DispatchClass; use frame_support::dispatch::GetDispatchInfo; -use frame_support::weights::constants::RocksDbWeight; use frame_support::weights::WeightToFee as WeightToFeeTrait; use hydradx_runtime::evm::precompiles::DISPATCH_ADDR; use hydradx_runtime::TransactionPayment; use hydradx_runtime::EVM; -use hydradx_runtime::{ExtrinsicBaseWeight, Runtime, Tokens, WeightToFee}; +use hydradx_runtime::{Runtime, Tokens}; use orml_traits::MultiCurrency; use pallet_evm::FeeCalculator; use primitives::constants::chain::Weight; @@ -17,7 +16,6 @@ use primitives::constants::currency::UNITS; use primitives::constants::time::HOURS; use sp_core::Encode; use sp_core::U256; -use sp_io::storage::changes_root; use sp_runtime::{FixedU128, Permill}; use test_utils::assert_eq_approx; use xcm_emulator::TestExt; @@ -206,16 +204,7 @@ fn substrate_and_evm_fee_growth_simulator_with_idle_chain() { let info = call.get_dispatch_info(); let fee = TransactionPayment::compute_fee(SWAP_ENCODED_LEN, &info, 0); - let fee_in_cent = (fee as f64 * HDX_USD_SPOT_PRICE) / 1000000000000.0; - let fee_in_cent = round(fee_in_cent); - - let evm_fee_in_cent = round(get_evm_fee_in_cent(nonce as u128)); - let next = TransactionPayment::next_fee_multiplier(); - - let gas_price = hydradx_runtime::DynamicEvmFee::min_gas_price(); - println!("{b:?} - fee: {fee:?}"); - //println!("{b:?} - fee: ${fee_in_cent:?} - evm_fee: ${evm_fee_in_cent:?} - multiplier: {next:?} - gas {gas_price:?}"); } }); } diff --git a/integration-tests/src/router.rs b/integration-tests/src/router.rs index e68797d06..a6f529ddd 100644 --- a/integration-tests/src/router.rs +++ b/integration-tests/src/router.rs @@ -157,6 +157,7 @@ mod router_different_pools_tests { asset_out: DOT, amount_in: amount_to_sell, amount_out, + event_id: 0, } .into()]); }); @@ -223,6 +224,7 @@ mod router_different_pools_tests { asset_out: stable_asset_2, amount_in: amount_to_sell, amount_out, + event_id: 0, } .into()]); @@ -286,6 +288,7 @@ mod router_different_pools_tests { asset_out: DOT, amount_in, amount_out: amount_to_buy, + event_id: 0, } .into()]); }); @@ -352,6 +355,7 @@ mod router_different_pools_tests { asset_out: stable_asset_2, amount_in, amount_out: amount_to_buy, + event_id: 0, } .into()]); TransactionOutcome::Commit(DispatchResult::Ok(())) @@ -802,6 +806,7 @@ mod omnipool_router_tests { asset_out: DAI, amount_in: amount_to_sell, amount_out, + event_id: 0, } .into()]); }); @@ -1976,6 +1981,7 @@ mod omnipool_router_tests { asset_out: DAI, amount_in: amount_to_sell, amount_out, + event_id: 0, } .into()]); }); @@ -2019,6 +2025,7 @@ mod omnipool_router_tests { asset_out: DAI, amount_in: amount_to_sell, amount_out, + event_id: 0, } .into()]); }); @@ -2094,6 +2101,7 @@ mod omnipool_router_tests { asset_out: DAI, amount_in, amount_out: amount_to_buy, + event_id: 0, } .into()]); }); @@ -2199,6 +2207,7 @@ mod omnipool_router_tests { asset_out: DAI, amount_in, amount_out: amount_to_buy, + event_id: 0, } .into()]); }); @@ -2311,6 +2320,7 @@ mod lbp_router_tests { asset_out: DAI, amount_in: amount_to_sell, amount_out, + event_id: 0, } .into()]); }); @@ -2354,6 +2364,7 @@ mod lbp_router_tests { asset_out: HDX, amount_in: amount_to_sell, amount_out, + event_id: 0, } .into()]); }); @@ -2406,6 +2417,7 @@ mod lbp_router_tests { asset_out: DOT, amount_in: amount_to_sell, amount_out, + event_id: 0, } .into()]); }); @@ -2458,6 +2470,7 @@ mod lbp_router_tests { asset_out: DOT, amount_in: amount_to_sell, amount_out, + event_id: 0, } .into()]); }); @@ -2501,6 +2514,7 @@ mod lbp_router_tests { asset_out: DAI, amount_in: amount_to_sell, amount_out: received_amount_out, + event_id: 0, } .into()]); }); @@ -2576,6 +2590,7 @@ mod lbp_router_tests { asset_out: DAI, amount_in, amount_out: amount_to_buy, + event_id: 0, } .into()]); }); @@ -2619,6 +2634,7 @@ mod lbp_router_tests { asset_out: HDX, amount_in, amount_out: amount_to_buy, + event_id: 0, } .into()]); }); @@ -2671,6 +2687,7 @@ mod lbp_router_tests { asset_out: DOT, amount_in, amount_out: amount_to_buy, + event_id: 0, } .into()]); }); @@ -2723,6 +2740,7 @@ mod lbp_router_tests { asset_out: DOT, amount_in, amount_out: amount_to_buy, + event_id: 0, } .into()]); }); @@ -2766,6 +2784,7 @@ mod lbp_router_tests { asset_out: DAI, amount_in: spent_amount_in, amount_out: amount_to_buy, + event_id: 0, } .into()]); }); @@ -2868,6 +2887,7 @@ mod xyk_router_tests { asset_out: DOT, amount_in: amount_to_sell, amount_out, + event_id: 0, } .into()]); }); @@ -2931,6 +2951,7 @@ mod xyk_router_tests { asset_out: DOT, amount_in: amount_to_sell, amount_out, + event_id: 0, } .into()]); }); @@ -3096,6 +3117,7 @@ mod xyk_router_tests { asset_out: DOT, amount_in, amount_out: amount_to_buy, + event_id: 0, } .into()]); }); @@ -3151,6 +3173,7 @@ mod xyk_router_tests { asset_out: DAI, amount_in, amount_out: amount_to_buy, + event_id: 0, } .into()]); }); @@ -3214,6 +3237,7 @@ mod xyk_router_tests { asset_out: DAI, amount_in, amount_out: amount_to_buy, + event_id: 0, } .into()]); }); @@ -4935,6 +4959,7 @@ mod with_on_chain_and_default_route { asset_out: DAI, amount_in: amount_to_sell, amount_out, + event_id: 0, } .into()]); }); @@ -4972,6 +4997,7 @@ mod with_on_chain_and_default_route { asset_out: DAI, amount_in, amount_out: amount_to_buy, + event_id: 0, } .into()]); }); @@ -5333,6 +5359,7 @@ mod sell_all { asset_out: DAI, amount_in: bob_hdx_balance, amount_out, + event_id: 0, } .into()]); }); @@ -5374,6 +5401,7 @@ mod sell_all { asset_out: HDX, amount_in: bob_nonnative_balance, amount_out, + event_id: 0, } .into()]); }); diff --git a/pallets/amm-support/src/lib.rs b/pallets/amm-support/src/lib.rs index 846e4e7c7..16e563884 100644 --- a/pallets/amm-support/src/lib.rs +++ b/pallets/amm-support/src/lib.rs @@ -21,7 +21,7 @@ type AssetId = u32; type Balance = u128; pub use hydradx_traits::{ - router::{PoolType, TradeOperation}, + router::{Filler, TradeOperation}, IncrementalIdProvider, }; pub use primitives::IncrementalId as IncrementalIdType; @@ -55,8 +55,9 @@ pub mod pallet { pub enum Event { /// Trade executed. Swapped { - who: T::AccountId, - pool: PoolType, + swapper: T::AccountId, + filler: T::AccountId, + filler_type: Filler, operation: TradeOperation, asset_in: AssetId, asset_out: AssetId, @@ -80,26 +81,28 @@ impl Pallet { #[allow(clippy::too_many_arguments)] pub fn deposit_trade_event( - who: T::AccountId, - pool: PoolType, + swapper: T::AccountId, + filler: T::AccountId, + filler_type: Filler, operation: TradeOperation, asset_in: AssetId, asset_out: AssetId, amount_in: Balance, amount_out: Balance, fees: Vec<(AssetId, Balance)>, - event_id: Option, + event_id: Option, ) { Self::deposit_event(Event::::Swapped { - who, - pool, + swapper, + filler, + filler_type, operation, asset_in, asset_out, amount_in, amount_out, fees, - event_id: event_id, + event_id, }); } } diff --git a/pallets/lbp/src/lib.rs b/pallets/lbp/src/lib.rs index e5f9ea46c..b883a49ac 100644 --- a/pallets/lbp/src/lib.rs +++ b/pallets/lbp/src/lib.rs @@ -1128,9 +1128,11 @@ impl AMM, IncrementalI fee_amount: transfer.fee.1, }); + let pool_account = Self::get_pair_id(transfer.assets); pallet_amm_support::Pallet::::deposit_trade_event( transfer.origin.clone(), - pallet_amm_support::PoolType::LBP, + pool_account, + pallet_amm_support::Filler::LBP, pallet_amm_support::TradeOperation::Sell, transfer.assets.asset_in, transfer.assets.asset_out, @@ -1279,9 +1281,11 @@ impl AMM, IncrementalI fee_amount: transfer.fee.1, }); + let pool_account = Self::get_pair_id(transfer.assets); pallet_amm_support::Pallet::::deposit_trade_event( transfer.origin.clone(), - pallet_amm_support::PoolType::LBP, + pool_account, + pallet_amm_support::Filler::LBP, pallet_amm_support::TradeOperation::Buy, transfer.assets.asset_in, transfer.assets.asset_out, diff --git a/pallets/lbp/src/tests.rs b/pallets/lbp/src/tests.rs index 73c301915..a2106c6cc 100644 --- a/pallets/lbp/src/tests.rs +++ b/pallets/lbp/src/tests.rs @@ -1886,7 +1886,10 @@ fn execute_sell_should_not_work() { assert_eq!(Currency::free_balance(KUSD, &KUSD_BSX_POOL_ID), 1_000_000_000); assert_eq!(Currency::free_balance(BSX, &KUSD_BSX_POOL_ID), 2_000_000_000); - assert_noop!(LBPPallet::execute_sell(&t, None), orml_tokens::Error::::BalanceTooLow); + assert_noop!( + LBPPallet::execute_sell(&t, None), + orml_tokens::Error::::BalanceTooLow + ); assert_eq!(Currency::free_balance(KUSD, &ALICE), 999_999_000_000_000); assert_eq!(Currency::free_balance(BSX, &ALICE), 999_998_000_000_000); diff --git a/pallets/omnipool/src/lib.rs b/pallets/omnipool/src/lib.rs index 2704f2f4a..53f605c52 100644 --- a/pallets/omnipool/src/lib.rs +++ b/pallets/omnipool/src/lib.rs @@ -1673,7 +1673,8 @@ impl Pallet { pallet_amm_support::Pallet::::deposit_trade_event( who.clone(), - pallet_amm_support::PoolType::Omnipool, + Self::protocol_account(), + pallet_amm_support::Filler::Omnipool, pallet_amm_support::TradeOperation::Sell, asset_in.into(), asset_out.into(), @@ -1874,7 +1875,8 @@ impl Pallet { pallet_amm_support::Pallet::::deposit_trade_event( who.clone(), - pallet_amm_support::PoolType::Omnipool, + Self::protocol_account(), + pallet_amm_support::Filler::Omnipool, pallet_amm_support::TradeOperation::Buy, asset_in.into(), asset_out.into(), @@ -1998,7 +2000,8 @@ impl Pallet { pallet_amm_support::Pallet::::deposit_trade_event( who.clone(), - pallet_amm_support::PoolType::Omnipool, + Self::protocol_account(), + pallet_amm_support::Filler::Omnipool, pallet_amm_support::TradeOperation::Sell, T::HubAssetId::get().into(), asset_out.into(), @@ -2118,7 +2121,8 @@ impl Pallet { pallet_amm_support::Pallet::::deposit_trade_event( who.clone(), - pallet_amm_support::PoolType::Omnipool, + Self::protocol_account(), + pallet_amm_support::Filler::Omnipool, pallet_amm_support::TradeOperation::Buy, T::HubAssetId::get().into(), asset_out.into(), diff --git a/pallets/otc/src/lib.rs b/pallets/otc/src/lib.rs index e90c89254..2dcca4654 100644 --- a/pallets/otc/src/lib.rs +++ b/pallets/otc/src/lib.rs @@ -308,9 +308,11 @@ pub mod pallet { fee, }); + // TODO: order_id is missing pallet_amm_support::Pallet::::deposit_trade_event( who, - pallet_amm_support::PoolType::OTC(order_id), + order.owner.clone(), + pallet_amm_support::Filler::OTC, pallet_amm_support::TradeOperation::Sell, order.asset_in.into(), order.asset_out.into(), @@ -352,9 +354,11 @@ pub mod pallet { fee, }); + // TODO: order_id is missing pallet_amm_support::Pallet::::deposit_trade_event( who, - pallet_amm_support::PoolType::OTC(order_id), + order.owner, + pallet_amm_support::Filler::OTC, pallet_amm_support::TradeOperation::Sell, order.asset_in.into(), order.asset_out.into(), diff --git a/pallets/route-executor/src/lib.rs b/pallets/route-executor/src/lib.rs index 0948bfa65..b7f31c6e3 100644 --- a/pallets/route-executor/src/lib.rs +++ b/pallets/route-executor/src/lib.rs @@ -39,6 +39,7 @@ pub use hydradx_traits::router::{ }; use hydradx_traits::IncrementalIdProvider; use orml_traits::arithmetic::{CheckedAdd, CheckedSub}; +use pallet_amm_support::IncrementalIdType; use primitives::IncrementalId; use sp_core::U512; use sp_runtime::traits::{AccountIdConversion, CheckedDiv}; @@ -143,6 +144,7 @@ pub mod pallet { asset_out: T::AssetId, amount_in: T::Balance, amount_out: T::Balance, + event_id: IncrementalIdType, }, ///The route with trades has been successfully executed RouteUpdated { asset_ids: Vec }, @@ -298,6 +300,7 @@ pub mod pallet { asset_out, amount_in: first_trade.amount_in, amount_out, + event_id: next_event_id, }); Ok(()) @@ -532,6 +535,7 @@ impl Pallet { asset_out, amount_in, amount_out: last_trade_amount.amount_out, + event_id: next_event_id, }); Ok(()) @@ -695,7 +699,6 @@ impl Pallet { PoolType::Stableswap(pool_id) => pool_id, PoolType::XYK => first_route.asset_out, PoolType::LBP => first_route.asset_out, - _ => return Err(Error::::PoolNotSupported.into()), }; let asset_in_liquidity = T::AMM::get_liquidity_depth(first_route.pool, first_route.asset_in, asset_b); diff --git a/pallets/stableswap/src/lib.rs b/pallets/stableswap/src/lib.rs index a6749ba74..7cfb1e6b8 100644 --- a/pallets/stableswap/src/lib.rs +++ b/pallets/stableswap/src/lib.rs @@ -856,7 +856,8 @@ impl Pallet { pallet_amm_support::Pallet::::deposit_trade_event( who, - pallet_amm_support::PoolType::Stableswap(pool_id.into()), + pool_account, + pallet_amm_support::Filler::Stableswap, pallet_amm_support::TradeOperation::Sell, asset_in.into(), asset_out.into(), @@ -932,7 +933,8 @@ impl Pallet { pallet_amm_support::Pallet::::deposit_trade_event( who, - pallet_amm_support::PoolType::Stableswap(pool_id.into()), + pool_account, + pallet_amm_support::Filler::Stableswap, pallet_amm_support::TradeOperation::Buy, asset_in.into(), asset_out.into(), diff --git a/pallets/xyk/src/lib.rs b/pallets/xyk/src/lib.rs index 8f4c33ed0..4c226db1c 100644 --- a/pallets/xyk/src/lib.rs +++ b/pallets/xyk/src/lib.rs @@ -919,12 +919,13 @@ impl AMM::deposit_trade_event( transfer.origin.clone(), - pallet_amm_support::PoolType::XYK, + pair_account, + pallet_amm_support::Filler::XYK, pallet_amm_support::TradeOperation::Sell, transfer.assets.asset_in, transfer.assets.asset_out, @@ -1098,12 +1099,13 @@ impl AMM::deposit_trade_event( transfer.origin.clone(), - pallet_amm_support::PoolType::XYK, + pair_account, + pallet_amm_support::Filler::XYK, pallet_amm_support::TradeOperation::Buy, transfer.assets.asset_in, transfer.assets.asset_out, diff --git a/runtime/hydradx/src/assets.rs b/runtime/hydradx/src/assets.rs index 1b212f5a4..12574609e 100644 --- a/runtime/hydradx/src/assets.rs +++ b/runtime/hydradx/src/assets.rs @@ -969,7 +969,6 @@ impl AmmTradeWeights> for RouterWeightInfo { } PoolType::XYK => weights::pallet_xyk::HydraWeight::::router_execution_sell(c, e) .saturating_add(::AMMHandler::on_trade_weight()), - _ => Weight::MAX, }; weight.saturating_accrue(amm_weight); } @@ -1018,7 +1017,6 @@ impl AmmTradeWeights> for RouterWeightInfo { } PoolType::XYK => weights::pallet_xyk::HydraWeight::::router_execution_buy(c, e) .saturating_add(::AMMHandler::on_trade_weight()), - _ => Weight::MAX, }; weight.saturating_accrue(amm_weight); } @@ -1051,7 +1049,6 @@ impl AmmTradeWeights> for RouterWeightInfo { } PoolType::XYK => weights::pallet_xyk::HydraWeight::::router_execution_buy(c, e) .saturating_add(::AMMHandler::on_trade_weight()), - _ => Weight::MAX, }; weight.saturating_accrue(amm_weight); } @@ -1076,7 +1073,6 @@ impl AmmTradeWeights> for RouterWeightInfo { } PoolType::XYK => weights::pallet_xyk::HydraWeight::::router_execution_sell(c, e) .saturating_add(::AMMHandler::on_trade_weight()), - _ => Weight::MAX, }; weight.saturating_accrue(amm_weight); } @@ -1101,7 +1097,6 @@ impl AmmTradeWeights> for RouterWeightInfo { } PoolType::XYK => weights::pallet_xyk::HydraWeight::::router_execution_buy(c, e) .saturating_add(::AMMHandler::on_trade_weight()), - _ => Weight::MAX, }; weight.saturating_accrue(amm_weight); } @@ -1134,7 +1129,6 @@ impl AmmTradeWeights> for RouterWeightInfo { weights::pallet_stableswap::HydraWeight::::router_execution_sell(1, 0) } PoolType::XYK => weights::pallet_xyk::HydraWeight::::router_execution_sell(1, 0), - _ => Weight::MAX, }; weight.saturating_accrue(amm_weight); } @@ -1148,7 +1142,6 @@ impl AmmTradeWeights> for RouterWeightInfo { weights::pallet_stableswap::HydraWeight::::router_execution_sell(1, 0) } PoolType::XYK => weights::pallet_xyk::HydraWeight::::router_execution_sell(1, 0), - _ => Weight::MAX, }; weight.saturating_accrue(amm_weight); } @@ -1181,7 +1174,6 @@ impl AmmTradeWeights> for RouterWeightInfo { weights::pallet_stableswap::HydraWeight::::calculate_spot_price_with_fee() } PoolType::XYK => weights::pallet_xyk::HydraWeight::::calculate_spot_price_with_fee(), - _ => Weight::MAX, }; weight.saturating_accrue(amm_weight); } diff --git a/traits/src/router.rs b/traits/src/router.rs index 225255a41..028ef18d2 100644 --- a/traits/src/router.rs +++ b/traits/src/router.rs @@ -72,7 +72,15 @@ pub enum PoolType { LBP, Stableswap(AssetId), Omnipool, - OTC(u32), +} + +#[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] +pub enum Filler { + Omnipool, + Stableswap, + XYK, + LBP, + OTC, ICE, } From 0f5c9a3ed3297fb8da34c0f65aad5d8dc2c2225a Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Mon, 30 Sep 2024 14:55:52 +0200 Subject: [PATCH 009/142] fix lbp tests --- pallets/amm-support/src/lib.rs | 4 +- pallets/lbp/src/lib.rs | 11 +- pallets/lbp/src/tests.rs | 220 +++++++++++++++++++++++---------- 3 files changed, 167 insertions(+), 68 deletions(-) diff --git a/pallets/amm-support/src/lib.rs b/pallets/amm-support/src/lib.rs index 16e563884..a30430b3c 100644 --- a/pallets/amm-support/src/lib.rs +++ b/pallets/amm-support/src/lib.rs @@ -63,7 +63,7 @@ pub mod pallet { asset_out: AssetId, amount_in: Balance, amount_out: Balance, - fees: Vec<(AssetId, Balance)>, + fees: Vec<(AssetId, Balance, T::AccountId)>, // (asset, fee amount, fee recipient) event_id: Option, }, } @@ -89,7 +89,7 @@ impl Pallet { asset_out: AssetId, amount_in: Balance, amount_out: Balance, - fees: Vec<(AssetId, Balance)>, + fees: Vec<(AssetId, Balance, T::AccountId)>, event_id: Option, ) { Self::deposit_event(Event::::Swapped { diff --git a/pallets/lbp/src/lib.rs b/pallets/lbp/src/lib.rs index b883a49ac..fbb60007a 100644 --- a/pallets/lbp/src/lib.rs +++ b/pallets/lbp/src/lib.rs @@ -28,7 +28,6 @@ use frame_support::sp_runtime::{ DispatchError, RuntimeDebug, }; use frame_support::{ - dispatch, dispatch::DispatchResult, ensure, traits::{EnsureOrigin, Get, LockIdentifier}, @@ -1129,6 +1128,8 @@ impl AMM, IncrementalI }); let pool_account = Self::get_pair_id(transfer.assets); + let pool = >::try_get(&pool_account).map_err(|_| Error::::PoolNotFound)?; + pallet_amm_support::Pallet::::deposit_trade_event( transfer.origin.clone(), pool_account, @@ -1138,7 +1139,7 @@ impl AMM, IncrementalI transfer.assets.asset_out, transfer.amount, transfer.amount_b, - vec![transfer.fee], + vec![(transfer.fee.0, transfer.fee.1, pool.fee_collector)], event_id, ); @@ -1267,7 +1268,7 @@ impl AMM, IncrementalI transfer: &AMMTransfer>, _destination: Option<&T::AccountId>, event_id: Option, - ) -> dispatch::DispatchResult { + ) -> DispatchResult { Self::execute_trade(transfer)?; // TODO: Deprecated, remove when ready @@ -1282,6 +1283,8 @@ impl AMM, IncrementalI }); let pool_account = Self::get_pair_id(transfer.assets); + let pool = >::try_get(&pool_account).map_err(|_| Error::::PoolNotFound)?; + pallet_amm_support::Pallet::::deposit_trade_event( transfer.origin.clone(), pool_account, @@ -1291,7 +1294,7 @@ impl AMM, IncrementalI transfer.assets.asset_out, transfer.amount, transfer.amount_b, - vec![transfer.fee], + vec![(transfer.fee.0, transfer.fee.1, pool.fee_collector)], event_id, ); diff --git a/pallets/lbp/src/tests.rs b/pallets/lbp/src/tests.rs index a2106c6cc..dd2d95a05 100644 --- a/pallets/lbp/src/tests.rs +++ b/pallets/lbp/src/tests.rs @@ -1809,6 +1809,7 @@ fn execute_sell_should_work() { let asset_in = KUSD; let asset_out = BSX; let pool_id = LBPPallet::get_pair_id(AssetPair { asset_in, asset_out }); + let pool_data = >::try_get(&pool_id).unwrap(); let amount_in = 8_000_000_u128; let amount_b = 20_000_000_u128; @@ -1831,16 +1832,31 @@ fn execute_sell_should_work() { assert_ok!(LBPPallet::execute_sell(&t, None)); - expect_events(vec![Event::SellExecuted { - who: ALICE, - asset_in, - asset_out, - amount: amount_in, - sale_price: amount_b, - fee_asset: asset_in, - fee_amount: 1_000, - } - .into()]); + expect_events(vec![ + Event::SellExecuted { + who: ALICE, + asset_in, + asset_out, + amount: amount_in, + sale_price: amount_b, + fee_asset: asset_in, + fee_amount: 1_000, + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: ALICE, + filler: pool_id, + filler_type: pallet_amm_support::Filler::LBP, + operation: pallet_amm_support::TradeOperation::Sell, + asset_in, + asset_out, + amount_in, + amount_out: amount_b, + fees: vec![(asset_in, 1_000, pool_data.fee_collector)], + event_id: None, + } + .into(), + ]); assert_eq!(Currency::free_balance(asset_in, &ALICE), 999_998_991_999_000); assert_eq!(Currency::free_balance(asset_out, &ALICE), 999_998_020_000_000); @@ -1848,17 +1864,6 @@ fn execute_sell_should_work() { assert_eq!(Currency::free_balance(asset_in, &pool_id), 1_008_000_000); assert_eq!(Currency::free_balance(asset_out, &pool_id), 1_980_000_000); - - expect_events(vec![Event::SellExecuted { - who: ALICE, - asset_in, - asset_out, - amount: 8_000_000, - sale_price: 20_000_000, - fee_asset: asset_in, - fee_amount: 1_000, - } - .into()]); }); } @@ -1943,6 +1948,7 @@ fn execute_buy_should_work() { let asset_in = KUSD; let asset_out = BSX; let pool_id = LBPPallet::get_pair_id(AssetPair { asset_in, asset_out }); + let pool_data = >::try_get(&pool_id).unwrap(); let amount_in = 8_000_000_u128; let amount_b = 20_000_000_u128; @@ -1974,16 +1980,31 @@ fn execute_buy_should_work() { assert_eq!(Currency::free_balance(asset_in, &pool_id), 1_008_000_000); assert_eq!(Currency::free_balance(asset_out, &pool_id), 1_980_000_000); - expect_events(vec![Event::BuyExecuted { - who: ALICE, - asset_out, - asset_in, - amount: 8_000_000, - buy_price: 20_000_000, - fee_asset: asset_in, - fee_amount: 1_000, - } - .into()]); + expect_events(vec![ + Event::BuyExecuted { + who: ALICE, + asset_in, + asset_out, + amount: amount_in, + buy_price: amount_b, + fee_asset: asset_in, + fee_amount: 1_000, + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: ALICE, + filler: pool_id, + filler_type: pallet_amm_support::Filler::LBP, + operation: pallet_amm_support::TradeOperation::Buy, + asset_in, + asset_out, + amount_in, + amount_out: amount_b, + fees: vec![(asset_in, 1_000, pool_data.fee_collector)], + event_id: None, + } + .into(), + ]); }); } @@ -2278,6 +2299,7 @@ fn buy_should_work() { let asset_in = KUSD; let asset_out = BSX; let pool_id = LBPPallet::get_pair_id(AssetPair { asset_in, asset_out }); + let pool_data = >::try_get(&pool_id).unwrap(); //start sale set_block_number(11); @@ -2289,6 +2311,32 @@ fn buy_should_work() { 2_000_000_000_u128 )); + expect_events(vec![ + Event::BuyExecuted { + who: buyer, + asset_in, + asset_out, + amount: 17_894_738, + buy_price: 10_000_000, + fee_asset: asset_in, + fee_amount: 35860, + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: buyer, + filler: pool_id, + filler_type: pallet_amm_support::Filler::LBP, + operation: pallet_amm_support::TradeOperation::Buy, + asset_in, + asset_out, + amount_in: 17_894_738, + amount_out: 10_000_000, + fees: vec![(asset_in, 35860, pool_data.fee_collector)], + event_id: None, // calling buy directly from the pallet doesn't set event_id + } + .into(), + ]); + assert_eq!(Currency::free_balance(asset_in, &buyer), 999_999_982_069_402); assert_eq!(Currency::free_balance(asset_out, &buyer), 1_000_000_010_000_000); assert_eq!(Currency::free_balance(asset_in, &pool_id), 1_017_894_738); @@ -2396,6 +2444,8 @@ fn buy_should_work_when_limit_is_set_above_account_balance() { let buyer = BOB; let asset_in = KUSD; let asset_out = BSX; + let pool_id = LBPPallet::get_pair_id(AssetPair { asset_in, asset_out }); + let pool_data = >::try_get(&pool_id).unwrap(); //start sale set_block_number(11); @@ -2408,16 +2458,31 @@ fn buy_should_work_when_limit_is_set_above_account_balance() { u128::MAX, )); - expect_events(vec![Event::BuyExecuted { - who: buyer, - asset_out: BSX, - asset_in: KUSD, - amount: 17_894_738, - buy_price: 10_000_000, - fee_asset: KUSD, - fee_amount: 35_860, - } - .into()]); + expect_events(vec![ + Event::BuyExecuted { + who: buyer, + asset_in, + asset_out, + amount: 17_894_738, + buy_price: 10_000_000, + fee_asset: asset_in, + fee_amount: 35860, + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: buyer, + filler: pool_id, + filler_type: pallet_amm_support::Filler::LBP, + operation: pallet_amm_support::TradeOperation::Buy, + asset_in, + asset_out, + amount_in: 17_894_738, + amount_out: 10_000_000, + fees: vec![(asset_in, 35860, pool_data.fee_collector)], + event_id: None, + } + .into(), + ]); // swap assets set_block_number(11); @@ -2429,16 +2494,31 @@ fn buy_should_work_when_limit_is_set_above_account_balance() { u128::MAX, )); - expect_events(vec![Event::BuyExecuted { - who: buyer, - asset_out: KUSD, - asset_in: BSX, - amount: 5_560_304, - buy_price: 10_000_000, - fee_asset: KUSD, - fee_amount: 20_000, - } - .into()]); + expect_events(vec![ + Event::BuyExecuted { + who: buyer, + asset_in: BSX, + asset_out: KUSD, + amount: 5_560_304, + buy_price: 10_000_000, + fee_asset: KUSD, + fee_amount: 20_000, + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: buyer, + filler: pool_id, + filler_type: pallet_amm_support::Filler::LBP, + operation: pallet_amm_support::TradeOperation::Buy, + asset_in: BSX, + asset_out: KUSD, + amount_in: 5_560_304, + amount_out: 10_000_000, + fees: vec![(KUSD, 20_000, pool_data.fee_collector)], + event_id: None, + } + .into(), + ]); }); } @@ -2468,17 +2548,6 @@ fn update_pool_data_after_sale_should_not_work() { set_block_number(41); - expect_events(vec![Event::BuyExecuted { - who: buyer, - asset_out: BSX, - asset_in: KUSD, - amount: 17_894_738, - buy_price: 10_000_000, - fee_asset: KUSD, - fee_amount: 35_860, - } - .into()]); - assert_noop!( LBPPallet::update_pool_data( Origin::signed(ALICE), @@ -2504,6 +2573,7 @@ fn sell_should_work() { let asset_in = KUSD; let asset_out = BSX; let pool_id = LBPPallet::get_pair_id(AssetPair { asset_in, asset_out }); + let pool_data = >::try_get(&pool_id).unwrap(); //start sale set_block_number(11); @@ -2516,6 +2586,32 @@ fn sell_should_work() { 2_000_u128 )); + expect_events(vec![ + Event::SellExecuted { + who: buyer, + asset_in, + asset_out, + amount: 9_980_000, + sale_price: 5_605_138, + fee_asset: asset_in, + fee_amount: 20_000, + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: buyer, + filler: pool_id, + filler_type: pallet_amm_support::Filler::LBP, + operation: pallet_amm_support::TradeOperation::Sell, + asset_in, + asset_out, + amount_in: 9_980_000, + amount_out: 5_605_138, + fees: vec![(asset_in, 20_000, pool_data.fee_collector)], + event_id: None, + } + .into(), + ]); + assert_eq!(Currency::free_balance(asset_in, &buyer), 999_999_990_000_000); assert_eq!(Currency::free_balance(asset_out, &buyer), 1_000_000_005_605_138); assert_eq!(Currency::free_balance(asset_in, &pool_id), 1_009_980_000); From cb02e145da1bcbbe669a82b632fcba3db58dc708 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Mon, 30 Sep 2024 18:37:11 +0200 Subject: [PATCH 010/142] fix xyk tests --- pallets/lbp/src/tests.rs | 10 +- pallets/xyk/src/lib.rs | 8 +- pallets/xyk/src/tests/fees.rs | 222 ++++++++++++++++++++++---------- pallets/xyk/src/tests/trades.rs | 108 +++++++++++++++- 4 files changed, 273 insertions(+), 75 deletions(-) diff --git a/pallets/lbp/src/tests.rs b/pallets/lbp/src/tests.rs index dd2d95a05..63da4bed5 100644 --- a/pallets/lbp/src/tests.rs +++ b/pallets/lbp/src/tests.rs @@ -1830,7 +1830,8 @@ fn execute_sell_should_work() { assert_eq!(Currency::free_balance(asset_in, &pool_id), 1_000_000_000); assert_eq!(Currency::free_balance(asset_out, &pool_id), 2_000_000_000); - assert_ok!(LBPPallet::execute_sell(&t, None)); + let event_id = Some(7); + assert_ok!(LBPPallet::execute_sell(&t, event_id)); expect_events(vec![ Event::SellExecuted { @@ -1853,7 +1854,7 @@ fn execute_sell_should_work() { amount_in, amount_out: amount_b, fees: vec![(asset_in, 1_000, pool_data.fee_collector)], - event_id: None, + event_id, } .into(), ]); @@ -1970,7 +1971,8 @@ fn execute_buy_should_work() { assert_eq!(Currency::free_balance(asset_in, &pool_id), 1_000_000_000); assert_eq!(Currency::free_balance(asset_out, &pool_id), 2_000_000_000); - assert_ok!(LBPPallet::execute_buy(&t, None, None)); + let event_id = Some(7); + assert_ok!(LBPPallet::execute_buy(&t, None, event_id)); assert_eq!(Currency::free_balance(asset_in, &ALICE), 999_998_991_999_000); assert_eq!(Currency::free_balance(asset_out, &ALICE), 999_998_020_000_000); @@ -2001,7 +2003,7 @@ fn execute_buy_should_work() { amount_in, amount_out: amount_b, fees: vec![(asset_in, 1_000, pool_data.fee_collector)], - event_id: None, + event_id, } .into(), ]); diff --git a/pallets/xyk/src/lib.rs b/pallets/xyk/src/lib.rs index 4c226db1c..41ea01929 100644 --- a/pallets/xyk/src/lib.rs +++ b/pallets/xyk/src/lib.rs @@ -924,14 +924,14 @@ impl AMM::deposit_trade_event( transfer.origin.clone(), - pair_account, + pair_account.clone(), pallet_amm_support::Filler::XYK, pallet_amm_support::TradeOperation::Sell, transfer.assets.asset_in, transfer.assets.asset_out, transfer.amount, transfer.amount_b, - vec![transfer.fee], + vec![(transfer.fee.0, transfer.fee.1, pair_account)], event_id, ); @@ -1104,14 +1104,14 @@ impl AMM::deposit_trade_event( transfer.origin.clone(), - pair_account, + pair_account.clone(), pallet_amm_support::Filler::XYK, pallet_amm_support::TradeOperation::Buy, transfer.assets.asset_in, transfer.assets.asset_out, transfer.amount, transfer.amount_b, - vec![transfer.fee], + vec![(transfer.fee.0, transfer.fee.1, pair_account)], event_id, ); diff --git a/pallets/xyk/src/tests/fees.rs b/pallets/xyk/src/tests/fees.rs index 49937e3a8..5ad2bb653 100644 --- a/pallets/xyk/src/tests/fees.rs +++ b/pallets/xyk/src/tests/fees.rs @@ -129,17 +129,32 @@ fn discount_sell_fees_should_work() { assert_eq!(Currency::free_balance(asset_b, &ALICE), 600_000_019_986_006); assert_eq!(Currency::free_balance(HDX, &ALICE), 997_999_999_972_014); - expect_events(vec![Event::SellExecuted { - who: ALICE, - asset_in: asset_a, - asset_out: asset_b, - amount: 10_000_000, - sale_price: 19_986_006, - fee_asset: asset_b, - fee_amount: 13_993, - pool: pair_account, - } - .into()]); + expect_events(vec![ + Event::SellExecuted { + who: ALICE, + asset_in: asset_a, + asset_out: asset_b, + amount: 10_000_000, + sale_price: 19_986_006, + fee_asset: asset_b, + fee_amount: 13_993, + pool: pair_account, + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: ALICE, + filler: pair_account, + filler_type: pallet_amm_support::Filler::XYK, + operation: pallet_amm_support::TradeOperation::Sell, + asset_in: asset_a, + asset_out: asset_b, + amount_in: 10_000_000, + amount_out: 19_986_006, + fees: vec![(asset_b, 13_993, pair_account)], + event_id: None, + } + .into(), + ]); }); // 0.1% discount fee @@ -200,17 +215,32 @@ fn discount_sell_fees_should_work() { assert_eq!(Currency::free_balance(asset_b, &ALICE), 600_000_019_980_009); assert_eq!(Currency::free_balance(HDX, &ALICE), 997_999_999_960_020); - expect_events(vec![Event::SellExecuted { - who: ALICE, - asset_in: asset_a, - asset_out: asset_b, - amount: 10_000_000, - sale_price: 19_980_009, - fee_asset: asset_b, - fee_amount: 19_990, - pool: pair_account, - } - .into()]); + expect_events(vec![ + Event::SellExecuted { + who: ALICE, + asset_in: asset_a, + asset_out: asset_b, + amount: 10_000_000, + sale_price: 19_980_009, + fee_asset: asset_b, + fee_amount: 19_990, + pool: pair_account, + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: ALICE, + filler: pair_account, + filler_type: pallet_amm_support::Filler::XYK, + operation: pallet_amm_support::TradeOperation::Sell, + asset_in: asset_a, + asset_out: asset_b, + amount_in: 10_000_000, + amount_out: 19_980_009, + fees: vec![(asset_b, 19_990, pair_account)], + event_id: None, + } + .into(), + ]); }); // zero discount fee @@ -264,17 +294,32 @@ fn discount_sell_fees_should_work() { assert_eq!(Currency::free_balance(asset_a, &ALICE), 798_999_990_000_000); assert_eq!(Currency::free_balance(asset_b, &ALICE), 600_000_019_999_999); - expect_events(vec![Event::SellExecuted { - who: ALICE, - asset_in: asset_a, - asset_out: asset_b, - amount: 10_000_000, - sale_price: 19_999_999, - fee_asset: asset_b, - fee_amount: 0, - pool: pair_account, - } - .into()]); + expect_events(vec![ + Event::SellExecuted { + who: ALICE, + asset_in: asset_a, + asset_out: asset_b, + amount: 10_000_000, + sale_price: 19_999_999, + fee_asset: asset_b, + fee_amount: 0, + pool: pair_account, + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: ALICE, + filler: pair_account, + filler_type: pallet_amm_support::Filler::XYK, + operation: pallet_amm_support::TradeOperation::Sell, + asset_in: asset_a, + asset_out: asset_b, + amount_in: 10_000_000, + amount_out: 19_999_999, + fees: vec![(asset_b, 0, pair_account)], + event_id: None, + } + .into(), + ]); }); } @@ -345,17 +390,32 @@ fn discount_buy_fees_should_work() { assert_eq!(Currency::free_balance(asset_b, &ALICE), 599_999_979_985_998); // compare to values in previous test to see difference! assert_eq!(Currency::free_balance(HDX, &ALICE), 997_999_999_972_000); - expect_events(vec![Event::BuyExecuted { - who: ALICE, - asset_out: asset_a, - asset_in: asset_b, - amount: 10_000_000, - buy_price: 20_000_002, - fee_asset: asset_b, - fee_amount: 14_000, - pool: pair_account, - } - .into()]); + expect_events(vec![ + Event::BuyExecuted { + who: ALICE, + asset_in: asset_b, + asset_out: asset_a, + amount: 10_000_000, + buy_price: 20_000_002, + fee_asset: asset_b, + fee_amount: 14_000, + pool: pair_account, + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: ALICE, + filler: pair_account, + filler_type: pallet_amm_support::Filler::XYK, + operation: pallet_amm_support::TradeOperation::Buy, + asset_in: asset_b, + asset_out: asset_a, + amount_in: 10_000_000, + amount_out: 20_000_002, + fees: vec![(asset_b, 14_000, pair_account)], + event_id: None, + } + .into(), + ]); }); // 0.1% discount fee @@ -418,17 +478,32 @@ fn discount_buy_fees_should_work() { assert_eq!(Currency::free_balance(asset_b, &ALICE), 599_999_979_979_998); // compare to values in previous test to see difference! assert_eq!(Currency::free_balance(HDX, &ALICE), 997_999_999_960_000); - expect_events(vec![Event::BuyExecuted { - who: ALICE, - asset_out: asset_a, - asset_in: asset_b, - amount: 10_000_000, - buy_price: 20_000_002, - fee_asset: asset_b, - fee_amount: 20_000, - pool: pair_account, - } - .into()]); + expect_events(vec![ + Event::BuyExecuted { + who: ALICE, + asset_in: asset_b, + asset_out: asset_a, + amount: 10_000_000, + buy_price: 20_000_002, + fee_asset: asset_b, + fee_amount: 20_000, + pool: pair_account, + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: ALICE, + filler: pair_account, + filler_type: pallet_amm_support::Filler::XYK, + operation: pallet_amm_support::TradeOperation::Buy, + asset_in: asset_b, + asset_out: asset_a, + amount_in: 10_000_000, + amount_out: 20_000_002, + fees: vec![(asset_b, 20_000, pair_account)], + event_id: None, + } + .into(), + ]); }); // zero discount fee @@ -483,16 +558,31 @@ fn discount_buy_fees_should_work() { assert_eq!(Currency::free_balance(asset_a, &ALICE), 799_000_010_000_000); assert_eq!(Currency::free_balance(asset_b, &ALICE), 599_999_979_999_998); - expect_events(vec![Event::BuyExecuted { - who: ALICE, - asset_out: asset_a, - asset_in: asset_b, - amount: 10_000_000, - buy_price: 20_000_002, - fee_asset: asset_b, - fee_amount: 0, - pool: pair_account, - } - .into()]); + expect_events(vec![ + Event::BuyExecuted { + who: ALICE, + asset_in: asset_b, + asset_out: asset_a, + amount: 10_000_000, + buy_price: 20_000_002, + fee_asset: asset_b, + fee_amount: 0, + pool: pair_account, + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: ALICE, + filler: pair_account, + filler_type: pallet_amm_support::Filler::XYK, + operation: pallet_amm_support::TradeOperation::Buy, + asset_in: asset_b, + asset_out: asset_a, + amount_in: 10_000_000, + amount_out: 20_000_002, + fees: vec![(asset_b, 0, pair_account)], + event_id: None, + } + .into(), + ]); }); } diff --git a/pallets/xyk/src/tests/trades.rs b/pallets/xyk/src/tests/trades.rs index 5369bb9ea..ba944b337 100644 --- a/pallets/xyk/src/tests/trades.rs +++ b/pallets/xyk/src/tests/trades.rs @@ -1,5 +1,5 @@ pub use super::mock::*; -use crate::{Error, Event}; +use crate::{Error, Event, AMMTransfer}; use frame_support::{assert_noop, assert_ok}; use hydradx_traits::AMM as AmmPool; use orml_traits::MultiCurrency; @@ -70,10 +70,90 @@ fn sell_test() { pool: pair_account, } .into(), + pallet_amm_support::Event::Swapped { + swapper: ALICE, + filler: pair_account, + filler_type: pallet_amm_support::Filler::XYK, + operation: pallet_amm_support::TradeOperation::Sell, + asset_in: asset_a, + asset_out: asset_b, + amount_in: 456444678, + amount_out: 1363483591788, + fees: vec![(asset_b, 2732432046, pair_account)], + event_id: None, + } + .into(), ]); }); } +#[test] +fn execute_sell_should_use_event_id() { + new_test_ext().execute_with(|| { + let user_1 = ALICE; + let asset_a = ACA; + let asset_b = DOT; + + assert_ok!(XYK::create_pool( + RuntimeOrigin::signed(user_1), + asset_a, + 200_000_000_000, + asset_b, + 600_000_000_000_000, + )); + + let pair_account = XYK::get_pair_id(AssetPair { + asset_in: asset_a, + asset_out: asset_b, + }); + + let t = AMMTransfer { + origin: user_1, + assets: AssetPair { asset_in: asset_a, asset_out: asset_b }, + amount: 456_444_678, + amount_b: 1363483591788, + discount: false, + discount_amount: 0_u128, + fee: (asset_b, 2732432046), + }; + + let event_id = Some(7); + assert_ok!(XYK::execute_sell( + &t, + event_id, + )); + + expect_events(vec![ + Event::SellExecuted { + who: ALICE, + asset_in: asset_a, + asset_out: asset_b, + amount: 456444678, + sale_price: 1363483591788, + fee_asset: asset_b, + fee_amount: 2732432046, + pool: pair_account, + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: ALICE, + filler: pair_account, + filler_type: pallet_amm_support::Filler::XYK, + operation: pallet_amm_support::TradeOperation::Sell, + asset_in: asset_a, + asset_out: asset_b, + amount_in: 456444678, + amount_out: 1363483591788, + fees: vec![(asset_b, 2732432046, pair_account)], + event_id, + } + .into(), + ]); + }); +} + + + #[test] fn work_flow_happy_path_should_work() { new_test_ext().execute_with(|| { @@ -366,6 +446,19 @@ fn sell_with_correct_fees_should_work() { pool: pair_account, } .into(), + pallet_amm_support::Event::Swapped { + swapper: user_1, + filler: pair_account, + filler_type: pallet_amm_support::Filler::XYK, + operation: pallet_amm_support::TradeOperation::Sell, + asset_in: asset_a, + asset_out: asset_b, + amount_in: 100_000, + amount_out: 19_762_378, + fees: vec![(asset_b, 39_602, pair_account)], + event_id: None, + } + .into(), ]); }); } @@ -573,6 +666,19 @@ fn single_buy_should_work() { pool: pair_account, } .into(), + pallet_amm_support::Event::Swapped { + swapper: user_1, + filler: pair_account, + filler_type: pallet_amm_support::Filler::XYK, + operation: pallet_amm_support::TradeOperation::Buy, + asset_in: asset_b, + asset_out: asset_a, + amount_in: 6_666_666, + amount_out: 22_068_963_235, + fees: vec![(asset_b, 44_137_926, pair_account)], + event_id: None, + } + .into(), ]); }); } From 914b332a35a973689e54b3b19b2e5e0c3a535021 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Tue, 1 Oct 2024 13:24:32 +0200 Subject: [PATCH 011/142] fix router tests --- pallets/route-executor/src/tests/buy.rs | 6 ++++++ pallets/route-executor/src/tests/sell.rs | 6 ++++++ pallets/route-executor/src/tests/sell_all.rs | 6 ++++++ pallets/stableswap/src/lib.rs | 8 ++++---- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/pallets/route-executor/src/tests/buy.rs b/pallets/route-executor/src/tests/buy.rs index 62a02119f..1999e5499 100644 --- a/pallets/route-executor/src/tests/buy.rs +++ b/pallets/route-executor/src/tests/buy.rs @@ -49,6 +49,7 @@ fn buy_should_work_when_route_has_single_trade() { asset_out: AUSD, amount_in: XYK_BUY_CALCULATION_RESULT, amount_out: amount_to_buy, + event_id: 0, } .into()]); }); @@ -78,6 +79,7 @@ fn buy_should_work_with_omnipool_when_no_route_or_onchain_route_exist() { asset_out: DOT, amount_in: OMNIPOOL_BUY_CALCULATION_RESULT, amount_out: amount_to_buy, + event_id: 0, } .into()]); }); @@ -137,6 +139,7 @@ fn buy_should_work_when_onchain_route_present_in_reverse_order() { asset_out: HDX, amount_in: XYK_BUY_CALCULATION_RESULT, amount_out: amount_to_buy, + event_id: 0, } .into()]); }); @@ -294,6 +297,7 @@ fn buy_should_when_route_has_multiple_trades_with_same_pool_type() { asset_out: KSM, amount_in: XYK_BUY_CALCULATION_RESULT, amount_out: amount_to_buy, + event_id: 0, } .into()]); }); @@ -347,6 +351,7 @@ fn buy_should_work_when_route_has_multiple_trades_with_different_pool_type() { asset_out: KSM, amount_in: XYK_BUY_CALCULATION_RESULT, amount_out: amount_to_buy, + event_id: 0, } .into()]); }); @@ -406,6 +411,7 @@ fn buy_should_work_with_onchain_route_when_no_route_specified() { asset_out: KSM, amount_in: XYK_BUY_CALCULATION_RESULT, amount_out: amount_to_buy, + event_id: 0, } .into()]); }); diff --git a/pallets/route-executor/src/tests/sell.rs b/pallets/route-executor/src/tests/sell.rs index c22447ef5..fa6638392 100644 --- a/pallets/route-executor/src/tests/sell.rs +++ b/pallets/route-executor/src/tests/sell.rs @@ -50,6 +50,7 @@ fn sell_should_work_when_route_has_single_trade() { asset_out: AUSD, amount_in: amount_to_sell, amount_out: XYK_SELL_CALCULATION_RESULT, + event_id: 0, } .into()]); }); @@ -79,6 +80,7 @@ fn sell_should_work_with_omnipool_when_no_specified_or_onchain_route_exist() { asset_out: AUSD, amount_in: amount_to_sell, amount_out: OMNIPOOL_SELL_CALCULATION_RESULT, + event_id: 0, } .into()]); }); @@ -185,6 +187,7 @@ fn sell_should_work_when_route_has_multiple_trades_with_same_pooltype() { asset_out: KSM, amount_in: amount_to_sell, amount_out: XYK_SELL_CALCULATION_RESULT, + event_id: 0, } .into()]); }); @@ -235,6 +238,7 @@ fn sell_should_work_when_route_has_multiple_trades_with_different_pool_type() { asset_out: KSM, amount_in: amount_to_sell, amount_out: OMNIPOOL_SELL_CALCULATION_RESULT, + event_id: 0, } .into()]); }); @@ -293,6 +297,7 @@ fn sell_should_work_with_onchain_route_when_no_routes_specified() { asset_out: KSM, amount_in: amount_to_sell, amount_out: XYK_SELL_CALCULATION_RESULT, + event_id: 0, } .into()]); }); @@ -355,6 +360,7 @@ fn sell_should_work_with_onchain_route_when_onchain_route_present_in_reverse_ord asset_out: HDX, amount_in: amount_to_sell, amount_out: XYK_SELL_CALCULATION_RESULT, + event_id: 0, } .into()]); }); diff --git a/pallets/route-executor/src/tests/sell_all.rs b/pallets/route-executor/src/tests/sell_all.rs index a95700ae4..26a8c3ed5 100644 --- a/pallets/route-executor/src/tests/sell_all.rs +++ b/pallets/route-executor/src/tests/sell_all.rs @@ -44,6 +44,7 @@ fn sell_should_work_when_route_has_single_trade() { asset_out: AUSD, amount_in: alice_balance, amount_out: XYK_SELL_CALCULATION_RESULT, + event_id: 0, } .into()]); }); @@ -67,6 +68,7 @@ fn sell_should_work_with_omnipool_when_no_specified_or_onchain_route_exist() { asset_out: AUSD, amount_in: alice_balance, amount_out: OMNIPOOL_SELL_CALCULATION_RESULT, + event_id: 0, } .into()]); }); @@ -135,6 +137,7 @@ fn sell_should_work_when_route_has_multiple_trades_with_same_pooltype() { asset_out: KSM, amount_in: alice_native_balance, amount_out: XYK_SELL_CALCULATION_RESULT, + event_id: 0, } .into()]); }); @@ -179,6 +182,7 @@ fn sell_should_work_when_route_has_multiple_trades_with_different_pool_type() { asset_out: KSM, amount_in: alice_native_balance, amount_out: OMNIPOOL_SELL_CALCULATION_RESULT, + event_id: 0, } .into()]); }); @@ -230,6 +234,7 @@ fn sell_should_work_with_onchain_route_when_no_routes_specified() { asset_out: KSM, amount_in: alice_native_balance, amount_out: XYK_SELL_CALCULATION_RESULT, + event_id: 0, } .into()]); }); @@ -286,6 +291,7 @@ fn sell_should_work_with_onchain_route_when_onchain_route_present_in_reverse_ord asset_out: HDX, amount_in: alice_nonnative_balance, amount_out: XYK_SELL_CALCULATION_RESULT, + event_id: 0, } .into()]); }); diff --git a/pallets/stableswap/src/lib.rs b/pallets/stableswap/src/lib.rs index 7cfb1e6b8..f9e6985a3 100644 --- a/pallets/stableswap/src/lib.rs +++ b/pallets/stableswap/src/lib.rs @@ -856,14 +856,14 @@ impl Pallet { pallet_amm_support::Pallet::::deposit_trade_event( who, - pool_account, + pool_account.clone(), pallet_amm_support::Filler::Stableswap, pallet_amm_support::TradeOperation::Sell, asset_in.into(), asset_out.into(), amount_in, amount_out, - vec![(asset_out.into(), fee_amount)], + vec![(asset_out.into(), fee_amount, pool_account)], event_id, ); @@ -933,14 +933,14 @@ impl Pallet { pallet_amm_support::Pallet::::deposit_trade_event( who, - pool_account, + pool_account.clone(), pallet_amm_support::Filler::Stableswap, pallet_amm_support::TradeOperation::Buy, asset_in.into(), asset_out.into(), amount_in, amount_out, - vec![(asset_in.into(), fee_amount)], + vec![(asset_in.into(), fee_amount, pool_account)], event_id, ); From 66272e8a7090cca40095b15677ba699db12b9a4f Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Tue, 1 Oct 2024 13:59:37 +0200 Subject: [PATCH 012/142] fix omnipool tests --- pallets/omnipool/src/lib.rs | 22 +++++++++---- pallets/omnipool/src/tests/buy.rs | 54 +++++++++++++++++++++++++++++-- 2 files changed, 68 insertions(+), 8 deletions(-) diff --git a/pallets/omnipool/src/lib.rs b/pallets/omnipool/src/lib.rs index 53f605c52..d3a2faa63 100644 --- a/pallets/omnipool/src/lib.rs +++ b/pallets/omnipool/src/lib.rs @@ -1486,14 +1486,14 @@ impl Pallet { } fn do_sell( - origin: frame_system::pallet_prelude::OriginFor, + origin: OriginFor, asset_in: T::AssetId, asset_out: T::AssetId, amount: Balance, min_buy_amount: Balance, event_id: Option, ) -> DispatchResult { - let who = frame_system::ensure_signed(origin.clone())?; + let who = ensure_signed(origin.clone())?; ensure!(asset_in != asset_out, Error::::SameAssetTradeNotAllowed); @@ -1680,7 +1680,10 @@ impl Pallet { asset_out.into(), amount, *state_changes.asset_out.delta_reserve, - vec![], // TODO + vec![ + (asset_out.into(), state_changes.fee.asset_fee, Self::protocol_account()), + (T::HubAssetId::get().into(), state_changes.fee.protocol_fee, Self::protocol_account()) + ], event_id, ); @@ -1882,7 +1885,10 @@ impl Pallet { asset_out.into(), *state_changes.asset_in.delta_reserve, *state_changes.asset_out.delta_reserve, - vec![], // TODO + vec![ + (asset_out.into(), state_changes.fee.asset_fee, Self::protocol_account()), + (T::HubAssetId::get().into(), state_changes.fee.protocol_fee, Self::protocol_account()) + ], event_id, ); @@ -2007,7 +2013,9 @@ impl Pallet { asset_out.into(), *state_changes.asset.delta_hub_reserve, *state_changes.asset.delta_reserve, - vec![], // TODO + vec![ + (asset_out.into(), state_changes.fee.asset_fee, Self::protocol_account()), + ], None, ); @@ -2128,7 +2136,9 @@ impl Pallet { asset_out.into(), *state_changes.asset.delta_hub_reserve, *state_changes.asset.delta_reserve, - vec![], // TODO + vec![ + (asset_out.into(), state_changes.fee.asset_fee, Self::protocol_account()), + ], None, ); diff --git a/pallets/omnipool/src/tests/buy.rs b/pallets/omnipool/src/tests/buy.rs index 8d42f0b98..5b431a2e6 100644 --- a/pallets/omnipool/src/tests/buy.rs +++ b/pallets/omnipool/src/tests/buy.rs @@ -435,6 +435,22 @@ fn buy_should_emit_event_with_correct_asset_fee_amount() { asset_fee_amount: 5_555_555_555_556, protocol_fee_amount: 0, } + .into(), + pallet_amm_support::Event::Swapped { + swapper: LP1, + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::Filler::Omnipool, + operation: pallet_amm_support::TradeOperation::Buy, + asset_in: 100, + asset_out: 200, + amount_in: expected_sold_amount, + amount_out: buy_amount, + fees: vec![ + (200, 5555555555556, Omnipool::protocol_account()), + (1, 0, Omnipool::protocol_account()) + ], + event_id: None, + } .into()]); }); } @@ -480,7 +496,24 @@ fn buy_should_emit_event_with_correct_protocol_fee_amount() { asset_fee_amount: 0, protocol_fee_amount: 5698005698005, } - .into()]); + .into(), + pallet_amm_support::Event::Swapped { + swapper: LP1, + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::Filler::Omnipool, + operation: pallet_amm_support::TradeOperation::Buy, + asset_in: 100, + asset_out: 200, + amount_in: expected_sold_amount, + amount_out: buy_amount, + fees: vec![ + (200, 0, Omnipool::protocol_account()), + (1, 5698005698005, Omnipool::protocol_account()) + ], + event_id: None, + } + .into() + ]); }); } @@ -524,7 +557,24 @@ fn sell_should_get_same_amount() { asset_fee_amount: 5555555555556, protocol_fee_amount: 0, } - .into()]); + .into(), + pallet_amm_support::Event::Swapped { + swapper: LP1, + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::Filler::Omnipool, + operation: pallet_amm_support::TradeOperation::Sell, + asset_in: 100, + asset_out: 200, + amount_in: expected_sold_amount, + amount_out: buy_amount, + fees: vec![ + (200, 5555555555556, Omnipool::protocol_account()), + (1, 0, Omnipool::protocol_account()) + ], + event_id: None, + } + .into(), + ]); }); } From cd80ac67d023a02f791bb43ec77e63c1338f2fba Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Tue, 1 Oct 2024 13:59:45 +0200 Subject: [PATCH 013/142] formatting --- pallets/omnipool/src/lib.rs | 20 ++-- pallets/omnipool/src/tests/buy.rs | 172 +++++++++++++++--------------- pallets/xyk/src/tests/trades.rs | 14 ++- 3 files changed, 106 insertions(+), 100 deletions(-) diff --git a/pallets/omnipool/src/lib.rs b/pallets/omnipool/src/lib.rs index d3a2faa63..44e2c8ab7 100644 --- a/pallets/omnipool/src/lib.rs +++ b/pallets/omnipool/src/lib.rs @@ -1682,7 +1682,11 @@ impl Pallet { *state_changes.asset_out.delta_reserve, vec![ (asset_out.into(), state_changes.fee.asset_fee, Self::protocol_account()), - (T::HubAssetId::get().into(), state_changes.fee.protocol_fee, Self::protocol_account()) + ( + T::HubAssetId::get().into(), + state_changes.fee.protocol_fee, + Self::protocol_account(), + ), ], event_id, ); @@ -1887,7 +1891,11 @@ impl Pallet { *state_changes.asset_out.delta_reserve, vec![ (asset_out.into(), state_changes.fee.asset_fee, Self::protocol_account()), - (T::HubAssetId::get().into(), state_changes.fee.protocol_fee, Self::protocol_account()) + ( + T::HubAssetId::get().into(), + state_changes.fee.protocol_fee, + Self::protocol_account(), + ), ], event_id, ); @@ -2013,9 +2021,7 @@ impl Pallet { asset_out.into(), *state_changes.asset.delta_hub_reserve, *state_changes.asset.delta_reserve, - vec![ - (asset_out.into(), state_changes.fee.asset_fee, Self::protocol_account()), - ], + vec![(asset_out.into(), state_changes.fee.asset_fee, Self::protocol_account())], None, ); @@ -2136,9 +2142,7 @@ impl Pallet { asset_out.into(), *state_changes.asset.delta_hub_reserve, *state_changes.asset.delta_reserve, - vec![ - (asset_out.into(), state_changes.fee.asset_fee, Self::protocol_account()), - ], + vec![(asset_out.into(), state_changes.fee.asset_fee, Self::protocol_account())], None, ); diff --git a/pallets/omnipool/src/tests/buy.rs b/pallets/omnipool/src/tests/buy.rs index 5b431a2e6..36e5c2212 100644 --- a/pallets/omnipool/src/tests/buy.rs +++ b/pallets/omnipool/src/tests/buy.rs @@ -424,34 +424,36 @@ fn buy_should_emit_event_with_correct_asset_fee_amount() { max_limit )); - expect_events(vec![Event::BuyExecuted { - who: LP1, - asset_in: 100, - asset_out: 200, - amount_in: expected_sold_amount, - amount_out: buy_amount, - hub_amount_in: 57142857142858, - hub_amount_out: 57142857142858, - asset_fee_amount: 5_555_555_555_556, - protocol_fee_amount: 0, - } - .into(), - pallet_amm_support::Event::Swapped { - swapper: LP1, - filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::Buy, - asset_in: 100, - asset_out: 200, - amount_in: expected_sold_amount, - amount_out: buy_amount, - fees: vec![ - (200, 5555555555556, Omnipool::protocol_account()), - (1, 0, Omnipool::protocol_account()) - ], - event_id: None, - } - .into()]); + expect_events(vec![ + Event::BuyExecuted { + who: LP1, + asset_in: 100, + asset_out: 200, + amount_in: expected_sold_amount, + amount_out: buy_amount, + hub_amount_in: 57142857142858, + hub_amount_out: 57142857142858, + asset_fee_amount: 5_555_555_555_556, + protocol_fee_amount: 0, + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: LP1, + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::Filler::Omnipool, + operation: pallet_amm_support::TradeOperation::Buy, + asset_in: 100, + asset_out: 200, + amount_in: expected_sold_amount, + amount_out: buy_amount, + fees: vec![ + (200, 5555555555556, Omnipool::protocol_account()), + (1, 0, Omnipool::protocol_account()), + ], + event_id: None, + } + .into(), + ]); }); } @@ -485,34 +487,35 @@ fn buy_should_emit_event_with_correct_protocol_fee_amount() { max_limit )); - expect_events(vec![Event::BuyExecuted { - who: LP1, - asset_in: 100, - asset_out: 200, - amount_in: expected_sold_amount, - amount_out: buy_amount, - hub_amount_in: 56980056980057, - hub_amount_out: 51282051282052, - asset_fee_amount: 0, - protocol_fee_amount: 5698005698005, - } - .into(), - pallet_amm_support::Event::Swapped { - swapper: LP1, - filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::Buy, - asset_in: 100, - asset_out: 200, - amount_in: expected_sold_amount, - amount_out: buy_amount, - fees: vec![ - (200, 0, Omnipool::protocol_account()), - (1, 5698005698005, Omnipool::protocol_account()) - ], - event_id: None, - } - .into() + expect_events(vec![ + Event::BuyExecuted { + who: LP1, + asset_in: 100, + asset_out: 200, + amount_in: expected_sold_amount, + amount_out: buy_amount, + hub_amount_in: 56980056980057, + hub_amount_out: 51282051282052, + asset_fee_amount: 0, + protocol_fee_amount: 5698005698005, + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: LP1, + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::Filler::Omnipool, + operation: pallet_amm_support::TradeOperation::Buy, + asset_in: 100, + asset_out: 200, + amount_in: expected_sold_amount, + amount_out: buy_amount, + fees: vec![ + (200, 0, Omnipool::protocol_account()), + (1, 5698005698005, Omnipool::protocol_account()), + ], + event_id: None, + } + .into(), ]); }); } @@ -546,34 +549,35 @@ fn sell_should_get_same_amount() { 0 )); - expect_events(vec![Event::SellExecuted { - who: LP1, - asset_in: 100, - asset_out: 200, - amount_in: expected_sold_amount, - amount_out: buy_amount, - hub_amount_in: 57142857142858, - hub_amount_out: 57142857142858, - asset_fee_amount: 5555555555556, - protocol_fee_amount: 0, - } - .into(), - pallet_amm_support::Event::Swapped { - swapper: LP1, - filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::Sell, - asset_in: 100, - asset_out: 200, - amount_in: expected_sold_amount, - amount_out: buy_amount, - fees: vec![ - (200, 5555555555556, Omnipool::protocol_account()), - (1, 0, Omnipool::protocol_account()) - ], - event_id: None, - } - .into(), + expect_events(vec![ + Event::SellExecuted { + who: LP1, + asset_in: 100, + asset_out: 200, + amount_in: expected_sold_amount, + amount_out: buy_amount, + hub_amount_in: 57142857142858, + hub_amount_out: 57142857142858, + asset_fee_amount: 5555555555556, + protocol_fee_amount: 0, + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: LP1, + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::Filler::Omnipool, + operation: pallet_amm_support::TradeOperation::Sell, + asset_in: 100, + asset_out: 200, + amount_in: expected_sold_amount, + amount_out: buy_amount, + fees: vec![ + (200, 5555555555556, Omnipool::protocol_account()), + (1, 0, Omnipool::protocol_account()), + ], + event_id: None, + } + .into(), ]); }); } diff --git a/pallets/xyk/src/tests/trades.rs b/pallets/xyk/src/tests/trades.rs index ba944b337..7778c1229 100644 --- a/pallets/xyk/src/tests/trades.rs +++ b/pallets/xyk/src/tests/trades.rs @@ -1,5 +1,5 @@ pub use super::mock::*; -use crate::{Error, Event, AMMTransfer}; +use crate::{AMMTransfer, Error, Event}; use frame_support::{assert_noop, assert_ok}; use hydradx_traits::AMM as AmmPool; use orml_traits::MultiCurrency; @@ -109,7 +109,10 @@ fn execute_sell_should_use_event_id() { let t = AMMTransfer { origin: user_1, - assets: AssetPair { asset_in: asset_a, asset_out: asset_b }, + assets: AssetPair { + asset_in: asset_a, + asset_out: asset_b, + }, amount: 456_444_678, amount_b: 1363483591788, discount: false, @@ -118,10 +121,7 @@ fn execute_sell_should_use_event_id() { }; let event_id = Some(7); - assert_ok!(XYK::execute_sell( - &t, - event_id, - )); + assert_ok!(XYK::execute_sell(&t, event_id,)); expect_events(vec![ Event::SellExecuted { @@ -152,8 +152,6 @@ fn execute_sell_should_use_event_id() { }); } - - #[test] fn work_flow_happy_path_should_work() { new_test_ext().execute_with(|| { From 065d0a7190faca1ef0bc15e4ec9a85d2194464df Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Tue, 1 Oct 2024 16:06:00 +0200 Subject: [PATCH 014/142] fix stableswap tests --- pallets/circuit-breaker/src/tests/mock.rs | 2 +- pallets/dca/src/tests/mock.rs | 4 +- pallets/lbp/src/mock.rs | 2 +- .../src/tests/mock.rs | 2 +- pallets/omnipool/src/tests/mock.rs | 2 +- pallets/otc-settlements/src/mock.rs | 4 +- pallets/otc/src/tests/mock.rs | 2 +- pallets/route-executor/src/tests/mock.rs | 4 +- pallets/stableswap/src/tests/creation.rs | 8 +-- pallets/stableswap/src/tests/mock.rs | 10 +++- pallets/stableswap/src/tests/trades.rs | 54 ++++++++++++++++++- pallets/stableswap/src/tests/update_pool.rs | 8 +-- pallets/xyk/src/tests/mock.rs | 2 +- runtime/adapters/src/tests/mock.rs | 4 +- runtime/hydradx/src/assets.rs | 2 +- runtime/hydradx/src/lib.rs | 2 +- 16 files changed, 85 insertions(+), 27 deletions(-) diff --git a/pallets/circuit-breaker/src/tests/mock.rs b/pallets/circuit-breaker/src/tests/mock.rs index 8ff3b4307..b8ce0923f 100644 --- a/pallets/circuit-breaker/src/tests/mock.rs +++ b/pallets/circuit-breaker/src/tests/mock.rs @@ -86,7 +86,7 @@ frame_support::construct_runtime!( Omnipool: pallet_omnipool, Tokens: orml_tokens, CircuitBreaker: pallet_circuit_breaker, - TradeEvent: pallet_amm_support, + AmmSupport: pallet_amm_support, } ); diff --git a/pallets/dca/src/tests/mock.rs b/pallets/dca/src/tests/mock.rs index 27dd45dc2..04224dc82 100644 --- a/pallets/dca/src/tests/mock.rs +++ b/pallets/dca/src/tests/mock.rs @@ -80,7 +80,7 @@ frame_support::construct_runtime!( Balances: pallet_balances, Currencies: pallet_currencies, EmaOracle: pallet_ema_oracle, - TradeEvent: pallet_amm_support, + AmmSupport: pallet_amm_support, } ); @@ -371,7 +371,7 @@ impl pallet_route_executor::Config for Test { type EdToRefundCalculator = MockedEdCalculator; type OraclePriceProvider = PriceProviderMock; type OraclePeriod = RouteValidationOraclePeriod; - type BatchIdProvider = TradeEvent; + type BatchIdProvider = AmmSupport; type WeightInfo = (); } diff --git a/pallets/lbp/src/mock.rs b/pallets/lbp/src/mock.rs index 09b20fc12..22b1f9c07 100644 --- a/pallets/lbp/src/mock.rs +++ b/pallets/lbp/src/mock.rs @@ -75,7 +75,7 @@ frame_support::construct_runtime!( System: frame_system, LBPPallet: lbp, Currency: orml_tokens, - TradeEvent: pallet_amm_support, + AmmSupport: pallet_amm_support, } ); diff --git a/pallets/omnipool-liquidity-mining/src/tests/mock.rs b/pallets/omnipool-liquidity-mining/src/tests/mock.rs index d5a0dd65c..97844bfdd 100644 --- a/pallets/omnipool-liquidity-mining/src/tests/mock.rs +++ b/pallets/omnipool-liquidity-mining/src/tests/mock.rs @@ -110,7 +110,7 @@ construct_runtime!( WarehouseLM: warehouse_liquidity_mining::, OmnipoolMining: omnipool_liquidity_mining, EmaOracle: pallet_ema_oracle, - TradeEvent: pallet_amm_support, + AmmSupport: pallet_amm_support, } ); diff --git a/pallets/omnipool/src/tests/mock.rs b/pallets/omnipool/src/tests/mock.rs index 3cbd0c81f..cfe586d9a 100644 --- a/pallets/omnipool/src/tests/mock.rs +++ b/pallets/omnipool/src/tests/mock.rs @@ -86,7 +86,7 @@ construct_runtime!( Balances: pallet_balances, Omnipool: pallet_omnipool, Tokens: orml_tokens, - TradeEvent: pallet_amm_support, + AmmSupport: pallet_amm_support, } ); diff --git a/pallets/otc-settlements/src/mock.rs b/pallets/otc-settlements/src/mock.rs index 20e79195b..2f3ddbb5e 100644 --- a/pallets/otc-settlements/src/mock.rs +++ b/pallets/otc-settlements/src/mock.rs @@ -74,7 +74,7 @@ frame_support::construct_runtime!( Omnipool: pallet_omnipool, Router: pallet_route_executor, OtcSettlements: pallet_otc_settlements, - TradeEvent: pallet_amm_support, + AmmSupport: pallet_amm_support, } ); @@ -157,7 +157,7 @@ impl pallet_route_executor::Config for Test { type OraclePeriod = RouteValidationOraclePeriod; type DefaultRoutePoolType = DefaultRoutePoolType; type TechnicalOrigin = EnsureRoot; - type BatchIdProvider = TradeEvent; + type BatchIdProvider = AmmSupport; type WeightInfo = (); } diff --git a/pallets/otc/src/tests/mock.rs b/pallets/otc/src/tests/mock.rs index d76841a9c..cdb4039d4 100644 --- a/pallets/otc/src/tests/mock.rs +++ b/pallets/otc/src/tests/mock.rs @@ -57,7 +57,7 @@ frame_support::construct_runtime!( System: frame_system, OTC: otc, Tokens: orml_tokens, - TradeEvent: pallet_amm_support, + AmmSupport: pallet_amm_support, } ); diff --git a/pallets/route-executor/src/tests/mock.rs b/pallets/route-executor/src/tests/mock.rs index 98f8daccb..cbe31b0f8 100644 --- a/pallets/route-executor/src/tests/mock.rs +++ b/pallets/route-executor/src/tests/mock.rs @@ -51,7 +51,7 @@ frame_support::construct_runtime!( Tokens: orml_tokens, Balances: pallet_balances, Currencies: pallet_currencies, - TradeEvent: pallet_amm_support, + AmmSupport: pallet_amm_support, } ); @@ -164,7 +164,7 @@ impl Config for Test { type OraclePeriod = RouteValidationOraclePeriod; type DefaultRoutePoolType = DefaultRoutePoolType; type TechnicalOrigin = EnsureRoot; - type BatchIdProvider = TradeEvent; + type BatchIdProvider = AmmSupport; type WeightInfo = (); } diff --git a/pallets/stableswap/src/tests/creation.rs b/pallets/stableswap/src/tests/creation.rs index d191f6a0a..b9d1dfe0d 100644 --- a/pallets/stableswap/src/tests/creation.rs +++ b/pallets/stableswap/src/tests/creation.rs @@ -33,8 +33,8 @@ fn create_two_asset_pool_should_work_when_assets_are_registered() { assets: vec![asset_a, asset_b].try_into().unwrap(), initial_amplification: NonZeroU16::new(100).unwrap(), final_amplification: NonZeroU16::new(100).unwrap(), - initial_block: 0, - final_block: 0, + initial_block: 1, + final_block: 1, fee: Permill::from_percent(0), } ); @@ -102,8 +102,8 @@ fn create_pool_should_store_assets_correctly_when_input_is_not_sorted() { assets: vec![asset_a, asset_b, asset_c, asset_d].try_into().unwrap(), initial_amplification: NonZeroU16::new(amplification).unwrap(), final_amplification: NonZeroU16::new(100).unwrap(), - initial_block: 0, - final_block: 0, + initial_block: 1, + final_block: 1, fee: Permill::from_percent(5), } ); diff --git a/pallets/stableswap/src/tests/mock.rs b/pallets/stableswap/src/tests/mock.rs index b7637c241..95c3cbce0 100644 --- a/pallets/stableswap/src/tests/mock.rs +++ b/pallets/stableswap/src/tests/mock.rs @@ -81,12 +81,12 @@ construct_runtime!( System: frame_system, Tokens: orml_tokens, Stableswap: pallet_stableswap, - TradeEvent: pallet_amm_support, + AmmSupport: pallet_amm_support, } ); impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::Everything; + type BaseCallFilter = Everything; type BlockWeights = (); type BlockLength = (); type RuntimeOrigin = RuntimeOrigin; @@ -280,6 +280,8 @@ impl ExtBuilder { let mut r: sp_io::TestExternalities = t.into(); r.execute_with(|| { + frame_system::Pallet::::set_block_number(1); + for (_who, pool, initial_liquid) in self.created_pools { let pool_id = retrieve_current_asset_id(); REGISTERED_ASSETS.with(|v| { @@ -441,3 +443,7 @@ pub(crate) fn last_liquidity_changed_hook_state() -> Option<(AssetId, PoolState< pub(crate) fn last_trade_hook_state() -> Option<(AssetId, AssetId, AssetId, PoolState)> { LAST_TRADE_HOOK.with(|v| v.borrow().clone()) } + +pub(crate) fn expect_events(e: Vec) { + e.into_iter().for_each(frame_system::Pallet::::assert_has_event); +} diff --git a/pallets/stableswap/src/tests/trades.rs b/pallets/stableswap/src/tests/trades.rs index d27b7fd44..0630bad50 100644 --- a/pallets/stableswap/src/tests/trades.rs +++ b/pallets/stableswap/src/tests/trades.rs @@ -1,6 +1,6 @@ use crate::tests::mock::*; use crate::types::{AssetAmount, PoolInfo}; -use crate::{assert_balance, to_precision, Error}; +use crate::{assert_balance, to_precision, Error, Event}; use std::num::NonZeroU16; use frame_support::{assert_noop, assert_ok}; @@ -53,6 +53,32 @@ fn sell_should_work_when_correct_input_provided() { assert_balance!(BOB, asset_b, expected); assert_balance!(pool_account, asset_a, 130 * ONE); assert_balance!(pool_account, asset_b, 100 * ONE - expected); + + expect_events(vec![ + Event::SellExecuted { + who: BOB, + pool_id, + asset_in: asset_a, + asset_out: asset_b, + amount_in: 30000000000000, + amount_out: 29902625420922, + fee: 0, + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: BOB, + filler: pool_account, + filler_type: pallet_amm_support::Filler::Stableswap, + operation: pallet_amm_support::TradeOperation::Sell, + asset_in: asset_a, + asset_out: asset_b, + amount_in: 30000000000000, + amount_out: 29902625420922, + fees: vec![(asset_b, 0, pool_account)], + event_id: None, + } + .into(), + ]); }); } @@ -103,6 +129,32 @@ fn buy_should_work_when_correct_input_provided() { assert_balance!(BOB, asset_b, 30 * ONE); assert_balance!(pool_account, asset_a, 100 * ONE + expected_to_sell); assert_balance!(pool_account, asset_b, 70 * ONE); + + expect_events(vec![ + Event::BuyExecuted { + who: BOB, + pool_id, + asset_in: asset_a, + asset_out: asset_b, + amount_in: 30098072706882, + amount_out: 30000000000000, + fee: 0, + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: BOB, + filler: pool_account, + filler_type: pallet_amm_support::Filler::Stableswap, + operation: pallet_amm_support::TradeOperation::Buy, + asset_in: asset_a, + asset_out: asset_b, + amount_in: 30098072706882, + amount_out: 30000000000000, + fees: vec![(asset_a, 0, pool_account)], + event_id: None, + } + .into(), + ]); }); } diff --git a/pallets/stableswap/src/tests/update_pool.rs b/pallets/stableswap/src/tests/update_pool.rs index 2da8836af..2b7550a60 100644 --- a/pallets/stableswap/src/tests/update_pool.rs +++ b/pallets/stableswap/src/tests/update_pool.rs @@ -38,8 +38,8 @@ fn update_pool_should_work_when_all_parames_are_updated() { assets: vec![asset_a, asset_b].try_into().unwrap(), initial_amplification: NonZeroU16::new(100).unwrap(), final_amplification: NonZeroU16::new(100).unwrap(), - initial_block: 0, - final_block: 0, + initial_block: 1, + final_block: 1, fee: Permill::from_percent(10), } ); @@ -79,8 +79,8 @@ fn update_pool_should_work_when_only_fee_is_updated() { assets: vec![asset_a, asset_b].try_into().unwrap(), initial_amplification: NonZeroU16::new(100).unwrap(), final_amplification: NonZeroU16::new(100).unwrap(), - initial_block: 0, - final_block: 0, + initial_block: 1, + final_block: 1, fee: Permill::from_percent(20), } ); diff --git a/pallets/xyk/src/tests/mock.rs b/pallets/xyk/src/tests/mock.rs index 3d2fcf51c..679d48d03 100644 --- a/pallets/xyk/src/tests/mock.rs +++ b/pallets/xyk/src/tests/mock.rs @@ -61,7 +61,7 @@ frame_support::construct_runtime!( XYK: xyk, Currency: orml_tokens, AssetRegistry: pallet_asset_registry, - TradeEvent: pallet_amm_support, + AmmSupport: pallet_amm_support, } ); diff --git a/runtime/adapters/src/tests/mock.rs b/runtime/adapters/src/tests/mock.rs index 22785b712..57bf7d1ce 100644 --- a/runtime/adapters/src/tests/mock.rs +++ b/runtime/adapters/src/tests/mock.rs @@ -101,7 +101,7 @@ construct_runtime!( RouteExecutor: pallet_route_executor, Currencies: pallet_currencies, XYK: pallet_xyk, - TradeEvent: pallet_amm_support, + AmmSupport: pallet_amm_support, } ); @@ -340,7 +340,7 @@ impl pallet_route_executor::Config for Test { type DefaultRoutePoolType = DefaultRoutePoolType; type TechnicalOrigin = EnsureRoot; type OraclePeriod = RouteValidationOraclePeriod; - type BatchIdProvider = TradeEvent; + type BatchIdProvider = AmmSupport; type WeightInfo = (); } diff --git a/runtime/hydradx/src/assets.rs b/runtime/hydradx/src/assets.rs index 99a415cd1..49e37e576 100644 --- a/runtime/hydradx/src/assets.rs +++ b/runtime/hydradx/src/assets.rs @@ -1205,7 +1205,7 @@ impl pallet_route_executor::Config for Runtime { type TechnicalOrigin = SuperMajorityTechCommittee; type EdToRefundCalculator = RefundAndLockedEdCalculator; type OraclePriceProvider = hydradx_adapters::OraclePriceProvider; - type BatchIdProvider = TradeEvent; + type BatchIdProvider = AmmSupport; type OraclePeriod = RouteValidationOraclePeriod; } diff --git a/runtime/hydradx/src/lib.rs b/runtime/hydradx/src/lib.rs index 38ebe4987..8f5165aab 100644 --- a/runtime/hydradx/src/lib.rs +++ b/runtime/hydradx/src/lib.rs @@ -185,7 +185,7 @@ construct_runtime!( LBP: pallet_lbp = 73, XYK: pallet_xyk = 74, Referrals: pallet_referrals = 75, - TradeEvent: pallet_amm_support = 76, + AmmSupport: pallet_amm_support = 76, // ORML related modules Tokens: orml_tokens = 77, From 1d0a377ca2591db305212232ba85b3284eb0c2bc Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Tue, 1 Oct 2024 16:29:43 +0200 Subject: [PATCH 015/142] fix otc tests --- pallets/otc/src/lib.rs | 8 +- pallets/otc/src/tests/fill_order.rs | 96 +++++++++++++++------ pallets/otc/src/tests/partial_fill_order.rs | 31 +++++-- 3 files changed, 97 insertions(+), 38 deletions(-) diff --git a/pallets/otc/src/lib.rs b/pallets/otc/src/lib.rs index 2dcca4654..2271c5977 100644 --- a/pallets/otc/src/lib.rs +++ b/pallets/otc/src/lib.rs @@ -316,9 +316,9 @@ pub mod pallet { pallet_amm_support::TradeOperation::Sell, order.asset_in.into(), order.asset_out.into(), - order.amount_in, - order.amount_out, - vec![(order.asset_out.into(), fee)], + amount_in, + amount_out, + vec![(order.asset_out.into(), fee, T::FeeReceiver::get().into())], None, ); @@ -364,7 +364,7 @@ pub mod pallet { order.asset_out.into(), order.amount_in, order.amount_out, - vec![(order.asset_out.into(), fee)], + vec![(order.asset_out.into(), fee, T::FeeReceiver::get().into())], None, ); diff --git a/pallets/otc/src/tests/fill_order.rs b/pallets/otc/src/tests/fill_order.rs index 42fb8fa70..098a4f8b4 100644 --- a/pallets/otc/src/tests/fill_order.rs +++ b/pallets/otc/src/tests/fill_order.rs @@ -45,8 +45,7 @@ fn complete_fill_order_should_work() { assert_ok!(OTC::fill_order(RuntimeOrigin::signed(BOB), 0)); // Assert - let order = OTC::orders(0); - assert!(order.is_none()); + assert!(OTC::orders(0).is_none()); let fee = OTC::calculate_fee(amount_out); @@ -71,14 +70,29 @@ fn complete_fill_order_should_work() { TREASURY_INITIAL_BALANCE + fee ); - expect_events(vec![Event::Filled { - order_id: 0, - who: BOB, - amount_in: 20 * ONE, - amount_out: 100 * ONE, - fee: ONE, - } - .into()]); + expect_events(vec![ + Event::Filled { + order_id: 0, + who: BOB, + amount_in: 20 * ONE, + amount_out: 100 * ONE, + fee: ONE, + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: BOB, + filler: ALICE, + filler_type: pallet_amm_support::Filler::OTC, + operation: pallet_amm_support::TradeOperation::Sell, + asset_in: DAI, + asset_out: HDX, + amount_in: 20 * ONE, + amount_out: 100 * ONE, + fees: vec![(HDX, ONE, ::FeeReceiver::get().into())], + event_id: None, + } + .into(), + ]); }); } @@ -133,14 +147,29 @@ fn complete_fill_order_should_work_when_order_is_not_partially_fillable() { TREASURY_INITIAL_BALANCE + fee ); - expect_events(vec![Event::Filled { - order_id: 0, - who: BOB, - amount_in: 20 * ONE, - amount_out: 100 * ONE, - fee: ONE, - } - .into()]); + expect_events(vec![ + Event::Filled { + order_id: 0, + who: BOB, + amount_in: 20 * ONE, + amount_out: 100 * ONE, + fee: ONE, + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: BOB, + filler: ALICE, + filler_type: pallet_amm_support::Filler::OTC, + operation: pallet_amm_support::TradeOperation::Sell, + asset_in: DAI, + asset_out: HDX, + amount_in: 20 * ONE, + amount_out: 100 * ONE, + fees: vec![(HDX, ONE, ::FeeReceiver::get().into())], + event_id: None, + } + .into(), + ]); }); } @@ -207,14 +236,29 @@ fn complete_fill_order_should_work_when_there_are_multiple_orders() { TREASURY_INITIAL_BALANCE + fee ); - expect_events(vec![Event::Filled { - order_id: 0, - who: BOB, - amount_in: 20 * ONE, - amount_out: 100 * ONE, - fee: ONE, - } - .into()]); + expect_events(vec![ + Event::Filled { + order_id: 0, + who: BOB, + amount_in: 20 * ONE, + amount_out: 100 * ONE, + fee: ONE, + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: BOB, + filler: ALICE, + filler_type: pallet_amm_support::Filler::OTC, + operation: pallet_amm_support::TradeOperation::Sell, + asset_in: DAI, + asset_out: HDX, + amount_in: 20 * ONE, + amount_out: 100 * ONE, + fees: vec![(HDX, ONE, ::FeeReceiver::get().into())], + event_id: None, + } + .into(), + ]); }); } diff --git a/pallets/otc/src/tests/partial_fill_order.rs b/pallets/otc/src/tests/partial_fill_order.rs index 2b97f4509..7f48a0370 100644 --- a/pallets/otc/src/tests/partial_fill_order.rs +++ b/pallets/otc/src/tests/partial_fill_order.rs @@ -83,14 +83,29 @@ fn partial_fill_order_should_work_when_order_is_partially_fillable() { TREASURY_INITIAL_BALANCE + fee ); - expect_events(vec![Event::PartiallyFilled { - order_id: 0, - who: BOB, - amount_in: 5 * ONE, - amount_out: expected_amount_out, - fee, - } - .into()]); + expect_events(vec![ + Event::PartiallyFilled { + order_id: 0, + who: BOB, + amount_in: 5 * ONE, + amount_out: expected_amount_out, + fee, + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: BOB, + filler: order.owner, + filler_type: pallet_amm_support::Filler::OTC, + operation: pallet_amm_support::TradeOperation::Sell, + asset_in: order.asset_in, + asset_out: order.asset_out, + amount_in: 5 * ONE, + amount_out: expected_amount_out, + fees: vec![(order.asset_out, fee, ::FeeReceiver::get().into())], + event_id: None, + } + .into(), + ]); }); } From 81c4b6ab5dde68651fbe8b6ecff86fc987b1217b Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Wed, 2 Oct 2024 14:55:29 +0200 Subject: [PATCH 016/142] fix integration tests --- Cargo.lock | 1 + integration-tests/Cargo.toml | 2 + integration-tests/src/router.rs | 292 ++++++++++++++++++++++++++-- pallets/omnipool/src/lib.rs | 10 +- pallets/otc/src/tests/fill_order.rs | 2 +- pallets/stableswap/src/lib.rs | 2 +- 6 files changed, 284 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fd00f98f3..b9214a886 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11992,6 +11992,7 @@ dependencies = [ "orml-xcm", "orml-xcm-support", "orml-xtokens", + "pallet-amm-support", "pallet-asset-registry", "pallet-aura", "pallet-authorship", diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index fdafaaffb..596017904 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -41,6 +41,7 @@ pallet-staking = { workspace = true } pallet-lbp = { workspace = true } pallet-xyk = { workspace = true } pallet-evm-accounts = { workspace = true } +pallet-amm-support = { workspace = true } pallet-treasury = { workspace = true } pallet-democracy = { workspace = true } @@ -211,6 +212,7 @@ std = [ "pallet-dynamic-evm-fee/std", "precompile-utils/std", "pallet-transaction-pause/std", + "pallet-amm-support/std", ] # we don't include integration tests when benchmarking feature is enabled diff --git a/integration-tests/src/router.rs b/integration-tests/src/router.rs index a6f529ddd..a5e18990f 100644 --- a/integration-tests/src/router.rs +++ b/integration-tests/src/router.rs @@ -36,7 +36,7 @@ use sp_runtime::{ DispatchError, DispatchResult, FixedU128, Permill, TransactionOutcome, }; -use hydradx_runtime::InsufficientEDinHDX; +use hydradx_runtime::{AccountIdFor, InsufficientEDinHDX}; use orml_traits::MultiCurrency; pub const LBP_SALE_START: BlockNumber = 10; pub const LBP_SALE_END: BlockNumber = 40; @@ -152,12 +152,52 @@ mod router_different_pools_tests { assert_balance!(BOB.into(), HDX, BOB_INITIAL_NATIVE_BALANCE); assert_balance!(BOB.into(), DOT, amount_out); - expect_hydra_last_events(vec![pallet_route_executor::Event::Executed { - asset_in: DAI, - asset_out: DOT, - amount_in: amount_to_sell, - amount_out, - event_id: 0, + expect_hydra_events(vec![ + pallet_amm_support::Event::Swapped { + swapper: BOB.into(), + filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA)), + filler_type: pallet_amm_support::Filler::LBP, + operation: pallet_amm_support::TradeOperation::Sell, + asset_in: DAI, + asset_out: LRNA, + amount_in: 9980000000, + amount_out: 5640664064, + fees: vec![(DAI, 20000000, LBP::pool_data(LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA))).unwrap().fee_collector)], + event_id: Some(0), + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: BOB.into(), + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::Filler::Omnipool, + operation: pallet_amm_support::TradeOperation::Sell, + asset_in: LRNA, + asset_out: HDX, + amount_in: 5640664064, + amount_out: 4682924837974, + fees: vec![(HDX, 11736653730, Omnipool::protocol_account())], + event_id: Some(0), + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: BOB.into(), + filler: XYK::get_pair_id(pallet_xyk::types::AssetPair{ asset_in: HDX, asset_out: DOT}), + filler_type: pallet_amm_support::Filler::XYK, + operation: pallet_amm_support::TradeOperation::Sell, + asset_in: HDX, + asset_out: DOT, + amount_in: 4682924837974, + amount_out: 2230008413831, + fees: vec![(DOT, 6710155707, XYK::get_pair_id(pallet_xyk::types::AssetPair{ asset_in: HDX, asset_out: DOT}))], + event_id: Some(0), + } + .into(), + pallet_route_executor::Event::Executed { + asset_in: DAI, + asset_out: DOT, + amount_in: amount_to_sell, + amount_out, + event_id: 0, } .into()]); }); @@ -219,14 +259,55 @@ mod router_different_pools_tests { assert_balance!(BOB.into(), stable_asset_1, 0); assert_balance!(BOB.into(), stable_asset_2, amount_out); - expect_hydra_last_events(vec![pallet_route_executor::Event::Executed { + expect_hydra_events(vec![ + pallet_amm_support::Event::Swapped { + swapper: BOB.into(), + filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX)), + filler_type: pallet_amm_support::Filler::LBP, + operation: pallet_amm_support::TradeOperation::Sell, + asset_in: DAI, + asset_out: HDX, + amount_in: 9980000000, + amount_out: 5640664064, + fees: vec![(DAI, 20000000, LBP::pool_data(LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX))).unwrap().fee_collector)], + event_id: Some(0), + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: BOB.into(), + filler: XYK::get_pair_id(pallet_xyk::types::AssetPair{ asset_in: HDX, asset_out: stable_asset_1}), + filler_type: pallet_amm_support::Filler::XYK, + operation: pallet_amm_support::TradeOperation::Sell, + asset_in: HDX, + asset_out: stable_asset_1, + amount_in: 5640664064, + amount_out: 2811712439, + fees: vec![(stable_asset_1, 8460516, XYK::get_pair_id(pallet_xyk::types::AssetPair{ asset_in: HDX, asset_out: stable_asset_1}))], + event_id: Some(0), + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: BOB.into(), + filler: ::ShareAccountId::from_assets(&stable_pool_id, Some(pallet_stableswap::POOL_IDENTIFIER)), + filler_type: pallet_amm_support::Filler::Stableswap, + operation: pallet_amm_support::TradeOperation::Sell, + asset_in: stable_asset_1, + asset_out: stable_asset_2, + amount_in: 2811712439, + amount_out: 2783595233, + fees: vec![(stable_asset_2, 28117123, ::ShareAccountId::from_assets(&stable_pool_id, Some(pallet_stableswap::POOL_IDENTIFIER)))], + event_id: Some(0), + } + .into(), + pallet_route_executor::Event::Executed { asset_in: DAI, asset_out: stable_asset_2, amount_in: amount_to_sell, amount_out, event_id: 0, - } - .into()]); + } + .into() + ]); TransactionOutcome::Commit(DispatchResult::Ok(())) }); @@ -283,12 +364,52 @@ mod router_different_pools_tests { assert_balance!(BOB.into(), HDX, BOB_INITIAL_NATIVE_BALANCE); assert_balance!(BOB.into(), DOT, amount_to_buy); - expect_hydra_last_events(vec![pallet_route_executor::Event::Executed { - asset_in: DAI, - asset_out: DOT, - amount_in, - amount_out: amount_to_buy, - event_id: 0, + expect_hydra_events(vec![ + pallet_amm_support::Event::Swapped { + swapper: BOB.into(), + filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA)), + filler_type: pallet_amm_support::Filler::LBP, + operation: pallet_amm_support::TradeOperation::Buy, + asset_in: DAI, + asset_out: LRNA, + amount_in: 4362157193, + amount_out: 2465566245, + fees: vec![(DAI, 8741796, LBP::pool_data(LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA))).unwrap().fee_collector)], + event_id: Some(0), + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: BOB.into(), + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::Filler::Omnipool, + operation: pallet_amm_support::TradeOperation::Buy, + asset_in: LRNA, + asset_out: HDX, + amount_in: 2465566245, + amount_out: 2046938775509, + fees: vec![(HDX, 5130172370, Omnipool::protocol_account())], + event_id: Some(0), + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: BOB.into(), + filler: XYK::get_pair_id(pallet_xyk::types::AssetPair{ asset_in: HDX, asset_out: DOT}), + filler_type: pallet_amm_support::Filler::XYK, + operation: pallet_amm_support::TradeOperation::Buy, + asset_in: HDX, + asset_out: DOT, + amount_in: 1000000000000, + amount_out: 2040816326531, + fees: vec![(HDX, 6122448978, XYK::get_pair_id(pallet_xyk::types::AssetPair{ asset_in: HDX, asset_out: DOT}))], + event_id: Some(0), + } + .into(), + pallet_route_executor::Event::Executed { + asset_in: DAI, + asset_out: DOT, + amount_in, + amount_out: amount_to_buy, + event_id: 0, } .into()]); }); @@ -350,19 +471,152 @@ mod router_different_pools_tests { assert_balance!(BOB.into(), stable_asset_1, 0); assert_balance!(BOB.into(), stable_asset_2, amount_to_buy); - expect_hydra_last_events(vec![pallet_route_executor::Event::Executed { + expect_hydra_events(vec![ + pallet_amm_support::Event::Swapped { + swapper: BOB.into(), + filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX)), + filler_type: pallet_amm_support::Filler::LBP, + operation: pallet_amm_support::TradeOperation::Buy, + asset_in: DAI, + asset_out: HDX, + amount_in: 3746042043754, + amount_out: 2067851065323, + fees: vec![(DAI, 7507098284, LBP::pool_data(LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX))).unwrap().fee_collector)], + event_id: Some(0), + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: BOB.into(), + filler: XYK::get_pair_id(pallet_xyk::types::AssetPair{ asset_in: HDX, asset_out: stable_asset_1}), + filler_type: pallet_amm_support::Filler::XYK, + operation: pallet_amm_support::TradeOperation::Buy, + asset_in: HDX, + asset_out: stable_asset_1, + amount_in: 1010010000114, + amount_out: 2061666067122, + fees: vec![(HDX, 6184998201, XYK::get_pair_id(pallet_xyk::types::AssetPair{ asset_in: HDX, asset_out: stable_asset_1}))], + event_id: Some(0), + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: BOB.into(), + filler: ::ShareAccountId::from_assets(&stable_pool_id, Some(pallet_stableswap::POOL_IDENTIFIER)), + filler_type: pallet_amm_support::Filler::Stableswap, + operation: pallet_amm_support::TradeOperation::Buy, + asset_in: stable_asset_1, + asset_out: stable_asset_2, + amount_in: 1010010000114, + amount_out: 1000000000000, + fees: vec![(stable_asset_1, 10000099012, ::ShareAccountId::from_assets(&stable_pool_id, Some(pallet_stableswap::POOL_IDENTIFIER)))], + event_id: Some(0), + } + .into(), + pallet_route_executor::Event::Executed { asset_in: DAI, asset_out: stable_asset_2, amount_in, amount_out: amount_to_buy, event_id: 0, - } - .into()]); + } + .into() + ]); + TransactionOutcome::Commit(DispatchResult::Ok(())) }); }); } + #[test] + fn multiple_trades_should_increase_event_id() { + TestNet::reset(); + + Hydra::execute_with(|| { + //Arrange + create_xyk_pool(HDX, DOT); + + let amount_to_sell = UNITS / 100; + let limit = 0; + let trades = vec![ + Trade { + pool: PoolType::XYK, + asset_in: HDX, + asset_out: DOT, + }, + ]; + + //Act + assert_ok!(Router::sell( + RuntimeOrigin::signed(BOB.into()), + HDX, + DOT, + amount_to_sell, + limit, + trades.clone() + )); + + assert_ok!(Router::buy( + RuntimeOrigin::signed(BOB.into()), + HDX, + DOT, + amount_to_sell, + 10 * amount_to_sell, + trades.clone() + )); + + assert_ok!(Router::sell( + RuntimeOrigin::signed(BOB.into()), + HDX, + DOT, + amount_to_sell, + limit, + trades + )); + + //Assert + expect_hydra_events(vec![ + pallet_amm_support::Event::Swapped { + swapper: BOB.into(), + filler: XYK::get_pair_id(pallet_xyk::types::AssetPair{ asset_in: HDX, asset_out: DOT}), + filler_type: pallet_amm_support::Filler::XYK, + operation: pallet_amm_support::TradeOperation::Sell, + asset_in: HDX, + asset_out: DOT, + amount_in: 10000000000, + amount_out: 4984501549, + fees: vec![(DOT, 14998500, XYK::get_pair_id(pallet_xyk::types::AssetPair{ asset_in: HDX, asset_out: DOT}))], + event_id: Some(0), + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: BOB.into(), + filler: XYK::get_pair_id(pallet_xyk::types::AssetPair{ asset_in: HDX, asset_out: DOT}), + filler_type: pallet_amm_support::Filler::XYK, + operation: pallet_amm_support::TradeOperation::Buy, + asset_in: HDX, + asset_out: DOT, + amount_in: 10000000000, + amount_out: 20007996198, + fees: vec![(HDX, 60023988, XYK::get_pair_id(pallet_xyk::types::AssetPair{ asset_in: HDX, asset_out: DOT}))], + event_id: Some(1), + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: BOB.into(), + filler: XYK::get_pair_id(pallet_xyk::types::AssetPair{ asset_in: HDX, asset_out: DOT}), + filler_type: pallet_amm_support::Filler::XYK, + operation: pallet_amm_support::TradeOperation::Sell, + asset_in: HDX, + asset_out: DOT, + amount_in: 10000000000, + amount_out: 4981510054, + fees: vec![(DOT, 14989497, XYK::get_pair_id(pallet_xyk::types::AssetPair{ asset_in: HDX, asset_out: DOT}))], + event_id: Some(2), + } + .into() + ]); + }); + } + #[test] fn router_should_work_for_hopping_from_omnipool_to_stableswap() { TestNet::reset(); diff --git a/pallets/omnipool/src/lib.rs b/pallets/omnipool/src/lib.rs index 44e2c8ab7..2295ef166 100644 --- a/pallets/omnipool/src/lib.rs +++ b/pallets/omnipool/src/lib.rs @@ -1510,7 +1510,7 @@ impl Pallet { // Special handling when one of the asset is Hub Asset // Math is simplified and asset_in is actually part of asset_out state in this case if asset_in == T::HubAssetId::get() { - return Self::sell_hub_asset(origin, &who, asset_out, amount, min_buy_amount); + return Self::sell_hub_asset(origin, &who, asset_out, amount, min_buy_amount, event_id); } if asset_out == T::HubAssetId::get() { @@ -1723,7 +1723,7 @@ impl Pallet { } if asset_in == T::HubAssetId::get() { - return Self::buy_asset_for_hub_asset(origin, &who, asset_out, amount, max_sell_amount); + return Self::buy_asset_for_hub_asset(origin, &who, asset_out, amount, max_sell_amount, event_id); } let asset_in_state = Self::load_asset_state(asset_in)?; @@ -1917,6 +1917,7 @@ impl Pallet { asset_out: T::AssetId, amount: Balance, limit: Balance, + event_id: Option, ) -> DispatchResult { ensure!( HubAssetTradability::::get().contains(Tradability::SELL), @@ -2022,7 +2023,7 @@ impl Pallet { *state_changes.asset.delta_hub_reserve, *state_changes.asset.delta_reserve, vec![(asset_out.into(), state_changes.fee.asset_fee, Self::protocol_account())], - None, + event_id, ); T::OmnipoolHooks::on_hub_asset_trade(origin, info)?; @@ -2038,6 +2039,7 @@ impl Pallet { asset_out: T::AssetId, amount: Balance, limit: Balance, + event_id: Option, ) -> DispatchResult { ensure!( HubAssetTradability::::get().contains(Tradability::SELL), @@ -2143,7 +2145,7 @@ impl Pallet { *state_changes.asset.delta_hub_reserve, *state_changes.asset.delta_reserve, vec![(asset_out.into(), state_changes.fee.asset_fee, Self::protocol_account())], - None, + event_id, ); T::OmnipoolHooks::on_hub_asset_trade(origin, info)?; diff --git a/pallets/otc/src/tests/fill_order.rs b/pallets/otc/src/tests/fill_order.rs index 098a4f8b4..f519c83f4 100644 --- a/pallets/otc/src/tests/fill_order.rs +++ b/pallets/otc/src/tests/fill_order.rs @@ -257,7 +257,7 @@ fn complete_fill_order_should_work_when_there_are_multiple_orders() { fees: vec![(HDX, ONE, ::FeeReceiver::get().into())], event_id: None, } - .into(), + .into() ]); }); } diff --git a/pallets/stableswap/src/lib.rs b/pallets/stableswap/src/lib.rs index f9e6985a3..8dbf02e8b 100644 --- a/pallets/stableswap/src/lib.rs +++ b/pallets/stableswap/src/lib.rs @@ -800,7 +800,7 @@ impl Pallet { } fn do_sell( - origin: frame_system::pallet_prelude::OriginFor, + origin: OriginFor, pool_id: T::AssetId, asset_in: T::AssetId, asset_out: T::AssetId, From a50ffb75330418f54ef7d2069b68f44d0c9f91ea Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Wed, 2 Oct 2024 14:55:42 +0200 Subject: [PATCH 017/142] formatting --- integration-tests/src/router.rs | 388 ++++++++++++++++++---------- pallets/otc/src/tests/fill_order.rs | 2 +- 2 files changed, 252 insertions(+), 138 deletions(-) diff --git a/integration-tests/src/router.rs b/integration-tests/src/router.rs index a5e18990f..2a7ad6c2a 100644 --- a/integration-tests/src/router.rs +++ b/integration-tests/src/router.rs @@ -153,7 +153,7 @@ mod router_different_pools_tests { assert_balance!(BOB.into(), DOT, amount_out); expect_hydra_events(vec![ - pallet_amm_support::Event::Swapped { + pallet_amm_support::Event::Swapped { swapper: BOB.into(), filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA)), filler_type: pallet_amm_support::Filler::LBP, @@ -162,10 +162,16 @@ mod router_different_pools_tests { asset_out: LRNA, amount_in: 9980000000, amount_out: 5640664064, - fees: vec![(DAI, 20000000, LBP::pool_data(LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA))).unwrap().fee_collector)], + fees: vec![( + DAI, + 20000000, + LBP::pool_data(LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA))) + .unwrap() + .fee_collector, + )], event_id: Some(0), - } - .into(), + } + .into(), pallet_amm_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), @@ -177,29 +183,40 @@ mod router_different_pools_tests { amount_out: 4682924837974, fees: vec![(HDX, 11736653730, Omnipool::protocol_account())], event_id: Some(0), - } - .into(), + } + .into(), pallet_amm_support::Event::Swapped { swapper: BOB.into(), - filler: XYK::get_pair_id(pallet_xyk::types::AssetPair{ asset_in: HDX, asset_out: DOT}), + filler: XYK::get_pair_id(pallet_xyk::types::AssetPair { + asset_in: HDX, + asset_out: DOT, + }), filler_type: pallet_amm_support::Filler::XYK, operation: pallet_amm_support::TradeOperation::Sell, asset_in: HDX, asset_out: DOT, amount_in: 4682924837974, amount_out: 2230008413831, - fees: vec![(DOT, 6710155707, XYK::get_pair_id(pallet_xyk::types::AssetPair{ asset_in: HDX, asset_out: DOT}))], + fees: vec![( + DOT, + 6710155707, + XYK::get_pair_id(pallet_xyk::types::AssetPair { + asset_in: HDX, + asset_out: DOT, + }), + )], event_id: Some(0), - } - .into(), - pallet_route_executor::Event::Executed { + } + .into(), + pallet_route_executor::Event::Executed { asset_in: DAI, asset_out: DOT, amount_in: amount_to_sell, amount_out, event_id: 0, - } - .into()]); + } + .into(), + ]); }); TestNet::reset(); @@ -261,52 +278,78 @@ mod router_different_pools_tests { expect_hydra_events(vec![ pallet_amm_support::Event::Swapped { - swapper: BOB.into(), - filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX)), - filler_type: pallet_amm_support::Filler::LBP, - operation: pallet_amm_support::TradeOperation::Sell, - asset_in: DAI, - asset_out: HDX, - amount_in: 9980000000, - amount_out: 5640664064, - fees: vec![(DAI, 20000000, LBP::pool_data(LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX))).unwrap().fee_collector)], - event_id: Some(0), - } - .into(), - pallet_amm_support::Event::Swapped { - swapper: BOB.into(), - filler: XYK::get_pair_id(pallet_xyk::types::AssetPair{ asset_in: HDX, asset_out: stable_asset_1}), - filler_type: pallet_amm_support::Filler::XYK, - operation: pallet_amm_support::TradeOperation::Sell, - asset_in: HDX, - asset_out: stable_asset_1, - amount_in: 5640664064, - amount_out: 2811712439, - fees: vec![(stable_asset_1, 8460516, XYK::get_pair_id(pallet_xyk::types::AssetPair{ asset_in: HDX, asset_out: stable_asset_1}))], - event_id: Some(0), - } - .into(), - pallet_amm_support::Event::Swapped { - swapper: BOB.into(), - filler: ::ShareAccountId::from_assets(&stable_pool_id, Some(pallet_stableswap::POOL_IDENTIFIER)), - filler_type: pallet_amm_support::Filler::Stableswap, - operation: pallet_amm_support::TradeOperation::Sell, - asset_in: stable_asset_1, - asset_out: stable_asset_2, - amount_in: 2811712439, - amount_out: 2783595233, - fees: vec![(stable_asset_2, 28117123, ::ShareAccountId::from_assets(&stable_pool_id, Some(pallet_stableswap::POOL_IDENTIFIER)))], - event_id: Some(0), - } - .into(), - pallet_route_executor::Event::Executed { - asset_in: DAI, - asset_out: stable_asset_2, - amount_in: amount_to_sell, - amount_out, - event_id: 0, - } - .into() + swapper: BOB.into(), + filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX)), + filler_type: pallet_amm_support::Filler::LBP, + operation: pallet_amm_support::TradeOperation::Sell, + asset_in: DAI, + asset_out: HDX, + amount_in: 9980000000, + amount_out: 5640664064, + fees: vec![( + DAI, + 20000000, + LBP::pool_data(LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX))) + .unwrap() + .fee_collector, + )], + event_id: Some(0), + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: BOB.into(), + filler: XYK::get_pair_id(pallet_xyk::types::AssetPair { + asset_in: HDX, + asset_out: stable_asset_1, + }), + filler_type: pallet_amm_support::Filler::XYK, + operation: pallet_amm_support::TradeOperation::Sell, + asset_in: HDX, + asset_out: stable_asset_1, + amount_in: 5640664064, + amount_out: 2811712439, + fees: vec![( + stable_asset_1, + 8460516, + XYK::get_pair_id(pallet_xyk::types::AssetPair { + asset_in: HDX, + asset_out: stable_asset_1, + }), + )], + event_id: Some(0), + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: BOB.into(), + filler: ::ShareAccountId::from_assets( + &stable_pool_id, + Some(pallet_stableswap::POOL_IDENTIFIER), + ), + filler_type: pallet_amm_support::Filler::Stableswap, + operation: pallet_amm_support::TradeOperation::Sell, + asset_in: stable_asset_1, + asset_out: stable_asset_2, + amount_in: 2811712439, + amount_out: 2783595233, + fees: vec![( + stable_asset_2, + 28117123, + ::ShareAccountId::from_assets( + &stable_pool_id, + Some(pallet_stableswap::POOL_IDENTIFIER), + ), + )], + event_id: Some(0), + } + .into(), + pallet_route_executor::Event::Executed { + asset_in: DAI, + asset_out: stable_asset_2, + amount_in: amount_to_sell, + amount_out, + event_id: 0, + } + .into(), ]); TransactionOutcome::Commit(DispatchResult::Ok(())) @@ -365,7 +408,7 @@ mod router_different_pools_tests { assert_balance!(BOB.into(), DOT, amount_to_buy); expect_hydra_events(vec![ - pallet_amm_support::Event::Swapped { + pallet_amm_support::Event::Swapped { swapper: BOB.into(), filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA)), filler_type: pallet_amm_support::Filler::LBP, @@ -374,10 +417,16 @@ mod router_different_pools_tests { asset_out: LRNA, amount_in: 4362157193, amount_out: 2465566245, - fees: vec![(DAI, 8741796, LBP::pool_data(LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA))).unwrap().fee_collector)], + fees: vec![( + DAI, + 8741796, + LBP::pool_data(LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA))) + .unwrap() + .fee_collector, + )], event_id: Some(0), - } - .into(), + } + .into(), pallet_amm_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), @@ -389,29 +438,40 @@ mod router_different_pools_tests { amount_out: 2046938775509, fees: vec![(HDX, 5130172370, Omnipool::protocol_account())], event_id: Some(0), - } - .into(), + } + .into(), pallet_amm_support::Event::Swapped { swapper: BOB.into(), - filler: XYK::get_pair_id(pallet_xyk::types::AssetPair{ asset_in: HDX, asset_out: DOT}), + filler: XYK::get_pair_id(pallet_xyk::types::AssetPair { + asset_in: HDX, + asset_out: DOT, + }), filler_type: pallet_amm_support::Filler::XYK, operation: pallet_amm_support::TradeOperation::Buy, asset_in: HDX, asset_out: DOT, amount_in: 1000000000000, amount_out: 2040816326531, - fees: vec![(HDX, 6122448978, XYK::get_pair_id(pallet_xyk::types::AssetPair{ asset_in: HDX, asset_out: DOT}))], + fees: vec![( + HDX, + 6122448978, + XYK::get_pair_id(pallet_xyk::types::AssetPair { + asset_in: HDX, + asset_out: DOT, + }), + )], event_id: Some(0), - } - .into(), - pallet_route_executor::Event::Executed { + } + .into(), + pallet_route_executor::Event::Executed { asset_in: DAI, asset_out: DOT, amount_in, amount_out: amount_to_buy, event_id: 0, - } - .into()]); + } + .into(), + ]); }); TestNet::reset(); @@ -473,52 +533,78 @@ mod router_different_pools_tests { expect_hydra_events(vec![ pallet_amm_support::Event::Swapped { - swapper: BOB.into(), - filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX)), - filler_type: pallet_amm_support::Filler::LBP, - operation: pallet_amm_support::TradeOperation::Buy, - asset_in: DAI, - asset_out: HDX, - amount_in: 3746042043754, - amount_out: 2067851065323, - fees: vec![(DAI, 7507098284, LBP::pool_data(LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX))).unwrap().fee_collector)], - event_id: Some(0), - } - .into(), - pallet_amm_support::Event::Swapped { - swapper: BOB.into(), - filler: XYK::get_pair_id(pallet_xyk::types::AssetPair{ asset_in: HDX, asset_out: stable_asset_1}), - filler_type: pallet_amm_support::Filler::XYK, - operation: pallet_amm_support::TradeOperation::Buy, - asset_in: HDX, - asset_out: stable_asset_1, - amount_in: 1010010000114, - amount_out: 2061666067122, - fees: vec![(HDX, 6184998201, XYK::get_pair_id(pallet_xyk::types::AssetPair{ asset_in: HDX, asset_out: stable_asset_1}))], - event_id: Some(0), - } - .into(), - pallet_amm_support::Event::Swapped { - swapper: BOB.into(), - filler: ::ShareAccountId::from_assets(&stable_pool_id, Some(pallet_stableswap::POOL_IDENTIFIER)), - filler_type: pallet_amm_support::Filler::Stableswap, - operation: pallet_amm_support::TradeOperation::Buy, - asset_in: stable_asset_1, - asset_out: stable_asset_2, - amount_in: 1010010000114, - amount_out: 1000000000000, - fees: vec![(stable_asset_1, 10000099012, ::ShareAccountId::from_assets(&stable_pool_id, Some(pallet_stableswap::POOL_IDENTIFIER)))], - event_id: Some(0), - } - .into(), - pallet_route_executor::Event::Executed { - asset_in: DAI, - asset_out: stable_asset_2, - amount_in, - amount_out: amount_to_buy, - event_id: 0, - } - .into() + swapper: BOB.into(), + filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX)), + filler_type: pallet_amm_support::Filler::LBP, + operation: pallet_amm_support::TradeOperation::Buy, + asset_in: DAI, + asset_out: HDX, + amount_in: 3746042043754, + amount_out: 2067851065323, + fees: vec![( + DAI, + 7507098284, + LBP::pool_data(LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX))) + .unwrap() + .fee_collector, + )], + event_id: Some(0), + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: BOB.into(), + filler: XYK::get_pair_id(pallet_xyk::types::AssetPair { + asset_in: HDX, + asset_out: stable_asset_1, + }), + filler_type: pallet_amm_support::Filler::XYK, + operation: pallet_amm_support::TradeOperation::Buy, + asset_in: HDX, + asset_out: stable_asset_1, + amount_in: 1010010000114, + amount_out: 2061666067122, + fees: vec![( + HDX, + 6184998201, + XYK::get_pair_id(pallet_xyk::types::AssetPair { + asset_in: HDX, + asset_out: stable_asset_1, + }), + )], + event_id: Some(0), + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: BOB.into(), + filler: ::ShareAccountId::from_assets( + &stable_pool_id, + Some(pallet_stableswap::POOL_IDENTIFIER), + ), + filler_type: pallet_amm_support::Filler::Stableswap, + operation: pallet_amm_support::TradeOperation::Buy, + asset_in: stable_asset_1, + asset_out: stable_asset_2, + amount_in: 1010010000114, + amount_out: 1000000000000, + fees: vec![( + stable_asset_1, + 10000099012, + ::ShareAccountId::from_assets( + &stable_pool_id, + Some(pallet_stableswap::POOL_IDENTIFIER), + ), + )], + event_id: Some(0), + } + .into(), + pallet_route_executor::Event::Executed { + asset_in: DAI, + asset_out: stable_asset_2, + amount_in, + amount_out: amount_to_buy, + event_id: 0, + } + .into(), ]); TransactionOutcome::Commit(DispatchResult::Ok(())) @@ -536,13 +622,11 @@ mod router_different_pools_tests { let amount_to_sell = UNITS / 100; let limit = 0; - let trades = vec![ - Trade { - pool: PoolType::XYK, - asset_in: HDX, - asset_out: DOT, - }, - ]; + let trades = vec![Trade { + pool: PoolType::XYK, + asset_in: HDX, + asset_out: DOT, + }]; //Act assert_ok!(Router::sell( @@ -576,43 +660,73 @@ mod router_different_pools_tests { expect_hydra_events(vec![ pallet_amm_support::Event::Swapped { swapper: BOB.into(), - filler: XYK::get_pair_id(pallet_xyk::types::AssetPair{ asset_in: HDX, asset_out: DOT}), + filler: XYK::get_pair_id(pallet_xyk::types::AssetPair { + asset_in: HDX, + asset_out: DOT, + }), filler_type: pallet_amm_support::Filler::XYK, operation: pallet_amm_support::TradeOperation::Sell, asset_in: HDX, asset_out: DOT, amount_in: 10000000000, amount_out: 4984501549, - fees: vec![(DOT, 14998500, XYK::get_pair_id(pallet_xyk::types::AssetPair{ asset_in: HDX, asset_out: DOT}))], + fees: vec![( + DOT, + 14998500, + XYK::get_pair_id(pallet_xyk::types::AssetPair { + asset_in: HDX, + asset_out: DOT, + }), + )], event_id: Some(0), - } - .into(), + } + .into(), pallet_amm_support::Event::Swapped { swapper: BOB.into(), - filler: XYK::get_pair_id(pallet_xyk::types::AssetPair{ asset_in: HDX, asset_out: DOT}), + filler: XYK::get_pair_id(pallet_xyk::types::AssetPair { + asset_in: HDX, + asset_out: DOT, + }), filler_type: pallet_amm_support::Filler::XYK, operation: pallet_amm_support::TradeOperation::Buy, asset_in: HDX, asset_out: DOT, amount_in: 10000000000, amount_out: 20007996198, - fees: vec![(HDX, 60023988, XYK::get_pair_id(pallet_xyk::types::AssetPair{ asset_in: HDX, asset_out: DOT}))], + fees: vec![( + HDX, + 60023988, + XYK::get_pair_id(pallet_xyk::types::AssetPair { + asset_in: HDX, + asset_out: DOT, + }), + )], event_id: Some(1), - } - .into(), + } + .into(), pallet_amm_support::Event::Swapped { swapper: BOB.into(), - filler: XYK::get_pair_id(pallet_xyk::types::AssetPair{ asset_in: HDX, asset_out: DOT}), + filler: XYK::get_pair_id(pallet_xyk::types::AssetPair { + asset_in: HDX, + asset_out: DOT, + }), filler_type: pallet_amm_support::Filler::XYK, operation: pallet_amm_support::TradeOperation::Sell, asset_in: HDX, asset_out: DOT, amount_in: 10000000000, amount_out: 4981510054, - fees: vec![(DOT, 14989497, XYK::get_pair_id(pallet_xyk::types::AssetPair{ asset_in: HDX, asset_out: DOT}))], + fees: vec![( + DOT, + 14989497, + XYK::get_pair_id(pallet_xyk::types::AssetPair { + asset_in: HDX, + asset_out: DOT, + }), + )], event_id: Some(2), - } - .into() + } + .into(), ]); }); } diff --git a/pallets/otc/src/tests/fill_order.rs b/pallets/otc/src/tests/fill_order.rs index f519c83f4..098a4f8b4 100644 --- a/pallets/otc/src/tests/fill_order.rs +++ b/pallets/otc/src/tests/fill_order.rs @@ -257,7 +257,7 @@ fn complete_fill_order_should_work_when_there_are_multiple_orders() { fees: vec![(HDX, ONE, ::FeeReceiver::get().into())], event_id: None, } - .into() + .into(), ]); }); } From 1e209bb85d0ea68cb58d622f1f8497ab2a5c8602 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Wed, 2 Oct 2024 15:58:19 +0200 Subject: [PATCH 018/142] fix integration tests --- integration-tests/src/referrals.rs | 94 ++++++++--- integration-tests/src/router.rs | 242 ++++++++++++++++++++++------- 2 files changed, 254 insertions(+), 82 deletions(-) diff --git a/integration-tests/src/referrals.rs b/integration-tests/src/referrals.rs index 136992a5b..574bd3b6e 100644 --- a/integration-tests/src/referrals.rs +++ b/integration-tests/src/referrals.rs @@ -339,18 +339,41 @@ fn buying_hdx_in_omnipool_should_transfer_correct_fee() { u128::MAX, )); - expect_hydra_last_events(vec![pallet_omnipool::Event::BuyExecuted { - who: BOB.into(), - asset_in: DAI, - asset_out: HDX, - amount_in: 26_835_579_541_620_354, - amount_out: 1_000_000_000_000, - hub_amount_in: 1_209_746_177, - hub_amount_out: 1_209_141_304, - asset_fee_amount: 2_794_789_078, - protocol_fee_amount: 604_873, - } - .into()]); + expect_hydra_last_events(vec![ + pallet_omnipool::Event::BuyExecuted { + who: BOB.into(), + asset_in: DAI, + asset_out: HDX, + amount_in: 26_835_579_541_620_354, + amount_out: 1_000_000_000_000, + hub_amount_in: 1_209_746_177, + hub_amount_out: 1_209_141_304, + asset_fee_amount: 2_794_789_078, + protocol_fee_amount: 604_873, + } + .into(), + pallet_omnipool::Event::HubAmountUpdated { + hub_amount_in: 1_209_746_177, + hub_amount_out: 1_209_141_304, + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: BOB.into(), + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::Filler::Omnipool, + operation: pallet_amm_support::TradeOperation::Buy, + asset_in: DAI, + asset_out: HDX, + amount_in: 26_835_579_541_620_354, + amount_out: 1_000_000_000_000, + fees: vec![ + (HDX, 2_794_789_078, Omnipool::protocol_account()), + (LRNA, 604_873, Omnipool::protocol_account()), + ], + event_id: None, + } + .into(), + ]); let ref_dai_balance = Currencies::free_balance(DAI, &ref_account); let staking_balance = Currencies::free_balance(HDX, &staking_acc); @@ -376,18 +399,41 @@ fn buying_with_hdx_in_omnipool_should_transfer_correct_fee() { u128::MAX, )); - expect_hydra_last_events(vec![pallet_omnipool::Event::BuyExecuted { - who: BOB.into(), - asset_in: HDX, - asset_out: DAI, - amount_in: 37_506_757_329_085, - amount_out: 1_000_000_000_000_000_000, - hub_amount_in: 45_222_713_080, - hub_amount_out: 45_200_101_724, - asset_fee_amount: 2_644_977_450_514_458, - protocol_fee_amount: 22_611_356, - } - .into()]); + expect_hydra_last_events(vec![ + pallet_omnipool::Event::BuyExecuted { + who: BOB.into(), + asset_in: HDX, + asset_out: DAI, + amount_in: 37_506_757_329_085, + amount_out: 1_000_000_000_000_000_000, + hub_amount_in: 45_222_713_080, + hub_amount_out: 45_200_101_724, + asset_fee_amount: 2_644_977_450_514_458, + protocol_fee_amount: 22_611_356, + } + .into(), + pallet_omnipool::Event::HubAmountUpdated { + hub_amount_in: 45_222_713_080, + hub_amount_out: 45_200_101_724, + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: BOB.into(), + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::Filler::Omnipool, + operation: pallet_amm_support::TradeOperation::Buy, + asset_in: HDX, + asset_out: DAI, + amount_in: 37_506_757_329_085, + amount_out: 1_000_000_000_000_000_000, + fees: vec![ + (DAI, 2_644_977_450_514_458, Omnipool::protocol_account()), + (LRNA, 22_611_356, Omnipool::protocol_account()), + ], + event_id: None, + } + .into(), + ]); let ref_dai_balance = Currencies::free_balance(DAI, &ref_account); let staking_balance = Currencies::free_balance(HDX, &staking_acc); diff --git a/integration-tests/src/router.rs b/integration-tests/src/router.rs index 2a7ad6c2a..2c20b0b52 100644 --- a/integration-tests/src/router.rs +++ b/integration-tests/src/router.rs @@ -2388,14 +2388,32 @@ mod omnipool_router_tests { assert_balance!(BOB.into(), HDX, BOB_INITIAL_NATIVE_BALANCE - amount_to_sell); assert_balance!(BOB.into(), DAI, BOB_INITIAL_DAI_BALANCE + amount_out); - expect_hydra_last_events(vec![pallet_route_executor::Event::Executed { - asset_in: HDX, - asset_out: DAI, - amount_in: amount_to_sell, - amount_out, - event_id: 0, - } - .into()]); + expect_hydra_last_events(vec![ + pallet_amm_support::Event::Swapped { + swapper: BOB.into(), + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::Filler::Omnipool, + operation: pallet_amm_support::TradeOperation::Sell, + asset_in: HDX, + asset_out: DAI, + amount_in: amount_to_sell, + amount_out, + fees: vec![ + (DAI, 667155563986401, Omnipool::protocol_account()), + (LRNA, 6007435, Omnipool::protocol_account()), + ], + event_id: Some(0), + } + .into(), + pallet_route_executor::Event::Executed { + asset_in: HDX, + asset_out: DAI, + amount_in: amount_to_sell, + amount_out, + event_id: 0, + } + .into(), + ]); }); TestNet::reset(); @@ -2414,18 +2432,41 @@ mod omnipool_router_tests { )); //Assert - expect_hydra_last_events(vec![pallet_omnipool::Event::SellExecuted { - who: BOB.into(), - asset_in: HDX, - asset_out: DAI, - amount_in: amount_to_sell, - amount_out, - hub_amount_in: 12014871681, - hub_amount_out: 12008864246, - asset_fee_amount: 667_155_563_986_401, - protocol_fee_amount: 6_007_435, - } - .into()]); + expect_hydra_last_events(vec![ + pallet_omnipool::Event::SellExecuted { + who: BOB.into(), + asset_in: HDX, + asset_out: DAI, + amount_in: amount_to_sell, + amount_out, + hub_amount_in: 12014871681, + hub_amount_out: 12008864246, + asset_fee_amount: 667_155_563_986_401, + protocol_fee_amount: 6_007_435, + } + .into(), + pallet_omnipool::Event::HubAmountUpdated { + hub_amount_in: 12014871681, + hub_amount_out: 12008864246, + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: BOB.into(), + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::Filler::Omnipool, + operation: pallet_amm_support::TradeOperation::Sell, + asset_in: HDX, + asset_out: DAI, + amount_in: amount_to_sell, + amount_out, + fees: vec![ + (DAI, 667155563986401, Omnipool::protocol_account()), + (LRNA, 6007435, Omnipool::protocol_account()), + ], + event_id: None, + } + .into(), + ]); assert_balance!(BOB.into(), HDX, BOB_INITIAL_NATIVE_BALANCE - amount_to_sell); assert_balance!(BOB.into(), DAI, BOB_INITIAL_DAI_BALANCE + amount_out); @@ -2570,14 +2611,32 @@ mod omnipool_router_tests { assert_balance!(BOB.into(), HDX, BOB_INITIAL_NATIVE_BALANCE - amount_in); assert_balance!(BOB.into(), DAI, BOB_INITIAL_DAI_BALANCE + amount_to_buy); - expect_hydra_last_events(vec![pallet_route_executor::Event::Executed { - asset_in: HDX, - asset_out: DAI, - amount_in, - amount_out: amount_to_buy, - event_id: 0, - } - .into()]); + expect_hydra_last_events(vec![ + pallet_amm_support::Event::Swapped { + swapper: BOB.into(), + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::Filler::Omnipool, + operation: pallet_amm_support::TradeOperation::Buy, + asset_in: HDX, + asset_out: DAI, + amount_in, + amount_out: amount_to_buy, + fees: vec![ + (DAI, 2506265665, Omnipool::protocol_account()), + (LRNA, 22, Omnipool::protocol_account()), + ], + event_id: Some(0), + } + .into(), + pallet_route_executor::Event::Executed { + asset_in: HDX, + asset_out: DAI, + amount_in, + amount_out: amount_to_buy, + event_id: 0, + } + .into(), + ]); }); TestNet::reset(); @@ -2596,18 +2655,41 @@ mod omnipool_router_tests { )); //Assert - expect_hydra_last_events(vec![pallet_omnipool::Event::BuyExecuted { - who: BOB.into(), - asset_in: HDX, - asset_out: DAI, - amount_in, - amount_out: amount_to_buy, - hub_amount_in: 45135, - hub_amount_out: 45113, - asset_fee_amount: 2_506_265_665, - protocol_fee_amount: 22, - } - .into()]); + expect_hydra_last_events(vec![ + pallet_omnipool::Event::BuyExecuted { + who: BOB.into(), + asset_in: HDX, + asset_out: DAI, + amount_in, + amount_out: amount_to_buy, + hub_amount_in: 45135, + hub_amount_out: 45113, + asset_fee_amount: 2_506_265_665, + protocol_fee_amount: 22, + } + .into(), + pallet_omnipool::Event::HubAmountUpdated { + hub_amount_in: 45135, + hub_amount_out: 45113, + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: BOB.into(), + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::Filler::Omnipool, + operation: pallet_amm_support::TradeOperation::Buy, + asset_in: HDX, + asset_out: DAI, + amount_in, + amount_out: amount_to_buy, + fees: vec![ + (DAI, 2_506_265_665, Omnipool::protocol_account()), + (LRNA, 22, Omnipool::protocol_account()), + ], + event_id: None, + } + .into(), + ]); assert_balance!(BOB.into(), HDX, BOB_INITIAL_NATIVE_BALANCE - amount_in); assert_balance!(BOB.into(), DAI, BOB_INITIAL_DAI_BALANCE + amount_to_buy); @@ -2877,14 +2959,37 @@ mod lbp_router_tests { assert_balance!(BOB.into(), HDX, BOB_INITIAL_NATIVE_BALANCE - amount_to_sell); assert_balance!(BOB.into(), DAI, BOB_INITIAL_DAI_BALANCE + received_amount_out); - expect_hydra_last_events(vec![pallet_route_executor::Event::Executed { - asset_in: HDX, - asset_out: DAI, - amount_in: amount_to_sell, - amount_out: received_amount_out, - event_id: 0, - } - .into()]); + let fee = 20000000000; + + expect_hydra_last_events(vec![ + pallet_amm_support::Event::Swapped { + swapper: BOB.into(), + filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX)), + filler_type: pallet_amm_support::Filler::LBP, + operation: pallet_amm_support::TradeOperation::Sell, + asset_in: HDX, + asset_out: DAI, + amount_in: amount_to_sell - fee, + amount_out: received_amount_out, + fees: vec![( + HDX, + fee, + LBP::pool_data(LBP::get_pair_id(pallet_lbp::types::AssetPair::new(HDX, DAI))) + .unwrap() + .fee_collector, + )], + event_id: Some(0), + } + .into(), + pallet_route_executor::Event::Executed { + asset_in: HDX, + asset_out: DAI, + amount_in: amount_to_sell, + amount_out: received_amount_out, + event_id: 0, + } + .into(), + ]); }); TestNet::reset(); @@ -2904,16 +3009,37 @@ mod lbp_router_tests { )); //Assert - expect_hydra_last_events(vec![pallet_lbp::Event::SellExecuted { - who: BOB.into(), - asset_in: HDX, - asset_out: DAI, - amount: 9_980_000_000_000, - sale_price: received_amount_out, - fee_asset: HDX, - fee_amount: 20_000_000_000, - } - .into()]); + expect_hydra_last_events(vec![ + pallet_lbp::Event::SellExecuted { + who: BOB.into(), + asset_in: HDX, + asset_out: DAI, + amount: 9_980_000_000_000, + sale_price: received_amount_out, + fee_asset: HDX, + fee_amount: 20_000_000_000, + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: BOB.into(), + filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX)), + filler_type: pallet_amm_support::Filler::LBP, + operation: pallet_amm_support::TradeOperation::Sell, + asset_in: HDX, + asset_out: DAI, + amount_in: 9_980_000_000_000, + amount_out: received_amount_out, + fees: vec![( + HDX, + 20_000_000_000, + LBP::pool_data(LBP::get_pair_id(pallet_lbp::types::AssetPair::new(HDX, DAI))) + .unwrap() + .fee_collector, + )], + event_id: None, + } + .into(), + ]); assert_balance!(BOB.into(), HDX, BOB_INITIAL_NATIVE_BALANCE - amount_to_sell); assert_balance!(BOB.into(), DAI, BOB_INITIAL_DAI_BALANCE + received_amount_out); From d58de6c41cc31e495f17ebf69903a264a63f8b9b Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Wed, 2 Oct 2024 16:14:24 +0200 Subject: [PATCH 019/142] satisfy clippy --- integration-tests/src/fee_calculation.rs | 2 +- integration-tests/src/insufficient_assets_ed.rs | 2 +- pallets/lbp/src/tests.rs | 10 +++++----- pallets/otc/src/lib.rs | 4 ++-- pallets/otc/src/tests/fill_order.rs | 6 +++--- pallets/otc/src/tests/partial_fill_order.rs | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/integration-tests/src/fee_calculation.rs b/integration-tests/src/fee_calculation.rs index 8d3eb203e..603d0d85d 100644 --- a/integration-tests/src/fee_calculation.rs +++ b/integration-tests/src/fee_calculation.rs @@ -189,7 +189,7 @@ fn substrate_and_evm_fee_growth_simulator_with_idle_chain() { .max_total .unwrap(); - for (nonce, b) in (2..HOURS).enumerate() { + for b in 2..HOURS { //=HOURS { hydradx_run_to_block(b); hydradx_runtime::System::set_block_consumed_resources(block_weight, 0); diff --git a/integration-tests/src/insufficient_assets_ed.rs b/integration-tests/src/insufficient_assets_ed.rs index d87f65076..36c0d4aed 100644 --- a/integration-tests/src/insufficient_assets_ed.rs +++ b/integration-tests/src/insufficient_assets_ed.rs @@ -1485,7 +1485,7 @@ fn ed_should_be_paid_in_insufficient_asset_through_dot() { hydradx_runtime::Currencies::free_balance(insufficient_asset, &ALICE.into()); //Act - assert_ok!(Tokens::deposit(insufficient_asset2, &ALICE.into(), 1 * UNITS)); + assert_ok!(Tokens::deposit(insufficient_asset2, &ALICE.into(), UNITS)); //Assert let alice_new_insuff_balance = hydradx_runtime::Currencies::free_balance(insufficient_asset, &ALICE.into()); diff --git a/pallets/lbp/src/tests.rs b/pallets/lbp/src/tests.rs index 63da4bed5..c626747e1 100644 --- a/pallets/lbp/src/tests.rs +++ b/pallets/lbp/src/tests.rs @@ -1809,7 +1809,7 @@ fn execute_sell_should_work() { let asset_in = KUSD; let asset_out = BSX; let pool_id = LBPPallet::get_pair_id(AssetPair { asset_in, asset_out }); - let pool_data = >::try_get(&pool_id).unwrap(); + let pool_data = >::try_get(pool_id).unwrap(); let amount_in = 8_000_000_u128; let amount_b = 20_000_000_u128; @@ -1949,7 +1949,7 @@ fn execute_buy_should_work() { let asset_in = KUSD; let asset_out = BSX; let pool_id = LBPPallet::get_pair_id(AssetPair { asset_in, asset_out }); - let pool_data = >::try_get(&pool_id).unwrap(); + let pool_data = >::try_get(pool_id).unwrap(); let amount_in = 8_000_000_u128; let amount_b = 20_000_000_u128; @@ -2301,7 +2301,7 @@ fn buy_should_work() { let asset_in = KUSD; let asset_out = BSX; let pool_id = LBPPallet::get_pair_id(AssetPair { asset_in, asset_out }); - let pool_data = >::try_get(&pool_id).unwrap(); + let pool_data = >::try_get(pool_id).unwrap(); //start sale set_block_number(11); @@ -2447,7 +2447,7 @@ fn buy_should_work_when_limit_is_set_above_account_balance() { let asset_in = KUSD; let asset_out = BSX; let pool_id = LBPPallet::get_pair_id(AssetPair { asset_in, asset_out }); - let pool_data = >::try_get(&pool_id).unwrap(); + let pool_data = >::try_get(pool_id).unwrap(); //start sale set_block_number(11); @@ -2575,7 +2575,7 @@ fn sell_should_work() { let asset_in = KUSD; let asset_out = BSX; let pool_id = LBPPallet::get_pair_id(AssetPair { asset_in, asset_out }); - let pool_data = >::try_get(&pool_id).unwrap(); + let pool_data = >::try_get(pool_id).unwrap(); //start sale set_block_number(11); diff --git a/pallets/otc/src/lib.rs b/pallets/otc/src/lib.rs index 2271c5977..d755a9d5c 100644 --- a/pallets/otc/src/lib.rs +++ b/pallets/otc/src/lib.rs @@ -318,7 +318,7 @@ pub mod pallet { order.asset_out.into(), amount_in, amount_out, - vec![(order.asset_out.into(), fee, T::FeeReceiver::get().into())], + vec![(order.asset_out.into(), fee, T::FeeReceiver::get())], None, ); @@ -364,7 +364,7 @@ pub mod pallet { order.asset_out.into(), order.amount_in, order.amount_out, - vec![(order.asset_out.into(), fee, T::FeeReceiver::get().into())], + vec![(order.asset_out.into(), fee, T::FeeReceiver::get())], None, ); diff --git a/pallets/otc/src/tests/fill_order.rs b/pallets/otc/src/tests/fill_order.rs index 098a4f8b4..6f9f693c0 100644 --- a/pallets/otc/src/tests/fill_order.rs +++ b/pallets/otc/src/tests/fill_order.rs @@ -88,7 +88,7 @@ fn complete_fill_order_should_work() { asset_out: HDX, amount_in: 20 * ONE, amount_out: 100 * ONE, - fees: vec![(HDX, ONE, ::FeeReceiver::get().into())], + fees: vec![(HDX, ONE, ::FeeReceiver::get())], event_id: None, } .into(), @@ -165,7 +165,7 @@ fn complete_fill_order_should_work_when_order_is_not_partially_fillable() { asset_out: HDX, amount_in: 20 * ONE, amount_out: 100 * ONE, - fees: vec![(HDX, ONE, ::FeeReceiver::get().into())], + fees: vec![(HDX, ONE, ::FeeReceiver::get())], event_id: None, } .into(), @@ -254,7 +254,7 @@ fn complete_fill_order_should_work_when_there_are_multiple_orders() { asset_out: HDX, amount_in: 20 * ONE, amount_out: 100 * ONE, - fees: vec![(HDX, ONE, ::FeeReceiver::get().into())], + fees: vec![(HDX, ONE, ::FeeReceiver::get())], event_id: None, } .into(), diff --git a/pallets/otc/src/tests/partial_fill_order.rs b/pallets/otc/src/tests/partial_fill_order.rs index 7f48a0370..f3a31e522 100644 --- a/pallets/otc/src/tests/partial_fill_order.rs +++ b/pallets/otc/src/tests/partial_fill_order.rs @@ -101,7 +101,7 @@ fn partial_fill_order_should_work_when_order_is_partially_fillable() { asset_out: order.asset_out, amount_in: 5 * ONE, amount_out: expected_amount_out, - fees: vec![(order.asset_out, fee, ::FeeReceiver::get().into())], + fees: vec![(order.asset_out, fee, ::FeeReceiver::get())], event_id: None, } .into(), From 2fe9d651b2e4266ea870ec16b2d98a1f171ff3c1 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Wed, 2 Oct 2024 16:54:37 +0200 Subject: [PATCH 020/142] check event in otc-settlements test --- pallets/otc-settlements/src/tests.rs | 30 +++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/pallets/otc-settlements/src/tests.rs b/pallets/otc-settlements/src/tests.rs index fde983164..fb3207010 100644 --- a/pallets/otc-settlements/src/tests.rs +++ b/pallets/otc-settlements/src/tests.rs @@ -292,11 +292,31 @@ fn existing_arb_opportunity_should_trigger_trade_when_correct_amount_can_be_foun assert!(Currencies::free_balance(HDX, &OtcSettlements::account_id()) == 0); assert!(Currencies::free_balance(DAI, &OtcSettlements::account_id()) == 0); - expect_last_events(vec![Event::Executed { - asset_id: HDX, - profit: 17_736_110_470_326, - } - .into()]); + expect_events(vec![ + Event::Executed { + asset_id: HDX, + profit: 17_736_110_470_326, + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: OtcSettlements::account_id(), + filler: otc.owner, + filler_type: pallet_amm_support::Filler::OTC, + operation: pallet_amm_support::TradeOperation::Sell, + asset_in: HDX, + asset_out: DAI, + amount_in: 2413749694825193, + amount_out: 4948186874391645, + fees: vec![ + ( + DAI, + 49481868743917, + ::FeeReceiver::get(), + ), + ], + event_id: None, + }.into() + ]); }); } From c24094e7bc709dc184eee5c0735ec94b2e8c2f4f Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Wed, 2 Oct 2024 16:54:49 +0200 Subject: [PATCH 021/142] formatting --- pallets/otc-settlements/src/tests.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/pallets/otc-settlements/src/tests.rs b/pallets/otc-settlements/src/tests.rs index fb3207010..6802ee408 100644 --- a/pallets/otc-settlements/src/tests.rs +++ b/pallets/otc-settlements/src/tests.rs @@ -297,25 +297,20 @@ fn existing_arb_opportunity_should_trigger_trade_when_correct_amount_can_be_foun asset_id: HDX, profit: 17_736_110_470_326, } - .into(), + .into(), pallet_amm_support::Event::Swapped { swapper: OtcSettlements::account_id(), filler: otc.owner, - filler_type: pallet_amm_support::Filler::OTC, - operation: pallet_amm_support::TradeOperation::Sell, + filler_type: pallet_amm_support::Filler::OTC, + operation: pallet_amm_support::TradeOperation::Sell, asset_in: HDX, asset_out: DAI, amount_in: 2413749694825193, amount_out: 4948186874391645, - fees: vec![ - ( - DAI, - 49481868743917, - ::FeeReceiver::get(), - ), - ], + fees: vec![(DAI, 49481868743917, ::FeeReceiver::get())], event_id: None, - }.into() + } + .into(), ]); }); } From 4bca2b61595be6eecbe728ab97434d4807be1f86 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Wed, 2 Oct 2024 17:23:00 +0200 Subject: [PATCH 022/142] add pallet-amm-support tests --- Cargo.lock | 2 + pallets/amm-support/Cargo.toml | 4 + pallets/amm-support/src/lib.rs | 3 + .../amm-support/src/tests/incremental_id.rs | 67 ++++++++++++ pallets/amm-support/src/tests/mock.rs | 100 ++++++++++++++++++ pallets/amm-support/src/tests/mod.rs | 2 + 6 files changed, 178 insertions(+) create mode 100644 pallets/amm-support/src/tests/incremental_id.rs create mode 100644 pallets/amm-support/src/tests/mock.rs create mode 100644 pallets/amm-support/src/tests/mod.rs diff --git a/Cargo.lock b/Cargo.lock index b9214a886..67960f501 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7479,6 +7479,8 @@ dependencies = [ "primitives", "scale-info", "sp-api", + "sp-core", + "sp-io", "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", ] diff --git a/pallets/amm-support/Cargo.toml b/pallets/amm-support/Cargo.toml index a851f8144..f03340955 100644 --- a/pallets/amm-support/Cargo.toml +++ b/pallets/amm-support/Cargo.toml @@ -20,6 +20,8 @@ primitives = { workspace = true } # Substrate dependencies sp-std = { workspace = true } sp-api = { workspace = true } +sp-core = { workspace = true } +sp-io = { workspace = true } frame-support = { workspace = true } frame-system = { workspace = true } @@ -32,6 +34,8 @@ std = [ "frame-system/std", "sp-std/std", "sp-api/std", + "sp-core/std", + "sp-io/std", "primitives/std", ] try-runtime = ["frame-support/try-runtime"] diff --git a/pallets/amm-support/src/lib.rs b/pallets/amm-support/src/lib.rs index a30430b3c..ae7bb9cf6 100644 --- a/pallets/amm-support/src/lib.rs +++ b/pallets/amm-support/src/lib.rs @@ -26,6 +26,9 @@ pub use hydradx_traits::{ }; pub use primitives::IncrementalId as IncrementalIdType; +#[cfg(test)] +mod tests; + // Re-export pallet items so that they can be accessed from the crate namespace. pub use pallet::*; diff --git a/pallets/amm-support/src/tests/incremental_id.rs b/pallets/amm-support/src/tests/incremental_id.rs new file mode 100644 index 000000000..b750b8fb7 --- /dev/null +++ b/pallets/amm-support/src/tests/incremental_id.rs @@ -0,0 +1,67 @@ +// This file is part of HydraDX-node. + +// Copyright (C) 2020-2022 Intergalactic, Limited (GIB). +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use hydradx_traits::router::{Filler, TradeOperation}; +use crate::tests::mock::*; +use crate::Event; + +#[test] +fn event_id_should_be_incremented() { + ExtBuilder::default().build().execute_with(|| { + + assert_eq!(AmmSupport::incremental_id(), 0); + assert_eq!(AmmSupport::next_incremental_id(), 0); + + assert_eq!(AmmSupport::incremental_id(), 1); + assert_eq!(AmmSupport::next_incremental_id(), 1); + + assert_eq!(AmmSupport::incremental_id(), 2); + assert_eq!(AmmSupport::next_incremental_id(), 2); + }); +} + +#[test] +fn event_should_be_deposited() { + ExtBuilder::default().build().execute_with(|| { + AmmSupport::deposit_trade_event( + ALICE, + BOB, + Filler::Omnipool, + TradeOperation::Sell, + HDX, + DOT, + 1_000_000, + 2_000_000, + vec![(HDX, 1_000, ALICE), (DOT, 2_000, BOB)], + Some(7), + ); + + expect_events(vec![Event::Swapped { + swapper: ALICE, + filler: BOB, + filler_type: Filler::Omnipool, + operation: TradeOperation::Sell, + asset_in: HDX, + asset_out: DOT, + amount_in: 1_000_000, + amount_out: 2_000_000, + fees: vec![(HDX, 1_000, ALICE), (DOT, 2_000, BOB)], + event_id: Some(7), + } + .into()]); + }); +} \ No newline at end of file diff --git a/pallets/amm-support/src/tests/mock.rs b/pallets/amm-support/src/tests/mock.rs new file mode 100644 index 000000000..0d859ec48 --- /dev/null +++ b/pallets/amm-support/src/tests/mock.rs @@ -0,0 +1,100 @@ +// This file is part of HydraDX. + +// Copyright (C) 2020-2022 Intergalactic, Limited (GIB). +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use crate as pallet_amm_support; + +use frame_support::{ + construct_runtime, + sp_runtime::{ + traits::{BlakeTwo256, IdentityLookup}, + BuildStorage, + }, + traits::{ConstU32, ConstU64, Everything}, +}; +use sp_core::H256; + +type Block = frame_system::mocking::MockBlock; + +pub type AccountId = u64; +pub type AssetId = u32; + +pub const HDX: AssetId = 0; +pub const DOT: AssetId = 1; + +pub const ALICE: AccountId = 1; +pub const BOB: AccountId = 2; + +construct_runtime!( + pub enum Test + { + System: frame_system, + AmmSupport: pallet_amm_support, + } +); + +impl crate::Config for Test { + type RuntimeEvent = RuntimeEvent; +} + +impl frame_system::Config for Test { + type BaseCallFilter = Everything; + type BlockWeights = (); + type BlockLength = (); + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; + type RuntimeTask = RuntimeTask; + type Nonce = u64; + type Block = Block; + type Hash = H256; + type Hashing = BlakeTwo256; + type AccountId = AccountId; + type Lookup = IdentityLookup; + type RuntimeEvent = RuntimeEvent; + type BlockHashCount = ConstU64<250>; + type DbWeight = (); + type Version = (); + type PalletInfo = PalletInfo; + type AccountData = (); + type OnNewAccount = (); + type OnKilledAccount = (); + type SystemWeightInfo = (); + type SS58Prefix = (); + type OnSetCode = (); + type MaxConsumers = ConstU32<16>; +} + +#[derive(Default)] +pub struct ExtBuilder { +} + +impl ExtBuilder { + pub fn build(self) -> sp_io::TestExternalities { + let t = frame_system::GenesisConfig::::default().build_storage().unwrap(); + + let mut r: sp_io::TestExternalities = t.into(); + + r.execute_with(|| { + System::set_block_number(1); + }); + + r + } +} + +pub fn expect_events(e: Vec) { + e.into_iter().for_each(frame_system::Pallet::::assert_has_event); +} diff --git a/pallets/amm-support/src/tests/mod.rs b/pallets/amm-support/src/tests/mod.rs new file mode 100644 index 000000000..9394fa916 --- /dev/null +++ b/pallets/amm-support/src/tests/mod.rs @@ -0,0 +1,2 @@ +pub mod mock; +mod incremental_id; From d38504eec7065a66abd60b8b88572662749b4c1f Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Wed, 2 Oct 2024 17:25:52 +0200 Subject: [PATCH 023/142] formatting --- .../amm-support/src/tests/incremental_id.rs | 75 +++++++++---------- pallets/amm-support/src/tests/mock.rs | 3 +- pallets/amm-support/src/tests/mod.rs | 2 +- 3 files changed, 39 insertions(+), 41 deletions(-) diff --git a/pallets/amm-support/src/tests/incremental_id.rs b/pallets/amm-support/src/tests/incremental_id.rs index b750b8fb7..0423dd06d 100644 --- a/pallets/amm-support/src/tests/incremental_id.rs +++ b/pallets/amm-support/src/tests/incremental_id.rs @@ -15,53 +15,52 @@ // See the License for the specific language governing permissions and // limitations under the License. -use hydradx_traits::router::{Filler, TradeOperation}; use crate::tests::mock::*; use crate::Event; +use hydradx_traits::router::{Filler, TradeOperation}; #[test] fn event_id_should_be_incremented() { - ExtBuilder::default().build().execute_with(|| { + ExtBuilder::default().build().execute_with(|| { + assert_eq!(AmmSupport::incremental_id(), 0); + assert_eq!(AmmSupport::next_incremental_id(), 0); - assert_eq!(AmmSupport::incremental_id(), 0); - assert_eq!(AmmSupport::next_incremental_id(), 0); - - assert_eq!(AmmSupport::incremental_id(), 1); - assert_eq!(AmmSupport::next_incremental_id(), 1); + assert_eq!(AmmSupport::incremental_id(), 1); + assert_eq!(AmmSupport::next_incremental_id(), 1); - assert_eq!(AmmSupport::incremental_id(), 2); - assert_eq!(AmmSupport::next_incremental_id(), 2); - }); + assert_eq!(AmmSupport::incremental_id(), 2); + assert_eq!(AmmSupport::next_incremental_id(), 2); + }); } #[test] fn event_should_be_deposited() { - ExtBuilder::default().build().execute_with(|| { - AmmSupport::deposit_trade_event( - ALICE, - BOB, - Filler::Omnipool, - TradeOperation::Sell, - HDX, - DOT, - 1_000_000, - 2_000_000, - vec![(HDX, 1_000, ALICE), (DOT, 2_000, BOB)], - Some(7), - ); + ExtBuilder::default().build().execute_with(|| { + AmmSupport::deposit_trade_event( + ALICE, + BOB, + Filler::Omnipool, + TradeOperation::Sell, + HDX, + DOT, + 1_000_000, + 2_000_000, + vec![(HDX, 1_000, ALICE), (DOT, 2_000, BOB)], + Some(7), + ); - expect_events(vec![Event::Swapped { - swapper: ALICE, - filler: BOB, - filler_type: Filler::Omnipool, - operation: TradeOperation::Sell, - asset_in: HDX, - asset_out: DOT, - amount_in: 1_000_000, - amount_out: 2_000_000, - fees: vec![(HDX, 1_000, ALICE), (DOT, 2_000, BOB)], - event_id: Some(7), - } - .into()]); - }); -} \ No newline at end of file + expect_events(vec![Event::Swapped { + swapper: ALICE, + filler: BOB, + filler_type: Filler::Omnipool, + operation: TradeOperation::Sell, + asset_in: HDX, + asset_out: DOT, + amount_in: 1_000_000, + amount_out: 2_000_000, + fees: vec![(HDX, 1_000, ALICE), (DOT, 2_000, BOB)], + event_id: Some(7), + } + .into()]); + }); +} diff --git a/pallets/amm-support/src/tests/mock.rs b/pallets/amm-support/src/tests/mock.rs index 0d859ec48..fb36ac1cc 100644 --- a/pallets/amm-support/src/tests/mock.rs +++ b/pallets/amm-support/src/tests/mock.rs @@ -78,8 +78,7 @@ impl frame_system::Config for Test { } #[derive(Default)] -pub struct ExtBuilder { -} +pub struct ExtBuilder {} impl ExtBuilder { pub fn build(self) -> sp_io::TestExternalities { diff --git a/pallets/amm-support/src/tests/mod.rs b/pallets/amm-support/src/tests/mod.rs index 9394fa916..73687e527 100644 --- a/pallets/amm-support/src/tests/mod.rs +++ b/pallets/amm-support/src/tests/mod.rs @@ -1,2 +1,2 @@ -pub mod mock; mod incremental_id; +pub mod mock; From 288705dda07687ac97c03ebe9d0e0ac5a0f6e4ad Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Wed, 2 Oct 2024 18:01:31 +0200 Subject: [PATCH 024/142] refactor incremental id computation --- pallets/amm-support/src/lib.rs | 20 +++++++++++++------ .../amm-support/src/tests/incremental_id.rs | 6 +++--- traits/src/lib.rs | 2 +- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/pallets/amm-support/src/lib.rs b/pallets/amm-support/src/lib.rs index ae7bb9cf6..018eefe91 100644 --- a/pallets/amm-support/src/lib.rs +++ b/pallets/amm-support/src/lib.rs @@ -20,6 +20,7 @@ type AssetId = u32; type Balance = u128; +use frame_support::sp_runtime::{ArithmeticError, DispatchError}; pub use hydradx_traits::{ router::{Filler, TradeOperation}, IncrementalIdProvider, @@ -37,7 +38,11 @@ pub mod pallet { use super::*; use frame_support::pallet_prelude::*; + /// The current storage version. + const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); + #[pallet::pallet] + #[pallet::storage_version(STORAGE_VERSION)] pub struct Pallet(_); #[pallet::config] @@ -46,7 +51,7 @@ pub mod pallet { } #[pallet::storage] - /// Incremental ID + /// Next available incremental ID #[pallet::getter(fn incremental_id)] pub(super) type IncrementalId = StorageValue<_, IncrementalIdType, ValueQuery>; @@ -76,10 +81,13 @@ pub mod pallet { } impl Pallet { - pub fn next_incremental_id() -> IncrementalIdType { - let next_incremental_id = Self::incremental_id(); - >::set(next_incremental_id + 1); // TODO: checked math - next_incremental_id + /// Returns next incremental ID and updates the storage. + pub fn next_incremental_id() -> Result { + IncrementalId::::try_mutate(|current_id| -> Result { + let inc_id = *current_id; + *current_id = current_id.checked_add(1).ok_or(ArithmeticError::Overflow)?; + Ok(inc_id) + }) } #[allow(clippy::too_many_arguments)] @@ -111,7 +119,7 @@ impl Pallet { } impl IncrementalIdProvider for Pallet { - fn next_id() -> IncrementalIdType { + fn next_id() -> Result { Self::next_incremental_id() } } diff --git a/pallets/amm-support/src/tests/incremental_id.rs b/pallets/amm-support/src/tests/incremental_id.rs index 0423dd06d..63cd1c766 100644 --- a/pallets/amm-support/src/tests/incremental_id.rs +++ b/pallets/amm-support/src/tests/incremental_id.rs @@ -23,13 +23,13 @@ use hydradx_traits::router::{Filler, TradeOperation}; fn event_id_should_be_incremented() { ExtBuilder::default().build().execute_with(|| { assert_eq!(AmmSupport::incremental_id(), 0); - assert_eq!(AmmSupport::next_incremental_id(), 0); + assert_eq!(AmmSupport::next_incremental_id().unwrap(), 0); assert_eq!(AmmSupport::incremental_id(), 1); - assert_eq!(AmmSupport::next_incremental_id(), 1); + assert_eq!(AmmSupport::next_incremental_id().unwrap(), 1); assert_eq!(AmmSupport::incremental_id(), 2); - assert_eq!(AmmSupport::next_incremental_id(), 2); + assert_eq!(AmmSupport::next_incremental_id().unwrap(), 2); }); } diff --git a/traits/src/lib.rs b/traits/src/lib.rs index 6666e6269..60f4d2942 100644 --- a/traits/src/lib.rs +++ b/traits/src/lib.rs @@ -305,5 +305,5 @@ pub trait AccountFeeCurrencyBalanceInCurrency { } pub trait IncrementalIdProvider { - fn next_id() -> IncrementalId; + fn next_id() -> Result; } From 5f79fbb383905187e559ada9504c207bb04cf815 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Wed, 2 Oct 2024 18:05:58 +0200 Subject: [PATCH 025/142] satisfy clippy --- pallets/route-executor/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pallets/route-executor/src/lib.rs b/pallets/route-executor/src/lib.rs index b7f31c6e3..5e8713ddb 100644 --- a/pallets/route-executor/src/lib.rs +++ b/pallets/route-executor/src/lib.rs @@ -260,7 +260,7 @@ pub mod pallet { ensure!(first_trade.amount_in <= max_amount_in, Error::::TradingLimitReached); let route_length = route.len(); - let next_event_id = T::BatchIdProvider::next_id(); + let next_event_id = T::BatchIdProvider::next_id().map_err(|_| ArithmeticError::Overflow)?; for (trade_index, (trade_amount, trade)) in trade_amounts.iter().rev().zip(route).enumerate() { Self::disable_ed_handling_for_insufficient_assets(route_length, trade_index, trade); let user_balance_of_asset_out_before_trade = @@ -493,7 +493,7 @@ impl Pallet { ); let route_length = route.len(); - let next_event_id = T::BatchIdProvider::next_id(); + let next_event_id = T::BatchIdProvider::next_id().map_err(|_| ArithmeticError::Overflow)?; for (trade_index, (trade_amount, trade)) in trade_amounts.iter().zip(route.clone()).enumerate() { Self::disable_ed_handling_for_insufficient_assets(route_length, trade_index, trade); From 682c88bd6ec98eddddbad0e188f5e071acadf278 Mon Sep 17 00:00:00 2001 From: dmoka Date: Mon, 4 Nov 2024 14:03:56 +0100 Subject: [PATCH 026/142] fix compilation error --- pallets/amm-support/src/lib.rs | 1 + pallets/otc/src/lib.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/pallets/amm-support/src/lib.rs b/pallets/amm-support/src/lib.rs index 018eefe91..6ccc9ad97 100644 --- a/pallets/amm-support/src/lib.rs +++ b/pallets/amm-support/src/lib.rs @@ -25,6 +25,7 @@ pub use hydradx_traits::{ router::{Filler, TradeOperation}, IncrementalIdProvider, }; +use sp_std::vec::Vec; pub use primitives::IncrementalId as IncrementalIdType; #[cfg(test)] diff --git a/pallets/otc/src/lib.rs b/pallets/otc/src/lib.rs index d755a9d5c..a53abc979 100644 --- a/pallets/otc/src/lib.rs +++ b/pallets/otc/src/lib.rs @@ -42,6 +42,7 @@ use orml_traits::{GetByKey, MultiCurrency, NamedMultiReservableCurrency}; use sp_core::U256; use sp_runtime::traits::{One, Zero}; use sp_runtime::Permill; +use sp_std::vec; #[cfg(test)] mod tests; From 1f8f7bd9c57566a81c2d3ae8118492cbc4a390b6 Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Mon, 4 Nov 2024 15:51:44 +0100 Subject: [PATCH 027/142] stack --- integration-tests/src/polkadot_test_net.rs | 6 +- integration-tests/src/referrals.rs | 30 +- integration-tests/src/router.rs | 423 ++++++++---------- pallets/amm-support/src/lib.rs | 92 +++- .../amm-support/src/tests/incremental_id.rs | 82 +++- pallets/amm-support/src/tests/mock.rs | 5 +- pallets/lbp/src/lib.rs | 26 +- pallets/omnipool/src/lib.rs | 61 +-- pallets/otc/src/lib.rs | 32 +- pallets/route-executor/src/lib.rs | 15 +- pallets/route-executor/src/tests/mock.rs | 1 + pallets/stableswap/src/lib.rs | 31 +- pallets/xyk/src/lib.rs | 28 +- runtime/hydradx/src/assets.rs | 1 + traits/src/router.rs | 54 ++- 15 files changed, 479 insertions(+), 408 deletions(-) diff --git a/integration-tests/src/polkadot_test_net.rs b/integration-tests/src/polkadot_test_net.rs index a7eb113ba..5298d3250 100644 --- a/integration-tests/src/polkadot_test_net.rs +++ b/integration-tests/src/polkadot_test_net.rs @@ -16,7 +16,11 @@ use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder; pub use frame_system::RawOrigin; use hex_literal::hex; use hydradx_runtime::{evm::WETH_ASSET_LOCATION, Referrals, RuntimeOrigin}; -pub use hydradx_traits::{evm::InspectEvmAccounts, registry::Mutate}; +pub use hydradx_traits::{ + evm::InspectEvmAccounts, + registry::Mutate, + router::{Filler, AssetType, TradeOperation, ExecutionType, Fee}, +}; use pallet_referrals::{FeeDistribution, Level}; pub use polkadot_primitives::v6::{BlockNumber, MAX_CODE_SIZE, MAX_POV_SIZE}; use polkadot_runtime_parachains::configuration::HostConfiguration; diff --git a/integration-tests/src/referrals.rs b/integration-tests/src/referrals.rs index 574bd3b6e..f3ed29978 100644 --- a/integration-tests/src/referrals.rs +++ b/integration-tests/src/referrals.rs @@ -360,17 +360,15 @@ fn buying_hdx_in_omnipool_should_transfer_correct_fee() { pallet_amm_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::Buy, - asset_in: DAI, - asset_out: HDX, - amount_in: 26_835_579_541_620_354, - amount_out: 1_000_000_000_000, + filler_type: Filler::Omnipool, + operation: TradeOperation::ExactOut, + inputs: vec![(AssetType::Fungible(DAI), 26_835_579_541_620_354)], + outputs: vec![(AssetType::Fungible(HDX), 1_000_000_000_000)], fees: vec![ - (HDX, 2_794_789_078, Omnipool::protocol_account()), - (LRNA, 604_873, Omnipool::protocol_account()), + Fee::new(HDX, 2_794_789_078, Omnipool::protocol_account()), + Fee::new(LRNA, 604_873, Omnipool::protocol_account()), ], - event_id: None, + operation_id: vec![], } .into(), ]); @@ -421,16 +419,14 @@ fn buying_with_hdx_in_omnipool_should_transfer_correct_fee() { swapper: BOB.into(), filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::Buy, - asset_in: HDX, - asset_out: DAI, - amount_in: 37_506_757_329_085, - amount_out: 1_000_000_000_000_000_000, + operation: pallet_amm_support::TradeOperation::ExactOut, + inputs: vec![(AssetType::Fungible(HDX), 37_506_757_329_085)], + outputs: vec![(AssetType::Fungible(DAI), 1_000_000_000_000_000_000)], fees: vec![ - (DAI, 2_644_977_450_514_458, Omnipool::protocol_account()), - (LRNA, 22_611_356, Omnipool::protocol_account()), + Fee::new(DAI, 2_644_977_450_514_458, Omnipool::protocol_account()), + Fee::new(LRNA, 22_611_356, Omnipool::protocol_account()), ], - event_id: None, + operation_id: vec![], } .into(), ]); diff --git a/integration-tests/src/router.rs b/integration-tests/src/router.rs index 2c20b0b52..a95dc1672 100644 --- a/integration-tests/src/router.rs +++ b/integration-tests/src/router.rs @@ -53,7 +53,7 @@ fn router_weights_should_be_non_zero() { mod router_different_pools_tests { use super::*; - use hydradx_traits::router::PoolType; + use hydradx_traits::router::{ExecutionType, PoolType}; #[test] fn route_should_fail_when_route_is_not_consistent() { @@ -157,32 +157,28 @@ mod router_different_pools_tests { swapper: BOB.into(), filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA)), filler_type: pallet_amm_support::Filler::LBP, - operation: pallet_amm_support::TradeOperation::Sell, - asset_in: DAI, - asset_out: LRNA, - amount_in: 9980000000, - amount_out: 5640664064, - fees: vec![( - DAI, - 20000000, - LBP::pool_data(LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA))) + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(DAI), 9980000000)], + outputs: vec![(AssetType::Fungible(LRNA), 5640664064)], + fees: vec![ + Fee::new(DAI, 20000000, LBP::pool_data(LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA))) .unwrap() - .fee_collector, - )], - event_id: Some(0), + .fee_collector), + ], + operation_id: vec![ExecutionType::Router(0)], } .into(), pallet_amm_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::Sell, - asset_in: LRNA, - asset_out: HDX, - amount_in: 5640664064, - amount_out: 4682924837974, - fees: vec![(HDX, 11736653730, Omnipool::protocol_account())], - event_id: Some(0), + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(LRNA), 5640664064)], + outputs: vec![(AssetType::Fungible(HDX), 4682924837974)], + fees: vec![ + Fee::new(HDX, 11736653730, Omnipool::protocol_account()), + ], + operation_id: vec![ExecutionType::Router(0)], } .into(), pallet_amm_support::Event::Swapped { @@ -191,21 +187,20 @@ mod router_different_pools_tests { asset_in: HDX, asset_out: DOT, }), - filler_type: pallet_amm_support::Filler::XYK, - operation: pallet_amm_support::TradeOperation::Sell, - asset_in: HDX, - asset_out: DOT, - amount_in: 4682924837974, - amount_out: 2230008413831, - fees: vec![( - DOT, - 6710155707, - XYK::get_pair_id(pallet_xyk::types::AssetPair { + filler_type: pallet_amm_support::Filler::XYK(XYK::share_token(XYK::get_pair_id(pallet_xyk::types::AssetPair { + asset_in: HDX, + asset_out: DOT, + }))), + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(HDX), 4682924837974)], + outputs: vec![(AssetType::Fungible(DOT), 2230008413831)], + fees: vec![ + Fee::new(DOT, 6710155707, XYK::get_pair_id(pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: DOT, - }), - )], - event_id: Some(0), + })), + ], + operation_id: vec![ExecutionType::Router(0)], } .into(), pallet_route_executor::Event::Executed { @@ -280,20 +275,16 @@ mod router_different_pools_tests { pallet_amm_support::Event::Swapped { swapper: BOB.into(), filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX)), - filler_type: pallet_amm_support::Filler::LBP, - operation: pallet_amm_support::TradeOperation::Sell, - asset_in: DAI, - asset_out: HDX, - amount_in: 9980000000, - amount_out: 5640664064, - fees: vec![( - DAI, - 20000000, - LBP::pool_data(LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX))) + filler_type: Filler::LBP, + operation: TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(DAI), 9980000000)], + outputs: vec![(AssetType::Fungible(HDX), 5640664064)], + fees: vec![ + Fee::new(DAI, 20000000, LBP::pool_data(LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX))) .unwrap() - .fee_collector, - )], - event_id: Some(0), + .fee_collector), + ], + operation_id: vec![ExecutionType::Router(0)], } .into(), pallet_amm_support::Event::Swapped { @@ -302,21 +293,20 @@ mod router_different_pools_tests { asset_in: HDX, asset_out: stable_asset_1, }), - filler_type: pallet_amm_support::Filler::XYK, - operation: pallet_amm_support::TradeOperation::Sell, + filler_type: pallet_amm_support::Filler::XYK(XYK::share_token(XYK::get_pair_id(pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: stable_asset_1, - amount_in: 5640664064, - amount_out: 2811712439, - fees: vec![( - stable_asset_1, - 8460516, - XYK::get_pair_id(pallet_xyk::types::AssetPair { + }))), + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(HDX), 5640664064)], + outputs: vec![(AssetType::Fungible(stable_asset_1), 2811712439)], + fees: vec![ + Fee::new(stable_asset_1, 8460516, XYK::get_pair_id(pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: stable_asset_1, - }), - )], - event_id: Some(0), + })), + ], + operation_id: vec![ExecutionType::Router(0)], } .into(), pallet_amm_support::Event::Swapped { @@ -325,21 +315,17 @@ mod router_different_pools_tests { &stable_pool_id, Some(pallet_stableswap::POOL_IDENTIFIER), ), - filler_type: pallet_amm_support::Filler::Stableswap, - operation: pallet_amm_support::TradeOperation::Sell, - asset_in: stable_asset_1, - asset_out: stable_asset_2, - amount_in: 2811712439, - amount_out: 2783595233, - fees: vec![( - stable_asset_2, - 28117123, - ::ShareAccountId::from_assets( + filler_type: pallet_amm_support::Filler::Stableswap(stable_pool_id), + operation: TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(stable_asset_1), 2811712439)], + outputs: vec![(AssetType::Fungible(stable_asset_2), 2783595233)], + fees: vec![ + Fee::new(stable_asset_2, 28117123, ::ShareAccountId::from_assets( &stable_pool_id, Some(pallet_stableswap::POOL_IDENTIFIER), - ), - )], - event_id: Some(0), + )), + ], + operation_id: vec![ExecutionType::Router(0)], } .into(), pallet_route_executor::Event::Executed { @@ -412,32 +398,28 @@ mod router_different_pools_tests { swapper: BOB.into(), filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA)), filler_type: pallet_amm_support::Filler::LBP, - operation: pallet_amm_support::TradeOperation::Buy, - asset_in: DAI, - asset_out: LRNA, - amount_in: 4362157193, - amount_out: 2465566245, - fees: vec![( - DAI, - 8741796, - LBP::pool_data(LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA))) + operation: pallet_amm_support::TradeOperation::ExactOut, + inputs: vec![(AssetType::Fungible(DAI), 4362157193)], + outputs: vec![(AssetType::Fungible(LRNA), 2465566245)], + fees: vec![ + Fee::new(DAI, 8741796, LBP::pool_data(LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA))) .unwrap() - .fee_collector, - )], - event_id: Some(0), + .fee_collector), + ], + operation_id: vec![ExecutionType::Router(0)], } .into(), pallet_amm_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::Buy, - asset_in: LRNA, - asset_out: HDX, - amount_in: 2465566245, - amount_out: 2046938775509, - fees: vec![(HDX, 5130172370, Omnipool::protocol_account())], - event_id: Some(0), + operation: pallet_amm_support::TradeOperation::ExactOut, + inputs: vec![(AssetType::Fungible(LRNA), 2465566245)], + outputs: vec![(AssetType::Fungible(HDX), 2046938775509)], + fees: vec![ + Fee::new(HDX, 5130172370, Omnipool::protocol_account()), + ], + operation_id: vec![ExecutionType::Router(0)], } .into(), pallet_amm_support::Event::Swapped { @@ -446,21 +428,20 @@ mod router_different_pools_tests { asset_in: HDX, asset_out: DOT, }), - filler_type: pallet_amm_support::Filler::XYK, - operation: pallet_amm_support::TradeOperation::Buy, - asset_in: HDX, - asset_out: DOT, - amount_in: 1000000000000, - amount_out: 2040816326531, - fees: vec![( - HDX, - 6122448978, - XYK::get_pair_id(pallet_xyk::types::AssetPair { + filler_type: pallet_amm_support::Filler::XYK(XYK::share_token(XYK::get_pair_id(pallet_xyk::types::AssetPair { + asset_in: HDX, + asset_out: DOT, + }))), + operation: pallet_amm_support::TradeOperation::ExactOut, + inputs: vec![(AssetType::Fungible(HDX), 1000000000000)], + outputs: vec![(AssetType::Fungible(DOT), 2040816326531)], + fees: vec![ + Fee::new(HDX, 6122448978, XYK::get_pair_id(pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: DOT, - }), - )], - event_id: Some(0), + })), + ], + operation_id: vec![ExecutionType::Router(0)], } .into(), pallet_route_executor::Event::Executed { @@ -536,19 +517,15 @@ mod router_different_pools_tests { swapper: BOB.into(), filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX)), filler_type: pallet_amm_support::Filler::LBP, - operation: pallet_amm_support::TradeOperation::Buy, - asset_in: DAI, - asset_out: HDX, - amount_in: 3746042043754, - amount_out: 2067851065323, - fees: vec![( - DAI, - 7507098284, - LBP::pool_data(LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX))) + operation: pallet_amm_support::TradeOperation::ExactOut, + inputs: vec![(AssetType::Fungible(DAI), 3746042043754)], + outputs: vec![(AssetType::Fungible(HDX), 2067851065323)], + fees: vec![ + Fee::new(DAI, 7507098284, LBP::pool_data(LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX))) .unwrap() - .fee_collector, - )], - event_id: Some(0), + .fee_collector), + ], + operation_id: vec![ExecutionType::Router(0)], } .into(), pallet_amm_support::Event::Swapped { @@ -557,21 +534,20 @@ mod router_different_pools_tests { asset_in: HDX, asset_out: stable_asset_1, }), - filler_type: pallet_amm_support::Filler::XYK, - operation: pallet_amm_support::TradeOperation::Buy, + filler_type: pallet_amm_support::Filler::XYK(XYK::share_token(XYK::get_pair_id(pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: stable_asset_1, - amount_in: 1010010000114, - amount_out: 2061666067122, - fees: vec![( - HDX, - 6184998201, - XYK::get_pair_id(pallet_xyk::types::AssetPair { + }))), + operation: pallet_amm_support::TradeOperation::ExactOut, + inputs: vec![(AssetType::Fungible(HDX), 1010010000114)], + outputs: vec![(AssetType::Fungible(stable_asset_1), 2061666067122)], + fees: vec![ + Fee::new(HDX, 6184998201, XYK::get_pair_id(pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: stable_asset_1, - }), - )], - event_id: Some(0), + })), + ], + operation_id: vec![ExecutionType::Router(0)], } .into(), pallet_amm_support::Event::Swapped { @@ -580,21 +556,17 @@ mod router_different_pools_tests { &stable_pool_id, Some(pallet_stableswap::POOL_IDENTIFIER), ), - filler_type: pallet_amm_support::Filler::Stableswap, - operation: pallet_amm_support::TradeOperation::Buy, - asset_in: stable_asset_1, - asset_out: stable_asset_2, - amount_in: 1010010000114, - amount_out: 1000000000000, - fees: vec![( - stable_asset_1, - 10000099012, - ::ShareAccountId::from_assets( + filler_type: pallet_amm_support::Filler::Stableswap(stable_pool_id), + operation: pallet_amm_support::TradeOperation::ExactOut, + inputs: vec![(AssetType::Fungible(stable_asset_1), 1010010000114)], + outputs: vec![(AssetType::Fungible(stable_asset_2), 1000000000000)], + fees: vec![ + Fee::new(stable_asset_1, 10000099012, ::ShareAccountId::from_assets( &stable_pool_id, Some(pallet_stableswap::POOL_IDENTIFIER), - ), - )], - event_id: Some(0), + )), + ], + operation_id: vec![ExecutionType::Router(0)], } .into(), pallet_route_executor::Event::Executed { @@ -664,21 +636,20 @@ mod router_different_pools_tests { asset_in: HDX, asset_out: DOT, }), - filler_type: pallet_amm_support::Filler::XYK, - operation: pallet_amm_support::TradeOperation::Sell, - asset_in: HDX, - asset_out: DOT, - amount_in: 10000000000, - amount_out: 4984501549, - fees: vec![( - DOT, - 14998500, - XYK::get_pair_id(pallet_xyk::types::AssetPair { + filler_type: pallet_amm_support::Filler::XYK(XYK::share_token(XYK::get_pair_id(pallet_xyk::types::AssetPair { + asset_in: HDX, + asset_out: DOT, + }))), + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(HDX), 10000000000)], + outputs: vec![(AssetType::Fungible(DOT), 4984501549)], + fees: vec![ + Fee::new(DOT, 14998500, XYK::get_pair_id(pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: DOT, - }), - )], - event_id: Some(0), + })), + ], + operation_id: vec![ExecutionType::Router(0)], } .into(), pallet_amm_support::Event::Swapped { @@ -687,21 +658,20 @@ mod router_different_pools_tests { asset_in: HDX, asset_out: DOT, }), - filler_type: pallet_amm_support::Filler::XYK, - operation: pallet_amm_support::TradeOperation::Buy, - asset_in: HDX, - asset_out: DOT, - amount_in: 10000000000, - amount_out: 20007996198, - fees: vec![( - HDX, - 60023988, - XYK::get_pair_id(pallet_xyk::types::AssetPair { + filler_type: pallet_amm_support::Filler::XYK(XYK::share_token(XYK::get_pair_id(pallet_xyk::types::AssetPair { + asset_in: HDX, + asset_out: DOT, + }))), + operation: pallet_amm_support::TradeOperation::ExactOut, + inputs: vec![(AssetType::Fungible(HDX), 10000000000)], + outputs: vec![(AssetType::Fungible(DOT), 20007996198)], + fees: vec![ + Fee::new(HDX, 60023988, XYK::get_pair_id(pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: DOT, - }), - )], - event_id: Some(1), + })), + ], + operation_id: vec![ExecutionType::Router(1)], } .into(), pallet_amm_support::Event::Swapped { @@ -710,21 +680,20 @@ mod router_different_pools_tests { asset_in: HDX, asset_out: DOT, }), - filler_type: pallet_amm_support::Filler::XYK, - operation: pallet_amm_support::TradeOperation::Sell, - asset_in: HDX, - asset_out: DOT, - amount_in: 10000000000, - amount_out: 4981510054, - fees: vec![( - DOT, - 14989497, - XYK::get_pair_id(pallet_xyk::types::AssetPair { - asset_in: HDX, - asset_out: DOT, - }), - )], - event_id: Some(2), + filler_type: pallet_amm_support::Filler::XYK(XYK::share_token(XYK::get_pair_id(pallet_xyk::types::AssetPair { + asset_in: HDX, + asset_out: DOT, + }))), + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(HDX), 10000000000)], + outputs: vec![(AssetType::Fungible(DOT), 4981510054)], + fees: vec![ + Fee::new(DOT, 14989497, XYK::get_pair_id(pallet_xyk::types::AssetPair { + asset_in: HDX, + asset_out: DOT, + })), + ], + operation_id: vec![ExecutionType::Router(2)], } .into(), ]); @@ -2393,16 +2362,14 @@ mod omnipool_router_tests { swapper: BOB.into(), filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::Sell, - asset_in: HDX, - asset_out: DAI, - amount_in: amount_to_sell, - amount_out, + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(HDX), amount_to_sell)], + outputs: vec![(AssetType::Fungible(DAI), amount_out)], fees: vec![ - (DAI, 667155563986401, Omnipool::protocol_account()), - (LRNA, 6007435, Omnipool::protocol_account()), + Fee::new(DAI, 667155563986401, Omnipool::protocol_account()), + Fee::new(LRNA, 6007435, Omnipool::protocol_account()), ], - event_id: Some(0), + operation_id: vec![ExecutionType::Router(0)], } .into(), pallet_route_executor::Event::Executed { @@ -2454,16 +2421,14 @@ mod omnipool_router_tests { swapper: BOB.into(), filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::Sell, - asset_in: HDX, - asset_out: DAI, - amount_in: amount_to_sell, - amount_out, + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(HDX), amount_to_sell)], + outputs: vec![(AssetType::Fungible(DAI), amount_out)], fees: vec![ - (DAI, 667155563986401, Omnipool::protocol_account()), - (LRNA, 6007435, Omnipool::protocol_account()), + Fee::new(DAI, 667155563986401, Omnipool::protocol_account()), + Fee::new(LRNA, 6007435, Omnipool::protocol_account()), ], - event_id: None, + operation_id: vec![], } .into(), ]); @@ -2616,16 +2581,14 @@ mod omnipool_router_tests { swapper: BOB.into(), filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::Buy, - asset_in: HDX, - asset_out: DAI, - amount_in, - amount_out: amount_to_buy, + operation: pallet_amm_support::TradeOperation::ExactOut, + inputs: vec![(AssetType::Fungible(HDX), amount_in)], + outputs: vec![(AssetType::Fungible(DAI), amount_to_buy)], fees: vec![ - (DAI, 2506265665, Omnipool::protocol_account()), - (LRNA, 22, Omnipool::protocol_account()), + Fee::new(DAI, 2506265665, Omnipool::protocol_account()), + Fee::new(LRNA, 22, Omnipool::protocol_account()), ], - event_id: Some(0), + operation_id: vec![ExecutionType::Router(0)], } .into(), pallet_route_executor::Event::Executed { @@ -2677,16 +2640,14 @@ mod omnipool_router_tests { swapper: BOB.into(), filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::Buy, - asset_in: HDX, - asset_out: DAI, - amount_in, - amount_out: amount_to_buy, + operation: pallet_amm_support::TradeOperation::ExactOut, + inputs: vec![(AssetType::Fungible(HDX), amount_in)], + outputs: vec![(AssetType::Fungible(DAI), amount_to_buy)], fees: vec![ - (DAI, 2_506_265_665, Omnipool::protocol_account()), - (LRNA, 22, Omnipool::protocol_account()), + Fee::new(DAI, 2_506_265_665, Omnipool::protocol_account()), + Fee::new(LRNA, 22, Omnipool::protocol_account()), ], - event_id: None, + operation_id: vec![], } .into(), ]); @@ -2966,19 +2927,15 @@ mod lbp_router_tests { swapper: BOB.into(), filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX)), filler_type: pallet_amm_support::Filler::LBP, - operation: pallet_amm_support::TradeOperation::Sell, - asset_in: HDX, - asset_out: DAI, - amount_in: amount_to_sell - fee, - amount_out: received_amount_out, - fees: vec![( - HDX, - fee, - LBP::pool_data(LBP::get_pair_id(pallet_lbp::types::AssetPair::new(HDX, DAI))) + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(HDX), amount_to_sell - fee)], + outputs: vec![(AssetType::Fungible(DAI), received_amount_out)], + fees: vec![ + Fee::new(HDX, fee, LBP::pool_data(LBP::get_pair_id(pallet_lbp::types::AssetPair::new(HDX, DAI))) .unwrap() - .fee_collector, - )], - event_id: Some(0), + .fee_collector), + ], + operation_id: vec![ExecutionType::Router(0)], } .into(), pallet_route_executor::Event::Executed { @@ -3024,19 +2981,15 @@ mod lbp_router_tests { swapper: BOB.into(), filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX)), filler_type: pallet_amm_support::Filler::LBP, - operation: pallet_amm_support::TradeOperation::Sell, - asset_in: HDX, - asset_out: DAI, - amount_in: 9_980_000_000_000, - amount_out: received_amount_out, - fees: vec![( - HDX, - 20_000_000_000, - LBP::pool_data(LBP::get_pair_id(pallet_lbp::types::AssetPair::new(HDX, DAI))) + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(HDX), 9_980_000_000_000)], + outputs: vec![(AssetType::Fungible(DAI), received_amount_out)], + fees: vec![ + Fee::new(HDX, 20_000_000_000, LBP::pool_data(LBP::get_pair_id(pallet_lbp::types::AssetPair::new(HDX, DAI))) .unwrap() - .fee_collector, - )], - event_id: None, + .fee_collector), + ], + operation_id: vec![], } .into(), ]); diff --git a/pallets/amm-support/src/lib.rs b/pallets/amm-support/src/lib.rs index 6ccc9ad97..e6107079b 100644 --- a/pallets/amm-support/src/lib.rs +++ b/pallets/amm-support/src/lib.rs @@ -20,13 +20,18 @@ type AssetId = u32; type Balance = u128; -use frame_support::sp_runtime::{ArithmeticError, DispatchError}; +use codec::{Decode, Encode, MaxEncodedLen}; +use scale_info::TypeInfo; +use frame_support::sp_runtime::{ArithmeticError, BoundedVec, DispatchError, DispatchResult}; +use frame_support::sp_runtime::app_crypto::sp_core; pub use hydradx_traits::{ - router::{Filler, TradeOperation}, + router::{AssetType, ExecutionType, ExecutionTypeStack, Fee, Filler, TradeOperation, OtcOrderId}, IncrementalIdProvider, }; use sp_std::vec::Vec; +use sp_core::{ConstU32, RuntimeDebug}; pub use primitives::IncrementalId as IncrementalIdType; +use primitives::ItemId as NftId; #[cfg(test)] mod tests; @@ -34,6 +39,28 @@ mod tests; // Re-export pallet items so that they can be accessed from the crate namespace. pub use pallet::*; +pub const MAX_STACK_SIZE: u32 = 10; + +#[derive(RuntimeDebug, Encode, Decode, Default, Clone, PartialEq, Eq, TypeInfo, MaxEncodedLen)] +pub struct ExecutionIdStack(BoundedVec, ConstU32>); +impl ExecutionIdStack { + fn push(& mut self, execution_type: ExecutionType) -> Result<(), ()> { + self.0.try_push(execution_type).map_err(|_| ()) + } + + fn pop(& mut self) -> Result, ()> { + self.0.pop().ok_or(()) + } + + fn get(self) -> Vec> { + self.0.into_inner() + } + + fn is_empty(&self) -> bool { + self.0.is_empty() + } +} + #[frame_support::pallet] pub mod pallet { use super::*; @@ -56,9 +83,19 @@ pub mod pallet { #[pallet::getter(fn incremental_id)] pub(super) type IncrementalId = StorageValue<_, IncrementalIdType, ValueQuery>; + // TODO: + #[pallet::storage] + /// Next available incremental ID + #[pallet::getter(fn id_stack)] + pub(super) type IdStack = StorageValue<_, ExecutionIdStack, ValueQuery>; + #[pallet::error] - pub enum Error {} + pub enum Error { + MaxStackSizeReached, + EmptyStack, + } + // on initialize - clear operation_id stack if not empty #[pallet::event] #[pallet::generate_deposit(pub(crate) fn deposit_event)] pub enum Event { @@ -66,14 +103,12 @@ pub mod pallet { Swapped { swapper: T::AccountId, filler: T::AccountId, - filler_type: Filler, + filler_type: Filler, operation: TradeOperation, - asset_in: AssetId, - asset_out: AssetId, - amount_in: Balance, - amount_out: Balance, - fees: Vec<(AssetId, Balance, T::AccountId)>, // (asset, fee amount, fee recipient) - event_id: Option, + inputs: Vec<(AssetType, Balance)>, + outputs: Vec<(AssetType, Balance)>, + fees: Vec>, + operation_id: Vec>, }, } @@ -95,30 +130,43 @@ impl Pallet { pub fn deposit_trade_event( swapper: T::AccountId, filler: T::AccountId, - filler_type: Filler, + filler_type: Filler, operation: TradeOperation, - asset_in: AssetId, - asset_out: AssetId, - amount_in: Balance, - amount_out: Balance, - fees: Vec<(AssetId, Balance, T::AccountId)>, - event_id: Option, + inputs: Vec<(AssetType, Balance)>, + outputs: Vec<(AssetType, Balance)>, + fees: Vec>, ) { Self::deposit_event(Event::::Swapped { swapper, filler, filler_type, operation, - asset_in, - asset_out, - amount_in, - amount_out, + inputs, + outputs, fees, - event_id, + operation_id: >::get(), }); } } +impl ExecutionTypeStack for Pallet { + fn push(execution_type: ExecutionType) -> DispatchResult { + IdStack::::try_mutate(|stack| -> DispatchResult { + stack.push(execution_type).map_err(|_| Error::::MaxStackSizeReached.into()) + }) + } + + fn pop() -> Result, DispatchError> { + IdStack::::try_mutate(|stack| -> Result, DispatchError> { + stack.pop().map_err(|_| Error::::EmptyStack.into()) + } + ) + } + + fn get() -> Vec> { + IdStack::::get().get() + } +} impl IncrementalIdProvider for Pallet { fn next_id() -> Result { Self::next_incremental_id() diff --git a/pallets/amm-support/src/tests/incremental_id.rs b/pallets/amm-support/src/tests/incremental_id.rs index 63cd1c766..2395920dd 100644 --- a/pallets/amm-support/src/tests/incremental_id.rs +++ b/pallets/amm-support/src/tests/incremental_id.rs @@ -17,7 +17,7 @@ use crate::tests::mock::*; use crate::Event; -use hydradx_traits::router::{Filler, TradeOperation}; +use hydradx_traits::router::{AssetType, ExecutionType, Filler, TradeOperation}; #[test] fn event_id_should_be_incremented() { @@ -33,6 +33,63 @@ fn event_id_should_be_incremented() { }); } +#[test] +fn stack_should_be_populated_when_pushed() { + ExtBuilder::default().build().execute_with(|| { + assert_ok!(AmmSupport::push(ExecutionType::Router(1))); + assert_eq!(AmmSupport::get(), vec![ExecutionType::Router(1)]); + assert_eq!(AmmSupport::id_stack().0.into_inner(), vec![ExecutionType::Router(1)]); + + assert_ok!(AmmSupport::push(ExecutionType::Router(2))); + assert_eq!(AmmSupport::get(), vec![ExecutionType::Router(1), ExecutionType::Router(2)]); + assert_eq!(AmmSupport::id_stack().0.into_inner(), vec![ExecutionType::Router(1), ExecutionType::Router(2)]); + + assert_ok!(AmmSupport::push(ExecutionType::ICE(3))); + assert_eq!(AmmSupport::get(), vec![ExecutionType::Router(1), ExecutionType::Router(2), ExecutionType::ICE(3)]); + assert_eq!(AmmSupport::id_stack().0.into_inner(), vec![ExecutionType::Router(1), ExecutionType::Router(2), ExecutionType::ICE(3)]); + }); +} + +#[test] +fn stack_should_not_panic_when_full() { + ExtBuilder::default().build().execute_with(|| { + for id in 0..MAX_STACK_SIZE { + assert_ok!(AmmSupport::push(ExecutionType::Router(id))); + } + + assert_err!( + AmmSupport::push(ExecutionType::Router(MAX_STACK_SIZE)), + Error::::MaxStackSizeReached + ); + }); +} + +#[test] +fn stack_should_be_reduced_when_poped() { + ExtBuilder::default().build().execute_with(|| { + assert_ok!(AmmSupport::push(ExecutionType::Router(1))); + assert_ok!(AmmSupport::push(ExecutionType::Router(2))); + assert_ok!(AmmSupport::push(ExecutionType::ICE(3))); + + assert_ok!(AmmSupport::pop(), ExecutionType::ICE(3)); + assert_eq!(AmmSupport::get(), vec![ExecutionType::Router(1), ExecutionType::Router(2)]); + assert_eq!(AmmSupport::id_stack().0.into_inner(), vec![ExecutionType::Router(1), ExecutionType::Router(2)]); + + assert_ok!(AmmSupport::push(ExecutionType::ICE(3))); + assert_eq!(AmmSupport::get(), vec![ExecutionType::Router(1), ExecutionType::Router(2), ExecutionType::ICE(3)]); + assert_eq!(AmmSupport::id_stack().0.into_inner(), vec![ExecutionType::Router(1), ExecutionType::Router(2), ExecutionType::ICE(3)]); + }); +} + +#[test] +fn pop_from_empty_stack_should_not_panic() { + ExtBuilder::default().build().execute_with(|| { + assert_err!(AmmSupport::pop(), + Error::::EmptyStack + ); + }); +} + #[test] fn event_should_be_deposited() { ExtBuilder::default().build().execute_with(|| { @@ -40,26 +97,21 @@ fn event_should_be_deposited() { ALICE, BOB, Filler::Omnipool, - TradeOperation::Sell, - HDX, - DOT, - 1_000_000, - 2_000_000, - vec![(HDX, 1_000, ALICE), (DOT, 2_000, BOB)], - Some(7), + TradeOperation::ExactIn, + vec![(AssetType::Fungible(HDX), 1_000_000)], + vec![(AssetType::Fungible(DOT), 2_000_000)], + vec![Fee::new(HDX, 1_000, ALICE), Fee::new(DOT, 2_000, BOB)], ); expect_events(vec![Event::Swapped { swapper: ALICE, filler: BOB, filler_type: Filler::Omnipool, - operation: TradeOperation::Sell, - asset_in: HDX, - asset_out: DOT, - amount_in: 1_000_000, - amount_out: 2_000_000, - fees: vec![(HDX, 1_000, ALICE), (DOT, 2_000, BOB)], - event_id: Some(7), + operation: TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(HDX), 1_000_000)], + outputs: vec![(AssetType::Fungible(DOT), 2_000_000)], + fees: vec![Fee::new(HDX, 1_000, ALICE), Fee::new(DOT, 2_000, BOB)], + operation_id: vec![], } .into()]); }); diff --git a/pallets/amm-support/src/tests/mock.rs b/pallets/amm-support/src/tests/mock.rs index fb36ac1cc..468c21151 100644 --- a/pallets/amm-support/src/tests/mock.rs +++ b/pallets/amm-support/src/tests/mock.rs @@ -16,9 +16,10 @@ // limitations under the License. use crate as pallet_amm_support; +pub use crate::*; -use frame_support::{ - construct_runtime, +pub use frame_support::{ + assert_ok, assert_err, construct_runtime, sp_runtime::{ traits::{BlakeTwo256, IdentityLookup}, BuildStorage, diff --git a/pallets/lbp/src/lib.rs b/pallets/lbp/src/lib.rs index fbb60007a..310b9f4df 100644 --- a/pallets/lbp/src/lib.rs +++ b/pallets/lbp/src/lib.rs @@ -36,7 +36,9 @@ use frame_support::{ use frame_system::ensure_signed; use frame_system::pallet_prelude::BlockNumberFor; use hydra_dx_math::types::LBPWeight; -use hydradx_traits::{AMMTransfer, AssetPairAccountIdFor, CanCreatePool, LockedBalance, AMM}; +use hydradx_traits::{AMMTransfer, AssetPairAccountIdFor, CanCreatePool, LockedBalance, AMM, + router::{AssetType, Fee}, +}; use orml_traits::{MultiCurrency, MultiCurrencyExtended, MultiLockableCurrency}; use pallet_amm_support::IncrementalIdType; @@ -1134,13 +1136,10 @@ impl AMM, IncrementalI transfer.origin.clone(), pool_account, pallet_amm_support::Filler::LBP, - pallet_amm_support::TradeOperation::Sell, - transfer.assets.asset_in, - transfer.assets.asset_out, - transfer.amount, - transfer.amount_b, - vec![(transfer.fee.0, transfer.fee.1, pool.fee_collector)], - event_id, + pallet_amm_support::TradeOperation::ExactIn, + vec![(AssetType::Fungible(transfer.assets.asset_in), transfer.amount)], + vec![(AssetType::Fungible(transfer.assets.asset_out), transfer.amount_b)], + vec![Fee{ asset: transfer.fee.0, amount: transfer.fee.1, recipient: pool.fee_collector}], ); Ok(()) @@ -1289,13 +1288,10 @@ impl AMM, IncrementalI transfer.origin.clone(), pool_account, pallet_amm_support::Filler::LBP, - pallet_amm_support::TradeOperation::Buy, - transfer.assets.asset_in, - transfer.assets.asset_out, - transfer.amount, - transfer.amount_b, - vec![(transfer.fee.0, transfer.fee.1, pool.fee_collector)], - event_id, + pallet_amm_support::TradeOperation::ExactOut, + vec![(AssetType::Fungible(transfer.assets.asset_in), transfer.amount)], + vec![(AssetType::Fungible(transfer.assets.asset_out), transfer.amount_b)], + vec![Fee{ asset: transfer.fee.0, amount: transfer.fee.1, recipient: pool.fee_collector}], ); Ok(()) diff --git a/pallets/omnipool/src/lib.rs b/pallets/omnipool/src/lib.rs index 2295ef166..e634c5c2e 100644 --- a/pallets/omnipool/src/lib.rs +++ b/pallets/omnipool/src/lib.rs @@ -97,6 +97,7 @@ use sp_std::prelude::*; use frame_support::traits::tokens::nonfungibles::{Create, Inspect, Mutate}; use hydra_dx_math::omnipool::types::{AssetStateChange, BalanceUpdate, I129}; use hydradx_traits::registry::Inspect as RegistryInspect; +use hydradx_traits::router::{AssetType, Fee}; use orml_traits::{GetByKey, MultiCurrency}; #[cfg(feature = "try-runtime")] use primitive_types::U256; @@ -1675,20 +1676,13 @@ impl Pallet { who.clone(), Self::protocol_account(), pallet_amm_support::Filler::Omnipool, - pallet_amm_support::TradeOperation::Sell, - asset_in.into(), - asset_out.into(), - amount, - *state_changes.asset_out.delta_reserve, + pallet_amm_support::TradeOperation::ExactIn, + vec![(AssetType::Fungible(asset_in.into()), amount)], + vec![(AssetType::Fungible(asset_out.into()), *state_changes.asset_out.delta_reserve)], vec![ - (asset_out.into(), state_changes.fee.asset_fee, Self::protocol_account()), - ( - T::HubAssetId::get().into(), - state_changes.fee.protocol_fee, - Self::protocol_account(), - ), + Fee{ asset: asset_out.into(), amount: state_changes.fee.asset_fee, recipient: Self::protocol_account()}, + Fee{ asset: T::HubAssetId::get().into(), amount: state_changes.fee.protocol_fee, recipient: Self::protocol_account()} ], - event_id, ); #[cfg(feature = "try-runtime")] @@ -1884,20 +1878,13 @@ impl Pallet { who.clone(), Self::protocol_account(), pallet_amm_support::Filler::Omnipool, - pallet_amm_support::TradeOperation::Buy, - asset_in.into(), - asset_out.into(), - *state_changes.asset_in.delta_reserve, - *state_changes.asset_out.delta_reserve, + pallet_amm_support::TradeOperation::ExactOut, + vec![(AssetType::Fungible(asset_in.into()), *state_changes.asset_in.delta_reserve)], + vec![(AssetType::Fungible(asset_out.into()), *state_changes.asset_out.delta_reserve)], vec![ - (asset_out.into(), state_changes.fee.asset_fee, Self::protocol_account()), - ( - T::HubAssetId::get().into(), - state_changes.fee.protocol_fee, - Self::protocol_account(), - ), + Fee{ asset: asset_out.into(), amount: state_changes.fee.asset_fee, recipient: Self::protocol_account()}, + Fee{ asset: T::HubAssetId::get().into(), amount: state_changes.fee.protocol_fee, recipient: Self::protocol_account()} ], - event_id, ); #[cfg(feature = "try-runtime")] @@ -2017,13 +2004,12 @@ impl Pallet { who.clone(), Self::protocol_account(), pallet_amm_support::Filler::Omnipool, - pallet_amm_support::TradeOperation::Sell, - T::HubAssetId::get().into(), - asset_out.into(), - *state_changes.asset.delta_hub_reserve, - *state_changes.asset.delta_reserve, - vec![(asset_out.into(), state_changes.fee.asset_fee, Self::protocol_account())], - event_id, + pallet_amm_support::TradeOperation::ExactIn, + vec![(AssetType::Fungible(T::HubAssetId::get().into()), *state_changes.asset.delta_hub_reserve)], + vec![(AssetType::Fungible(asset_out.into()), *state_changes.asset.delta_reserve)], + vec![ + Fee{ asset: asset_out.into(), amount: state_changes.fee.asset_fee, recipient: Self::protocol_account()} + ], ); T::OmnipoolHooks::on_hub_asset_trade(origin, info)?; @@ -2139,13 +2125,12 @@ impl Pallet { who.clone(), Self::protocol_account(), pallet_amm_support::Filler::Omnipool, - pallet_amm_support::TradeOperation::Buy, - T::HubAssetId::get().into(), - asset_out.into(), - *state_changes.asset.delta_hub_reserve, - *state_changes.asset.delta_reserve, - vec![(asset_out.into(), state_changes.fee.asset_fee, Self::protocol_account())], - event_id, + pallet_amm_support::TradeOperation::ExactOut, + vec![(AssetType::Fungible(T::HubAssetId::get().into()), *state_changes.asset.delta_hub_reserve)], + vec![(AssetType::Fungible(asset_out.into()), *state_changes.asset.delta_reserve)], + vec![ + Fee{ asset: asset_out.into(), amount: state_changes.fee.asset_fee, recipient: Self::protocol_account()} + ], ); T::OmnipoolHooks::on_hub_asset_trade(origin, info)?; diff --git a/pallets/otc/src/lib.rs b/pallets/otc/src/lib.rs index a53abc979..f63f0fb10 100644 --- a/pallets/otc/src/lib.rs +++ b/pallets/otc/src/lib.rs @@ -37,7 +37,7 @@ use codec::MaxEncodedLen; use frame_support::{pallet_prelude::*, require_transactional}; use frame_system::{ensure_signed, pallet_prelude::OriginFor}; -use hydradx_traits::Inspect; +use hydradx_traits::{Inspect, router::{AssetType, Fee}}; use orml_traits::{GetByKey, MultiCurrency, NamedMultiReservableCurrency}; use sp_core::U256; use sp_runtime::traits::{One, Zero}; @@ -58,7 +58,7 @@ pub use weights::WeightInfo; pub use pallet::*; pub type Balance = u128; -pub type OrderId = u32; +pub type OrderId = hydradx_traits::router::OtcOrderId; pub type NamedReserveIdentifier = [u8; 8]; pub const NAMED_RESERVE_ID: NamedReserveIdentifier = *b"otcorder"; @@ -309,18 +309,14 @@ pub mod pallet { fee, }); - // TODO: order_id is missing pallet_amm_support::Pallet::::deposit_trade_event( who, order.owner.clone(), - pallet_amm_support::Filler::OTC, - pallet_amm_support::TradeOperation::Sell, - order.asset_in.into(), - order.asset_out.into(), - amount_in, - amount_out, - vec![(order.asset_out.into(), fee, T::FeeReceiver::get())], - None, + pallet_amm_support::Filler::OTC(order_id), + pallet_amm_support::TradeOperation::ExactIn, + vec![(AssetType::Fungible(order.asset_in.into()), amount_in)], + vec![(AssetType::Fungible(order.asset_out.into()), amount_out)], + vec![Fee{ asset: order.asset_out.into(), amount: fee, recipient: T::FeeReceiver::get()}], ); Ok(()) @@ -355,18 +351,14 @@ pub mod pallet { fee, }); - // TODO: order_id is missing pallet_amm_support::Pallet::::deposit_trade_event( who, order.owner, - pallet_amm_support::Filler::OTC, - pallet_amm_support::TradeOperation::Sell, - order.asset_in.into(), - order.asset_out.into(), - order.amount_in, - order.amount_out, - vec![(order.asset_out.into(), fee, T::FeeReceiver::get())], - None, + pallet_amm_support::Filler::OTC(order_id), + pallet_amm_support::TradeOperation::ExactIn, + vec![(AssetType::Fungible(order.asset_in.into()), order.amount_in)], + vec![(AssetType::Fungible(order.asset_out.into()), order.amount_out)], + vec![Fee{ asset: order.asset_out.into(), amount: fee, recipient: T::FeeReceiver::get()}], ); Ok(()) diff --git a/pallets/route-executor/src/lib.rs b/pallets/route-executor/src/lib.rs index 5e8713ddb..c3f672e5e 100644 --- a/pallets/route-executor/src/lib.rs +++ b/pallets/route-executor/src/lib.rs @@ -35,7 +35,7 @@ use frame_system::{ensure_signed, Origin}; use hydradx_traits::registry::Inspect as RegistryInspect; use hydradx_traits::router::{inverse_route, AssetPair, RefundEdCalculator, RouteProvider, RouteSpotPriceProvider}; pub use hydradx_traits::router::{ - AmmTradeWeights, AmountInAndOut, ExecutorError, PoolType, RouterT, Trade, TradeExecution, + AssetType, Fee, ExecutionType, ExecutionTypeStack, AmmTradeWeights, AmountInAndOut, ExecutorError, PoolType, RouterT, Trade, TradeExecution, }; use hydradx_traits::IncrementalIdProvider; use orml_traits::arithmetic::{CheckedAdd, CheckedSub}; @@ -131,6 +131,9 @@ pub mod pallet { type TechnicalOrigin: EnsureOrigin; type BatchIdProvider: IncrementalIdProvider; + + type OperationIdProvider: ExecutionTypeStack; + /// Weight information for the extrinsics. type WeightInfo: AmmTradeWeights>; } @@ -260,7 +263,10 @@ pub mod pallet { ensure!(first_trade.amount_in <= max_amount_in, Error::::TradingLimitReached); let route_length = route.len(); + let next_event_id = T::BatchIdProvider::next_id().map_err(|_| ArithmeticError::Overflow)?; + T::OperationIdProvider::push(ExecutionType::Router(next_event_id))?; + for (trade_index, (trade_amount, trade)) in trade_amounts.iter().rev().zip(route).enumerate() { Self::disable_ed_handling_for_insufficient_assets(route_length, trade_index, trade); let user_balance_of_asset_out_before_trade = @@ -303,6 +309,8 @@ pub mod pallet { event_id: next_event_id, }); + let _ = T::OperationIdProvider::pop()?; + Ok(()) } @@ -493,7 +501,10 @@ impl Pallet { ); let route_length = route.len(); + let next_event_id = T::BatchIdProvider::next_id().map_err(|_| ArithmeticError::Overflow)?; + T::OperationIdProvider::push(ExecutionType::Router(next_event_id))?; + for (trade_index, (trade_amount, trade)) in trade_amounts.iter().zip(route.clone()).enumerate() { Self::disable_ed_handling_for_insufficient_assets(route_length, trade_index, trade); @@ -538,6 +549,8 @@ impl Pallet { event_id: next_event_id, }); + let _ = T::OperationIdProvider::pop()?; + Ok(()) } diff --git a/pallets/route-executor/src/tests/mock.rs b/pallets/route-executor/src/tests/mock.rs index cbe31b0f8..49037dd92 100644 --- a/pallets/route-executor/src/tests/mock.rs +++ b/pallets/route-executor/src/tests/mock.rs @@ -165,6 +165,7 @@ impl Config for Test { type DefaultRoutePoolType = DefaultRoutePoolType; type TechnicalOrigin = EnsureRoot; type BatchIdProvider = AmmSupport; + type OperationIdProvider = AmmSupport; type WeightInfo = (); } diff --git a/pallets/stableswap/src/lib.rs b/pallets/stableswap/src/lib.rs index 8dbf02e8b..35626dde8 100644 --- a/pallets/stableswap/src/lib.rs +++ b/pallets/stableswap/src/lib.rs @@ -59,7 +59,10 @@ use frame_system::{ ensure_signed, pallet_prelude::{BlockNumberFor, OriginFor}, }; -use hydradx_traits::{registry::Inspect, AccountIdFor}; +use hydradx_traits::{ + registry::Inspect, AccountIdFor, + router::{AssetType, Fee}, +}; pub use pallet::*; use sp_runtime::traits::{AccountIdConversion, BlockNumberProvider, Zero}; use sp_runtime::{ArithmeticError, DispatchError, Permill, SaturatedConversion}; @@ -857,14 +860,11 @@ impl Pallet { pallet_amm_support::Pallet::::deposit_trade_event( who, pool_account.clone(), - pallet_amm_support::Filler::Stableswap, - pallet_amm_support::TradeOperation::Sell, - asset_in.into(), - asset_out.into(), - amount_in, - amount_out, - vec![(asset_out.into(), fee_amount, pool_account)], - event_id, + pallet_amm_support::Filler::Stableswap(pool_id.clone().into()), + pallet_amm_support::TradeOperation::ExactIn, + vec![(AssetType::Fungible(asset_in.into()), amount_in)], + vec![(AssetType::Fungible(asset_out.into()), amount_out)], + vec![Fee{ asset: asset_out.into(), amount: fee_amount, recipient: pool_account}], ); #[cfg(feature = "try-runtime")] @@ -934,14 +934,11 @@ impl Pallet { pallet_amm_support::Pallet::::deposit_trade_event( who, pool_account.clone(), - pallet_amm_support::Filler::Stableswap, - pallet_amm_support::TradeOperation::Buy, - asset_in.into(), - asset_out.into(), - amount_in, - amount_out, - vec![(asset_in.into(), fee_amount, pool_account)], - event_id, + pallet_amm_support::Filler::Stableswap(pool_id.clone().into()), + pallet_amm_support::TradeOperation::ExactOut, + vec![(AssetType::Fungible(asset_in.into()), amount_in)], + vec![(AssetType::Fungible(asset_out.into()), amount_out)], + vec![Fee{ asset: asset_in.into(), amount: fee_amount, recipient: pool_account}], ); #[cfg(feature = "try-runtime")] diff --git a/pallets/xyk/src/lib.rs b/pallets/xyk/src/lib.rs index 41ea01929..f15200f68 100644 --- a/pallets/xyk/src/lib.rs +++ b/pallets/xyk/src/lib.rs @@ -34,7 +34,7 @@ use frame_system::ensure_signed; use frame_system::pallet_prelude::BlockNumberFor; use hydradx_traits::{ AMMPosition, AMMTransfer, AssetPairAccountIdFor, CanCreatePool, OnCreatePoolHandler, OnLiquidityChangedHandler, - OnTradeHandler, AMM, + OnTradeHandler, AMM, router::{AssetType, Fee}, }; use sp_std::{vec, vec::Vec}; @@ -925,14 +925,11 @@ impl AMM::deposit_trade_event( transfer.origin.clone(), pair_account.clone(), - pallet_amm_support::Filler::XYK, - pallet_amm_support::TradeOperation::Sell, - transfer.assets.asset_in, - transfer.assets.asset_out, - transfer.amount, - transfer.amount_b, - vec![(transfer.fee.0, transfer.fee.1, pair_account)], - event_id, + pallet_amm_support::Filler::XYK(Self::share_token(&pair_account)), + pallet_amm_support::TradeOperation::ExactIn, + vec![(AssetType::Fungible(transfer.assets.asset_in), transfer.amount)], + vec![(AssetType::Fungible(transfer.assets.asset_out), transfer.amount_b)], + vec![Fee{ asset: transfer.fee.0, amount: transfer.fee.1, recipient: pair_account}], ); Ok(()) @@ -1105,14 +1102,11 @@ impl AMM::deposit_trade_event( transfer.origin.clone(), pair_account.clone(), - pallet_amm_support::Filler::XYK, - pallet_amm_support::TradeOperation::Buy, - transfer.assets.asset_in, - transfer.assets.asset_out, - transfer.amount, - transfer.amount_b, - vec![(transfer.fee.0, transfer.fee.1, pair_account)], - event_id, + pallet_amm_support::Filler::XYK(Self::share_token(&pair_account)), + pallet_amm_support::TradeOperation::ExactOut, + vec![(AssetType::Fungible(transfer.assets.asset_in), transfer.amount)], + vec![(AssetType::Fungible(transfer.assets.asset_out), transfer.amount_b)], + vec![Fee{ asset: transfer.fee.0, amount: transfer.fee.1, recipient: pair_account}], ); Ok(()) diff --git a/runtime/hydradx/src/assets.rs b/runtime/hydradx/src/assets.rs index 49e37e576..4b09ffe7d 100644 --- a/runtime/hydradx/src/assets.rs +++ b/runtime/hydradx/src/assets.rs @@ -1207,6 +1207,7 @@ impl pallet_route_executor::Config for Runtime { type OraclePriceProvider = hydradx_adapters::OraclePriceProvider; type BatchIdProvider = AmmSupport; type OraclePeriod = RouteValidationOraclePeriod; + type OperationIdProvider = AmmSupport; } parameter_types! { diff --git a/traits/src/router.rs b/traits/src/router.rs index 028ef18d2..eaa0dd6b7 100644 --- a/traits/src/router.rs +++ b/traits/src/router.rs @@ -1,3 +1,5 @@ +#[cfg(feature = "std")] +use serde::{Deserialize, Serialize}; use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::dispatch::DispatchResultWithPostInfo; use frame_support::sp_runtime::{DispatchError, DispatchResult}; @@ -60,10 +62,32 @@ pub trait RouteProvider { } } +#[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] +pub struct Fee { + pub asset: AssetId, + pub amount: Balance, + pub recipient: AccountId +} +impl Fee { + pub fn new(asset: AssetId, amount: Balance, recipient: AccountId) -> Self { + Self {asset, amount, recipient} + } +} + +#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] +#[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] +pub enum ExecutionType { + Router(IncrementalId), + DCA(IncrementalId), + ICE(IncrementalId), + Batch(IncrementalId), +} + #[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] pub enum TradeOperation { - Sell, - Buy, + ExactIn, + ExactOut, + Limit, } #[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] @@ -75,13 +99,27 @@ pub enum PoolType { } #[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] -pub enum Filler { +pub enum AssetType { + Fungible(AssetId), + NFT(NFTId), +} + +pub type OtcOrderId = u32; + +#[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] +pub enum Filler { Omnipool, - Stableswap, - XYK, - LBP, - OTC, - ICE, + Stableswap(AssetId), // asset id + XYK(AssetId), // share token + LBP, // ???? LBP(AssetId), // share token + OTC(OtcOrderId), + // ICE(solution_id/block id), swapper: alice, filler: solver +} + +pub trait ExecutionTypeStack { + fn push(execution_type: ExecutionType) -> DispatchResult; + fn pop() -> Result, DispatchError>; + fn get() -> Vec>; } #[derive(Debug, PartialEq, Eq)] From e2efb8a4ca557e56fee43858d553b18fae23561e Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Tue, 5 Nov 2024 13:46:44 +0100 Subject: [PATCH 028/142] revert old impl that is not needed anymore --- pallets/dca/src/tests/mock.rs | 5 +- pallets/lbp/src/lib.rs | 10 +- pallets/lbp/src/trade_execution.rs | 33 +- pallets/liquidity-mining/src/tests/mock.rs | 5 +- pallets/omnipool/src/lib.rs | 767 ++++++++---------- pallets/omnipool/src/router_execution.rs | 10 +- pallets/route-executor/src/lib.rs | 3 - pallets/route-executor/src/tests/mock.rs | 5 +- pallets/stableswap/src/lib.rs | 252 +++--- pallets/stableswap/src/trade_execution.rs | 11 +- pallets/xyk-liquidity-mining/src/lib.rs | 2 +- .../xyk-liquidity-mining/src/tests/mock.rs | 4 +- pallets/xyk/src/lib.rs | 23 +- pallets/xyk/src/trade_execution.rs | 33 +- traits/src/lib.rs | 9 +- traits/src/router.rs | 16 +- 16 files changed, 483 insertions(+), 705 deletions(-) diff --git a/pallets/dca/src/tests/mock.rs b/pallets/dca/src/tests/mock.rs index 04224dc82..cfbc5f2e0 100644 --- a/pallets/dca/src/tests/mock.rs +++ b/pallets/dca/src/tests/mock.rs @@ -23,7 +23,6 @@ use frame_support::weights::constants::ExtrinsicBaseWeight; use frame_support::weights::WeightToFeeCoefficient; use frame_support::weights::{IdentityFee, Weight}; use frame_support::PalletId; -use primitives::IncrementalId; use frame_support::BoundedVec; use frame_support::{assert_ok, parameter_types}; @@ -403,7 +402,7 @@ pub const CALCULATED_AMOUNT_IN_FOR_OMNIPOOL_BUY: Balance = 10 * ONE; pub struct OmniPool; pub struct Xyk; -impl TradeExecution for OmniPool { +impl TradeExecution for OmniPool { type Error = DispatchError; fn calculate_sell( @@ -448,7 +447,6 @@ impl TradeExecution, ) -> Result<(), ExecutorError> { if !matches!(pool_type, PoolType::Omnipool) { return Err(ExecutorError::NotSupported); @@ -488,7 +486,6 @@ impl TradeExecution, ) -> Result<(), ExecutorError> { if !matches!(pool_type, PoolType::Omnipool) { return Err(ExecutorError::NotSupported); diff --git a/pallets/lbp/src/lib.rs b/pallets/lbp/src/lib.rs index 310b9f4df..ef39fc18a 100644 --- a/pallets/lbp/src/lib.rs +++ b/pallets/lbp/src/lib.rs @@ -40,7 +40,6 @@ use hydradx_traits::{AMMTransfer, AssetPairAccountIdFor, CanCreatePool, LockedBa router::{AssetType, Fee}, }; use orml_traits::{MultiCurrency, MultiCurrencyExtended, MultiLockableCurrency}; -use pallet_amm_support::IncrementalIdType; use scale_info::TypeInfo; @@ -735,13 +734,12 @@ pub mod pallet { ) -> DispatchResult { let who = ensure_signed(origin)?; - >::sell( + >::sell( &who, AssetPair { asset_in, asset_out }, amount, max_limit, false, - None, )?; Ok(()) @@ -773,7 +771,7 @@ pub mod pallet { ) -> DispatchResult { let who = ensure_signed(origin)?; - >::buy(&who, AssetPair { asset_in, asset_out }, amount, max_limit, false, None)?; + >::buy(&who, AssetPair { asset_in, asset_out }, amount, max_limit, false)?; Ok(()) } @@ -944,7 +942,7 @@ impl Pallet { } } -impl AMM, IncrementalIdType> for Pallet { +impl AMM> for Pallet { fn exists(assets: AssetPair) -> bool { let pair_account = Self::pair_account_from_assets(assets.asset_in, assets.asset_out); >::contains_key(&pair_account) @@ -1114,7 +1112,6 @@ impl AMM, IncrementalI fn execute_sell( transfer: &AMMTransfer, - event_id: Option, ) -> DispatchResult { Self::execute_trade(transfer)?; @@ -1266,7 +1263,6 @@ impl AMM, IncrementalI fn execute_buy( transfer: &AMMTransfer>, _destination: Option<&T::AccountId>, - event_id: Option, ) -> DispatchResult { Self::execute_trade(transfer)?; diff --git a/pallets/lbp/src/trade_execution.rs b/pallets/lbp/src/trade_execution.rs index bb113d276..423f4a6d5 100644 --- a/pallets/lbp/src/trade_execution.rs +++ b/pallets/lbp/src/trade_execution.rs @@ -2,12 +2,11 @@ use crate::*; use hydradx_traits::router::{ExecutorError, PoolType, TradeExecution}; use hydradx_traits::AMM; use orml_traits::MultiCurrency; -use pallet_amm_support::IncrementalIdType; use sp_runtime::traits::BlockNumberProvider; use sp_runtime::DispatchError::Corruption; use sp_runtime::{ArithmeticError, DispatchError, FixedPointNumber, FixedU128}; -impl TradeExecution for Pallet { +impl TradeExecution for Pallet { type Error = DispatchError; fn calculate_sell( @@ -112,25 +111,12 @@ impl TradeExecution, ) -> Result<(), ExecutorError> { if pool_type != PoolType::LBP { return Err(ExecutorError::NotSupported); } - let who = crate::ensure_signed(who).map_err(|e| ExecutorError::Error(e.into()))?; - - >::sell( - &who, - AssetPair { asset_in, asset_out }, - amount_in, - min_limit, - false, - event_id, - ) - .map_err(ExecutorError::Error)?; - - Ok(()) + Self::sell(who, asset_in, asset_out, amount_in, min_limit).map_err(ExecutorError::Error) } fn execute_buy( @@ -140,25 +126,12 @@ impl TradeExecution, ) -> Result<(), ExecutorError> { if pool_type != PoolType::LBP { return Err(ExecutorError::NotSupported); } - let who = crate::ensure_signed(who).map_err(|e| ExecutorError::Error(e.into()))?; - - >::buy( - &who, - AssetPair { asset_in, asset_out }, - amount_out, - max_limit, - false, - event_id, - ) - .map_err(ExecutorError::Error)?; - - Ok(()) + Self::buy(who, asset_out, asset_in, amount_out, max_limit).map_err(ExecutorError::Error) } fn get_liquidity_depth( diff --git a/pallets/liquidity-mining/src/tests/mock.rs b/pallets/liquidity-mining/src/tests/mock.rs index 30b428fe4..f0a270d6d 100644 --- a/pallets/liquidity-mining/src/tests/mock.rs +++ b/pallets/liquidity-mining/src/tests/mock.rs @@ -24,7 +24,6 @@ use frame_support::{dispatch, parameter_types, traits::Contains, traits::Everyth use frame_system as system; use hydradx_traits::{pools::DustRemovalAccountWhitelist, registry::Inspect, AMMTransfer, AssetKind, AMM}; use orml_traits::GetByKey; -use primitives::IncrementalId; use sp_core::H256; use sp_runtime::{ traits::{BlakeTwo256, BlockNumberProvider, IdentityLookup}, @@ -173,7 +172,7 @@ thread_local! { pub static DUSTER_WHITELIST: RefCell> = RefCell::new(Vec::new()); } -impl AMM for Amm { +impl AMM for Amm { fn get_max_out_ratio() -> u128 { 0_u32.into() } @@ -210,14 +209,12 @@ impl AMM for Amm { fn execute_buy( _transfer: &AMMTransfer, _destination: Option<&AccountId>, - _event_id: Option, ) -> dispatch::DispatchResult { Err(sp_runtime::DispatchError::Other("NotImplemented")) } fn execute_sell( _transfer: &hydradx_traits::AMMTransfer, - _event_id: Option, ) -> frame_support::dispatch::DispatchResult { Err(sp_runtime::DispatchError::Other("NotImplemented")) } diff --git a/pallets/omnipool/src/lib.rs b/pallets/omnipool/src/lib.rs index e634c5c2e..9b435e593 100644 --- a/pallets/omnipool/src/lib.rs +++ b/pallets/omnipool/src/lib.rs @@ -116,7 +116,6 @@ pub mod weights; use crate::traits::{AssetInfo, OmnipoolHooks}; use crate::types::{AssetReserveState, AssetState, Balance, Position, SimpleImbalance, Tradability}; pub use pallet::*; -use pallet_amm_support::IncrementalIdType; pub use weights::WeightInfo; /// NFT class id type of provided nft implementation @@ -1044,7 +1043,185 @@ pub mod pallet { amount: Balance, min_buy_amount: Balance, ) -> DispatchResult { - Self::do_sell(origin, asset_in, asset_out, amount, min_buy_amount, None) + let who = ensure_signed(origin.clone())?; + + ensure!(asset_in != asset_out, Error::::SameAssetTradeNotAllowed); + + ensure!( + amount >= T::MinimumTradingLimit::get(), + Error::::InsufficientTradingAmount + ); + + ensure!( + T::Currency::ensure_can_withdraw(asset_in, &who, amount).is_ok(), + Error::::InsufficientBalance + ); + + // Special handling when one of the asset is Hub Asset + // Math is simplified and asset_in is actually part of asset_out state in this case + if asset_in == T::HubAssetId::get() { + return Self::sell_hub_asset(origin, &who, asset_out, amount, min_buy_amount); + } + + if asset_out == T::HubAssetId::get() { + return Self::sell_asset_for_hub_asset(&who, asset_in, amount, min_buy_amount); + } + + let asset_in_state = Self::load_asset_state(asset_in)?; + let asset_out_state = Self::load_asset_state(asset_out)?; + + ensure!( + Self::allow_assets(&asset_in_state, &asset_out_state), + Error::::NotAllowed + ); + + ensure!( + amount + <= asset_in_state + .reserve + .checked_div(T::MaxInRatio::get()) + .ok_or(ArithmeticError::DivisionByZero)?, // Note: this can only fail if MaxInRatio is zero. + Error::::MaxInRatioExceeded + ); + + let current_imbalance = >::get(); + + let (asset_fee, _) = T::Fee::get(&asset_out); + let (_, protocol_fee) = T::Fee::get(&asset_in); + + let state_changes = hydra_dx_math::omnipool::calculate_sell_state_changes( + &(&asset_in_state).into(), + &(&asset_out_state).into(), + amount, + asset_fee, + protocol_fee, + current_imbalance.value, + ) + .ok_or(ArithmeticError::Overflow)?; + + ensure!( + *state_changes.asset_out.delta_reserve > Balance::zero(), + Error::::ZeroAmountOut + ); + + ensure!( + *state_changes.asset_out.delta_reserve >= min_buy_amount, + Error::::BuyLimitNotReached + ); + + ensure!( + *state_changes.asset_out.delta_reserve + <= asset_out_state + .reserve + .checked_div(T::MaxOutRatio::get()) + .ok_or(ArithmeticError::DivisionByZero)?, // Note: let's be safe. this can only fail if MaxOutRatio is zero. + Error::::MaxOutRatioExceeded + ); + + let new_asset_in_state = asset_in_state + .delta_update(&state_changes.asset_in) + .ok_or(ArithmeticError::Overflow)?; + let new_asset_out_state = asset_out_state + .delta_update(&state_changes.asset_out) + .ok_or(ArithmeticError::Overflow)?; + + debug_assert_eq!( + *state_changes.asset_in.delta_reserve, amount, + "delta_reserve_in is not equal to given amount in" + ); + + T::Currency::transfer( + asset_in, + &who, + &Self::protocol_account(), + *state_changes.asset_in.delta_reserve, + )?; + T::Currency::transfer( + asset_out, + &Self::protocol_account(), + &who, + *state_changes.asset_out.delta_reserve, + )?; + + // Hub liquidity update - work out difference between in and amount so only one update is needed. + let delta_hub_asset = state_changes + .asset_in + .delta_hub_reserve + .merge( + state_changes + .asset_out + .delta_hub_reserve + .merge(BalanceUpdate::Increase(state_changes.hdx_hub_amount)) + .ok_or(ArithmeticError::Overflow)?, + ) + .ok_or(ArithmeticError::Overflow)?; + + match delta_hub_asset { + BalanceUpdate::Increase(val) if val == Balance::zero() => { + // nothing to do if zero. + } + BalanceUpdate::Increase(_) => { + // trade can only burn some. This would be a bug. + return Err(Error::::HubAssetUpdateError.into()); + } + BalanceUpdate::Decrease(amount) => { + T::Currency::withdraw(T::HubAssetId::get(), &Self::protocol_account(), amount)?; + } + }; + + // Callback hook info + let info_in: AssetInfo = AssetInfo::new( + asset_in, + &asset_in_state, + &new_asset_in_state, + &state_changes.asset_in, + false, + ); + + let info_out: AssetInfo = AssetInfo::new( + asset_out, + &asset_out_state, + &new_asset_out_state, + &state_changes.asset_out, + false, + ); + + Self::update_imbalance(state_changes.delta_imbalance)?; + + Self::set_asset_state(asset_in, new_asset_in_state); + Self::set_asset_state(asset_out, new_asset_out_state); + + T::OmnipoolHooks::on_trade(origin.clone(), info_in, info_out)?; + + Self::update_hdx_subpool_hub_asset(origin, state_changes.hdx_hub_amount)?; + + Self::process_trade_fee(&who, asset_out, state_changes.fee.asset_fee)?; + + debug_assert!(*state_changes.asset_in.delta_hub_reserve >= *state_changes.asset_out.delta_hub_reserve); + debug_assert_eq!( + *state_changes.asset_in.delta_hub_reserve - *state_changes.asset_out.delta_hub_reserve, + state_changes.fee.protocol_fee + ); + + Self::deposit_event(Event::SellExecuted { + who, + asset_in, + asset_out, + amount_in: amount, + amount_out: *state_changes.asset_out.delta_reserve, + hub_amount_in: *state_changes.asset_in.delta_hub_reserve, + hub_amount_out: *state_changes.asset_out.delta_hub_reserve, + asset_fee_amount: state_changes.fee.asset_fee, + protocol_fee_amount: state_changes.fee.protocol_fee, + }); + + #[cfg(feature = "try-runtime")] + Self::ensure_trade_invariant( + (asset_in, asset_in_state, new_asset_in_state), + (asset_out, asset_out_state, new_asset_out_state), + ); + + Ok(()) } /// Execute a swap of `asset_out` for `asset_in`. @@ -1077,7 +1254,179 @@ pub mod pallet { amount: Balance, max_sell_amount: Balance, ) -> DispatchResult { - Self::do_buy(origin, asset_out, asset_in, amount, max_sell_amount, None) + let who = ensure_signed(origin.clone())?; + + ensure!(asset_in != asset_out, Error::::SameAssetTradeNotAllowed); + + ensure!( + amount >= T::MinimumTradingLimit::get(), + Error::::InsufficientTradingAmount + ); + + // Special handling when one of the asset is Hub Asset + if asset_out == T::HubAssetId::get() { + return Self::buy_hub_asset(&who, asset_in, amount, max_sell_amount); + } + + if asset_in == T::HubAssetId::get() { + return Self::buy_asset_for_hub_asset(origin, &who, asset_out, amount, max_sell_amount); + } + + let asset_in_state = Self::load_asset_state(asset_in)?; + let asset_out_state = Self::load_asset_state(asset_out)?; + + ensure!( + Self::allow_assets(&asset_in_state, &asset_out_state), + Error::::NotAllowed + ); + + ensure!(asset_out_state.reserve >= amount, Error::::InsufficientLiquidity); + + ensure!( + amount + <= asset_out_state + .reserve + .checked_div(T::MaxOutRatio::get()) + .ok_or(ArithmeticError::DivisionByZero)?, // Note: Let's be safe. this can only fail if MaxOutRatio is zero. + Error::::MaxOutRatioExceeded + ); + + let current_imbalance = >::get(); + + let (asset_fee, _) = T::Fee::get(&asset_out); + let (_, protocol_fee) = T::Fee::get(&asset_in); + let state_changes = hydra_dx_math::omnipool::calculate_buy_state_changes( + &(&asset_in_state).into(), + &(&asset_out_state).into(), + amount, + asset_fee, + protocol_fee, + current_imbalance.value, + ) + .ok_or(ArithmeticError::Overflow)?; + + ensure!( + T::Currency::ensure_can_withdraw(asset_in, &who, *state_changes.asset_in.delta_reserve).is_ok(), + Error::::InsufficientBalance + ); + + ensure!( + *state_changes.asset_in.delta_reserve <= max_sell_amount, + Error::::SellLimitExceeded + ); + + ensure!( + *state_changes.asset_in.delta_reserve + <= asset_in_state + .reserve + .checked_div(T::MaxInRatio::get()) + .ok_or(ArithmeticError::DivisionByZero)?, // Note: this can only fail if MaxInRatio is zero. + Error::::MaxInRatioExceeded + ); + + let new_asset_in_state = asset_in_state + .delta_update(&state_changes.asset_in) + .ok_or(ArithmeticError::Overflow)?; + let new_asset_out_state = asset_out_state + .delta_update(&state_changes.asset_out) + .ok_or(ArithmeticError::Overflow)?; + + debug_assert_eq!( + *state_changes.asset_out.delta_reserve, amount, + "delta_reserve_out is not equal to given amount out" + ); + + T::Currency::transfer( + asset_in, + &who, + &Self::protocol_account(), + *state_changes.asset_in.delta_reserve, + )?; + T::Currency::transfer( + asset_out, + &Self::protocol_account(), + &who, + *state_changes.asset_out.delta_reserve, + )?; + + // Hub liquidity update - work out difference between in and amount so only one update is needed. + let delta_hub_asset = state_changes + .asset_in + .delta_hub_reserve + .merge( + state_changes + .asset_out + .delta_hub_reserve + .merge(BalanceUpdate::Increase(state_changes.hdx_hub_amount)) + .ok_or(ArithmeticError::Overflow)?, + ) + .ok_or(ArithmeticError::Overflow)?; + + match delta_hub_asset { + BalanceUpdate::Increase(val) if val == Balance::zero() => { + // nothing to do if zero. + } + BalanceUpdate::Increase(_) => { + // trade can only burn some. This would be a bug. + return Err(Error::::HubAssetUpdateError.into()); + } + BalanceUpdate::Decrease(amount) => { + T::Currency::withdraw(T::HubAssetId::get(), &Self::protocol_account(), amount)?; + } + }; + + // Callback hook info + let info_in: AssetInfo = AssetInfo::new( + asset_in, + &asset_in_state, + &new_asset_in_state, + &state_changes.asset_in, + false, + ); + + let info_out: AssetInfo = AssetInfo::new( + asset_out, + &asset_out_state, + &new_asset_out_state, + &state_changes.asset_out, + false, + ); + + Self::update_imbalance(state_changes.delta_imbalance)?; + Self::set_asset_state(asset_in, new_asset_in_state); + Self::set_asset_state(asset_out, new_asset_out_state); + + T::OmnipoolHooks::on_trade(origin.clone(), info_in, info_out)?; + + Self::update_hdx_subpool_hub_asset(origin, state_changes.hdx_hub_amount)?; + + Self::process_trade_fee(&who, asset_out, state_changes.fee.asset_fee)?; + + debug_assert!(*state_changes.asset_in.delta_hub_reserve >= *state_changes.asset_out.delta_hub_reserve); + debug_assert_eq!( + *state_changes.asset_in.delta_hub_reserve - *state_changes.asset_out.delta_hub_reserve, + state_changes.fee.protocol_fee + ); + + Self::deposit_event(Event::BuyExecuted { + who, + asset_in, + asset_out, + amount_in: *state_changes.asset_in.delta_reserve, + amount_out: *state_changes.asset_out.delta_reserve, + hub_amount_in: *state_changes.asset_in.delta_hub_reserve, + hub_amount_out: *state_changes.asset_out.delta_hub_reserve, + asset_fee_amount: state_changes.fee.asset_fee, + protocol_fee_amount: state_changes.fee.protocol_fee, + }); + + #[cfg(feature = "try-runtime")] + Self::ensure_trade_invariant( + (asset_in, asset_in_state, new_asset_in_state), + (asset_out, asset_out_state, new_asset_out_state), + ); + + Ok(()) } /// Update asset's tradable state. @@ -1486,416 +1835,6 @@ impl Pallet { asset_in.tradable.contains(Tradability::SELL) && asset_out.tradable.contains(Tradability::BUY) } - fn do_sell( - origin: OriginFor, - asset_in: T::AssetId, - asset_out: T::AssetId, - amount: Balance, - min_buy_amount: Balance, - event_id: Option, - ) -> DispatchResult { - let who = ensure_signed(origin.clone())?; - - ensure!(asset_in != asset_out, Error::::SameAssetTradeNotAllowed); - - ensure!( - amount >= T::MinimumTradingLimit::get(), - Error::::InsufficientTradingAmount - ); - - ensure!( - T::Currency::ensure_can_withdraw(asset_in, &who, amount).is_ok(), - Error::::InsufficientBalance - ); - - // Special handling when one of the asset is Hub Asset - // Math is simplified and asset_in is actually part of asset_out state in this case - if asset_in == T::HubAssetId::get() { - return Self::sell_hub_asset(origin, &who, asset_out, amount, min_buy_amount, event_id); - } - - if asset_out == T::HubAssetId::get() { - return Self::sell_asset_for_hub_asset(&who, asset_in, amount, min_buy_amount); - } - - let asset_in_state = Self::load_asset_state(asset_in)?; - let asset_out_state = Self::load_asset_state(asset_out)?; - - ensure!( - Self::allow_assets(&asset_in_state, &asset_out_state), - Error::::NotAllowed - ); - - ensure!( - amount - <= asset_in_state - .reserve - .checked_div(T::MaxInRatio::get()) - .ok_or(ArithmeticError::DivisionByZero)?, // Note: this can only fail if MaxInRatio is zero. - Error::::MaxInRatioExceeded - ); - - let current_imbalance = >::get(); - - let (asset_fee, _) = T::Fee::get(&asset_out); - let (_, protocol_fee) = T::Fee::get(&asset_in); - - let state_changes = hydra_dx_math::omnipool::calculate_sell_state_changes( - &(&asset_in_state).into(), - &(&asset_out_state).into(), - amount, - asset_fee, - protocol_fee, - current_imbalance.value, - ) - .ok_or(ArithmeticError::Overflow)?; - - ensure!( - *state_changes.asset_out.delta_reserve > Balance::zero(), - Error::::ZeroAmountOut - ); - - ensure!( - *state_changes.asset_out.delta_reserve >= min_buy_amount, - Error::::BuyLimitNotReached - ); - - ensure!( - *state_changes.asset_out.delta_reserve - <= asset_out_state - .reserve - .checked_div(T::MaxOutRatio::get()) - .ok_or(ArithmeticError::DivisionByZero)?, // Note: let's be safe. this can only fail if MaxOutRatio is zero. - Error::::MaxOutRatioExceeded - ); - - let new_asset_in_state = asset_in_state - .delta_update(&state_changes.asset_in) - .ok_or(ArithmeticError::Overflow)?; - let new_asset_out_state = asset_out_state - .delta_update(&state_changes.asset_out) - .ok_or(ArithmeticError::Overflow)?; - - debug_assert_eq!( - *state_changes.asset_in.delta_reserve, amount, - "delta_reserve_in is not equal to given amount in" - ); - - T::Currency::transfer( - asset_in, - &who, - &Self::protocol_account(), - *state_changes.asset_in.delta_reserve, - )?; - T::Currency::transfer( - asset_out, - &Self::protocol_account(), - &who, - *state_changes.asset_out.delta_reserve, - )?; - - // Hub liquidity update - work out difference between in and amount so only one update is needed. - let delta_hub_asset = state_changes - .asset_in - .delta_hub_reserve - .merge( - state_changes - .asset_out - .delta_hub_reserve - .merge(BalanceUpdate::Increase(state_changes.hdx_hub_amount)) - .ok_or(ArithmeticError::Overflow)?, - ) - .ok_or(ArithmeticError::Overflow)?; - - match delta_hub_asset { - BalanceUpdate::Increase(val) if val == Balance::zero() => { - // nothing to do if zero. - } - BalanceUpdate::Increase(_) => { - // trade can only burn some. This would be a bug. - return Err(Error::::HubAssetUpdateError.into()); - } - BalanceUpdate::Decrease(amount) => { - T::Currency::withdraw(T::HubAssetId::get(), &Self::protocol_account(), amount)?; - } - }; - - // Callback hook info - let info_in: AssetInfo = AssetInfo::new( - asset_in, - &asset_in_state, - &new_asset_in_state, - &state_changes.asset_in, - false, - ); - - let info_out: AssetInfo = AssetInfo::new( - asset_out, - &asset_out_state, - &new_asset_out_state, - &state_changes.asset_out, - false, - ); - - Self::update_imbalance(state_changes.delta_imbalance)?; - - Self::set_asset_state(asset_in, new_asset_in_state); - Self::set_asset_state(asset_out, new_asset_out_state); - - T::OmnipoolHooks::on_trade(origin.clone(), info_in, info_out)?; - - Self::update_hdx_subpool_hub_asset(origin, state_changes.hdx_hub_amount)?; - - Self::process_trade_fee(&who, asset_out, state_changes.fee.asset_fee)?; - - debug_assert!(*state_changes.asset_in.delta_hub_reserve >= *state_changes.asset_out.delta_hub_reserve); - debug_assert_eq!( - *state_changes.asset_in.delta_hub_reserve - *state_changes.asset_out.delta_hub_reserve, - state_changes.fee.protocol_fee - ); - - // TODO: Deprecated, remove when ready - Self::deposit_event(Event::SellExecuted { - who: who.clone(), - asset_in, - asset_out, - amount_in: amount, - amount_out: *state_changes.asset_out.delta_reserve, - hub_amount_in: *state_changes.asset_in.delta_hub_reserve, - hub_amount_out: *state_changes.asset_out.delta_hub_reserve, - asset_fee_amount: state_changes.fee.asset_fee, - protocol_fee_amount: state_changes.fee.protocol_fee, - }); - - Self::deposit_event(Event::HubAmountUpdated { - hub_amount_in: *state_changes.asset_in.delta_hub_reserve, - hub_amount_out: *state_changes.asset_out.delta_hub_reserve, - }); - - pallet_amm_support::Pallet::::deposit_trade_event( - who.clone(), - Self::protocol_account(), - pallet_amm_support::Filler::Omnipool, - pallet_amm_support::TradeOperation::ExactIn, - vec![(AssetType::Fungible(asset_in.into()), amount)], - vec![(AssetType::Fungible(asset_out.into()), *state_changes.asset_out.delta_reserve)], - vec![ - Fee{ asset: asset_out.into(), amount: state_changes.fee.asset_fee, recipient: Self::protocol_account()}, - Fee{ asset: T::HubAssetId::get().into(), amount: state_changes.fee.protocol_fee, recipient: Self::protocol_account()} - ], - ); - - #[cfg(feature = "try-runtime")] - Self::ensure_trade_invariant( - (asset_in, asset_in_state, new_asset_in_state), - (asset_out, asset_out_state, new_asset_out_state), - ); - - Ok(()) - } - - fn do_buy( - origin: OriginFor, - asset_out: T::AssetId, - asset_in: T::AssetId, - amount: Balance, - max_sell_amount: Balance, - event_id: Option, - ) -> DispatchResult { - let who = ensure_signed(origin.clone())?; - - ensure!(asset_in != asset_out, Error::::SameAssetTradeNotAllowed); - - ensure!( - amount >= T::MinimumTradingLimit::get(), - Error::::InsufficientTradingAmount - ); - - // Special handling when one of the asset is Hub Asset - if asset_out == T::HubAssetId::get() { - return Self::buy_hub_asset(&who, asset_in, amount, max_sell_amount); - } - - if asset_in == T::HubAssetId::get() { - return Self::buy_asset_for_hub_asset(origin, &who, asset_out, amount, max_sell_amount, event_id); - } - - let asset_in_state = Self::load_asset_state(asset_in)?; - let asset_out_state = Self::load_asset_state(asset_out)?; - - ensure!( - Self::allow_assets(&asset_in_state, &asset_out_state), - Error::::NotAllowed - ); - - ensure!(asset_out_state.reserve >= amount, Error::::InsufficientLiquidity); - - ensure!( - amount - <= asset_out_state - .reserve - .checked_div(T::MaxOutRatio::get()) - .ok_or(ArithmeticError::DivisionByZero)?, // Note: Let's be safe. this can only fail if MaxOutRatio is zero. - Error::::MaxOutRatioExceeded - ); - - let current_imbalance = >::get(); - - let (asset_fee, _) = T::Fee::get(&asset_out); - let (_, protocol_fee) = T::Fee::get(&asset_in); - let state_changes = hydra_dx_math::omnipool::calculate_buy_state_changes( - &(&asset_in_state).into(), - &(&asset_out_state).into(), - amount, - asset_fee, - protocol_fee, - current_imbalance.value, - ) - .ok_or(ArithmeticError::Overflow)?; - - ensure!( - T::Currency::ensure_can_withdraw(asset_in, &who, *state_changes.asset_in.delta_reserve).is_ok(), - Error::::InsufficientBalance - ); - - ensure!( - *state_changes.asset_in.delta_reserve <= max_sell_amount, - Error::::SellLimitExceeded - ); - - ensure!( - *state_changes.asset_in.delta_reserve - <= asset_in_state - .reserve - .checked_div(T::MaxInRatio::get()) - .ok_or(ArithmeticError::DivisionByZero)?, // Note: this can only fail if MaxInRatio is zero. - Error::::MaxInRatioExceeded - ); - - let new_asset_in_state = asset_in_state - .delta_update(&state_changes.asset_in) - .ok_or(ArithmeticError::Overflow)?; - let new_asset_out_state = asset_out_state - .delta_update(&state_changes.asset_out) - .ok_or(ArithmeticError::Overflow)?; - - debug_assert_eq!( - *state_changes.asset_out.delta_reserve, amount, - "delta_reserve_out is not equal to given amount out" - ); - - T::Currency::transfer( - asset_in, - &who, - &Self::protocol_account(), - *state_changes.asset_in.delta_reserve, - )?; - T::Currency::transfer( - asset_out, - &Self::protocol_account(), - &who, - *state_changes.asset_out.delta_reserve, - )?; - - // Hub liquidity update - work out difference between in and amount so only one update is needed. - let delta_hub_asset = state_changes - .asset_in - .delta_hub_reserve - .merge( - state_changes - .asset_out - .delta_hub_reserve - .merge(BalanceUpdate::Increase(state_changes.hdx_hub_amount)) - .ok_or(ArithmeticError::Overflow)?, - ) - .ok_or(ArithmeticError::Overflow)?; - - match delta_hub_asset { - BalanceUpdate::Increase(val) if val == Balance::zero() => { - // nothing to do if zero. - } - BalanceUpdate::Increase(_) => { - // trade can only burn some. This would be a bug. - return Err(Error::::HubAssetUpdateError.into()); - } - BalanceUpdate::Decrease(amount) => { - T::Currency::withdraw(T::HubAssetId::get(), &Self::protocol_account(), amount)?; - } - }; - - // Callback hook info - let info_in: AssetInfo = AssetInfo::new( - asset_in, - &asset_in_state, - &new_asset_in_state, - &state_changes.asset_in, - false, - ); - - let info_out: AssetInfo = AssetInfo::new( - asset_out, - &asset_out_state, - &new_asset_out_state, - &state_changes.asset_out, - false, - ); - - Self::update_imbalance(state_changes.delta_imbalance)?; - Self::set_asset_state(asset_in, new_asset_in_state); - Self::set_asset_state(asset_out, new_asset_out_state); - - T::OmnipoolHooks::on_trade(origin.clone(), info_in, info_out)?; - - Self::update_hdx_subpool_hub_asset(origin, state_changes.hdx_hub_amount)?; - - Self::process_trade_fee(&who, asset_out, state_changes.fee.asset_fee)?; - - debug_assert!(*state_changes.asset_in.delta_hub_reserve >= *state_changes.asset_out.delta_hub_reserve); - debug_assert_eq!( - *state_changes.asset_in.delta_hub_reserve - *state_changes.asset_out.delta_hub_reserve, - state_changes.fee.protocol_fee - ); - - // TODO: Deprecated, remove when ready - Self::deposit_event(Event::BuyExecuted { - who: who.clone(), - asset_in, - asset_out, - amount_in: *state_changes.asset_in.delta_reserve, - amount_out: *state_changes.asset_out.delta_reserve, - hub_amount_in: *state_changes.asset_in.delta_hub_reserve, - hub_amount_out: *state_changes.asset_out.delta_hub_reserve, - asset_fee_amount: state_changes.fee.asset_fee, - protocol_fee_amount: state_changes.fee.protocol_fee, - }); - - Self::deposit_event(Event::HubAmountUpdated { - hub_amount_in: *state_changes.asset_in.delta_hub_reserve, - hub_amount_out: *state_changes.asset_out.delta_hub_reserve, - }); - - pallet_amm_support::Pallet::::deposit_trade_event( - who.clone(), - Self::protocol_account(), - pallet_amm_support::Filler::Omnipool, - pallet_amm_support::TradeOperation::ExactOut, - vec![(AssetType::Fungible(asset_in.into()), *state_changes.asset_in.delta_reserve)], - vec![(AssetType::Fungible(asset_out.into()), *state_changes.asset_out.delta_reserve)], - vec![ - Fee{ asset: asset_out.into(), amount: state_changes.fee.asset_fee, recipient: Self::protocol_account()}, - Fee{ asset: T::HubAssetId::get().into(), amount: state_changes.fee.protocol_fee, recipient: Self::protocol_account()} - ], - ); - - #[cfg(feature = "try-runtime")] - Self::ensure_trade_invariant( - (asset_in, asset_in_state, new_asset_in_state), - (asset_out, asset_out_state, new_asset_out_state), - ); - - Ok(()) - } - /// Swap hub asset for asset_out. /// Special handling of sell trade where asset in is Hub Asset. fn sell_hub_asset( @@ -1904,7 +1843,6 @@ impl Pallet { asset_out: T::AssetId, amount: Balance, limit: Balance, - event_id: Option, ) -> DispatchResult { ensure!( HubAssetTradability::::get().contains(Tradability::SELL), @@ -2025,7 +1963,6 @@ impl Pallet { asset_out: T::AssetId, amount: Balance, limit: Balance, - event_id: Option, ) -> DispatchResult { ensure!( HubAssetTradability::::get().contains(Tradability::SELL), diff --git a/pallets/omnipool/src/router_execution.rs b/pallets/omnipool/src/router_execution.rs index 2298bf06b..a6b17cccf 100644 --- a/pallets/omnipool/src/router_execution.rs +++ b/pallets/omnipool/src/router_execution.rs @@ -5,14 +5,13 @@ use hydra_dx_math::omnipool::types::I129; use hydradx_traits::router::{ExecutorError, PoolType, TradeExecution}; use orml_traits::{GetByKey, MultiCurrency}; -use pallet_amm_support::IncrementalIdType; use sp_runtime::traits::Get; use sp_runtime::DispatchError::Corruption; use sp_runtime::{ArithmeticError, DispatchError, FixedPointNumber, FixedU128}; // dev note: The code is calculate sell and buy is copied from the corresponding functions. // This is not ideal and should be refactored to avoid code duplication. -impl TradeExecution, T::AccountId, T::AssetId, Balance, IncrementalIdType> for Pallet { +impl TradeExecution, T::AccountId, T::AssetId, Balance> for Pallet { type Error = DispatchError; fn calculate_sell( @@ -132,13 +131,12 @@ impl TradeExecution, T::AccountId, T::AssetId, Balance, asset_out: T::AssetId, amount_in: Balance, min_limit: Balance, - event_id: Option, ) -> Result<(), ExecutorError> { if pool_type != PoolType::Omnipool { return Err(ExecutorError::NotSupported); } - Self::do_sell(who, asset_in, asset_out, amount_in, min_limit, event_id).map_err(ExecutorError::Error) + Self::sell(who, asset_in, asset_out, amount_in, min_limit).map_err(ExecutorError::Error) } fn execute_buy( @@ -148,13 +146,11 @@ impl TradeExecution, T::AccountId, T::AssetId, Balance, asset_out: T::AssetId, amount_out: Balance, max_limit: Balance, - event_id: Option, ) -> Result<(), ExecutorError> { if pool_type != PoolType::Omnipool { return Err(ExecutorError::NotSupported); } - - Self::do_buy(who, asset_out, asset_in, amount_out, max_limit, event_id).map_err(ExecutorError::Error) + Self::buy(who, asset_out, asset_in, amount_out, max_limit).map_err(ExecutorError::Error) } fn get_liquidity_depth( diff --git a/pallets/route-executor/src/lib.rs b/pallets/route-executor/src/lib.rs index c3f672e5e..69674cb0e 100644 --- a/pallets/route-executor/src/lib.rs +++ b/pallets/route-executor/src/lib.rs @@ -110,7 +110,6 @@ pub mod pallet { Self::AccountId, Self::AssetId, Self::Balance, - IncrementalId, Error = DispatchError, >; @@ -278,7 +277,6 @@ pub mod pallet { trade.asset_out, trade_amount.amount_out, trade_amount.amount_in, - Some(next_event_id), ); handle_execution_error!(execution_result); @@ -518,7 +516,6 @@ impl Pallet { trade.asset_out, trade_amount.amount_in, trade_amount.amount_out, - Some(next_event_id), ); handle_execution_error!(execution_result); diff --git a/pallets/route-executor/src/tests/mock.rs b/pallets/route-executor/src/tests/mock.rs index 49037dd92..8a63d2021 100644 --- a/pallets/route-executor/src/tests/mock.rs +++ b/pallets/route-executor/src/tests/mock.rs @@ -28,7 +28,6 @@ use hydradx_traits::router::{ExecutorError, PoolType, RefundEdCalculator, TradeE use orml_traits::parameter_type_with_key; use pallet_currencies::{fungibles::FungibleCurrencies, BasicCurrencyAdapter}; use pretty_assertions::assert_eq; -use primitives::IncrementalId; use sp_core::H256; use sp_runtime::FixedU128; use sp_runtime::{ @@ -340,7 +339,7 @@ type OriginForRuntime = OriginFor; macro_rules! impl_fake_executor { ($pool_struct:ident, $pool_type: pat, $sell_calculation_result: expr, $buy_calculation_result: expr) => { - impl TradeExecution for $pool_struct { + impl TradeExecution for $pool_struct { type Error = DispatchError; fn calculate_sell( @@ -384,7 +383,6 @@ macro_rules! impl_fake_executor { asset_out: AssetId, amount_in: Balance, _min_limit: Balance, - _event_id: Option, ) -> Result<(), ExecutorError> { let who = ensure_signed(who).map_err(|_| ExecutorError::Error(DispatchError::Other("Wrong origin")))?; if !matches!(pool_type, $pool_type) { @@ -423,7 +421,6 @@ macro_rules! impl_fake_executor { asset_out: AssetId, amount_out: Balance, _max_limit: Balance, - _event_id: Option, ) -> Result<(), ExecutorError> { let who = ensure_signed(who).map_err(|_| ExecutorError::Error(DispatchError::Other("Wrong origin")))?; diff --git a/pallets/stableswap/src/lib.rs b/pallets/stableswap/src/lib.rs index 35626dde8..1a64a71d2 100644 --- a/pallets/stableswap/src/lib.rs +++ b/pallets/stableswap/src/lib.rs @@ -61,7 +61,6 @@ use frame_system::{ }; use hydradx_traits::{ registry::Inspect, AccountIdFor, - router::{AssetType, Fee}, }; pub use pallet::*; use sp_runtime::traits::{AccountIdConversion, BlockNumberProvider, Zero}; @@ -78,7 +77,6 @@ use crate::types::{AssetAmount, Balance, PoolInfo, PoolState, StableswapHooks, T use hydra_dx_math::stableswap::types::AssetReserve; use hydradx_traits::pools::DustRemovalAccountWhitelist; use orml_traits::MultiCurrency; -use pallet_amm_support::IncrementalIdType; use sp_std::collections::btree_map::BTreeMap; pub use weights::WeightInfo; @@ -733,8 +731,55 @@ pub mod pallet { amount_in: Balance, min_buy_amount: Balance, ) -> DispatchResult { - Self::do_sell(origin, pool_id, asset_in, asset_out, amount_in, min_buy_amount, None) - } + let who = ensure_signed(origin)?; + + ensure!(asset_in != asset_out, Error::::NotAllowed); + + ensure!( + Self::is_asset_allowed(pool_id, asset_in, Tradability::SELL) + && Self::is_asset_allowed(pool_id, asset_out, Tradability::BUY), + Error::::NotAllowed + ); + + ensure!( + amount_in >= T::MinTradingLimit::get(), + Error::::InsufficientTradingAmount + ); + + ensure!( + T::Currency::free_balance(asset_in, &who) >= amount_in, + Error::::InsufficientBalance + ); + + let pool = Pools::::get(pool_id).ok_or(Error::::PoolNotFound)?; + let pool_account = Self::pool_account(pool_id); + let initial_reserves = pool + .reserves_with_decimals::(&pool_account) + .ok_or(Error::::UnknownDecimals)?; + + let (amount_out, fee_amount) = Self::calculate_out_amount(pool_id, asset_in, asset_out, amount_in)?; + ensure!(amount_out >= min_buy_amount, Error::::BuyLimitNotReached); + + T::Currency::transfer(asset_in, &who, &pool_account, amount_in)?; + T::Currency::transfer(asset_out, &pool_account, &who, amount_out)?; + + //All done and updated. Let's call on_trade hook. + Self::call_on_trade_hook(pool_id, asset_in, asset_out, &initial_reserves)?; + + Self::deposit_event(Event::SellExecuted { + who, + pool_id, + asset_in, + asset_out, + amount_in, + amount_out, + fee: fee_amount, + }); + + #[cfg(feature = "try-runtime")] + Self::ensure_trade_invariant(pool_id, &initial_reserves, pool.fee); + + Ok(()) } /// Execute a swap of `asset_in` for `asset_out`. /// @@ -761,8 +806,58 @@ pub mod pallet { amount_out: Balance, max_sell_amount: Balance, ) -> DispatchResult { - Self::do_buy(origin, pool_id, asset_out, asset_in, amount_out, max_sell_amount, None) - } + let who = ensure_signed(origin)?; + + ensure!(asset_in != asset_out, Error::::NotAllowed); + + ensure!( + Self::is_asset_allowed(pool_id, asset_in, Tradability::SELL) + && Self::is_asset_allowed(pool_id, asset_out, Tradability::BUY), + Error::::NotAllowed + ); + + ensure!( + amount_out >= T::MinTradingLimit::get(), + Error::::InsufficientTradingAmount + ); + + let pool = Pools::::get(pool_id).ok_or(Error::::PoolNotFound)?; + let pool_account = Self::pool_account(pool_id); + let initial_reserves = pool + .reserves_with_decimals::(&pool_account) + .ok_or(Error::::UnknownDecimals)?; + + let (amount_in, fee_amount) = Self::calculate_in_amount(pool_id, asset_in, asset_out, amount_out)?; + + let pool_account = Self::pool_account(pool_id); + + ensure!(amount_in <= max_sell_amount, Error::::SellLimitExceeded); + + ensure!( + T::Currency::free_balance(asset_in, &who) >= amount_in, + Error::::InsufficientBalance + ); + + T::Currency::transfer(asset_in, &who, &pool_account, amount_in)?; + T::Currency::transfer(asset_out, &pool_account, &who, amount_out)?; + + //All done and updated. Let's call on_trade_hook. + Self::call_on_trade_hook(pool_id, asset_in, asset_out, &initial_reserves)?; + + Self::deposit_event(Event::BuyExecuted { + who, + pool_id, + asset_in, + asset_out, + amount_in, + amount_out, + fee: fee_amount, + }); + + #[cfg(feature = "try-runtime")] + Self::ensure_trade_invariant(pool_id, &initial_reserves, pool.fee); + + Ok(()) } #[pallet::call_index(9)] #[pallet::weight(::WeightInfo::set_asset_tradable_state())] @@ -802,151 +897,6 @@ impl Pallet { PalletId(*b"stblpool").into_account_truncating() } - fn do_sell( - origin: OriginFor, - pool_id: T::AssetId, - asset_in: T::AssetId, - asset_out: T::AssetId, - amount_in: Balance, - min_buy_amount: Balance, - event_id: Option, - ) -> DispatchResult { - let who = frame_system::ensure_signed(origin)?; - - ensure!(asset_in != asset_out, Error::::NotAllowed); - - ensure!( - Self::is_asset_allowed(pool_id, asset_in, Tradability::SELL) - && Self::is_asset_allowed(pool_id, asset_out, Tradability::BUY), - Error::::NotAllowed - ); - - ensure!( - amount_in >= T::MinTradingLimit::get(), - Error::::InsufficientTradingAmount - ); - - ensure!( - T::Currency::free_balance(asset_in, &who) >= amount_in, - Error::::InsufficientBalance - ); - - let pool = Pools::::get(pool_id).ok_or(Error::::PoolNotFound)?; - let pool_account = Self::pool_account(pool_id); - let initial_reserves = pool - .reserves_with_decimals::(&pool_account) - .ok_or(Error::::UnknownDecimals)?; - - let (amount_out, fee_amount) = Self::calculate_out_amount(pool_id, asset_in, asset_out, amount_in)?; - ensure!(amount_out >= min_buy_amount, Error::::BuyLimitNotReached); - - T::Currency::transfer(asset_in, &who, &pool_account, amount_in)?; - T::Currency::transfer(asset_out, &pool_account, &who, amount_out)?; - - //All done and updated. Let's call on_trade hook. - Self::call_on_trade_hook(pool_id, asset_in, asset_out, &initial_reserves)?; - - // TODO: Deprecated, remove when ready - Self::deposit_event(Event::SellExecuted { - who: who.clone(), - pool_id, - asset_in, - asset_out, - amount_in, - amount_out, - fee: fee_amount, - }); - - pallet_amm_support::Pallet::::deposit_trade_event( - who, - pool_account.clone(), - pallet_amm_support::Filler::Stableswap(pool_id.clone().into()), - pallet_amm_support::TradeOperation::ExactIn, - vec![(AssetType::Fungible(asset_in.into()), amount_in)], - vec![(AssetType::Fungible(asset_out.into()), amount_out)], - vec![Fee{ asset: asset_out.into(), amount: fee_amount, recipient: pool_account}], - ); - - #[cfg(feature = "try-runtime")] - Self::ensure_trade_invariant(pool_id, &initial_reserves, pool.fee); - - Ok(()) - } - - fn do_buy( - origin: OriginFor, - pool_id: T::AssetId, - asset_out: T::AssetId, - asset_in: T::AssetId, - amount_out: Balance, - max_sell_amount: Balance, - event_id: Option, - ) -> DispatchResult { - let who = ensure_signed(origin)?; - - ensure!(asset_in != asset_out, Error::::NotAllowed); - - ensure!( - Self::is_asset_allowed(pool_id, asset_in, Tradability::SELL) - && Self::is_asset_allowed(pool_id, asset_out, Tradability::BUY), - Error::::NotAllowed - ); - - ensure!( - amount_out >= T::MinTradingLimit::get(), - Error::::InsufficientTradingAmount - ); - - let pool = Pools::::get(pool_id).ok_or(Error::::PoolNotFound)?; - let pool_account = Self::pool_account(pool_id); - let initial_reserves = pool - .reserves_with_decimals::(&pool_account) - .ok_or(Error::::UnknownDecimals)?; - - let (amount_in, fee_amount) = Self::calculate_in_amount(pool_id, asset_in, asset_out, amount_out)?; - - let pool_account = Self::pool_account(pool_id); - - ensure!(amount_in <= max_sell_amount, Error::::SellLimitExceeded); - - ensure!( - T::Currency::free_balance(asset_in, &who) >= amount_in, - Error::::InsufficientBalance - ); - - T::Currency::transfer(asset_in, &who, &pool_account, amount_in)?; - T::Currency::transfer(asset_out, &pool_account, &who, amount_out)?; - - //All done and updated. Let's call on_trade_hook. - Self::call_on_trade_hook(pool_id, asset_in, asset_out, &initial_reserves)?; - - // TODO: Deprecated, remove when ready - Self::deposit_event(Event::BuyExecuted { - who: who.clone(), - pool_id, - asset_in, - asset_out, - amount_in, - amount_out, - fee: fee_amount, - }); - - pallet_amm_support::Pallet::::deposit_trade_event( - who, - pool_account.clone(), - pallet_amm_support::Filler::Stableswap(pool_id.clone().into()), - pallet_amm_support::TradeOperation::ExactOut, - vec![(AssetType::Fungible(asset_in.into()), amount_in)], - vec![(AssetType::Fungible(asset_out.into()), amount_out)], - vec![Fee{ asset: asset_in.into(), amount: fee_amount, recipient: pool_account}], - ); - - #[cfg(feature = "try-runtime")] - Self::ensure_trade_invariant(pool_id, &initial_reserves, pool.fee); - - Ok(()) - } - /// Calculates out amount given in amount. /// Returns (out_amount, fee_amount) on success. Note that fee amount is already subtracted from the out amount. fn calculate_out_amount( diff --git a/pallets/stableswap/src/trade_execution.rs b/pallets/stableswap/src/trade_execution.rs index 7dbf6142c..53d54e25a 100644 --- a/pallets/stableswap/src/trade_execution.rs +++ b/pallets/stableswap/src/trade_execution.rs @@ -3,12 +3,11 @@ use crate::{Balance, Config, Error, Pallet, Pools, D_ITERATIONS, Y_ITERATIONS}; use hydra_dx_math::stableswap::types::AssetReserve; use hydradx_traits::router::{ExecutorError, PoolType, TradeExecution}; use orml_traits::MultiCurrency; -use pallet_amm_support::IncrementalIdType; use sp_core::Get; use sp_runtime::{ArithmeticError, DispatchError, FixedU128}; use sp_std::vec; -impl TradeExecution for Pallet +impl TradeExecution for Pallet where u32: sp_std::convert::From, sp_std::vec::Vec<(u32, AssetReserve)>: FromIterator<(T::AssetId, AssetReserve)>, @@ -143,7 +142,6 @@ where asset_out: T::AssetId, amount_in: Balance, min_limit: Balance, - event_id: Option, ) -> Result<(), ExecutorError> { match pool_type { PoolType::Stableswap(pool_id) => { @@ -161,8 +159,7 @@ where ) .map_err(ExecutorError::Error) } else { - Self::do_sell(who, pool_id, asset_in, asset_out, amount_in, min_limit, event_id) - .map_err(ExecutorError::Error) + Self::sell(who, pool_id, asset_in, asset_out, amount_in, min_limit).map_err(ExecutorError::Error) } } _ => Err(ExecutorError::NotSupported), @@ -176,7 +173,6 @@ where asset_out: T::AssetId, amount_out: Balance, max_limit: Balance, - event_id: Option, ) -> Result<(), ExecutorError> { match pool_type { PoolType::Stableswap(pool_id) => { @@ -187,8 +183,7 @@ where Self::withdraw_asset_amount(who, pool_id, asset_out, amount_out, max_limit) .map_err(ExecutorError::Error) } else { - Self::do_buy(who, pool_id, asset_out, asset_in, amount_out, max_limit, event_id) - .map_err(ExecutorError::Error) + Self::buy(who, pool_id, asset_out, asset_in, amount_out, max_limit).map_err(ExecutorError::Error) } } _ => Err(ExecutorError::NotSupported), diff --git a/pallets/xyk-liquidity-mining/src/lib.rs b/pallets/xyk-liquidity-mining/src/lib.rs index 5bc81871e..4ae443483 100644 --- a/pallets/xyk-liquidity-mining/src/lib.rs +++ b/pallets/xyk-liquidity-mining/src/lib.rs @@ -112,7 +112,7 @@ pub mod pallet { type Currencies: MultiCurrency; /// AMM helper functions. - type AMM: AMM + type AMM: AMM + AMMPosition; /// The origin account that can create new liquidity mining program. diff --git a/pallets/xyk-liquidity-mining/src/tests/mock.rs b/pallets/xyk-liquidity-mining/src/tests/mock.rs index fcddf9bd5..42fa78d51 100644 --- a/pallets/xyk-liquidity-mining/src/tests/mock.rs +++ b/pallets/xyk-liquidity-mining/src/tests/mock.rs @@ -31,7 +31,7 @@ use hydradx_traits::{pools::DustRemovalAccountWhitelist, AMMPosition, AMMTransfe use orml_traits::parameter_type_with_key; use pallet_liquidity_mining::{FarmMultiplier, YieldFarmId}; use pallet_xyk::types::{AssetId, AssetPair, Balance}; -use primitives::{Amount, IncrementalId, ItemId}; +use primitives::{Amount, ItemId}; use sp_core::H256; use sp_runtime::{ traits::{BlakeTwo256, BlockNumberProvider, IdentityLookup}, @@ -238,14 +238,12 @@ impl AMM for DummyAMM { fn execute_buy( _transfer: &AMMTransfer, _destination: Option<&AccountId>, - _event_id: Option, ) -> dispatch::DispatchResult { Err(sp_runtime::DispatchError::Other("NotImplemented")) } fn execute_sell( _transfer: &hydradx_traits::AMMTransfer, - _event_id: Option, ) -> frame_support::dispatch::DispatchResult { Err(sp_runtime::DispatchError::Other("NotImplemented")) } diff --git a/pallets/xyk/src/lib.rs b/pallets/xyk/src/lib.rs index f15200f68..9e0717603 100644 --- a/pallets/xyk/src/lib.rs +++ b/pallets/xyk/src/lib.rs @@ -41,7 +41,6 @@ use sp_std::{vec, vec::Vec}; use crate::types::{Amount, AssetId, AssetPair, Balance}; use hydra_dx_math::ratio::Ratio; use orml_traits::{MultiCurrency, MultiCurrencyExtended}; -use pallet_amm_support::IncrementalIdType; #[cfg(test)] mod tests; @@ -644,14 +643,7 @@ pub mod pallet { ) -> DispatchResult { let who = ensure_signed(origin)?; - >::sell( - &who, - AssetPair { asset_in, asset_out }, - amount, - max_limit, - discount, - None, - )?; + >::sell(&who, AssetPair { asset_in, asset_out }, amount, max_limit, discount)?; Ok(()) } @@ -675,14 +667,7 @@ pub mod pallet { ) -> DispatchResult { let who = ensure_signed(origin)?; - >::buy( - &who, - AssetPair { asset_in, asset_out }, - amount, - max_limit, - discount, - None, - )?; + >::buy(&who, AssetPair { asset_in, asset_out }, amount, max_limit, discount)?; Ok(()) } @@ -723,7 +708,7 @@ impl Pallet { } // Implementation of AMM API which makes possible to plug the AMM pool into the exchange pallet. -impl AMM for Pallet { +impl AMM for Pallet { fn exists(assets: AssetPair) -> bool { >::contains_key(&Self::get_pair_id(assets)) } @@ -874,7 +859,6 @@ impl AMM, - event_id: Option, ) -> DispatchResult { let pair_account = Self::get_pair_id(transfer.assets); @@ -1051,7 +1035,6 @@ impl AMM, destination: Option<&T::AccountId>, - event_id: Option, ) -> DispatchResult { let pair_account = Self::get_pair_id(transfer.assets); diff --git a/pallets/xyk/src/trade_execution.rs b/pallets/xyk/src/trade_execution.rs index 967ad8a8c..3cdb2f22b 100644 --- a/pallets/xyk/src/trade_execution.rs +++ b/pallets/xyk/src/trade_execution.rs @@ -5,11 +5,10 @@ use frame_support::traits::Get; use hydradx_traits::router::{ExecutorError, PoolType, TradeExecution}; use hydradx_traits::AMM; use orml_traits::MultiCurrency; -use pallet_amm_support::IncrementalIdType; use sp_runtime::DispatchError::Corruption; use sp_runtime::{ArithmeticError, DispatchError, FixedPointNumber, FixedU128}; -impl TradeExecution for Pallet { +impl TradeExecution for Pallet { type Error = DispatchError; fn calculate_sell( @@ -101,25 +100,12 @@ impl TradeExecution, ) -> Result<(), ExecutorError> { if pool_type != PoolType::XYK { return Err(ExecutorError::NotSupported); } - let who = crate::ensure_signed(who).map_err(|e| ExecutorError::Error(e.into()))?; - - >::sell( - &who, - AssetPair { asset_in, asset_out }, - amount_in, - min_limit, - false, - event_id, - ) - .map_err(ExecutorError::Error)?; - - Ok(()) + Self::sell(who, asset_in, asset_out, amount_in, min_limit, false).map_err(ExecutorError::Error) } fn execute_buy( @@ -129,25 +115,12 @@ impl TradeExecution, ) -> Result<(), ExecutorError> { if pool_type != PoolType::XYK { return Err(ExecutorError::NotSupported); } - let who = crate::ensure_signed(who).map_err(|e| ExecutorError::Error(e.into()))?; - - >::buy( - &who, - AssetPair { asset_in, asset_out }, - amount_out, - max_limit, - false, - event_id, - ) - .map_err(ExecutorError::Error)?; - - Ok(()) + Self::buy(who, asset_out, asset_in, amount_out, max_limit, false).map_err(ExecutorError::Error) } fn get_liquidity_depth( diff --git a/traits/src/lib.rs b/traits/src/lib.rs index 60f4d2942..dfc6477e5 100644 --- a/traits/src/lib.rs +++ b/traits/src/lib.rs @@ -54,7 +54,7 @@ pub struct AMMTransfer { } /// Traits for handling AMM Pool trades. -pub trait AMM { +pub trait AMM { /// Check if both assets exist in a pool. fn exists(assets: AssetPair) -> bool; @@ -83,7 +83,6 @@ pub trait AMM { /// Execute buy for given validated transfer. fn execute_sell( transfer: &AMMTransfer, - event_id: Option, ) -> dispatch::DispatchResult; /// Perform asset swap. @@ -94,11 +93,9 @@ pub trait AMM { amount: Amount, min_bought: Amount, discount: bool, - event_id: Option, ) -> dispatch::DispatchResult { Self::execute_sell( &Self::validate_sell(origin, assets, amount, min_bought, discount)?, - event_id, )?; Ok(()) @@ -118,7 +115,6 @@ pub trait AMM { fn execute_buy( transfer: &AMMTransfer, destination: Option<&AccountId>, - event_id: Option, ) -> dispatch::DispatchResult; /// Perform asset swap. @@ -128,12 +124,10 @@ pub trait AMM { amount: Amount, max_limit: Amount, discount: bool, - event_id: Option, ) -> dispatch::DispatchResult { Self::execute_buy( &Self::validate_buy(origin, assets, amount, max_limit, discount)?, None, - event_id, )?; Ok(()) @@ -151,7 +145,6 @@ pub trait AMM { Self::execute_buy( &Self::validate_buy(origin, assets, amount, max_limit, discount)?, Some(dest), - None, )?; Ok(()) } diff --git a/traits/src/router.rs b/traits/src/router.rs index eaa0dd6b7..7ca85ea81 100644 --- a/traits/src/router.rs +++ b/traits/src/router.rs @@ -197,7 +197,7 @@ pub trait RouterT { } /// All AMMs used in the router are required to implement this trait. -pub trait TradeExecution { +pub trait TradeExecution { type Error; fn calculate_sell( @@ -221,7 +221,6 @@ pub trait TradeExecution { asset_out: AssetId, amount_in: Balance, min_limit: Balance, - event_id: Option, ) -> Result<(), ExecutorError>; fn execute_buy( @@ -231,7 +230,6 @@ pub trait TradeExecution { asset_out: AssetId, amount_out: Balance, max_limit: Balance, - event_id: Option, ) -> Result<(), ExecutorError>; fn get_liquidity_depth( @@ -249,10 +247,10 @@ pub trait TradeExecution { #[allow(clippy::redundant_clone)] //Needed as it complains about redundant clone, but clone is needed as Origin is moved and it is not copy type. #[impl_trait_for_tuples::impl_for_tuples(1, 5)] -impl - TradeExecution for Tuple +impl + TradeExecution for Tuple { - for_tuples!( where #(Tuple: TradeExecution)*); + for_tuples!( where #(Tuple: TradeExecution)*); type Error = E; fn calculate_sell( @@ -298,11 +296,10 @@ impl, ) -> Result<(), ExecutorError> { for_tuples!( #( - let value = match Tuple::execute_sell(who.clone(),pool_type, asset_in, asset_out, amount_in, min_limit, event_id) { + let value = match Tuple::execute_sell(who.clone(),pool_type, asset_in, asset_out, amount_in, min_limit) { Ok(result) => return Ok(result), Err(v) if v == ExecutorError::NotSupported => v, Err(v) => return Err(v), @@ -319,11 +316,10 @@ impl, ) -> Result<(), ExecutorError> { for_tuples!( #( - let value = match Tuple::execute_buy(who.clone(), pool_type,asset_in, asset_out, amount_out, max_limit, event_id) { + let value = match Tuple::execute_buy(who.clone(), pool_type,asset_in, asset_out, amount_out, max_limit) { Ok(result) => return Ok(result), Err(v) if v == ExecutorError::NotSupported => v, Err(v) => return Err(v), From c083ebf78ce21c9a252e5e3fd9221e3d0f6efcda Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Tue, 5 Nov 2024 13:48:25 +0100 Subject: [PATCH 029/142] formatting --- integration-tests/src/polkadot_test_net.rs | 2 +- integration-tests/src/router.rs | 246 ++++++++++-------- pallets/amm-support/src/lib.rs | 21 +- .../amm-support/src/tests/incremental_id.rs | 60 ++++- pallets/amm-support/src/tests/mock.rs | 2 +- pallets/lbp/src/lib.rs | 27 +- pallets/omnipool/src/lib.rs | 40 ++- pallets/otc/src/lib.rs | 17 +- pallets/route-executor/src/lib.rs | 3 +- pallets/stableswap/src/lib.rs | 10 +- pallets/xyk/src/lib.rs | 19 +- traits/src/lib.rs | 13 +- traits/src/router.rs | 22 +- 13 files changed, 297 insertions(+), 185 deletions(-) diff --git a/integration-tests/src/polkadot_test_net.rs b/integration-tests/src/polkadot_test_net.rs index 5298d3250..b041f0589 100644 --- a/integration-tests/src/polkadot_test_net.rs +++ b/integration-tests/src/polkadot_test_net.rs @@ -19,7 +19,7 @@ use hydradx_runtime::{evm::WETH_ASSET_LOCATION, Referrals, RuntimeOrigin}; pub use hydradx_traits::{ evm::InspectEvmAccounts, registry::Mutate, - router::{Filler, AssetType, TradeOperation, ExecutionType, Fee}, + router::{AssetType, ExecutionType, Fee, Filler, TradeOperation}, }; use pallet_referrals::{FeeDistribution, Level}; pub use polkadot_primitives::v6::{BlockNumber, MAX_CODE_SIZE, MAX_POV_SIZE}; diff --git a/integration-tests/src/router.rs b/integration-tests/src/router.rs index a95dc1672..1450edc26 100644 --- a/integration-tests/src/router.rs +++ b/integration-tests/src/router.rs @@ -160,11 +160,13 @@ mod router_different_pools_tests { operation: pallet_amm_support::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(DAI), 9980000000)], outputs: vec![(AssetType::Fungible(LRNA), 5640664064)], - fees: vec![ - Fee::new(DAI, 20000000, LBP::pool_data(LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA))) + fees: vec![Fee::new( + DAI, + 20000000, + LBP::pool_data(LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA))) .unwrap() - .fee_collector), - ], + .fee_collector, + )], operation_id: vec![ExecutionType::Router(0)], } .into(), @@ -175,9 +177,7 @@ mod router_different_pools_tests { operation: pallet_amm_support::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(LRNA), 5640664064)], outputs: vec![(AssetType::Fungible(HDX), 4682924837974)], - fees: vec![ - Fee::new(HDX, 11736653730, Omnipool::protocol_account()), - ], + fees: vec![Fee::new(HDX, 11736653730, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Router(0)], } .into(), @@ -187,19 +187,23 @@ mod router_different_pools_tests { asset_in: HDX, asset_out: DOT, }), - filler_type: pallet_amm_support::Filler::XYK(XYK::share_token(XYK::get_pair_id(pallet_xyk::types::AssetPair { - asset_in: HDX, - asset_out: DOT, - }))), + filler_type: pallet_amm_support::Filler::XYK(XYK::share_token(XYK::get_pair_id( + pallet_xyk::types::AssetPair { + asset_in: HDX, + asset_out: DOT, + }, + ))), operation: pallet_amm_support::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(HDX), 4682924837974)], outputs: vec![(AssetType::Fungible(DOT), 2230008413831)], - fees: vec![ - Fee::new(DOT, 6710155707, XYK::get_pair_id(pallet_xyk::types::AssetPair { + fees: vec![Fee::new( + DOT, + 6710155707, + XYK::get_pair_id(pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: DOT, - })), - ], + }), + )], operation_id: vec![ExecutionType::Router(0)], } .into(), @@ -279,11 +283,13 @@ mod router_different_pools_tests { operation: TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(DAI), 9980000000)], outputs: vec![(AssetType::Fungible(HDX), 5640664064)], - fees: vec![ - Fee::new(DAI, 20000000, LBP::pool_data(LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX))) + fees: vec![Fee::new( + DAI, + 20000000, + LBP::pool_data(LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX))) .unwrap() - .fee_collector), - ], + .fee_collector, + )], operation_id: vec![ExecutionType::Router(0)], } .into(), @@ -293,19 +299,23 @@ mod router_different_pools_tests { asset_in: HDX, asset_out: stable_asset_1, }), - filler_type: pallet_amm_support::Filler::XYK(XYK::share_token(XYK::get_pair_id(pallet_xyk::types::AssetPair { - asset_in: HDX, - asset_out: stable_asset_1, - }))), + filler_type: pallet_amm_support::Filler::XYK(XYK::share_token(XYK::get_pair_id( + pallet_xyk::types::AssetPair { + asset_in: HDX, + asset_out: stable_asset_1, + }, + ))), operation: pallet_amm_support::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(HDX), 5640664064)], outputs: vec![(AssetType::Fungible(stable_asset_1), 2811712439)], - fees: vec![ - Fee::new(stable_asset_1, 8460516, XYK::get_pair_id(pallet_xyk::types::AssetPair { + fees: vec![Fee::new( + stable_asset_1, + 8460516, + XYK::get_pair_id(pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: stable_asset_1, - })), - ], + }), + )], operation_id: vec![ExecutionType::Router(0)], } .into(), @@ -319,12 +329,14 @@ mod router_different_pools_tests { operation: TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(stable_asset_1), 2811712439)], outputs: vec![(AssetType::Fungible(stable_asset_2), 2783595233)], - fees: vec![ - Fee::new(stable_asset_2, 28117123, ::ShareAccountId::from_assets( + fees: vec![Fee::new( + stable_asset_2, + 28117123, + ::ShareAccountId::from_assets( &stable_pool_id, Some(pallet_stableswap::POOL_IDENTIFIER), - )), - ], + ), + )], operation_id: vec![ExecutionType::Router(0)], } .into(), @@ -399,14 +411,16 @@ mod router_different_pools_tests { filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA)), filler_type: pallet_amm_support::Filler::LBP, operation: pallet_amm_support::TradeOperation::ExactOut, - inputs: vec![(AssetType::Fungible(DAI), 4362157193)], - outputs: vec![(AssetType::Fungible(LRNA), 2465566245)], - fees: vec![ - Fee::new(DAI, 8741796, LBP::pool_data(LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA))) + inputs: vec![(AssetType::Fungible(DAI), 4362157193)], + outputs: vec![(AssetType::Fungible(LRNA), 2465566245)], + fees: vec![Fee::new( + DAI, + 8741796, + LBP::pool_data(LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA))) .unwrap() - .fee_collector), - ], - operation_id: vec![ExecutionType::Router(0)], + .fee_collector, + )], + operation_id: vec![ExecutionType::Router(0)], } .into(), pallet_amm_support::Event::Swapped { @@ -416,9 +430,7 @@ mod router_different_pools_tests { operation: pallet_amm_support::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(LRNA), 2465566245)], outputs: vec![(AssetType::Fungible(HDX), 2046938775509)], - fees: vec![ - Fee::new(HDX, 5130172370, Omnipool::protocol_account()), - ], + fees: vec![Fee::new(HDX, 5130172370, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Router(0)], } .into(), @@ -428,19 +440,23 @@ mod router_different_pools_tests { asset_in: HDX, asset_out: DOT, }), - filler_type: pallet_amm_support::Filler::XYK(XYK::share_token(XYK::get_pair_id(pallet_xyk::types::AssetPair { - asset_in: HDX, - asset_out: DOT, - }))), + filler_type: pallet_amm_support::Filler::XYK(XYK::share_token(XYK::get_pair_id( + pallet_xyk::types::AssetPair { + asset_in: HDX, + asset_out: DOT, + }, + ))), operation: pallet_amm_support::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(HDX), 1000000000000)], outputs: vec![(AssetType::Fungible(DOT), 2040816326531)], - fees: vec![ - Fee::new(HDX, 6122448978, XYK::get_pair_id(pallet_xyk::types::AssetPair { + fees: vec![Fee::new( + HDX, + 6122448978, + XYK::get_pair_id(pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: DOT, - })), - ], + }), + )], operation_id: vec![ExecutionType::Router(0)], } .into(), @@ -520,11 +536,13 @@ mod router_different_pools_tests { operation: pallet_amm_support::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(DAI), 3746042043754)], outputs: vec![(AssetType::Fungible(HDX), 2067851065323)], - fees: vec![ - Fee::new(DAI, 7507098284, LBP::pool_data(LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX))) + fees: vec![Fee::new( + DAI, + 7507098284, + LBP::pool_data(LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX))) .unwrap() - .fee_collector), - ], + .fee_collector, + )], operation_id: vec![ExecutionType::Router(0)], } .into(), @@ -534,19 +552,23 @@ mod router_different_pools_tests { asset_in: HDX, asset_out: stable_asset_1, }), - filler_type: pallet_amm_support::Filler::XYK(XYK::share_token(XYK::get_pair_id(pallet_xyk::types::AssetPair { - asset_in: HDX, - asset_out: stable_asset_1, - }))), + filler_type: pallet_amm_support::Filler::XYK(XYK::share_token(XYK::get_pair_id( + pallet_xyk::types::AssetPair { + asset_in: HDX, + asset_out: stable_asset_1, + }, + ))), operation: pallet_amm_support::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(HDX), 1010010000114)], outputs: vec![(AssetType::Fungible(stable_asset_1), 2061666067122)], - fees: vec![ - Fee::new(HDX, 6184998201, XYK::get_pair_id(pallet_xyk::types::AssetPair { + fees: vec![Fee::new( + HDX, + 6184998201, + XYK::get_pair_id(pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: stable_asset_1, - })), - ], + }), + )], operation_id: vec![ExecutionType::Router(0)], } .into(), @@ -560,12 +582,14 @@ mod router_different_pools_tests { operation: pallet_amm_support::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(stable_asset_1), 1010010000114)], outputs: vec![(AssetType::Fungible(stable_asset_2), 1000000000000)], - fees: vec![ - Fee::new(stable_asset_1, 10000099012, ::ShareAccountId::from_assets( + fees: vec![Fee::new( + stable_asset_1, + 10000099012, + ::ShareAccountId::from_assets( &stable_pool_id, Some(pallet_stableswap::POOL_IDENTIFIER), - )), - ], + ), + )], operation_id: vec![ExecutionType::Router(0)], } .into(), @@ -636,20 +660,24 @@ mod router_different_pools_tests { asset_in: HDX, asset_out: DOT, }), - filler_type: pallet_amm_support::Filler::XYK(XYK::share_token(XYK::get_pair_id(pallet_xyk::types::AssetPair { - asset_in: HDX, - asset_out: DOT, - }))), + filler_type: pallet_amm_support::Filler::XYK(XYK::share_token(XYK::get_pair_id( + pallet_xyk::types::AssetPair { + asset_in: HDX, + asset_out: DOT, + }, + ))), operation: pallet_amm_support::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(HDX), 10000000000)], - outputs: vec![(AssetType::Fungible(DOT), 4984501549)], - fees: vec![ - Fee::new(DOT, 14998500, XYK::get_pair_id(pallet_xyk::types::AssetPair { + outputs: vec![(AssetType::Fungible(DOT), 4984501549)], + fees: vec![Fee::new( + DOT, + 14998500, + XYK::get_pair_id(pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: DOT, - })), - ], - operation_id: vec![ExecutionType::Router(0)], + }), + )], + operation_id: vec![ExecutionType::Router(0)], } .into(), pallet_amm_support::Event::Swapped { @@ -658,20 +686,24 @@ mod router_different_pools_tests { asset_in: HDX, asset_out: DOT, }), - filler_type: pallet_amm_support::Filler::XYK(XYK::share_token(XYK::get_pair_id(pallet_xyk::types::AssetPair { - asset_in: HDX, - asset_out: DOT, - }))), + filler_type: pallet_amm_support::Filler::XYK(XYK::share_token(XYK::get_pair_id( + pallet_xyk::types::AssetPair { + asset_in: HDX, + asset_out: DOT, + }, + ))), operation: pallet_amm_support::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(HDX), 10000000000)], - outputs: vec![(AssetType::Fungible(DOT), 20007996198)], - fees: vec![ - Fee::new(HDX, 60023988, XYK::get_pair_id(pallet_xyk::types::AssetPair { + outputs: vec![(AssetType::Fungible(DOT), 20007996198)], + fees: vec![Fee::new( + HDX, + 60023988, + XYK::get_pair_id(pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: DOT, - })), - ], - operation_id: vec![ExecutionType::Router(1)], + }), + )], + operation_id: vec![ExecutionType::Router(1)], } .into(), pallet_amm_support::Event::Swapped { @@ -680,19 +712,23 @@ mod router_different_pools_tests { asset_in: HDX, asset_out: DOT, }), - filler_type: pallet_amm_support::Filler::XYK(XYK::share_token(XYK::get_pair_id(pallet_xyk::types::AssetPair { - asset_in: HDX, - asset_out: DOT, - }))), + filler_type: pallet_amm_support::Filler::XYK(XYK::share_token(XYK::get_pair_id( + pallet_xyk::types::AssetPair { + asset_in: HDX, + asset_out: DOT, + }, + ))), operation: pallet_amm_support::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(HDX), 10000000000)], outputs: vec![(AssetType::Fungible(DOT), 4981510054)], - fees: vec![ - Fee::new(DOT, 14989497, XYK::get_pair_id(pallet_xyk::types::AssetPair { - asset_in: HDX, - asset_out: DOT, - })), - ], + fees: vec![Fee::new( + DOT, + 14989497, + XYK::get_pair_id(pallet_xyk::types::AssetPair { + asset_in: HDX, + asset_out: DOT, + }), + )], operation_id: vec![ExecutionType::Router(2)], } .into(), @@ -2930,11 +2966,13 @@ mod lbp_router_tests { operation: pallet_amm_support::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(HDX), amount_to_sell - fee)], outputs: vec![(AssetType::Fungible(DAI), received_amount_out)], - fees: vec![ - Fee::new(HDX, fee, LBP::pool_data(LBP::get_pair_id(pallet_lbp::types::AssetPair::new(HDX, DAI))) + fees: vec![Fee::new( + HDX, + fee, + LBP::pool_data(LBP::get_pair_id(pallet_lbp::types::AssetPair::new(HDX, DAI))) .unwrap() - .fee_collector), - ], + .fee_collector, + )], operation_id: vec![ExecutionType::Router(0)], } .into(), @@ -2984,11 +3022,13 @@ mod lbp_router_tests { operation: pallet_amm_support::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(HDX), 9_980_000_000_000)], outputs: vec![(AssetType::Fungible(DAI), received_amount_out)], - fees: vec![ - Fee::new(HDX, 20_000_000_000, LBP::pool_data(LBP::get_pair_id(pallet_lbp::types::AssetPair::new(HDX, DAI))) + fees: vec![Fee::new( + HDX, + 20_000_000_000, + LBP::pool_data(LBP::get_pair_id(pallet_lbp::types::AssetPair::new(HDX, DAI))) .unwrap() - .fee_collector), - ], + .fee_collector, + )], operation_id: vec![], } .into(), diff --git a/pallets/amm-support/src/lib.rs b/pallets/amm-support/src/lib.rs index e6107079b..e2a63f0f9 100644 --- a/pallets/amm-support/src/lib.rs +++ b/pallets/amm-support/src/lib.rs @@ -21,17 +21,17 @@ type AssetId = u32; type Balance = u128; use codec::{Decode, Encode, MaxEncodedLen}; -use scale_info::TypeInfo; -use frame_support::sp_runtime::{ArithmeticError, BoundedVec, DispatchError, DispatchResult}; use frame_support::sp_runtime::app_crypto::sp_core; +use frame_support::sp_runtime::{ArithmeticError, BoundedVec, DispatchError, DispatchResult}; pub use hydradx_traits::{ - router::{AssetType, ExecutionType, ExecutionTypeStack, Fee, Filler, TradeOperation, OtcOrderId}, + router::{AssetType, ExecutionType, ExecutionTypeStack, Fee, Filler, OtcOrderId, TradeOperation}, IncrementalIdProvider, }; -use sp_std::vec::Vec; -use sp_core::{ConstU32, RuntimeDebug}; pub use primitives::IncrementalId as IncrementalIdType; use primitives::ItemId as NftId; +use scale_info::TypeInfo; +use sp_core::{ConstU32, RuntimeDebug}; +use sp_std::vec::Vec; #[cfg(test)] mod tests; @@ -44,11 +44,11 @@ pub const MAX_STACK_SIZE: u32 = 10; #[derive(RuntimeDebug, Encode, Decode, Default, Clone, PartialEq, Eq, TypeInfo, MaxEncodedLen)] pub struct ExecutionIdStack(BoundedVec, ConstU32>); impl ExecutionIdStack { - fn push(& mut self, execution_type: ExecutionType) -> Result<(), ()> { + fn push(&mut self, execution_type: ExecutionType) -> Result<(), ()> { self.0.try_push(execution_type).map_err(|_| ()) } - fn pop(& mut self) -> Result, ()> { + fn pop(&mut self) -> Result, ()> { self.0.pop().ok_or(()) } @@ -152,15 +152,16 @@ impl Pallet { impl ExecutionTypeStack for Pallet { fn push(execution_type: ExecutionType) -> DispatchResult { IdStack::::try_mutate(|stack| -> DispatchResult { - stack.push(execution_type).map_err(|_| Error::::MaxStackSizeReached.into()) + stack + .push(execution_type) + .map_err(|_| Error::::MaxStackSizeReached.into()) }) } fn pop() -> Result, DispatchError> { IdStack::::try_mutate(|stack| -> Result, DispatchError> { stack.pop().map_err(|_| Error::::EmptyStack.into()) - } - ) + }) } fn get() -> Vec> { diff --git a/pallets/amm-support/src/tests/incremental_id.rs b/pallets/amm-support/src/tests/incremental_id.rs index 2395920dd..7be17510e 100644 --- a/pallets/amm-support/src/tests/incremental_id.rs +++ b/pallets/amm-support/src/tests/incremental_id.rs @@ -41,12 +41,32 @@ fn stack_should_be_populated_when_pushed() { assert_eq!(AmmSupport::id_stack().0.into_inner(), vec![ExecutionType::Router(1)]); assert_ok!(AmmSupport::push(ExecutionType::Router(2))); - assert_eq!(AmmSupport::get(), vec![ExecutionType::Router(1), ExecutionType::Router(2)]); - assert_eq!(AmmSupport::id_stack().0.into_inner(), vec![ExecutionType::Router(1), ExecutionType::Router(2)]); + assert_eq!( + AmmSupport::get(), + vec![ExecutionType::Router(1), ExecutionType::Router(2)] + ); + assert_eq!( + AmmSupport::id_stack().0.into_inner(), + vec![ExecutionType::Router(1), ExecutionType::Router(2)] + ); assert_ok!(AmmSupport::push(ExecutionType::ICE(3))); - assert_eq!(AmmSupport::get(), vec![ExecutionType::Router(1), ExecutionType::Router(2), ExecutionType::ICE(3)]); - assert_eq!(AmmSupport::id_stack().0.into_inner(), vec![ExecutionType::Router(1), ExecutionType::Router(2), ExecutionType::ICE(3)]); + assert_eq!( + AmmSupport::get(), + vec![ + ExecutionType::Router(1), + ExecutionType::Router(2), + ExecutionType::ICE(3) + ] + ); + assert_eq!( + AmmSupport::id_stack().0.into_inner(), + vec![ + ExecutionType::Router(1), + ExecutionType::Router(2), + ExecutionType::ICE(3) + ] + ); }); } @@ -72,21 +92,39 @@ fn stack_should_be_reduced_when_poped() { assert_ok!(AmmSupport::push(ExecutionType::ICE(3))); assert_ok!(AmmSupport::pop(), ExecutionType::ICE(3)); - assert_eq!(AmmSupport::get(), vec![ExecutionType::Router(1), ExecutionType::Router(2)]); - assert_eq!(AmmSupport::id_stack().0.into_inner(), vec![ExecutionType::Router(1), ExecutionType::Router(2)]); + assert_eq!( + AmmSupport::get(), + vec![ExecutionType::Router(1), ExecutionType::Router(2)] + ); + assert_eq!( + AmmSupport::id_stack().0.into_inner(), + vec![ExecutionType::Router(1), ExecutionType::Router(2)] + ); assert_ok!(AmmSupport::push(ExecutionType::ICE(3))); - assert_eq!(AmmSupport::get(), vec![ExecutionType::Router(1), ExecutionType::Router(2), ExecutionType::ICE(3)]); - assert_eq!(AmmSupport::id_stack().0.into_inner(), vec![ExecutionType::Router(1), ExecutionType::Router(2), ExecutionType::ICE(3)]); + assert_eq!( + AmmSupport::get(), + vec![ + ExecutionType::Router(1), + ExecutionType::Router(2), + ExecutionType::ICE(3) + ] + ); + assert_eq!( + AmmSupport::id_stack().0.into_inner(), + vec![ + ExecutionType::Router(1), + ExecutionType::Router(2), + ExecutionType::ICE(3) + ] + ); }); } #[test] fn pop_from_empty_stack_should_not_panic() { ExtBuilder::default().build().execute_with(|| { - assert_err!(AmmSupport::pop(), - Error::::EmptyStack - ); + assert_err!(AmmSupport::pop(), Error::::EmptyStack); }); } diff --git a/pallets/amm-support/src/tests/mock.rs b/pallets/amm-support/src/tests/mock.rs index 468c21151..780ad9cfa 100644 --- a/pallets/amm-support/src/tests/mock.rs +++ b/pallets/amm-support/src/tests/mock.rs @@ -19,7 +19,7 @@ use crate as pallet_amm_support; pub use crate::*; pub use frame_support::{ - assert_ok, assert_err, construct_runtime, + assert_err, assert_ok, construct_runtime, sp_runtime::{ traits::{BlakeTwo256, IdentityLookup}, BuildStorage, diff --git a/pallets/lbp/src/lib.rs b/pallets/lbp/src/lib.rs index ef39fc18a..cdbfbc8e3 100644 --- a/pallets/lbp/src/lib.rs +++ b/pallets/lbp/src/lib.rs @@ -36,8 +36,9 @@ use frame_support::{ use frame_system::ensure_signed; use frame_system::pallet_prelude::BlockNumberFor; use hydra_dx_math::types::LBPWeight; -use hydradx_traits::{AMMTransfer, AssetPairAccountIdFor, CanCreatePool, LockedBalance, AMM, +use hydradx_traits::{ router::{AssetType, Fee}, + AMMTransfer, AssetPairAccountIdFor, CanCreatePool, LockedBalance, AMM, }; use orml_traits::{MultiCurrency, MultiCurrencyExtended, MultiLockableCurrency}; @@ -734,13 +735,7 @@ pub mod pallet { ) -> DispatchResult { let who = ensure_signed(origin)?; - >::sell( - &who, - AssetPair { asset_in, asset_out }, - amount, - max_limit, - false, - )?; + >::sell(&who, AssetPair { asset_in, asset_out }, amount, max_limit, false)?; Ok(()) } @@ -1110,9 +1105,7 @@ impl AMM> for Pallet, - ) -> DispatchResult { + fn execute_sell(transfer: &AMMTransfer) -> DispatchResult { Self::execute_trade(transfer)?; // TODO: Deprecated, remove when ready @@ -1136,7 +1129,11 @@ impl AMM> for Pallet AMM> for Pallet Balance::zero(), @@ -1303,7 +1303,7 @@ pub mod pallet { protocol_fee, current_imbalance.value, ) - .ok_or(ArithmeticError::Overflow)?; + .ok_or(ArithmeticError::Overflow)?; ensure!( T::Currency::ensure_can_withdraw(asset_in, &who, *state_changes.asset_in.delta_reserve).is_ok(), @@ -1943,11 +1943,19 @@ impl Pallet { Self::protocol_account(), pallet_amm_support::Filler::Omnipool, pallet_amm_support::TradeOperation::ExactIn, - vec![(AssetType::Fungible(T::HubAssetId::get().into()), *state_changes.asset.delta_hub_reserve)], - vec![(AssetType::Fungible(asset_out.into()), *state_changes.asset.delta_reserve)], - vec![ - Fee{ asset: asset_out.into(), amount: state_changes.fee.asset_fee, recipient: Self::protocol_account()} - ], + vec![( + AssetType::Fungible(T::HubAssetId::get().into()), + *state_changes.asset.delta_hub_reserve, + )], + vec![( + AssetType::Fungible(asset_out.into()), + *state_changes.asset.delta_reserve, + )], + vec![Fee { + asset: asset_out.into(), + amount: state_changes.fee.asset_fee, + recipient: Self::protocol_account(), + }], ); T::OmnipoolHooks::on_hub_asset_trade(origin, info)?; @@ -2063,11 +2071,19 @@ impl Pallet { Self::protocol_account(), pallet_amm_support::Filler::Omnipool, pallet_amm_support::TradeOperation::ExactOut, - vec![(AssetType::Fungible(T::HubAssetId::get().into()), *state_changes.asset.delta_hub_reserve)], - vec![(AssetType::Fungible(asset_out.into()), *state_changes.asset.delta_reserve)], - vec![ - Fee{ asset: asset_out.into(), amount: state_changes.fee.asset_fee, recipient: Self::protocol_account()} - ], + vec![( + AssetType::Fungible(T::HubAssetId::get().into()), + *state_changes.asset.delta_hub_reserve, + )], + vec![( + AssetType::Fungible(asset_out.into()), + *state_changes.asset.delta_reserve, + )], + vec![Fee { + asset: asset_out.into(), + amount: state_changes.fee.asset_fee, + recipient: Self::protocol_account(), + }], ); T::OmnipoolHooks::on_hub_asset_trade(origin, info)?; diff --git a/pallets/otc/src/lib.rs b/pallets/otc/src/lib.rs index f63f0fb10..ddc8986cd 100644 --- a/pallets/otc/src/lib.rs +++ b/pallets/otc/src/lib.rs @@ -37,7 +37,10 @@ use codec::MaxEncodedLen; use frame_support::{pallet_prelude::*, require_transactional}; use frame_system::{ensure_signed, pallet_prelude::OriginFor}; -use hydradx_traits::{Inspect, router::{AssetType, Fee}}; +use hydradx_traits::{ + router::{AssetType, Fee}, + Inspect, +}; use orml_traits::{GetByKey, MultiCurrency, NamedMultiReservableCurrency}; use sp_core::U256; use sp_runtime::traits::{One, Zero}; @@ -316,7 +319,11 @@ pub mod pallet { pallet_amm_support::TradeOperation::ExactIn, vec![(AssetType::Fungible(order.asset_in.into()), amount_in)], vec![(AssetType::Fungible(order.asset_out.into()), amount_out)], - vec![Fee{ asset: order.asset_out.into(), amount: fee, recipient: T::FeeReceiver::get()}], + vec![Fee { + asset: order.asset_out.into(), + amount: fee, + recipient: T::FeeReceiver::get(), + }], ); Ok(()) @@ -358,7 +365,11 @@ pub mod pallet { pallet_amm_support::TradeOperation::ExactIn, vec![(AssetType::Fungible(order.asset_in.into()), order.amount_in)], vec![(AssetType::Fungible(order.asset_out.into()), order.amount_out)], - vec![Fee{ asset: order.asset_out.into(), amount: fee, recipient: T::FeeReceiver::get()}], + vec![Fee { + asset: order.asset_out.into(), + amount: fee, + recipient: T::FeeReceiver::get(), + }], ); Ok(()) diff --git a/pallets/route-executor/src/lib.rs b/pallets/route-executor/src/lib.rs index 69674cb0e..98c998fd5 100644 --- a/pallets/route-executor/src/lib.rs +++ b/pallets/route-executor/src/lib.rs @@ -35,7 +35,8 @@ use frame_system::{ensure_signed, Origin}; use hydradx_traits::registry::Inspect as RegistryInspect; use hydradx_traits::router::{inverse_route, AssetPair, RefundEdCalculator, RouteProvider, RouteSpotPriceProvider}; pub use hydradx_traits::router::{ - AssetType, Fee, ExecutionType, ExecutionTypeStack, AmmTradeWeights, AmountInAndOut, ExecutorError, PoolType, RouterT, Trade, TradeExecution, + AmmTradeWeights, AmountInAndOut, AssetType, ExecutionType, ExecutionTypeStack, ExecutorError, Fee, PoolType, + RouterT, Trade, TradeExecution, }; use hydradx_traits::IncrementalIdProvider; use orml_traits::arithmetic::{CheckedAdd, CheckedSub}; diff --git a/pallets/stableswap/src/lib.rs b/pallets/stableswap/src/lib.rs index 1a64a71d2..553cd4397 100644 --- a/pallets/stableswap/src/lib.rs +++ b/pallets/stableswap/src/lib.rs @@ -59,9 +59,7 @@ use frame_system::{ ensure_signed, pallet_prelude::{BlockNumberFor, OriginFor}, }; -use hydradx_traits::{ - registry::Inspect, AccountIdFor, -}; +use hydradx_traits::{registry::Inspect, AccountIdFor}; pub use pallet::*; use sp_runtime::traits::{AccountIdConversion, BlockNumberProvider, Zero}; use sp_runtime::{ArithmeticError, DispatchError, Permill, SaturatedConversion}; @@ -779,7 +777,8 @@ pub mod pallet { #[cfg(feature = "try-runtime")] Self::ensure_trade_invariant(pool_id, &initial_reserves, pool.fee); - Ok(()) } + Ok(()) + } /// Execute a swap of `asset_in` for `asset_out`. /// @@ -857,7 +856,8 @@ pub mod pallet { #[cfg(feature = "try-runtime")] Self::ensure_trade_invariant(pool_id, &initial_reserves, pool.fee); - Ok(()) } + Ok(()) + } #[pallet::call_index(9)] #[pallet::weight(::WeightInfo::set_asset_tradable_state())] diff --git a/pallets/xyk/src/lib.rs b/pallets/xyk/src/lib.rs index 9e0717603..c991814fa 100644 --- a/pallets/xyk/src/lib.rs +++ b/pallets/xyk/src/lib.rs @@ -33,8 +33,9 @@ use frame_support::{dispatch::DispatchResult, ensure, traits::Get, transactional use frame_system::ensure_signed; use frame_system::pallet_prelude::BlockNumberFor; use hydradx_traits::{ + router::{AssetType, Fee}, AMMPosition, AMMTransfer, AssetPairAccountIdFor, CanCreatePool, OnCreatePoolHandler, OnLiquidityChangedHandler, - OnTradeHandler, AMM, router::{AssetType, Fee}, + OnTradeHandler, AMM, }; use sp_std::{vec, vec::Vec}; @@ -857,9 +858,7 @@ impl AMM for Pallet { /// Perform necessary storage/state changes. /// Note : the execution should not return error as everything was previously verified and validated. #[transactional] - fn execute_sell( - transfer: &AMMTransfer, - ) -> DispatchResult { + fn execute_sell(transfer: &AMMTransfer) -> DispatchResult { let pair_account = Self::get_pair_id(transfer.assets); if transfer.discount && transfer.discount_amount > 0u128 { @@ -913,7 +912,11 @@ impl AMM for Pallet { pallet_amm_support::TradeOperation::ExactIn, vec![(AssetType::Fungible(transfer.assets.asset_in), transfer.amount)], vec![(AssetType::Fungible(transfer.assets.asset_out), transfer.amount_b)], - vec![Fee{ asset: transfer.fee.0, amount: transfer.fee.1, recipient: pair_account}], + vec![Fee { + asset: transfer.fee.0, + amount: transfer.fee.1, + recipient: pair_account, + }], ); Ok(()) @@ -1089,7 +1092,11 @@ impl AMM for Pallet { pallet_amm_support::TradeOperation::ExactOut, vec![(AssetType::Fungible(transfer.assets.asset_in), transfer.amount)], vec![(AssetType::Fungible(transfer.assets.asset_out), transfer.amount_b)], - vec![Fee{ asset: transfer.fee.0, amount: transfer.fee.1, recipient: pair_account}], + vec![Fee { + asset: transfer.fee.0, + amount: transfer.fee.1, + recipient: pair_account, + }], ); Ok(()) diff --git a/traits/src/lib.rs b/traits/src/lib.rs index dfc6477e5..21a3682d1 100644 --- a/traits/src/lib.rs +++ b/traits/src/lib.rs @@ -81,9 +81,7 @@ pub trait AMM { ) -> Result, frame_support::sp_runtime::DispatchError>; /// Execute buy for given validated transfer. - fn execute_sell( - transfer: &AMMTransfer, - ) -> dispatch::DispatchResult; + fn execute_sell(transfer: &AMMTransfer) -> dispatch::DispatchResult; /// Perform asset swap. /// Call execute following the validation. @@ -94,9 +92,7 @@ pub trait AMM { min_bought: Amount, discount: bool, ) -> dispatch::DispatchResult { - Self::execute_sell( - &Self::validate_sell(origin, assets, amount, min_bought, discount)?, - )?; + Self::execute_sell(&Self::validate_sell(origin, assets, amount, min_bought, discount)?)?; Ok(()) } @@ -125,10 +121,7 @@ pub trait AMM { max_limit: Amount, discount: bool, ) -> dispatch::DispatchResult { - Self::execute_buy( - &Self::validate_buy(origin, assets, amount, max_limit, discount)?, - None, - )?; + Self::execute_buy(&Self::validate_buy(origin, assets, amount, max_limit, discount)?, None)?; Ok(()) } diff --git a/traits/src/router.rs b/traits/src/router.rs index 7ca85ea81..8d871bf20 100644 --- a/traits/src/router.rs +++ b/traits/src/router.rs @@ -1,10 +1,10 @@ -#[cfg(feature = "std")] -use serde::{Deserialize, Serialize}; use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::dispatch::DispatchResultWithPostInfo; use frame_support::sp_runtime::{DispatchError, DispatchResult}; use frame_support::weights::Weight; use scale_info::TypeInfo; +#[cfg(feature = "std")] +use serde::{Deserialize, Serialize}; use sp_arithmetic::FixedU128; use sp_std::vec; use sp_std::vec::Vec; @@ -66,11 +66,15 @@ pub trait RouteProvider { pub struct Fee { pub asset: AssetId, pub amount: Balance, - pub recipient: AccountId + pub recipient: AccountId, } impl Fee { pub fn new(asset: AssetId, amount: Balance, recipient: AccountId) -> Self { - Self {asset, amount, recipient} + Self { + asset, + amount, + recipient, + } } } @@ -100,8 +104,8 @@ pub enum PoolType { #[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] pub enum AssetType { - Fungible(AssetId), - NFT(NFTId), + Fungible(AssetId), + NFT(NFTId), } pub type OtcOrderId = u32; @@ -109,9 +113,9 @@ pub type OtcOrderId = u32; #[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] pub enum Filler { Omnipool, - Stableswap(AssetId), // asset id - XYK(AssetId), // share token - LBP, // ???? LBP(AssetId), // share token + Stableswap(AssetId), // asset id + XYK(AssetId), // share token + LBP, // ???? LBP(AssetId), // share token OTC(OtcOrderId), // ICE(solution_id/block id), swapper: alice, filler: solver } From 58253684d1f344e1b52f2735fb5f2b461435ae80 Mon Sep 17 00:00:00 2001 From: dmoka Date: Tue, 5 Nov 2024 15:42:45 +0100 Subject: [PATCH 030/142] fixed some compilation error --- pallets/lbp/src/tests.rs | 88 +++++++-------- pallets/omnipool/src/tests/buy.rs | 42 +++---- pallets/otc-settlements/src/mock.rs | 1 + pallets/otc-settlements/src/tests.rs | 2 +- pallets/otc/src/tests/fill_order.rs | 4 +- pallets/otc/src/tests/partial_fill_order.rs | 18 +-- .../src/tests/calculate_spot_price.rs | 9 -- pallets/stableswap/src/tests/trades.rs | 29 +++-- .../xyk-liquidity-mining/src/tests/mock.rs | 2 +- pallets/xyk/src/tests/fees.rs | 104 ++++++++++-------- pallets/xyk/src/tests/trades.rs | 62 +++++------ 11 files changed, 172 insertions(+), 189 deletions(-) diff --git a/pallets/lbp/src/tests.rs b/pallets/lbp/src/tests.rs index c626747e1..2f4ea8754 100644 --- a/pallets/lbp/src/tests.rs +++ b/pallets/lbp/src/tests.rs @@ -1830,8 +1830,7 @@ fn execute_sell_should_work() { assert_eq!(Currency::free_balance(asset_in, &pool_id), 1_000_000_000); assert_eq!(Currency::free_balance(asset_out, &pool_id), 2_000_000_000); - let event_id = Some(7); - assert_ok!(LBPPallet::execute_sell(&t, event_id)); + assert_ok!(LBPPallet::execute_sell(&t)); expect_events(vec![ Event::SellExecuted { @@ -1848,13 +1847,11 @@ fn execute_sell_should_work() { swapper: ALICE, filler: pool_id, filler_type: pallet_amm_support::Filler::LBP, - operation: pallet_amm_support::TradeOperation::Sell, - asset_in, - asset_out, - amount_in, - amount_out: amount_b, - fees: vec![(asset_in, 1_000, pool_data.fee_collector)], - event_id, + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(asset_in), amount_in)], + outputs: vec![(AssetType::Fungible(asset_out), amount_b)], + fees: vec![Fee::new(asset_in, 1_000, pool_data.fee_collector)], + operation_id: vec![], } .into(), ]); @@ -1893,7 +1890,7 @@ fn execute_sell_should_not_work() { assert_eq!(Currency::free_balance(BSX, &KUSD_BSX_POOL_ID), 2_000_000_000); assert_noop!( - LBPPallet::execute_sell(&t, None), + LBPPallet::execute_sell(&t), orml_tokens::Error::::BalanceTooLow ); @@ -1972,7 +1969,7 @@ fn execute_buy_should_work() { assert_eq!(Currency::free_balance(asset_out, &pool_id), 2_000_000_000); let event_id = Some(7); - assert_ok!(LBPPallet::execute_buy(&t, None, event_id)); + assert_ok!(LBPPallet::execute_buy(&t, None)); assert_eq!(Currency::free_balance(asset_in, &ALICE), 999_998_991_999_000); assert_eq!(Currency::free_balance(asset_out, &ALICE), 999_998_020_000_000); @@ -1997,13 +1994,11 @@ fn execute_buy_should_work() { swapper: ALICE, filler: pool_id, filler_type: pallet_amm_support::Filler::LBP, - operation: pallet_amm_support::TradeOperation::Buy, - asset_in, - asset_out, - amount_in, - amount_out: amount_b, - fees: vec![(asset_in, 1_000, pool_data.fee_collector)], - event_id, + operation: pallet_amm_support::TradeOperation::ExactOut, + inputs: vec![(AssetType::Fungible(asset_in), amount_in)], + outputs: vec![(AssetType::Fungible(asset_out), amount_b)], + fees: vec![Fee::new(asset_in, 1_000, pool_data.fee_collector)], + operation_id: vec![], } .into(), ]); @@ -2038,7 +2033,7 @@ fn execute_buy_should_not_work() { assert_eq!(Currency::free_balance(asset_out, &pool_id), 2_000_000_000); assert_noop!( - LBPPallet::execute_buy(&t, None, None), + LBPPallet::execute_buy(&t, None), orml_tokens::Error::::BalanceTooLow ); @@ -2328,13 +2323,11 @@ fn buy_should_work() { swapper: buyer, filler: pool_id, filler_type: pallet_amm_support::Filler::LBP, - operation: pallet_amm_support::TradeOperation::Buy, - asset_in, - asset_out, - amount_in: 17_894_738, - amount_out: 10_000_000, - fees: vec![(asset_in, 35860, pool_data.fee_collector)], - event_id: None, // calling buy directly from the pallet doesn't set event_id + operation: pallet_amm_support::TradeOperation::ExactOut, + inputs: vec![(AssetType::Fungible(asset_in), 17_894_738)], + outputs: vec![(AssetType::Fungible(asset_out), 10_000_000)], + fees: vec![Fee::new(asset_in, 35860, pool_data.fee_collector)], + operation_id: vec![], // calling buy directly from the pallet doesn't set event_id } .into(), ]); @@ -2475,13 +2468,11 @@ fn buy_should_work_when_limit_is_set_above_account_balance() { swapper: buyer, filler: pool_id, filler_type: pallet_amm_support::Filler::LBP, - operation: pallet_amm_support::TradeOperation::Buy, - asset_in, - asset_out, - amount_in: 17_894_738, - amount_out: 10_000_000, - fees: vec![(asset_in, 35860, pool_data.fee_collector)], - event_id: None, + operation: pallet_amm_support::TradeOperation::ExactOut, + inputs: vec![(AssetType::Fungible(asset_in), 17_894_738)], + outputs: vec![(AssetType::Fungible(asset_out), 10_000_000)], + fees: vec![Fee::new(asset_in, 35860, pool_data.fee_collector)], + operation_id: vec![], } .into(), ]); @@ -2511,13 +2502,12 @@ fn buy_should_work_when_limit_is_set_above_account_balance() { swapper: buyer, filler: pool_id, filler_type: pallet_amm_support::Filler::LBP, - operation: pallet_amm_support::TradeOperation::Buy, - asset_in: BSX, - asset_out: KUSD, - amount_in: 5_560_304, - amount_out: 10_000_000, - fees: vec![(KUSD, 20_000, pool_data.fee_collector)], - event_id: None, + operation: pallet_amm_support::TradeOperation::ExactOut, + inputs: vec![(AssetType::Fungible(BSX), 5_560_304)], + outputs: vec![(AssetType::Fungible(KUSD), 10_000_000)], + + fees: vec![Fee::new(KUSD, 20_000, pool_data.fee_collector)], + operation_id: vec![], } .into(), ]); @@ -2603,13 +2593,11 @@ fn sell_should_work() { swapper: buyer, filler: pool_id, filler_type: pallet_amm_support::Filler::LBP, - operation: pallet_amm_support::TradeOperation::Sell, - asset_in, - asset_out, - amount_in: 9_980_000, - amount_out: 5_605_138, - fees: vec![(asset_in, 20_000, pool_data.fee_collector)], - event_id: None, + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(asset_in), 9_980_000)], + outputs: vec![(AssetType::Fungible(asset_out), 5_605_138)], + fees: vec![Fee::new(asset_in, 20_000, pool_data.fee_collector)], + operation_id: vec![], } .into(), ]); @@ -3793,7 +3781,7 @@ fn collected_fees_should_be_locked_and_unlocked_after_liquidity_is_removed() { run_to_sale_start(); let Pool { fee_collector, .. } = LBPPallet::pool_data(KUSD_BSX_POOL_ID).unwrap(); let (fee_asset, fee_amount) = SAMPLE_AMM_TRANSFER.fee; - assert_ok!(LBPPallet::execute_buy(&SAMPLE_AMM_TRANSFER, None, None)); + assert_ok!(LBPPallet::execute_buy(&SAMPLE_AMM_TRANSFER, None)); // collector receives locked fee assert_eq!(Currency::free_balance(fee_asset, &fee_collector), fee_amount); @@ -3824,8 +3812,8 @@ fn collected_fees_are_continually_locked() { run_to_sale_start(); let Pool { fee_collector, .. } = LBPPallet::pool_data(KUSD_BSX_POOL_ID).unwrap(); let (fee_asset, fee_amount) = SAMPLE_AMM_TRANSFER.fee; - assert_ok!(LBPPallet::execute_buy(&SAMPLE_AMM_TRANSFER, None, None)); - assert_ok!(LBPPallet::execute_buy(&SAMPLE_AMM_TRANSFER, None, None)); + assert_ok!(LBPPallet::execute_buy(&SAMPLE_AMM_TRANSFER, None)); + assert_ok!(LBPPallet::execute_buy(&SAMPLE_AMM_TRANSFER, None)); let total = 2 * fee_amount; assert_eq!(Currency::free_balance(fee_asset, &fee_collector), total); assert_eq!( diff --git a/pallets/omnipool/src/tests/buy.rs b/pallets/omnipool/src/tests/buy.rs index 36e5c2212..808c79fc0 100644 --- a/pallets/omnipool/src/tests/buy.rs +++ b/pallets/omnipool/src/tests/buy.rs @@ -441,16 +441,14 @@ fn buy_should_emit_event_with_correct_asset_fee_amount() { swapper: LP1, filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::Buy, - asset_in: 100, - asset_out: 200, - amount_in: expected_sold_amount, - amount_out: buy_amount, + operation: pallet_amm_support::TradeOperation::ExactOut, + inputs: vec![(AssetType::Fungible(100), expected_sold_amount)], + outputs: vec![(AssetType::Fungible(200), buy_amount)], fees: vec![ - (200, 5555555555556, Omnipool::protocol_account()), - (1, 0, Omnipool::protocol_account()), + Fee::new(200, 5555555555556, Omnipool::protocol_account()), + Fee::new(1, 0, Omnipool::protocol_account()), ], - event_id: None, + operation_id: vec![], } .into(), ]); @@ -504,16 +502,14 @@ fn buy_should_emit_event_with_correct_protocol_fee_amount() { swapper: LP1, filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::Buy, - asset_in: 100, - asset_out: 200, - amount_in: expected_sold_amount, - amount_out: buy_amount, + operation: pallet_amm_support::TradeOperation::ExactOut, + inputs: vec![(AssetType::Fungible(100), expected_sold_amount)], + outputs: vec![(AssetType::Fungible(200), buy_amount)], fees: vec![ - (200, 0, Omnipool::protocol_account()), - (1, 5698005698005, Omnipool::protocol_account()), + Fee::new(200, 0, Omnipool::protocol_account()), + Fee::new(1, 5698005698005, Omnipool::protocol_account()), ], - event_id: None, + operation_id: vec![], } .into(), ]); @@ -566,16 +562,14 @@ fn sell_should_get_same_amount() { swapper: LP1, filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::Sell, - asset_in: 100, - asset_out: 200, - amount_in: expected_sold_amount, - amount_out: buy_amount, + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(100), expected_sold_amount)], + outputs: vec![(AssetType::Fungible(200), buy_amount)], fees: vec![ - (200, 5555555555556, Omnipool::protocol_account()), - (1, 0, Omnipool::protocol_account()), + Fee::new(200, 5555555555556, Omnipool::protocol_account()), + Fee::new(1, 0, Omnipool::protocol_account()), ], - event_id: None, + operation_id: vec![], } .into(), ]); diff --git a/pallets/otc-settlements/src/mock.rs b/pallets/otc-settlements/src/mock.rs index 2f3ddbb5e..de7bb85c7 100644 --- a/pallets/otc-settlements/src/mock.rs +++ b/pallets/otc-settlements/src/mock.rs @@ -158,6 +158,7 @@ impl pallet_route_executor::Config for Test { type DefaultRoutePoolType = DefaultRoutePoolType; type TechnicalOrigin = EnsureRoot; type BatchIdProvider = AmmSupport; + type OperationIdProvider = AmmSupport; type WeightInfo = (); } diff --git a/pallets/otc-settlements/src/tests.rs b/pallets/otc-settlements/src/tests.rs index 6802ee408..129767355 100644 --- a/pallets/otc-settlements/src/tests.rs +++ b/pallets/otc-settlements/src/tests.rs @@ -301,7 +301,7 @@ fn existing_arb_opportunity_should_trigger_trade_when_correct_amount_can_be_foun pallet_amm_support::Event::Swapped { swapper: OtcSettlements::account_id(), filler: otc.owner, - filler_type: pallet_amm_support::Filler::OTC, + filler_type: pallet_amm_support::Filler::OTC(otc_id), operation: pallet_amm_support::TradeOperation::Sell, asset_in: HDX, asset_out: DAI, diff --git a/pallets/otc/src/tests/fill_order.rs b/pallets/otc/src/tests/fill_order.rs index 6f9f693c0..313764df8 100644 --- a/pallets/otc/src/tests/fill_order.rs +++ b/pallets/otc/src/tests/fill_order.rs @@ -82,7 +82,7 @@ fn complete_fill_order_should_work() { pallet_amm_support::Event::Swapped { swapper: BOB, filler: ALICE, - filler_type: pallet_amm_support::Filler::OTC, + filler_type: pallet_amm_support::Filler::OTC(0), operation: pallet_amm_support::TradeOperation::Sell, asset_in: DAI, asset_out: HDX, @@ -255,7 +255,7 @@ fn complete_fill_order_should_work_when_there_are_multiple_orders() { amount_in: 20 * ONE, amount_out: 100 * ONE, fees: vec![(HDX, ONE, ::FeeReceiver::get())], - event_id: None, + operation_id: vec![], } .into(), ]); diff --git a/pallets/otc/src/tests/partial_fill_order.rs b/pallets/otc/src/tests/partial_fill_order.rs index f3a31e522..1add8fc65 100644 --- a/pallets/otc/src/tests/partial_fill_order.rs +++ b/pallets/otc/src/tests/partial_fill_order.rs @@ -19,6 +19,7 @@ use frame_support::{assert_noop, assert_ok}; use orml_tokens::Error::BalanceTooLow; use orml_traits::{MultiCurrency, NamedMultiReservableCurrency}; use pretty_assertions::assert_eq; +use hydradx_traits::router::{AssetType, Fee}; #[test] fn partial_fill_order_should_work_when_order_is_partially_fillable() { @@ -83,9 +84,10 @@ fn partial_fill_order_should_work_when_order_is_partially_fillable() { TREASURY_INITIAL_BALANCE + fee ); + let order_id = 0; expect_events(vec![ Event::PartiallyFilled { - order_id: 0, + order_id, who: BOB, amount_in: 5 * ONE, amount_out: expected_amount_out, @@ -95,14 +97,12 @@ fn partial_fill_order_should_work_when_order_is_partially_fillable() { pallet_amm_support::Event::Swapped { swapper: BOB, filler: order.owner, - filler_type: pallet_amm_support::Filler::OTC, - operation: pallet_amm_support::TradeOperation::Sell, - asset_in: order.asset_in, - asset_out: order.asset_out, - amount_in: 5 * ONE, - amount_out: expected_amount_out, - fees: vec![(order.asset_out, fee, ::FeeReceiver::get())], - event_id: None, + filler_type: pallet_amm_support::Filler::OTC(order_id), + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(order.asset_in), 5 * ONE)], + outputs: vec![(AssetType::Fungible(order.asset_out), expected_amount_out)], + fees: vec![Fee::new(order.asset_out, fee, ::FeeReceiver::get())], + operation_id: vec![], } .into(), ]); diff --git a/pallets/stableswap/src/tests/calculate_spot_price.rs b/pallets/stableswap/src/tests/calculate_spot_price.rs index 00b26f43f..d28553512 100644 --- a/pallets/stableswap/src/tests/calculate_spot_price.rs +++ b/pallets/stableswap/src/tests/calculate_spot_price.rs @@ -57,7 +57,6 @@ fn spot_price_calculation_should_work_when_asset_in_is_share_with_6_decimals() { asset_b, sell_amount, 0, - None, )); let expected = 9; @@ -130,7 +129,6 @@ fn spot_price_calculation_should_work_when_asset_in_is_share_with_12_decimals() asset_b, sell_amount, 0, - None, )); let expected = 994999; @@ -207,7 +205,6 @@ fn spot_price_calculation_should_work_when_asset_in_is_share_with_18_decimals() asset_b, sell_amount, 0, - None, )); let expected = 991; @@ -293,7 +290,6 @@ fn spot_price_calculation_should_work_when_asset_out_is_share_with_12_decimals() pool_id, sell_amount, 0, - None, )); let expected = 986999999; @@ -369,7 +365,6 @@ fn spot_price_calculation_should_work_when_asset_out_is_share_with_18_decimals() pool_id, sell_amount, 0, - None, )); let expected = 984938537439245; @@ -436,7 +431,6 @@ fn spot_price_calculation_should_work_for_two_stableassets() { asset_b, sell_amount, 0, - None, )); let expected = 989999901; @@ -512,7 +506,6 @@ fn spot_price_calculation_should_work_for_two_stableassets_on_different_position asset_b, sell_amount, 0, - None, )); let expected = 968488820; @@ -599,7 +592,6 @@ mod invariants { asset_b, sell_amount, 0, - None, )); assert_balance!(BOB, pool_id, bob_share_balance - sell_amount); @@ -667,7 +659,6 @@ mod invariants { pool_id, sell_amount, 0, - None, )); diff --git a/pallets/stableswap/src/tests/trades.rs b/pallets/stableswap/src/tests/trades.rs index 0630bad50..d35ae42eb 100644 --- a/pallets/stableswap/src/tests/trades.rs +++ b/pallets/stableswap/src/tests/trades.rs @@ -5,6 +5,7 @@ use std::num::NonZeroU16; use frame_support::{assert_noop, assert_ok}; use sp_runtime::Permill; +use hydradx_traits::router::{AssetType, Fee}; #[test] fn sell_should_work_when_correct_input_provided() { @@ -68,14 +69,12 @@ fn sell_should_work_when_correct_input_provided() { pallet_amm_support::Event::Swapped { swapper: BOB, filler: pool_account, - filler_type: pallet_amm_support::Filler::Stableswap, - operation: pallet_amm_support::TradeOperation::Sell, - asset_in: asset_a, - asset_out: asset_b, - amount_in: 30000000000000, - amount_out: 29902625420922, - fees: vec![(asset_b, 0, pool_account)], - event_id: None, + filler_type: pallet_amm_support::Filler::Stableswap(pool_id), + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(asset_a), 30000000000000)], + outputs: vec![(AssetType::Fungible(asset_b), 29902625420922)], + fees: vec![Fee::new(asset_b, 0, pool_account)], + operation_id: vec![], } .into(), ]); @@ -144,14 +143,12 @@ fn buy_should_work_when_correct_input_provided() { pallet_amm_support::Event::Swapped { swapper: BOB, filler: pool_account, - filler_type: pallet_amm_support::Filler::Stableswap, - operation: pallet_amm_support::TradeOperation::Buy, - asset_in: asset_a, - asset_out: asset_b, - amount_in: 30098072706882, - amount_out: 30000000000000, - fees: vec![(asset_a, 0, pool_account)], - event_id: None, + filler_type: pallet_amm_support::Filler::Stableswap(pool_id), + operation: pallet_amm_support::TradeOperation::ExactOut, + inputs: vec![(AssetType::Fungible(asset_a), 30098072706882)], + outputs: vec![(AssetType::Fungible(asset_b), 30000000000000)], + fees: vec![Fee::new(asset_a, 0, pool_account)], + operation_id: vec![], } .into(), ]); diff --git a/pallets/xyk-liquidity-mining/src/tests/mock.rs b/pallets/xyk-liquidity-mining/src/tests/mock.rs index 42fa78d51..c8d8b3939 100644 --- a/pallets/xyk-liquidity-mining/src/tests/mock.rs +++ b/pallets/xyk-liquidity-mining/src/tests/mock.rs @@ -198,7 +198,7 @@ pub struct DummyFarmEntry { pub struct DummyAMM; -impl AMM for DummyAMM { +impl AMM for DummyAMM { fn get_max_out_ratio() -> u128 { 0_u32.into() } diff --git a/pallets/xyk/src/tests/fees.rs b/pallets/xyk/src/tests/fees.rs index 5ad2bb653..94d6d7a75 100644 --- a/pallets/xyk/src/tests/fees.rs +++ b/pallets/xyk/src/tests/fees.rs @@ -3,6 +3,7 @@ use crate::{Error, Event}; use frame_support::{assert_noop, assert_ok}; use hydradx_traits::AMM as AmmPool; use orml_traits::MultiCurrency; +use hydradx_traits::router::{AssetType, Fee}; use crate::types::AssetPair; @@ -179,10 +180,14 @@ fn discount_sell_fees_should_work() { 400_000_000_000_000, )); - let pair_account = XYK::get_pair_id(AssetPair { + let pair = AssetPair { asset_in: asset_a, asset_out: asset_b, - }); + }; + let pair_account = XYK::get_pair_id(pair); + + let share_token = XYK::get_share_token(pair); + let native_pair_account = XYK::get_pair_id(AssetPair { asset_in: asset_a, asset_out: HDX, @@ -230,14 +235,12 @@ fn discount_sell_fees_should_work() { pallet_amm_support::Event::Swapped { swapper: ALICE, filler: pair_account, - filler_type: pallet_amm_support::Filler::XYK, - operation: pallet_amm_support::TradeOperation::Sell, - asset_in: asset_a, - asset_out: asset_b, - amount_in: 10_000_000, - amount_out: 19_980_009, - fees: vec![(asset_b, 19_990, pair_account)], - event_id: None, + filler_type: pallet_amm_support::Filler::XYK(share_token), + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(asset_a), 10_000_000)], + outputs: vec![(AssetType::Fungible(asset_b), 19_980_009)], + fees: vec![Fee::new(asset_b, 19_990, pair_account)], + operation_id: vec![], } .into(), ]); @@ -268,11 +271,17 @@ fn discount_sell_fees_should_work() { 400_000_000_000_000, )); + let pair = AssetPair { + asset_in: asset_a, + asset_out: asset_b, + }; let pair_account = XYK::get_pair_id(AssetPair { asset_in: asset_a, asset_out: asset_b, }); + let share_token = XYK::get_share_token(pair); + assert_eq!(Currency::free_balance(asset_a, &pair_account), 200_000_000_000_000); assert_eq!(Currency::free_balance(asset_b, &pair_account), 400_000_000_000_000); @@ -309,14 +318,12 @@ fn discount_sell_fees_should_work() { pallet_amm_support::Event::Swapped { swapper: ALICE, filler: pair_account, - filler_type: pallet_amm_support::Filler::XYK, - operation: pallet_amm_support::TradeOperation::Sell, - asset_in: asset_a, - asset_out: asset_b, - amount_in: 10_000_000, - amount_out: 19_999_999, - fees: vec![(asset_b, 0, pair_account)], - event_id: None, + filler_type: pallet_amm_support::Filler::XYK(share_token), + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(asset_a), 10_000_000)], + outputs: vec![(AssetType::Fungible(asset_b), 19_999_999)], + fees: vec![Fee::new(asset_b, 0, pair_account)], + operation_id: vec![], } .into(), ]); @@ -358,11 +365,17 @@ fn discount_buy_fees_should_work() { asset_out: HDX, }); + let pair = AssetPair { + asset_in: asset_a, + asset_out: asset_b, + }; let pair_account = XYK::get_pair_id(AssetPair { asset_in: asset_a, asset_out: asset_b, }); + let share_token = XYK::get_share_token(pair); + assert_eq!(Currency::free_balance(asset_a, &pair_account), 200_000_000_000_000); assert_eq!(Currency::free_balance(asset_b, &pair_account), 400_000_000_000_000); assert_eq!(Currency::free_balance(asset_a, &native_pair_account), 1_000_000_000_000); @@ -405,14 +418,12 @@ fn discount_buy_fees_should_work() { pallet_amm_support::Event::Swapped { swapper: ALICE, filler: pair_account, - filler_type: pallet_amm_support::Filler::XYK, - operation: pallet_amm_support::TradeOperation::Buy, - asset_in: asset_b, - asset_out: asset_a, - amount_in: 10_000_000, - amount_out: 20_000_002, - fees: vec![(asset_b, 14_000, pair_account)], - event_id: None, + filler_type: pallet_amm_support::Filler::XYK(share_token), + operation: pallet_amm_support::TradeOperation::ExactOut, + inputs: vec![(AssetType::Fungible(asset_b), 10_000_000)], + outputs: vec![(AssetType::Fungible(asset_a), 20_000_002)], + fees: vec![Fee::new(asset_b, 14_000, pair_account)], + operation_id: vec![], } .into(), ]); @@ -446,11 +457,17 @@ fn discount_buy_fees_should_work() { asset_out: HDX, }); + let pair = AssetPair { + asset_in: asset_a, + asset_out: asset_b, + }; let pair_account = XYK::get_pair_id(AssetPair { asset_in: asset_a, asset_out: asset_b, }); + let share_token = XYK::get_share_token(pair); + assert_eq!(Currency::free_balance(asset_a, &pair_account), 200_000_000_000_000); assert_eq!(Currency::free_balance(asset_b, &pair_account), 400_000_000_000_000); assert_eq!(Currency::free_balance(asset_a, &native_pair_account), 1_000_000_000_000); @@ -493,14 +510,12 @@ fn discount_buy_fees_should_work() { pallet_amm_support::Event::Swapped { swapper: ALICE, filler: pair_account, - filler_type: pallet_amm_support::Filler::XYK, - operation: pallet_amm_support::TradeOperation::Buy, - asset_in: asset_b, - asset_out: asset_a, - amount_in: 10_000_000, - amount_out: 20_000_002, - fees: vec![(asset_b, 20_000, pair_account)], - event_id: None, + filler_type: pallet_amm_support::Filler::XYK(share_token), + operation: pallet_amm_support::TradeOperation::ExactOut, + inputs: vec![(AssetType::Fungible(asset_b), 10_000_000)], + outputs: vec![(AssetType::Fungible(asset_a), 20_000_002)], + fees: vec![Fee::new(asset_b, 20_000, pair_account)], + operation_id: vec![], } .into(), ]); @@ -532,10 +547,13 @@ fn discount_buy_fees_should_work() { 400_000_000_000_000, )); - let pair_account = XYK::get_pair_id(AssetPair { + let pair = AssetPair { asset_in: asset_a, asset_out: asset_b, - }); + }; + let pair_account = XYK::get_pair_id(pair); + + let share_token = XYK::get_share_token(pair); assert_eq!(Currency::free_balance(asset_a, &pair_account), 200_000_000_000_000); assert_eq!(Currency::free_balance(asset_b, &pair_account), 400_000_000_000_000); @@ -573,14 +591,12 @@ fn discount_buy_fees_should_work() { pallet_amm_support::Event::Swapped { swapper: ALICE, filler: pair_account, - filler_type: pallet_amm_support::Filler::XYK, - operation: pallet_amm_support::TradeOperation::Buy, - asset_in: asset_b, - asset_out: asset_a, - amount_in: 10_000_000, - amount_out: 20_000_002, - fees: vec![(asset_b, 0, pair_account)], - event_id: None, + filler_type: pallet_amm_support::Filler::XYK(share_token), + operation: pallet_amm_support::TradeOperation::ExactOut, + inputs: vec![(AssetType::Fungible(asset_b), 10_000_000)], + outputs: vec![(AssetType::Fungible(asset_a), 20_000_002)], + fees: vec![Fee::new(asset_b, 0, pair_account)], + operation_id: vec![], } .into(), ]); diff --git a/pallets/xyk/src/tests/trades.rs b/pallets/xyk/src/tests/trades.rs index 7778c1229..a21bd1337 100644 --- a/pallets/xyk/src/tests/trades.rs +++ b/pallets/xyk/src/tests/trades.rs @@ -3,6 +3,7 @@ use crate::{AMMTransfer, Error, Event}; use frame_support::{assert_noop, assert_ok}; use hydradx_traits::AMM as AmmPool; use orml_traits::MultiCurrency; +use hydradx_traits::router::{AssetType, Fee}; use crate::types::AssetPair; @@ -73,14 +74,12 @@ fn sell_test() { pallet_amm_support::Event::Swapped { swapper: ALICE, filler: pair_account, - filler_type: pallet_amm_support::Filler::XYK, - operation: pallet_amm_support::TradeOperation::Sell, - asset_in: asset_a, - asset_out: asset_b, - amount_in: 456444678, - amount_out: 1363483591788, - fees: vec![(asset_b, 2732432046, pair_account)], - event_id: None, + filler_type: pallet_amm_support::Filler::XYK(share_token), + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(asset_a), 456444678)], + outputs: vec![(AssetType::Fungible(asset_b), 1363483591788)], + fees: vec![Fee::new(asset_b, 2732432046, pair_account)], + operation_id: vec![], } .into(), ]); @@ -107,6 +106,9 @@ fn execute_sell_should_use_event_id() { asset_out: asset_b, }); + + let share_token = XYK::share_token(pair_account); + let t = AMMTransfer { origin: user_1, assets: AssetPair { @@ -121,7 +123,7 @@ fn execute_sell_should_use_event_id() { }; let event_id = Some(7); - assert_ok!(XYK::execute_sell(&t, event_id,)); + assert_ok!(XYK::execute_sell(&t)); expect_events(vec![ Event::SellExecuted { @@ -138,14 +140,12 @@ fn execute_sell_should_use_event_id() { pallet_amm_support::Event::Swapped { swapper: ALICE, filler: pair_account, - filler_type: pallet_amm_support::Filler::XYK, - operation: pallet_amm_support::TradeOperation::Sell, - asset_in: asset_a, - asset_out: asset_b, - amount_in: 456444678, - amount_out: 1363483591788, - fees: vec![(asset_b, 2732432046, pair_account)], - event_id, + filler_type: pallet_amm_support::Filler::XYK(share_token), + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(asset_a), 456444678)], + outputs: vec![(AssetType::Fungible(asset_b), 1363483591788)], + fees: vec![Fee::new(asset_b, 2732432046, pair_account)], + operation_id: vec![], } .into(), ]); @@ -447,14 +447,12 @@ fn sell_with_correct_fees_should_work() { pallet_amm_support::Event::Swapped { swapper: user_1, filler: pair_account, - filler_type: pallet_amm_support::Filler::XYK, - operation: pallet_amm_support::TradeOperation::Sell, - asset_in: asset_a, - asset_out: asset_b, - amount_in: 100_000, - amount_out: 19_762_378, - fees: vec![(asset_b, 39_602, pair_account)], - event_id: None, + filler_type: pallet_amm_support::Filler::XYK(share_token), + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(asset_a), 100_000)], + outputs: vec![(AssetType::Fungible(asset_b), 19_762_378)], + fees: vec![Fee::new(asset_b, 39_602, pair_account)], + operation_id: vec![], } .into(), ]); @@ -667,14 +665,12 @@ fn single_buy_should_work() { pallet_amm_support::Event::Swapped { swapper: user_1, filler: pair_account, - filler_type: pallet_amm_support::Filler::XYK, - operation: pallet_amm_support::TradeOperation::Buy, - asset_in: asset_b, - asset_out: asset_a, - amount_in: 6_666_666, - amount_out: 22_068_963_235, - fees: vec![(asset_b, 44_137_926, pair_account)], - event_id: None, + filler_type: pallet_amm_support::Filler::XYK(share_token), + operation: pallet_amm_support::TradeOperation::ExactOut, + inputs: vec![(AssetType::Fungible(asset_b), 6_666_666)], + outputs: vec![(AssetType::Fungible(asset_a), 22_068_963_235)], + fees: vec![Fee::new(asset_b, 44_137_926, pair_account)], + operation_id: vec![], } .into(), ]); From 94bc0f9584dfe6bcf57b417197a754f922edf0bd Mon Sep 17 00:00:00 2001 From: dmoka Date: Tue, 5 Nov 2024 19:18:07 +0100 Subject: [PATCH 031/142] fix compilation errors --- integration-tests/src/router.rs | 1 + pallets/dca/src/tests/mock.rs | 5 ++-- pallets/lbp/src/tests.rs | 1 - pallets/otc-settlements/src/tests.rs | 15 +++++----- pallets/otc/src/tests/fill_order.rs | 43 +++++++++++++--------------- pallets/xyk/src/tests/fees.rs | 23 ++++++++------- runtime/adapters/src/tests/mock.rs | 1 + 7 files changed, 44 insertions(+), 45 deletions(-) diff --git a/integration-tests/src/router.rs b/integration-tests/src/router.rs index 1450edc26..d015a3b3b 100644 --- a/integration-tests/src/router.rs +++ b/integration-tests/src/router.rs @@ -20,6 +20,7 @@ use pallet_omnipool::types::Tradability; use pallet_omnipool::weights::WeightInfo as OmnipoolWeights; use pallet_route_executor::AmmTradeWeights; use std::convert::Into; +use hydradx_traits::router::AssetType; use hydradx_traits::router::AssetPair as Pair; use primitives::AssetId; diff --git a/pallets/dca/src/tests/mock.rs b/pallets/dca/src/tests/mock.rs index cfbc5f2e0..3bf22a09d 100644 --- a/pallets/dca/src/tests/mock.rs +++ b/pallets/dca/src/tests/mock.rs @@ -371,6 +371,7 @@ impl pallet_route_executor::Config for Test { type OraclePriceProvider = PriceProviderMock; type OraclePeriod = RouteValidationOraclePeriod; type BatchIdProvider = AmmSupport; + type OperationIdProvider = AmmSupport; type WeightInfo = (); } @@ -534,7 +535,7 @@ impl TradeExecution for OmniPool pub const XYK_SELL_CALCULATION_RESULT: Balance = ONE * 5 / 4; pub const XYK_BUY_CALCULATION_RESULT: Balance = ONE / 3; -impl TradeExecution for Xyk { +impl TradeExecution for Xyk { type Error = DispatchError; fn calculate_sell( @@ -570,7 +571,6 @@ impl TradeExecution, ) -> Result<(), ExecutorError> { if !matches!(pool_type, PoolType::XYK) { return Err(ExecutorError::NotSupported); @@ -603,7 +603,6 @@ impl TradeExecution, ) -> Result<(), ExecutorError> { if !matches!(pool_type, PoolType::XYK) { return Err(ExecutorError::NotSupported); diff --git a/pallets/lbp/src/tests.rs b/pallets/lbp/src/tests.rs index 2f4ea8754..d04aa3ded 100644 --- a/pallets/lbp/src/tests.rs +++ b/pallets/lbp/src/tests.rs @@ -1968,7 +1968,6 @@ fn execute_buy_should_work() { assert_eq!(Currency::free_balance(asset_in, &pool_id), 1_000_000_000); assert_eq!(Currency::free_balance(asset_out, &pool_id), 2_000_000_000); - let event_id = Some(7); assert_ok!(LBPPallet::execute_buy(&t, None)); assert_eq!(Currency::free_balance(asset_in, &ALICE), 999_998_991_999_000); diff --git a/pallets/otc-settlements/src/tests.rs b/pallets/otc-settlements/src/tests.rs index 129767355..fe750b404 100644 --- a/pallets/otc-settlements/src/tests.rs +++ b/pallets/otc-settlements/src/tests.rs @@ -24,7 +24,8 @@ pub use crate::mock::*; use frame_support::{assert_ok, assert_storage_noop}; use hydradx_traits::Inspect; use orml_traits::MultiCurrency; - +use hydradx_traits::router::Fee; +use hydradx_traits::router::AssetType; pub fn expect_events(e: Vec) { e.into_iter().for_each(frame_system::Pallet::::assert_has_event); } @@ -302,13 +303,11 @@ fn existing_arb_opportunity_should_trigger_trade_when_correct_amount_can_be_foun swapper: OtcSettlements::account_id(), filler: otc.owner, filler_type: pallet_amm_support::Filler::OTC(otc_id), - operation: pallet_amm_support::TradeOperation::Sell, - asset_in: HDX, - asset_out: DAI, - amount_in: 2413749694825193, - amount_out: 4948186874391645, - fees: vec![(DAI, 49481868743917, ::FeeReceiver::get())], - event_id: None, + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(HDX), 2413749694825193)], + outputs: vec![(AssetType::Fungible(DAI), 4948186874391645)], + fees: vec![Fee::new(DAI, 49481868743917, ::FeeReceiver::get())], + operation_id: vec![], } .into(), ]); diff --git a/pallets/otc/src/tests/fill_order.rs b/pallets/otc/src/tests/fill_order.rs index 313764df8..38054b12b 100644 --- a/pallets/otc/src/tests/fill_order.rs +++ b/pallets/otc/src/tests/fill_order.rs @@ -19,6 +19,7 @@ use frame_support::{assert_noop, assert_ok}; use orml_tokens::Error::BalanceTooLow; use orml_traits::{MultiCurrency, NamedMultiReservableCurrency}; use pretty_assertions::assert_eq; +use hydradx_traits::router::{AssetType, Fee}; #[test] fn complete_fill_order_should_work() { @@ -83,13 +84,11 @@ fn complete_fill_order_should_work() { swapper: BOB, filler: ALICE, filler_type: pallet_amm_support::Filler::OTC(0), - operation: pallet_amm_support::TradeOperation::Sell, - asset_in: DAI, - asset_out: HDX, - amount_in: 20 * ONE, - amount_out: 100 * ONE, - fees: vec![(HDX, ONE, ::FeeReceiver::get())], - event_id: None, + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(DAI), 20 * ONE)], + outputs: vec![(AssetType::Fungible(HDX), 100 * ONE)], + fees: vec![Fee::new(HDX, ONE, ::FeeReceiver::get())], + operation_id: vec![], } .into(), ]); @@ -147,9 +146,10 @@ fn complete_fill_order_should_work_when_order_is_not_partially_fillable() { TREASURY_INITIAL_BALANCE + fee ); + let order_id = 0; expect_events(vec![ Event::Filled { - order_id: 0, + order_id, who: BOB, amount_in: 20 * ONE, amount_out: 100 * ONE, @@ -159,14 +159,12 @@ fn complete_fill_order_should_work_when_order_is_not_partially_fillable() { pallet_amm_support::Event::Swapped { swapper: BOB, filler: ALICE, - filler_type: pallet_amm_support::Filler::OTC, - operation: pallet_amm_support::TradeOperation::Sell, - asset_in: DAI, - asset_out: HDX, - amount_in: 20 * ONE, - amount_out: 100 * ONE, - fees: vec![(HDX, ONE, ::FeeReceiver::get())], - event_id: None, + filler_type: pallet_amm_support::Filler::OTC(order_id), + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(DAI), 20 * ONE)], + outputs: vec![(AssetType::Fungible(HDX), 100 * ONE)], + fees: vec![Fee::new(HDX, ONE, ::FeeReceiver::get())], + operation_id: vec![], } .into(), ]); @@ -236,6 +234,7 @@ fn complete_fill_order_should_work_when_there_are_multiple_orders() { TREASURY_INITIAL_BALANCE + fee ); + let order_id = 0; expect_events(vec![ Event::Filled { order_id: 0, @@ -248,13 +247,11 @@ fn complete_fill_order_should_work_when_there_are_multiple_orders() { pallet_amm_support::Event::Swapped { swapper: BOB, filler: ALICE, - filler_type: pallet_amm_support::Filler::OTC, - operation: pallet_amm_support::TradeOperation::Sell, - asset_in: DAI, - asset_out: HDX, - amount_in: 20 * ONE, - amount_out: 100 * ONE, - fees: vec![(HDX, ONE, ::FeeReceiver::get())], + filler_type: pallet_amm_support::Filler::OTC(order_id), + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(DAI), 20 * ONE)], + outputs: vec![(AssetType::Fungible(HDX), 100 * ONE)], + fees: vec![Fee::new(HDX, ONE, ::FeeReceiver::get())], operation_id: vec![], } .into(), diff --git a/pallets/xyk/src/tests/fees.rs b/pallets/xyk/src/tests/fees.rs index 94d6d7a75..0319825e1 100644 --- a/pallets/xyk/src/tests/fees.rs +++ b/pallets/xyk/src/tests/fees.rs @@ -94,10 +94,15 @@ fn discount_sell_fees_should_work() { 400_000_000_000_000, )); - let pair_account = XYK::get_pair_id(AssetPair { + let pair = AssetPair { asset_in: asset_a, asset_out: asset_b, - }); + }; + + + let pair_account = XYK::get_pair_id(pair); + + let share_token = XYK::get_share_token(pair); let native_pair_account = XYK::get_pair_id(AssetPair { asset_in: asset_a, asset_out: HDX, @@ -145,14 +150,12 @@ fn discount_sell_fees_should_work() { pallet_amm_support::Event::Swapped { swapper: ALICE, filler: pair_account, - filler_type: pallet_amm_support::Filler::XYK, - operation: pallet_amm_support::TradeOperation::Sell, - asset_in: asset_a, - asset_out: asset_b, - amount_in: 10_000_000, - amount_out: 19_986_006, - fees: vec![(asset_b, 13_993, pair_account)], - event_id: None, + filler_type: pallet_amm_support::Filler::XYK(share_token), + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(asset_a), 10_000_000)], + outputs: vec![(AssetType::Fungible(asset_b), 19_986_006)], + fees: vec![Fee::new(asset_b, 13_993, pair_account)], + operation_id: vec![], } .into(), ]); diff --git a/runtime/adapters/src/tests/mock.rs b/runtime/adapters/src/tests/mock.rs index 57bf7d1ce..463e8dc03 100644 --- a/runtime/adapters/src/tests/mock.rs +++ b/runtime/adapters/src/tests/mock.rs @@ -342,6 +342,7 @@ impl pallet_route_executor::Config for Test { type OraclePeriod = RouteValidationOraclePeriod; type BatchIdProvider = AmmSupport; type WeightInfo = (); + type OperationIdProvider = AmmSupport; } pub struct MockedEdCalculator; From 66023cb9f4f583d5ebc71cf2ede95634c638972c Mon Sep 17 00:00:00 2001 From: dmoka Date: Tue, 5 Nov 2024 20:05:06 +0100 Subject: [PATCH 032/142] emit missing swapped events in omnipool --- pallets/omnipool/src/lib.rs | 46 +++++++++++++++++++++++++++++-- pallets/omnipool/src/tests/buy.rs | 6 ++-- 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/pallets/omnipool/src/lib.rs b/pallets/omnipool/src/lib.rs index a7766e002..d29155b61 100644 --- a/pallets/omnipool/src/lib.rs +++ b/pallets/omnipool/src/lib.rs @@ -1204,7 +1204,7 @@ pub mod pallet { ); Self::deposit_event(Event::SellExecuted { - who, + who: who.clone(), asset_in, asset_out, amount_in: amount, @@ -1215,6 +1215,27 @@ pub mod pallet { protocol_fee_amount: state_changes.fee.protocol_fee, }); + pallet_amm_support::Pallet::::deposit_trade_event( + who, + Self::protocol_account(), + pallet_amm_support::Filler::Omnipool, + pallet_amm_support::TradeOperation::ExactIn, + vec![( + AssetType::Fungible(asset_in.into()), + amount, + )], + vec![( + AssetType::Fungible(asset_out.into()), + *state_changes.asset_out.delta_reserve, + )], + vec![Fee { + asset: asset_out.into(), + amount: state_changes.fee.asset_fee, + recipient: Self::protocol_account(), + }, + Fee::new(T::HubAssetId::get().into(), state_changes.fee.protocol_fee, Self::protocol_account())], + ); + #[cfg(feature = "try-runtime")] Self::ensure_trade_invariant( (asset_in, asset_in_state, new_asset_in_state), @@ -1409,7 +1430,7 @@ pub mod pallet { ); Self::deposit_event(Event::BuyExecuted { - who, + who: who.clone(), asset_in, asset_out, amount_in: *state_changes.asset_in.delta_reserve, @@ -1420,6 +1441,27 @@ pub mod pallet { protocol_fee_amount: state_changes.fee.protocol_fee, }); + pallet_amm_support::Pallet::::deposit_trade_event( + who, + Self::protocol_account(), + pallet_amm_support::Filler::Omnipool, + pallet_amm_support::TradeOperation::ExactOut, + vec![( + AssetType::Fungible(asset_in.into()), + *state_changes.asset_in.delta_reserve, + )], + vec![( + AssetType::Fungible(asset_out.into()), + *state_changes.asset_out.delta_reserve, + )], + vec![Fee { + asset: asset_out.into(), + amount: state_changes.fee.asset_fee, + recipient: Self::protocol_account(), + }, + Fee::new(T::HubAssetId::get().into(), state_changes.fee.protocol_fee, Self::protocol_account())], + ); + #[cfg(feature = "try-runtime")] Self::ensure_trade_invariant( (asset_in, asset_in_state, new_asset_in_state), diff --git a/pallets/omnipool/src/tests/buy.rs b/pallets/omnipool/src/tests/buy.rs index 808c79fc0..13df0c331 100644 --- a/pallets/omnipool/src/tests/buy.rs +++ b/pallets/omnipool/src/tests/buy.rs @@ -446,7 +446,7 @@ fn buy_should_emit_event_with_correct_asset_fee_amount() { outputs: vec![(AssetType::Fungible(200), buy_amount)], fees: vec![ Fee::new(200, 5555555555556, Omnipool::protocol_account()), - Fee::new(1, 0, Omnipool::protocol_account()), + Fee::new(LRNA, 0, Omnipool::protocol_account()), ], operation_id: vec![], } @@ -507,7 +507,7 @@ fn buy_should_emit_event_with_correct_protocol_fee_amount() { outputs: vec![(AssetType::Fungible(200), buy_amount)], fees: vec![ Fee::new(200, 0, Omnipool::protocol_account()), - Fee::new(1, 5698005698005, Omnipool::protocol_account()), + Fee::new(LRNA, 5698005698005, Omnipool::protocol_account()), ], operation_id: vec![], } @@ -567,7 +567,7 @@ fn sell_should_get_same_amount() { outputs: vec![(AssetType::Fungible(200), buy_amount)], fees: vec![ Fee::new(200, 5555555555556, Omnipool::protocol_account()), - Fee::new(1, 0, Omnipool::protocol_account()), + Fee::new(LRNA, 0, Omnipool::protocol_account()), ], operation_id: vec![], } From fc28af62d4a1bca3f2e292b5ad575ceb521b6e10 Mon Sep 17 00:00:00 2001 From: dmoka Date: Tue, 5 Nov 2024 20:15:49 +0100 Subject: [PATCH 033/142] clean up in comments --- pallets/route-executor/src/lib.rs | 1 + traits/src/router.rs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pallets/route-executor/src/lib.rs b/pallets/route-executor/src/lib.rs index 98c998fd5..e237062fd 100644 --- a/pallets/route-executor/src/lib.rs +++ b/pallets/route-executor/src/lib.rs @@ -300,6 +300,7 @@ pub mod pallet { first_trade.amount_in, )?; + //TODO: we want to deprecate it once unified events are working fine Self::deposit_event(Event::Executed { asset_in, asset_out, diff --git a/traits/src/router.rs b/traits/src/router.rs index 8d871bf20..9d70e3812 100644 --- a/traits/src/router.rs +++ b/traits/src/router.rs @@ -113,9 +113,9 @@ pub type OtcOrderId = u32; #[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] pub enum Filler { Omnipool, - Stableswap(AssetId), // asset id + Stableswap(AssetId), // pool id XYK(AssetId), // share token - LBP, // ???? LBP(AssetId), // share token + LBP, OTC(OtcOrderId), // ICE(solution_id/block id), swapper: alice, filler: solver } From 24721f7122ae82a2d5ded5f174271d7fd38ec0a7 Mon Sep 17 00:00:00 2001 From: dmoka Date: Tue, 5 Nov 2024 20:47:02 +0100 Subject: [PATCH 034/142] update lock --- Cargo.lock | 41 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e16bf2df7..1eb057e70 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4883,6 +4883,7 @@ dependencies = [ "orml-utilities", "orml-vesting", "orml-xcm-support", + "pallet-amm-support", "pallet-asset-registry", "pallet-balances", "pallet-bonds", @@ -4957,6 +4958,7 @@ dependencies = [ "orml-xcm", "orml-xcm-support", "orml-xtokens", + "pallet-amm-support", "pallet-asset-registry", "pallet-aura", "pallet-authorship", @@ -7495,6 +7497,22 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" +[[package]] +name = "pallet-amm-support" +version = "1.0.0" +dependencies = [ + "frame-support", + "frame-system", + "hydradx-traits", + "parity-scale-codec", + "primitives", + "scale-info", + "sp-api", + "sp-core", + "sp-io", + "sp-std", +] + [[package]] name = "pallet-asset-conversion" version = "10.0.0" @@ -7836,6 +7854,7 @@ dependencies = [ "hydradx-traits", "orml-tokens", "orml-traits", + "pallet-amm-support", "pallet-balances", "pallet-omnipool", "parity-scale-codec", @@ -7997,6 +8016,7 @@ dependencies = [ "log", "orml-tokens", "orml-traits", + "pallet-amm-support", "pallet-balances", "pallet-currencies", "pallet-ema-oracle", @@ -8488,7 +8508,7 @@ dependencies = [ [[package]] name = "pallet-lbp" -version = "4.8.6" +version = "4.10.0" dependencies = [ "frame-benchmarking", "frame-support", @@ -8497,6 +8517,7 @@ dependencies = [ "hydradx-traits", "orml-tokens", "orml-traits", + "pallet-amm-support", "parity-scale-codec", "primitive-types", "proptest", @@ -8525,6 +8546,7 @@ dependencies = [ "pallet-balances", "parity-scale-codec", "pretty_assertions", + "primitives", "proptest", "rand 0.8.5", "scale-info", @@ -8736,7 +8758,7 @@ dependencies = [ [[package]] name = "pallet-omnipool" -version = "4.3.5" +version = "4.5.0" dependencies = [ "bitflags 1.3.2", "frame-benchmarking", @@ -8748,6 +8770,7 @@ dependencies = [ "log", "orml-tokens", "orml-traits", + "pallet-amm-support", "pallet-balances", "parity-scale-codec", "pretty_assertions", @@ -8773,6 +8796,7 @@ dependencies = [ "log", "orml-tokens", "orml-traits", + "pallet-amm-support", "pallet-balances", "pallet-ema-oracle", "pallet-liquidity-mining", @@ -8791,7 +8815,7 @@ dependencies = [ [[package]] name = "pallet-otc" -version = "2.0.3" +version = "2.2.0" dependencies = [ "frame-benchmarking", "frame-support", @@ -8799,6 +8823,7 @@ dependencies = [ "hydradx-traits", "orml-tokens", "orml-traits", + "pallet-amm-support", "parity-scale-codec", "pretty_assertions", "proptest", @@ -8823,6 +8848,7 @@ dependencies = [ "log", "orml-tokens", "orml-traits", + "pallet-amm-support", "pallet-asset-registry", "pallet-balances", "pallet-currencies", @@ -8999,7 +9025,7 @@ dependencies = [ [[package]] name = "pallet-route-executor" -version = "2.6.2" +version = "2.8.0" dependencies = [ "frame-benchmarking", "frame-support", @@ -9009,10 +9035,12 @@ dependencies = [ "hydradx-traits", "orml-tokens", "orml-traits", + "pallet-amm-support", "pallet-balances", "pallet-currencies", "parity-scale-codec", "pretty_assertions", + "primitives", "scale-info", "serde", "sp-core", @@ -9099,7 +9127,7 @@ dependencies = [ [[package]] name = "pallet-stableswap" -version = "3.6.5" +version = "3.8.0" dependencies = [ "bitflags 1.3.2", "frame-benchmarking", @@ -9109,6 +9137,7 @@ dependencies = [ "hydradx-traits", "orml-tokens", "orml-traits", + "pallet-amm-support", "parity-scale-codec", "proptest", "scale-info", @@ -9499,6 +9528,7 @@ dependencies = [ "log", "orml-tokens", "orml-traits", + "pallet-amm-support", "pallet-asset-registry", "parity-scale-codec", "primitive-types", @@ -12236,6 +12266,7 @@ dependencies = [ "orml-xcm", "orml-xcm-support", "orml-xtokens", + "pallet-amm-support", "pallet-asset-registry", "pallet-aura", "pallet-authorship", From 2d5394e7f582e93ec7695313e414ff2a010114e9 Mon Sep 17 00:00:00 2001 From: dmoka Date: Tue, 5 Nov 2024 20:47:53 +0100 Subject: [PATCH 035/142] fix compilation error --- pallets/omnipool/src/lib.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/pallets/omnipool/src/lib.rs b/pallets/omnipool/src/lib.rs index 477789df8..9d6222851 100644 --- a/pallets/omnipool/src/lib.rs +++ b/pallets/omnipool/src/lib.rs @@ -96,8 +96,6 @@ use sp_std::prelude::*; use crate::traits::ShouldAllow; use frame_support::traits::tokens::nonfungibles::{Create, Inspect, Mutate}; -use frame_system::ensure_signed; -use frame_system::pallet_prelude::OriginFor; use hydra_dx_math::ema::EmaPrice; use hydra_dx_math::omnipool::types::{AssetStateChange, BalanceUpdate, I129}; use hydradx_traits::registry::Inspect as RegistryInspect; From b2d1ef5a15e926ffccb6642c00973d38036b054b Mon Sep 17 00:00:00 2001 From: dmoka Date: Tue, 5 Nov 2024 20:49:08 +0100 Subject: [PATCH 036/142] formatting --- integration-tests/src/router.rs | 2 +- pallets/lbp/src/tests.rs | 5 +-- pallets/omnipool/src/lib.rs | 41 +++++++++++++-------- pallets/otc-settlements/src/tests.rs | 10 +++-- pallets/otc/src/tests/fill_order.rs | 2 +- pallets/otc/src/tests/partial_fill_order.rs | 8 +++- pallets/stableswap/src/tests/trades.rs | 2 +- pallets/xyk/src/tests/fees.rs | 3 +- pallets/xyk/src/tests/trades.rs | 3 +- 9 files changed, 44 insertions(+), 32 deletions(-) diff --git a/integration-tests/src/router.rs b/integration-tests/src/router.rs index d015a3b3b..57fcd22b1 100644 --- a/integration-tests/src/router.rs +++ b/integration-tests/src/router.rs @@ -7,6 +7,7 @@ use hydradx_runtime::{ AssetRegistry, BlockNumber, Currencies, Omnipool, Router, RouterWeightInfo, Runtime, RuntimeOrigin, Stableswap, LBP, XYK, }; +use hydradx_traits::router::AssetType; use hydradx_traits::router::RouteSpotPriceProvider; use hydradx_traits::{ registry::Create, @@ -20,7 +21,6 @@ use pallet_omnipool::types::Tradability; use pallet_omnipool::weights::WeightInfo as OmnipoolWeights; use pallet_route_executor::AmmTradeWeights; use std::convert::Into; -use hydradx_traits::router::AssetType; use hydradx_traits::router::AssetPair as Pair; use primitives::AssetId; diff --git a/pallets/lbp/src/tests.rs b/pallets/lbp/src/tests.rs index d04aa3ded..144f662a8 100644 --- a/pallets/lbp/src/tests.rs +++ b/pallets/lbp/src/tests.rs @@ -1889,10 +1889,7 @@ fn execute_sell_should_not_work() { assert_eq!(Currency::free_balance(KUSD, &KUSD_BSX_POOL_ID), 1_000_000_000); assert_eq!(Currency::free_balance(BSX, &KUSD_BSX_POOL_ID), 2_000_000_000); - assert_noop!( - LBPPallet::execute_sell(&t), - orml_tokens::Error::::BalanceTooLow - ); + assert_noop!(LBPPallet::execute_sell(&t), orml_tokens::Error::::BalanceTooLow); assert_eq!(Currency::free_balance(KUSD, &ALICE), 999_999_000_000_000); assert_eq!(Currency::free_balance(BSX, &ALICE), 999_998_000_000_000); diff --git a/pallets/omnipool/src/lib.rs b/pallets/omnipool/src/lib.rs index 9d6222851..cf3215012 100644 --- a/pallets/omnipool/src/lib.rs +++ b/pallets/omnipool/src/lib.rs @@ -1104,20 +1104,23 @@ pub mod pallet { Self::protocol_account(), pallet_amm_support::Filler::Omnipool, pallet_amm_support::TradeOperation::ExactIn, - vec![( - AssetType::Fungible(asset_in.into()), - amount, - )], + vec![(AssetType::Fungible(asset_in.into()), amount)], vec![( AssetType::Fungible(asset_out.into()), *state_changes.asset_out.delta_reserve, )], - vec![Fee { - asset: asset_out.into(), - amount: state_changes.fee.asset_fee, - recipient: Self::protocol_account(), - }, - Fee::new(T::HubAssetId::get().into(), state_changes.fee.protocol_fee, Self::protocol_account())], + vec![ + Fee { + asset: asset_out.into(), + amount: state_changes.fee.asset_fee, + recipient: Self::protocol_account(), + }, + Fee::new( + T::HubAssetId::get().into(), + state_changes.fee.protocol_fee, + Self::protocol_account(), + ), + ], ); #[cfg(feature = "try-runtime")] @@ -1338,12 +1341,18 @@ pub mod pallet { AssetType::Fungible(asset_out.into()), *state_changes.asset_out.delta_reserve, )], - vec![Fee { - asset: asset_out.into(), - amount: state_changes.fee.asset_fee, - recipient: Self::protocol_account(), - }, - Fee::new(T::HubAssetId::get().into(), state_changes.fee.protocol_fee, Self::protocol_account())], + vec![ + Fee { + asset: asset_out.into(), + amount: state_changes.fee.asset_fee, + recipient: Self::protocol_account(), + }, + Fee::new( + T::HubAssetId::get().into(), + state_changes.fee.protocol_fee, + Self::protocol_account(), + ), + ], ); #[cfg(feature = "try-runtime")] diff --git a/pallets/otc-settlements/src/tests.rs b/pallets/otc-settlements/src/tests.rs index fe750b404..417fb57e5 100644 --- a/pallets/otc-settlements/src/tests.rs +++ b/pallets/otc-settlements/src/tests.rs @@ -22,10 +22,10 @@ use super::*; pub use crate::mock::*; use frame_support::{assert_ok, assert_storage_noop}; +use hydradx_traits::router::AssetType; +use hydradx_traits::router::Fee; use hydradx_traits::Inspect; use orml_traits::MultiCurrency; -use hydradx_traits::router::Fee; -use hydradx_traits::router::AssetType; pub fn expect_events(e: Vec) { e.into_iter().for_each(frame_system::Pallet::::assert_has_event); } @@ -306,7 +306,11 @@ fn existing_arb_opportunity_should_trigger_trade_when_correct_amount_can_be_foun operation: pallet_amm_support::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(HDX), 2413749694825193)], outputs: vec![(AssetType::Fungible(DAI), 4948186874391645)], - fees: vec![Fee::new(DAI, 49481868743917, ::FeeReceiver::get())], + fees: vec![Fee::new( + DAI, + 49481868743917, + ::FeeReceiver::get(), + )], operation_id: vec![], } .into(), diff --git a/pallets/otc/src/tests/fill_order.rs b/pallets/otc/src/tests/fill_order.rs index 38054b12b..f6d56bf45 100644 --- a/pallets/otc/src/tests/fill_order.rs +++ b/pallets/otc/src/tests/fill_order.rs @@ -16,10 +16,10 @@ use crate as otc; use crate::tests::mock::*; use crate::Event; use frame_support::{assert_noop, assert_ok}; +use hydradx_traits::router::{AssetType, Fee}; use orml_tokens::Error::BalanceTooLow; use orml_traits::{MultiCurrency, NamedMultiReservableCurrency}; use pretty_assertions::assert_eq; -use hydradx_traits::router::{AssetType, Fee}; #[test] fn complete_fill_order_should_work() { diff --git a/pallets/otc/src/tests/partial_fill_order.rs b/pallets/otc/src/tests/partial_fill_order.rs index 1add8fc65..02ed68795 100644 --- a/pallets/otc/src/tests/partial_fill_order.rs +++ b/pallets/otc/src/tests/partial_fill_order.rs @@ -16,10 +16,10 @@ use crate as otc; use crate::tests::mock::*; use crate::{Error, Event}; use frame_support::{assert_noop, assert_ok}; +use hydradx_traits::router::{AssetType, Fee}; use orml_tokens::Error::BalanceTooLow; use orml_traits::{MultiCurrency, NamedMultiReservableCurrency}; use pretty_assertions::assert_eq; -use hydradx_traits::router::{AssetType, Fee}; #[test] fn partial_fill_order_should_work_when_order_is_partially_fillable() { @@ -101,7 +101,11 @@ fn partial_fill_order_should_work_when_order_is_partially_fillable() { operation: pallet_amm_support::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(order.asset_in), 5 * ONE)], outputs: vec![(AssetType::Fungible(order.asset_out), expected_amount_out)], - fees: vec![Fee::new(order.asset_out, fee, ::FeeReceiver::get())], + fees: vec![Fee::new( + order.asset_out, + fee, + ::FeeReceiver::get(), + )], operation_id: vec![], } .into(), diff --git a/pallets/stableswap/src/tests/trades.rs b/pallets/stableswap/src/tests/trades.rs index d35ae42eb..af5db1837 100644 --- a/pallets/stableswap/src/tests/trades.rs +++ b/pallets/stableswap/src/tests/trades.rs @@ -4,8 +4,8 @@ use crate::{assert_balance, to_precision, Error, Event}; use std::num::NonZeroU16; use frame_support::{assert_noop, assert_ok}; -use sp_runtime::Permill; use hydradx_traits::router::{AssetType, Fee}; +use sp_runtime::Permill; #[test] fn sell_should_work_when_correct_input_provided() { diff --git a/pallets/xyk/src/tests/fees.rs b/pallets/xyk/src/tests/fees.rs index 0319825e1..0a1a51e5f 100644 --- a/pallets/xyk/src/tests/fees.rs +++ b/pallets/xyk/src/tests/fees.rs @@ -1,9 +1,9 @@ pub use super::mock::*; use crate::{Error, Event}; use frame_support::{assert_noop, assert_ok}; +use hydradx_traits::router::{AssetType, Fee}; use hydradx_traits::AMM as AmmPool; use orml_traits::MultiCurrency; -use hydradx_traits::router::{AssetType, Fee}; use crate::types::AssetPair; @@ -99,7 +99,6 @@ fn discount_sell_fees_should_work() { asset_out: asset_b, }; - let pair_account = XYK::get_pair_id(pair); let share_token = XYK::get_share_token(pair); diff --git a/pallets/xyk/src/tests/trades.rs b/pallets/xyk/src/tests/trades.rs index a21bd1337..e01187871 100644 --- a/pallets/xyk/src/tests/trades.rs +++ b/pallets/xyk/src/tests/trades.rs @@ -1,9 +1,9 @@ pub use super::mock::*; use crate::{AMMTransfer, Error, Event}; use frame_support::{assert_noop, assert_ok}; +use hydradx_traits::router::{AssetType, Fee}; use hydradx_traits::AMM as AmmPool; use orml_traits::MultiCurrency; -use hydradx_traits::router::{AssetType, Fee}; use crate::types::AssetPair; @@ -106,7 +106,6 @@ fn execute_sell_should_use_event_id() { asset_out: asset_b, }); - let share_token = XYK::share_token(pair_account); let t = AMMTransfer { From ca4b6ba38eb5c9791eb325652accdd9feaadc8ee Mon Sep 17 00:00:00 2001 From: dmoka Date: Wed, 6 Nov 2024 09:28:43 +0100 Subject: [PATCH 037/142] update lock --- Cargo.lock | 41 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 796063658..6c2193861 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4883,6 +4883,7 @@ dependencies = [ "orml-utilities", "orml-vesting", "orml-xcm-support", + "pallet-amm-support", "pallet-asset-registry", "pallet-balances", "pallet-bonds", @@ -4957,6 +4958,7 @@ dependencies = [ "orml-xcm", "orml-xcm-support", "orml-xtokens", + "pallet-amm-support", "pallet-asset-registry", "pallet-aura", "pallet-authorship", @@ -7495,6 +7497,22 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" +[[package]] +name = "pallet-amm-support" +version = "1.0.0" +dependencies = [ + "frame-support", + "frame-system", + "hydradx-traits", + "parity-scale-codec", + "primitives", + "scale-info", + "sp-api", + "sp-core", + "sp-io", + "sp-std", +] + [[package]] name = "pallet-asset-conversion" version = "10.0.0" @@ -7836,6 +7854,7 @@ dependencies = [ "hydradx-traits", "orml-tokens", "orml-traits", + "pallet-amm-support", "pallet-balances", "pallet-omnipool", "parity-scale-codec", @@ -7997,6 +8016,7 @@ dependencies = [ "log", "orml-tokens", "orml-traits", + "pallet-amm-support", "pallet-balances", "pallet-currencies", "pallet-ema-oracle", @@ -8488,7 +8508,7 @@ dependencies = [ [[package]] name = "pallet-lbp" -version = "4.8.6" +version = "4.10.0" dependencies = [ "frame-benchmarking", "frame-support", @@ -8497,6 +8517,7 @@ dependencies = [ "hydradx-traits", "orml-tokens", "orml-traits", + "pallet-amm-support", "parity-scale-codec", "primitive-types", "proptest", @@ -8525,6 +8546,7 @@ dependencies = [ "pallet-balances", "parity-scale-codec", "pretty_assertions", + "primitives", "proptest", "rand 0.8.5", "scale-info", @@ -8736,7 +8758,7 @@ dependencies = [ [[package]] name = "pallet-omnipool" -version = "4.3.6" +version = "4.6.0" dependencies = [ "bitflags 1.3.2", "frame-benchmarking", @@ -8748,6 +8770,7 @@ dependencies = [ "log", "orml-tokens", "orml-traits", + "pallet-amm-support", "pallet-balances", "parity-scale-codec", "pretty_assertions", @@ -8773,6 +8796,7 @@ dependencies = [ "log", "orml-tokens", "orml-traits", + "pallet-amm-support", "pallet-balances", "pallet-ema-oracle", "pallet-liquidity-mining", @@ -8791,7 +8815,7 @@ dependencies = [ [[package]] name = "pallet-otc" -version = "2.0.3" +version = "2.2.0" dependencies = [ "frame-benchmarking", "frame-support", @@ -8799,6 +8823,7 @@ dependencies = [ "hydradx-traits", "orml-tokens", "orml-traits", + "pallet-amm-support", "parity-scale-codec", "pretty_assertions", "proptest", @@ -8823,6 +8848,7 @@ dependencies = [ "log", "orml-tokens", "orml-traits", + "pallet-amm-support", "pallet-asset-registry", "pallet-balances", "pallet-currencies", @@ -8999,7 +9025,7 @@ dependencies = [ [[package]] name = "pallet-route-executor" -version = "2.6.2" +version = "2.8.0" dependencies = [ "frame-benchmarking", "frame-support", @@ -9009,10 +9035,12 @@ dependencies = [ "hydradx-traits", "orml-tokens", "orml-traits", + "pallet-amm-support", "pallet-balances", "pallet-currencies", "parity-scale-codec", "pretty_assertions", + "primitives", "scale-info", "serde", "sp-core", @@ -9099,7 +9127,7 @@ dependencies = [ [[package]] name = "pallet-stableswap" -version = "3.6.5" +version = "3.8.0" dependencies = [ "bitflags 1.3.2", "frame-benchmarking", @@ -9109,6 +9137,7 @@ dependencies = [ "hydradx-traits", "orml-tokens", "orml-traits", + "pallet-amm-support", "parity-scale-codec", "proptest", "scale-info", @@ -9499,6 +9528,7 @@ dependencies = [ "log", "orml-tokens", "orml-traits", + "pallet-amm-support", "pallet-asset-registry", "parity-scale-codec", "primitive-types", @@ -12236,6 +12266,7 @@ dependencies = [ "orml-xcm", "orml-xcm-support", "orml-xtokens", + "pallet-amm-support", "pallet-asset-registry", "pallet-aura", "pallet-authorship", From 7ccd1c1c90e8e6ba52c5f9da51452c7b6fe90591 Mon Sep 17 00:00:00 2001 From: dmoka Date: Wed, 6 Nov 2024 09:35:11 +0100 Subject: [PATCH 038/142] update lock --- Cargo.lock | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3a93e4c53..18100b169 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4883,6 +4883,7 @@ dependencies = [ "orml-utilities", "orml-vesting", "orml-xcm-support", + "pallet-amm-support", "pallet-asset-registry", "pallet-balances", "pallet-bonds", @@ -4957,6 +4958,7 @@ dependencies = [ "orml-xcm", "orml-xcm-support", "orml-xtokens", + "pallet-amm-support", "pallet-asset-registry", "pallet-aura", "pallet-authorship", @@ -7495,6 +7497,22 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" +[[package]] +name = "pallet-amm-support" +version = "1.0.0" +dependencies = [ + "frame-support", + "frame-system", + "hydradx-traits", + "parity-scale-codec", + "primitives", + "scale-info", + "sp-api", + "sp-core", + "sp-io", + "sp-std", +] + [[package]] name = "pallet-asset-conversion" version = "10.0.0" @@ -7836,6 +7854,7 @@ dependencies = [ "hydradx-traits", "orml-tokens", "orml-traits", + "pallet-amm-support", "pallet-balances", "pallet-omnipool", "parity-scale-codec", @@ -7997,6 +8016,7 @@ dependencies = [ "log", "orml-tokens", "orml-traits", + "pallet-amm-support", "pallet-balances", "pallet-currencies", "pallet-ema-oracle", @@ -8488,7 +8508,7 @@ dependencies = [ [[package]] name = "pallet-lbp" -version = "4.8.6" +version = "4.10.0" dependencies = [ "frame-benchmarking", "frame-support", @@ -8497,6 +8517,7 @@ dependencies = [ "hydradx-traits", "orml-tokens", "orml-traits", + "pallet-amm-support", "parity-scale-codec", "primitive-types", "proptest", @@ -8525,6 +8546,7 @@ dependencies = [ "pallet-balances", "parity-scale-codec", "pretty_assertions", + "primitives", "proptest", "rand 0.8.5", "scale-info", @@ -8736,7 +8758,7 @@ dependencies = [ [[package]] name = "pallet-omnipool" -version = "4.3.6" +version = "4.6.0" dependencies = [ "bitflags 1.3.2", "frame-benchmarking", @@ -8748,6 +8770,7 @@ dependencies = [ "log", "orml-tokens", "orml-traits", + "pallet-amm-support", "pallet-balances", "parity-scale-codec", "pretty_assertions", @@ -8773,6 +8796,7 @@ dependencies = [ "log", "orml-tokens", "orml-traits", + "pallet-amm-support", "pallet-balances", "pallet-ema-oracle", "pallet-liquidity-mining", @@ -8791,7 +8815,7 @@ dependencies = [ [[package]] name = "pallet-otc" -version = "2.0.3" +version = "2.2.0" dependencies = [ "frame-benchmarking", "frame-support", @@ -8799,6 +8823,7 @@ dependencies = [ "hydradx-traits", "orml-tokens", "orml-traits", + "pallet-amm-support", "parity-scale-codec", "pretty_assertions", "proptest", @@ -8823,6 +8848,7 @@ dependencies = [ "log", "orml-tokens", "orml-traits", + "pallet-amm-support", "pallet-asset-registry", "pallet-balances", "pallet-currencies", @@ -8999,7 +9025,7 @@ dependencies = [ [[package]] name = "pallet-route-executor" -version = "2.6.2" +version = "2.8.0" dependencies = [ "frame-benchmarking", "frame-support", @@ -9009,10 +9035,12 @@ dependencies = [ "hydradx-traits", "orml-tokens", "orml-traits", + "pallet-amm-support", "pallet-balances", "pallet-currencies", "parity-scale-codec", "pretty_assertions", + "primitives", "scale-info", "serde", "sp-core", @@ -9099,7 +9127,7 @@ dependencies = [ [[package]] name = "pallet-stableswap" -version = "4.0.0" +version = "4.1.0" dependencies = [ "bitflags 1.3.2", "frame-benchmarking", @@ -9109,6 +9137,7 @@ dependencies = [ "hydradx-traits", "orml-tokens", "orml-traits", + "pallet-amm-support", "parity-scale-codec", "proptest", "scale-info", @@ -9499,6 +9528,7 @@ dependencies = [ "log", "orml-tokens", "orml-traits", + "pallet-amm-support", "pallet-asset-registry", "parity-scale-codec", "primitive-types", @@ -12199,7 +12229,7 @@ dependencies = [ [[package]] name = "runtime-integration-tests" -version = "1.25.1" +version = "1.25.0" dependencies = [ "cumulus-pallet-aura-ext", "cumulus-pallet-parachain-system", @@ -12236,6 +12266,7 @@ dependencies = [ "orml-xcm", "orml-xcm-support", "orml-xtokens", + "pallet-amm-support", "pallet-asset-registry", "pallet-aura", "pallet-authorship", From 0d6c6cb7e1ab02972ea4a424a169e674beb9e1f6 Mon Sep 17 00:00:00 2001 From: dmoka Date: Wed, 6 Nov 2024 09:49:08 +0100 Subject: [PATCH 039/142] fix compilation error --- pallets/amm-support/src/tests/mock.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pallets/amm-support/src/tests/mock.rs b/pallets/amm-support/src/tests/mock.rs index 780ad9cfa..b0c12b300 100644 --- a/pallets/amm-support/src/tests/mock.rs +++ b/pallets/amm-support/src/tests/mock.rs @@ -76,6 +76,11 @@ impl frame_system::Config for Test { type SS58Prefix = (); type OnSetCode = (); type MaxConsumers = ConstU32<16>; + type SingleBlockMigrations = (); + type MultiBlockMigrator = (); + type PreInherents = (); + type PostInherents = (); + type PostTransactions = (); } #[derive(Default)] From abd9ed2ea76291901451fde175f169913667e819 Mon Sep 17 00:00:00 2001 From: dmoka Date: Wed, 6 Nov 2024 10:10:42 +0100 Subject: [PATCH 040/142] raise swapped event in stableswap --- pallets/stableswap/src/lib.rs | 35 +++++++++++++++++++++++++++++++-- pallets/xyk/src/tests/trades.rs | 1 - 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/pallets/stableswap/src/lib.rs b/pallets/stableswap/src/lib.rs index 95ae59af6..d2ca47810 100644 --- a/pallets/stableswap/src/lib.rs +++ b/pallets/stableswap/src/lib.rs @@ -107,6 +107,7 @@ pub mod pallet { use sp_runtime::ArithmeticError; use sp_runtime::Permill; use sp_std::num::NonZeroU16; + use hydradx_traits::router::{AssetType, Fee}; #[pallet::pallet] pub struct Pallet(_); @@ -766,8 +767,9 @@ pub mod pallet { //All done and updated. Let's call on_trade hook. Self::call_on_trade_hook(pool_id, asset_in, asset_out, &initial_reserves)?; + //TODO: Remove once we migrated completely to Swapped event Self::deposit_event(Event::SellExecuted { - who, + who: who.clone(), pool_id, asset_in, asset_out, @@ -776,6 +778,20 @@ pub mod pallet { fee: fee_amount, }); + pallet_amm_support::Pallet::::deposit_trade_event( + who, + pool_account.clone(), + pallet_amm_support::Filler::Stableswap(pool_id.into()), + pallet_amm_support::TradeOperation::ExactIn, + vec![(AssetType::Fungible(asset_in.into()), amount_in)], + vec![(AssetType::Fungible(asset_out.into()), amount_out)], + vec![Fee { + asset: asset_out.into(), + amount: fee_amount, + recipient: pool_account, + }], + ); + #[cfg(feature = "try-runtime")] Self::ensure_trade_invariant(pool_id, &initial_reserves, pool.fee); @@ -845,8 +861,9 @@ pub mod pallet { //All done and updated. Let's call on_trade_hook. Self::call_on_trade_hook(pool_id, asset_in, asset_out, &initial_reserves)?; + //TODO: remove once we migrated completely to Swapped event Self::deposit_event(Event::BuyExecuted { - who, + who: who.clone(), pool_id, asset_in, asset_out, @@ -855,6 +872,20 @@ pub mod pallet { fee: fee_amount, }); + pallet_amm_support::Pallet::::deposit_trade_event( + who, + pool_account.clone(), + pallet_amm_support::Filler::Stableswap(pool_id.into()), + pallet_amm_support::TradeOperation::ExactOut, + vec![(AssetType::Fungible(asset_in.into()), amount_in)], + vec![(AssetType::Fungible(asset_out.into()), amount_out)], + vec![Fee { + asset: asset_in.into(), + amount: fee_amount, + recipient: pool_account, + }], + ); + #[cfg(feature = "try-runtime")] Self::ensure_trade_invariant(pool_id, &initial_reserves, pool.fee); diff --git a/pallets/xyk/src/tests/trades.rs b/pallets/xyk/src/tests/trades.rs index e01187871..86d8f4795 100644 --- a/pallets/xyk/src/tests/trades.rs +++ b/pallets/xyk/src/tests/trades.rs @@ -121,7 +121,6 @@ fn execute_sell_should_use_event_id() { fee: (asset_b, 2732432046), }; - let event_id = Some(7); assert_ok!(XYK::execute_sell(&t)); expect_events(vec![ From e262a045e8e23418199fc69cca689fc231d867d7 Mon Sep 17 00:00:00 2001 From: dmoka Date: Wed, 6 Nov 2024 10:43:24 +0100 Subject: [PATCH 041/142] add HubAmountUpdated event deposits as these are extra info relating to omnipool swaps --- pallets/omnipool/src/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pallets/omnipool/src/lib.rs b/pallets/omnipool/src/lib.rs index cf3215012..507aa87c4 100644 --- a/pallets/omnipool/src/lib.rs +++ b/pallets/omnipool/src/lib.rs @@ -1099,6 +1099,11 @@ pub mod pallet { protocol_fee_amount: state_changes.fee.protocol_fee, }); + Self::deposit_event(Event::HubAmountUpdated { + hub_amount_in: *state_changes.asset_in.delta_hub_reserve, + hub_amount_out: *state_changes.asset_out.delta_hub_reserve, + }); + pallet_amm_support::Pallet::::deposit_trade_event( who, Self::protocol_account(), @@ -1328,6 +1333,11 @@ pub mod pallet { protocol_fee_amount: state_changes.fee.protocol_fee, }); + Self::deposit_event(crate::pallet::Event::HubAmountUpdated { + hub_amount_in: *state_changes.asset_in.delta_hub_reserve, + hub_amount_out: *state_changes.asset_out.delta_hub_reserve, + }); + pallet_amm_support::Pallet::::deposit_trade_event( who, Self::protocol_account(), From 14b24ff02cc4d6255641328590cff222d294193e Mon Sep 17 00:00:00 2001 From: dmoka Date: Wed, 6 Nov 2024 11:08:03 +0100 Subject: [PATCH 042/142] add comments explaining the why --- pallets/omnipool/src/lib.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pallets/omnipool/src/lib.rs b/pallets/omnipool/src/lib.rs index 507aa87c4..956207b12 100644 --- a/pallets/omnipool/src/lib.rs +++ b/pallets/omnipool/src/lib.rs @@ -1883,6 +1883,8 @@ impl Pallet { protocol_fee_amount: state_changes.fee.protocol_fee, }); + //No need to deposit `HubAmountUpdated` event as hub amounts are zero + pallet_amm_support::Pallet::::deposit_trade_event( who.clone(), Self::protocol_account(), @@ -2011,6 +2013,8 @@ impl Pallet { protocol_fee_amount: state_changes.fee.protocol_fee, }); + //No need to deposit `HubAmountUpdated` event as hub amounts are zero + pallet_amm_support::Pallet::::deposit_trade_event( who.clone(), Self::protocol_account(), From 25808e98257ffc0ec7a7751c68fd8579c132bde3 Mon Sep 17 00:00:00 2001 From: dmoka Date: Wed, 6 Nov 2024 12:28:45 +0100 Subject: [PATCH 043/142] pass event id id to HubAmountUpdated event --- integration-tests/src/referrals.rs | 2 ++ integration-tests/src/router.rs | 12 ++++++++++++ pallets/circuit-breaker/src/tests/mock.rs | 1 + pallets/dca/src/tests/mock.rs | 1 + pallets/omnipool-liquidity-mining/src/tests/mock.rs | 1 + pallets/omnipool/src/lib.rs | 11 +++++++++-- pallets/omnipool/src/tests/mock.rs | 1 + pallets/otc-settlements/src/mock.rs | 1 + pallets/route-executor/src/lib.rs | 2 ++ runtime/adapters/src/tests/mock.rs | 1 + runtime/hydradx/src/assets.rs | 1 + 11 files changed, 32 insertions(+), 2 deletions(-) diff --git a/integration-tests/src/referrals.rs b/integration-tests/src/referrals.rs index f3ed29978..853b21a15 100644 --- a/integration-tests/src/referrals.rs +++ b/integration-tests/src/referrals.rs @@ -355,6 +355,7 @@ fn buying_hdx_in_omnipool_should_transfer_correct_fee() { pallet_omnipool::Event::HubAmountUpdated { hub_amount_in: 1_209_746_177, hub_amount_out: 1_209_141_304, + operation_id: vec![], } .into(), pallet_amm_support::Event::Swapped { @@ -413,6 +414,7 @@ fn buying_with_hdx_in_omnipool_should_transfer_correct_fee() { pallet_omnipool::Event::HubAmountUpdated { hub_amount_in: 45_222_713_080, hub_amount_out: 45_200_101_724, + operation_id: vec![], } .into(), pallet_amm_support::Event::Swapped { diff --git a/integration-tests/src/router.rs b/integration-tests/src/router.rs index 57fcd22b1..214acbe5c 100644 --- a/integration-tests/src/router.rs +++ b/integration-tests/src/router.rs @@ -2395,6 +2395,11 @@ mod omnipool_router_tests { assert_balance!(BOB.into(), DAI, BOB_INITIAL_DAI_BALANCE + amount_out); expect_hydra_last_events(vec![ + pallet_omnipool::Event::HubAmountUpdated { + hub_amount_in: 12014871681, + hub_amount_out: 12008864246, + operation_id: vec![ExecutionType::Router(0)], + }.into(), pallet_amm_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), @@ -2452,6 +2457,7 @@ mod omnipool_router_tests { pallet_omnipool::Event::HubAmountUpdated { hub_amount_in: 12014871681, hub_amount_out: 12008864246, + operation_id: vec![] } .into(), pallet_amm_support::Event::Swapped { @@ -2614,6 +2620,11 @@ mod omnipool_router_tests { assert_balance!(BOB.into(), DAI, BOB_INITIAL_DAI_BALANCE + amount_to_buy); expect_hydra_last_events(vec![ + pallet_omnipool::Event::HubAmountUpdated { + hub_amount_in: 45135, + hub_amount_out: 45113, + operation_id: vec![ExecutionType::Router(0)], + }.into(), pallet_amm_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), @@ -2671,6 +2682,7 @@ mod omnipool_router_tests { pallet_omnipool::Event::HubAmountUpdated { hub_amount_in: 45135, hub_amount_out: 45113, + operation_id: vec![] } .into(), pallet_amm_support::Event::Swapped { diff --git a/pallets/circuit-breaker/src/tests/mock.rs b/pallets/circuit-breaker/src/tests/mock.rs index 4d196ba13..f38aa5b3c 100644 --- a/pallets/circuit-breaker/src/tests/mock.rs +++ b/pallets/circuit-breaker/src/tests/mock.rs @@ -230,6 +230,7 @@ impl pallet_omnipool::Config for Test { type MinWithdrawalFee = MinWithdrawFee; type ExternalPriceOracle = WithdrawFeePriceOracle; type Fee = FeeProvider; + type OperationIdProvider = AmmSupport; } impl pallet_amm_support::Config for Test { diff --git a/pallets/dca/src/tests/mock.rs b/pallets/dca/src/tests/mock.rs index fca33ded4..2fe36282c 100644 --- a/pallets/dca/src/tests/mock.rs +++ b/pallets/dca/src/tests/mock.rs @@ -265,6 +265,7 @@ impl pallet_omnipool::Config for Test { type MinWithdrawalFee = (); type ExternalPriceOracle = WithdrawFeePriceOracle; type Fee = FeeProvider; + type OperationIdProvider = AmmSupport; } pub struct WithdrawFeePriceOracle; diff --git a/pallets/omnipool-liquidity-mining/src/tests/mock.rs b/pallets/omnipool-liquidity-mining/src/tests/mock.rs index 83fd6d167..105146c2b 100644 --- a/pallets/omnipool-liquidity-mining/src/tests/mock.rs +++ b/pallets/omnipool-liquidity-mining/src/tests/mock.rs @@ -306,6 +306,7 @@ impl pallet_omnipool::Config for Test { type MinWithdrawalFee = MinWithdrawFee; type ExternalPriceOracle = WithdrawFeePriceOracle; type Fee = FeeProvider; + type OperationIdProvider = AmmSupport; } impl pallet_amm_support::Config for Test { diff --git a/pallets/omnipool/src/lib.rs b/pallets/omnipool/src/lib.rs index 956207b12..caa29dd28 100644 --- a/pallets/omnipool/src/lib.rs +++ b/pallets/omnipool/src/lib.rs @@ -93,13 +93,13 @@ use sp_runtime::traits::{AccountIdConversion, AtLeast32BitUnsigned, One}; use sp_runtime::traits::{CheckedAdd, CheckedSub, Zero}; use sp_std::ops::{Add, Sub}; use sp_std::prelude::*; - +use hydradx_traits::router::ExecutionTypeStack; use crate::traits::ShouldAllow; use frame_support::traits::tokens::nonfungibles::{Create, Inspect, Mutate}; use hydra_dx_math::ema::EmaPrice; use hydra_dx_math::omnipool::types::{AssetStateChange, BalanceUpdate, I129}; use hydradx_traits::registry::Inspect as RegistryInspect; -use hydradx_traits::router::{AssetType, Fee}; +use hydradx_traits::router::{AssetType, Fee, ExecutionType}; use orml_traits::{GetByKey, MultiCurrency}; #[cfg(feature = "try-runtime")] use primitive_types::U256; @@ -136,6 +136,7 @@ pub mod pallet { use hydra_dx_math::ema::EmaPrice; use hydra_dx_math::omnipool::types::{BalanceUpdate, I129}; use orml_traits::GetByKey; + use pallet_amm_support::IncrementalIdType; use sp_runtime::ArithmeticError; #[pallet::pallet] @@ -233,6 +234,9 @@ pub mod pallet { /// Oracle price provider. Provides price for given asset. Used in remove liquidity to support calculation of dynamic withdrawal fee. type ExternalPriceOracle: ExternalPriceProvider; + + /// Operation id provider for unified events + type OperationIdProvider: ExecutionTypeStack; } #[pallet::storage] @@ -371,6 +375,7 @@ pub mod pallet { HubAmountUpdated { hub_amount_in: Balance, hub_amount_out: Balance, + operation_id: Vec> }, } @@ -1102,6 +1107,7 @@ pub mod pallet { Self::deposit_event(Event::HubAmountUpdated { hub_amount_in: *state_changes.asset_in.delta_hub_reserve, hub_amount_out: *state_changes.asset_out.delta_hub_reserve, + operation_id: T::OperationIdProvider::get() }); pallet_amm_support::Pallet::::deposit_trade_event( @@ -1336,6 +1342,7 @@ pub mod pallet { Self::deposit_event(crate::pallet::Event::HubAmountUpdated { hub_amount_in: *state_changes.asset_in.delta_hub_reserve, hub_amount_out: *state_changes.asset_out.delta_hub_reserve, + operation_id: T::OperationIdProvider::get() }); pallet_amm_support::Pallet::::deposit_trade_event( diff --git a/pallets/omnipool/src/tests/mock.rs b/pallets/omnipool/src/tests/mock.rs index b3731d0b9..09e155818 100644 --- a/pallets/omnipool/src/tests/mock.rs +++ b/pallets/omnipool/src/tests/mock.rs @@ -211,6 +211,7 @@ impl Config for Test { type MinWithdrawalFee = MinWithdrawFee; type ExternalPriceOracle = WithdrawFeePriceOracle; type Fee = FeeProvider; + type OperationIdProvider = AmmSupport; } pub struct ExtBuilder { diff --git a/pallets/otc-settlements/src/mock.rs b/pallets/otc-settlements/src/mock.rs index ac8b14622..fa0ea4461 100644 --- a/pallets/otc-settlements/src/mock.rs +++ b/pallets/otc-settlements/src/mock.rs @@ -353,6 +353,7 @@ impl pallet_omnipool::Config for Test { type MinWithdrawalFee = (); type ExternalPriceOracle = WithdrawFeePriceOracle; type Fee = FeeProvider; + type OperationIdProvider = AmmSupport; } pub struct DummyNFT; diff --git a/pallets/route-executor/src/lib.rs b/pallets/route-executor/src/lib.rs index e237062fd..0a064c167 100644 --- a/pallets/route-executor/src/lib.rs +++ b/pallets/route-executor/src/lib.rs @@ -130,8 +130,10 @@ pub mod pallet { /// Origin able to set route without validation type TechnicalOrigin: EnsureOrigin; + /// Event id provider for unified events type BatchIdProvider: IncrementalIdProvider; + /// Operation id provider for unified events type OperationIdProvider: ExecutionTypeStack; /// Weight information for the extrinsics. diff --git a/runtime/adapters/src/tests/mock.rs b/runtime/adapters/src/tests/mock.rs index 232ad517f..0d773584d 100644 --- a/runtime/adapters/src/tests/mock.rs +++ b/runtime/adapters/src/tests/mock.rs @@ -217,6 +217,7 @@ impl pallet_omnipool::Config for Test { ); type MinWithdrawalFee = MinWithdrawFee; type ExternalPriceOracle = WithdrawFeePriceOracle; + type OperationIdProvider = AmmSupport; } pub struct FeeProvider; diff --git a/runtime/hydradx/src/assets.rs b/runtime/hydradx/src/assets.rs index 0f6eef117..0d40f50b1 100644 --- a/runtime/hydradx/src/assets.rs +++ b/runtime/hydradx/src/assets.rs @@ -530,6 +530,7 @@ impl pallet_omnipool::Config for Runtime { ); type ExternalPriceOracle = EmaOraclePriceAdapter; type Fee = pallet_dynamic_fees::UpdateAndRetrieveFees; + type OperationIdProvider = AmmSupport; } pub struct CircuitBreakerWhitelist; From f5a986ec4dcf686f43c7462f6400198309a4c9ea Mon Sep 17 00:00:00 2001 From: dmoka Date: Wed, 6 Nov 2024 12:28:52 +0100 Subject: [PATCH 044/142] formatting --- integration-tests/src/router.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/integration-tests/src/router.rs b/integration-tests/src/router.rs index 214acbe5c..fdb3c4fc3 100644 --- a/integration-tests/src/router.rs +++ b/integration-tests/src/router.rs @@ -2399,7 +2399,8 @@ mod omnipool_router_tests { hub_amount_in: 12014871681, hub_amount_out: 12008864246, operation_id: vec![ExecutionType::Router(0)], - }.into(), + } + .into(), pallet_amm_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), @@ -2457,7 +2458,7 @@ mod omnipool_router_tests { pallet_omnipool::Event::HubAmountUpdated { hub_amount_in: 12014871681, hub_amount_out: 12008864246, - operation_id: vec![] + operation_id: vec![], } .into(), pallet_amm_support::Event::Swapped { @@ -2624,7 +2625,8 @@ mod omnipool_router_tests { hub_amount_in: 45135, hub_amount_out: 45113, operation_id: vec![ExecutionType::Router(0)], - }.into(), + } + .into(), pallet_amm_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), @@ -2682,7 +2684,7 @@ mod omnipool_router_tests { pallet_omnipool::Event::HubAmountUpdated { hub_amount_in: 45135, hub_amount_out: 45113, - operation_id: vec![] + operation_id: vec![], } .into(), pallet_amm_support::Event::Swapped { From 8169f00a1a4e6219af6d4b7bdea344c86632fda8 Mon Sep 17 00:00:00 2001 From: dmoka Date: Wed, 6 Nov 2024 15:52:40 +0100 Subject: [PATCH 045/142] add todos --- pallets/dca/src/lib.rs | 4 +++- pallets/stableswap/src/lib.rs | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pallets/dca/src/lib.rs b/pallets/dca/src/lib.rs index b230239cd..2b18480a7 100644 --- a/pallets/dca/src/lib.rs +++ b/pallets/dca/src/lib.rs @@ -330,7 +330,9 @@ pub mod pallet { who: T::AccountId, block: BlockNumberFor, }, - ///The DCA trade is successfully executed + /// Deprecated. Use pallet_amm::Event::Swapped instead. + /// The DCA trade is successfully executed + //TODO: remove once we migrated completely to pallet_amm::Event::Swapped TradeExecuted { id: ScheduleId, who: T::AccountId, diff --git a/pallets/stableswap/src/lib.rs b/pallets/stableswap/src/lib.rs index d2ca47810..986e83bab 100644 --- a/pallets/stableswap/src/lib.rs +++ b/pallets/stableswap/src/lib.rs @@ -209,6 +209,7 @@ pub mod pallet { }, /// Sell trade executed. Trade fee paid in asset leaving the pool (already subtracted from amount_out). /// Deprecated. Replaced by pallet_amm_support::Swapped + //TODO: remove once we migrated completely to pallet_amm::Event::Swapped SellExecuted { who: T::AccountId, pool_id: T::AssetId, @@ -767,7 +768,6 @@ pub mod pallet { //All done and updated. Let's call on_trade hook. Self::call_on_trade_hook(pool_id, asset_in, asset_out, &initial_reserves)?; - //TODO: Remove once we migrated completely to Swapped event Self::deposit_event(Event::SellExecuted { who: who.clone(), pool_id, @@ -861,7 +861,6 @@ pub mod pallet { //All done and updated. Let's call on_trade_hook. Self::call_on_trade_hook(pool_id, asset_in, asset_out, &initial_reserves)?; - //TODO: remove once we migrated completely to Swapped event Self::deposit_event(Event::BuyExecuted { who: who.clone(), pool_id, From d3186372d166cea5dbeb8dda52a35eef5b2cd942 Mon Sep 17 00:00:00 2001 From: dmoka Date: Thu, 7 Nov 2024 20:36:39 +0100 Subject: [PATCH 046/142] add unified event stack handling for DCA --- integration-tests/src/dca.rs | 141 +++++++++++++++++++++++++++++++++- pallets/dca/Cargo.toml | 1 + pallets/dca/src/lib.rs | 24 ++++-- pallets/dca/src/tests/mock.rs | 1 + pallets/omnipool/src/lib.rs | 22 +++--- pallets/stableswap/src/lib.rs | 2 +- runtime/hydradx/src/assets.rs | 1 + 7 files changed, 173 insertions(+), 19 deletions(-) diff --git a/integration-tests/src/dca.rs b/integration-tests/src/dca.rs index 8ed62338b..deb930c50 100644 --- a/integration-tests/src/dca.rs +++ b/integration-tests/src/dca.rs @@ -37,7 +37,7 @@ mod omnipool { use super::*; use frame_support::assert_ok; use hydradx_runtime::{DCA, XYK}; - use hydradx_traits::router::{PoolType, Trade}; + use hydradx_traits::router::{ExecutionType, PoolType, Trade}; use hydradx_traits::AssetKind; use sp_runtime::{FixedU128, TransactionOutcome}; @@ -201,6 +201,61 @@ mod omnipool { }); } + #[test] + fn buy_schedule_execution_should_emit_swapped_events() { + TestNet::reset(); + Hydra::execute_with(|| { + //Arrange + init_omnipool_with_oracle_for_block_10(); + + let dca_budget = 1000 * UNITS; + let amount_out = 100 * UNITS; + let schedule1 = schedule_fake_with_buy_order(PoolType::Omnipool, HDX, DAI, amount_out, dca_budget); + create_schedule(ALICE, schedule1); + + //Act + run_to_block2(11, 12); + + //Assert + let swapped_events = get_last_swapped_events(); + pretty_assertions::assert_eq!( + *swapped_events.last().unwrap(), + RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + swapper: ALICE.into(), + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::Filler::Omnipool, + operation: pallet_amm_support::TradeOperation::ExactOut, + inputs: vec![(AssetType::Fungible(HDX), 140421094367051)], + outputs: vec![(AssetType::Fungible(DAI), amount_out)], + fees: vec![ + Fee::new(DAI, 250626566417, Omnipool::protocol_account()), + Fee::new(LRNA, 35105272718, Omnipool::protocol_account()), + ], + operation_id: vec![ExecutionType::DCA(0), ExecutionType::Router(1)], + }) + ); + + run_to_block2(13, 17); + let swapped_events = get_last_swapped_events(); + pretty_assertions::assert_eq!( + *swapped_events.last().unwrap(), + RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + swapper: ALICE.into(), + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::Filler::Omnipool, + operation: pallet_amm_support::TradeOperation::ExactOut, + inputs: vec![(AssetType::Fungible(HDX), 140421107716515)], + outputs: vec![(AssetType::Fungible(DAI), amount_out)], + fees: vec![ + Fee::new(DAI, 250626566417, Omnipool::protocol_account()), + Fee::new(LRNA, 35105274224, Omnipool::protocol_account()), + ], + operation_id: vec![ExecutionType::DCA(2), ExecutionType::Router(3)], + }) + ); + }); + } + #[test] fn buy_schedule_execution_should_work_without_route() { TestNet::reset(); @@ -588,6 +643,69 @@ mod omnipool { }); } + #[test] + fn sell_schedule_execution_should_emit_swapped_event() { + TestNet::reset(); + Hydra::execute_with(|| { + //Arrange + init_omnipool_with_oracle_for_block_10(); + let alice_init_hdx_balance = 5000 * UNITS; + assert_ok!(Balances::force_set_balance( + RuntimeOrigin::root(), + ALICE.into(), + alice_init_hdx_balance, + )); + + let dca_budget = 1100 * UNITS; + let amount_to_sell = 100 * UNITS; + let schedule1 = + schedule_fake_with_sell_order(ALICE, PoolType::Omnipool, dca_budget, HDX, DAI, amount_to_sell); + create_schedule(ALICE, schedule1); + + //Act + run_to_block2(11, 12); + + //Assert + let swapped_events = get_last_swapped_events(); + pretty_assertions::assert_eq!( + *swapped_events.last().unwrap(), + RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + swapper: ALICE.into(), + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::Filler::Omnipool, + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(HDX), amount_to_sell)], + outputs: vec![(AssetType::Fungible(DAI), 71214372624126)], + fees: vec![ + Fee::new(DAI, 178482136903, Omnipool::protocol_account()), + Fee::new(LRNA, 24999999579, Omnipool::protocol_account()), + ], + operation_id: vec![ExecutionType::DCA(0), ExecutionType::Router(1)], + }) + ); + + run_to_block2(13, 17); + + let swapped_events = get_last_swapped_events(); + pretty_assertions::assert_eq!( + *swapped_events.last().unwrap(), + RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + swapper: ALICE.into(), + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::Filler::Omnipool, + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(HDX), amount_to_sell)], + outputs: vec![(AssetType::Fungible(DAI), 71214367826179)], + fees: vec![ + Fee::new(DAI, 178482124878, Omnipool::protocol_account()), + Fee::new(LRNA, 24999998680, Omnipool::protocol_account()), + ], + operation_id: vec![ExecutionType::DCA(2), ExecutionType::Router(3)], + }) + ); + }); + } + #[test] fn sell_schedule_be_retried_when_route_is_invalid() { TestNet::reset(); @@ -4036,6 +4154,13 @@ pub fn run_to_block(from: BlockNumber, to: BlockNumber) { } } +pub fn run_to_block2(from: BlockNumber, to: BlockNumber) { + for b in from..=to { + do_trade_to_populate_oracle(DAI, HDX, UNITS); + set_relaychain_block_number(b); + } +} + pub fn check_if_no_failed_events() { let failed_events = count_failed_trade_events(); assert_eq!(0, failed_events); @@ -4070,6 +4195,20 @@ pub fn get_last_schedule_ids_from_trade_executed_events() -> Vec { schedule_ids } +pub fn get_last_swapped_events() -> Vec { + let last_events: Vec = last_hydra_events(1000); + let mut swapped_events = vec![]; + + for event in last_events { + let e = event.clone(); + if let RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { .. }) = e { + swapped_events.push(e); + } + } + + swapped_events +} + pub fn count_failed_trade_events() -> u32 { count_dca_event!(pallet_dca::Event::TradeFailed { .. }) } diff --git a/pallets/dca/Cargo.toml b/pallets/dca/Cargo.toml index 8672abbf4..ab72dd8ca 100644 --- a/pallets/dca/Cargo.toml +++ b/pallets/dca/Cargo.toml @@ -34,6 +34,7 @@ pallet-omnipool = { workspace = true } hydradx-traits = { workspace = true } hydradx-adapters = { workspace = true } pallet-ema-oracle = { workspace = true } +pallet-amm-support = { workspace = true } hydra-dx-math = { workspace = true } diff --git a/pallets/dca/src/lib.rs b/pallets/dca/src/lib.rs index 2b18480a7..81b8d76bd 100644 --- a/pallets/dca/src/lib.rs +++ b/pallets/dca/src/lib.rs @@ -78,12 +78,14 @@ use frame_system::{ }; use hydradx_adapters::RelayChainBlockHashProvider; use hydradx_traits::fee::{InspectTransactionFeeCurrency, SwappablePaymentAssetTrader}; -use hydradx_traits::router::{inverse_route, RouteProvider}; +use hydradx_traits::router::{inverse_route, ExecutionType, ExecutionTypeStack, RouteProvider}; use hydradx_traits::router::{AmmTradeWeights, AmountInAndOut, RouterT, Trade}; -use hydradx_traits::NativePriceOracle; use hydradx_traits::OraclePeriod; use hydradx_traits::PriceOracle; +use hydradx_traits::{IncrementalIdProvider, NativePriceOracle}; use orml_traits::{arithmetic::CheckedAdd, MultiCurrency, NamedMultiReservableCurrency}; +use pallet_amm_support::IncrementalIdType; +use primitives::IncrementalId; use rand::rngs::StdRng; use rand::{Rng, SeedableRng}; use sp_runtime::helpers_128bit::multiply_by_rational_with_rounding; @@ -121,7 +123,8 @@ pub mod pallet { use frame_system::pallet_prelude::OriginFor; use hydra_dx_math::ema::EmaPrice; use hydradx_traits::fee::SwappablePaymentAssetTrader; - use hydradx_traits::{NativePriceOracle, PriceOracle}; + use hydradx_traits::router::{ExecutionTypeStack}; + use hydradx_traits::{IncrementalIdProvider, NativePriceOracle, PriceOracle}; use orml_traits::NamedMultiReservableCurrency; use sp_runtime::Percent; @@ -301,6 +304,9 @@ pub mod pallet { #[pallet::constant] type NamedReserveId: Get; + /// Support for depositing unified events + type AmmUnifiedEventSupport: IncrementalIdProvider + ExecutionTypeStack; + /// Convert a weight value into a deductible fee type WeightToFee: WeightToFee; @@ -693,9 +699,11 @@ impl Pallet { schedule_id: ScheduleId, schedule: &Schedule>, ) -> Result, DispatchError> { - let origin: OriginFor = Origin::::Signed(schedule.owner.clone()).into(); + let next_event_id = T::AmmUnifiedEventSupport::next_id().map_err(|_| ArithmeticError::Overflow)?; + T::AmmUnifiedEventSupport::push(ExecutionType::DCA(next_event_id))?; - match &schedule.order { + let origin: OriginFor = Origin::::Signed(schedule.owner.clone()).into(); + let trade_result = match &schedule.order { Order::Sell { asset_in, asset_out, @@ -778,7 +786,11 @@ impl Pallet { amount_out: *amount_out, }) } - } + }; + + T::AmmUnifiedEventSupport::pop()?; + + trade_result } fn replan_or_complete( diff --git a/pallets/dca/src/tests/mock.rs b/pallets/dca/src/tests/mock.rs index 2fe36282c..49a6c5609 100644 --- a/pallets/dca/src/tests/mock.rs +++ b/pallets/dca/src/tests/mock.rs @@ -709,6 +709,7 @@ impl Config for Test { type RetryOnError = (); type PolkadotNativeAssetId = PolkadotNativeCurrencyId; type SwappablePaymentAssetSupport = MockedInsufficientAssetSupport; + type AmmUnifiedEventSupport = AmmSupport; } pub struct MockedInsufficientAssetSupport; diff --git a/pallets/omnipool/src/lib.rs b/pallets/omnipool/src/lib.rs index caa29dd28..b19e3a2fc 100644 --- a/pallets/omnipool/src/lib.rs +++ b/pallets/omnipool/src/lib.rs @@ -84,27 +84,27 @@ #![cfg_attr(not(feature = "std"), no_std)] +use crate::traits::ShouldAllow; use frame_support::pallet_prelude::{DispatchResult, Get}; use frame_support::require_transactional; +use frame_support::traits::tokens::nonfungibles::{Create, Inspect, Mutate}; use frame_support::PalletId; use frame_support::{ensure, transactional}; use frame_system::{ensure_signed, pallet_prelude::OriginFor}; -use sp_runtime::traits::{AccountIdConversion, AtLeast32BitUnsigned, One}; -use sp_runtime::traits::{CheckedAdd, CheckedSub, Zero}; -use sp_std::ops::{Add, Sub}; -use sp_std::prelude::*; -use hydradx_traits::router::ExecutionTypeStack; -use crate::traits::ShouldAllow; -use frame_support::traits::tokens::nonfungibles::{Create, Inspect, Mutate}; use hydra_dx_math::ema::EmaPrice; use hydra_dx_math::omnipool::types::{AssetStateChange, BalanceUpdate, I129}; use hydradx_traits::registry::Inspect as RegistryInspect; -use hydradx_traits::router::{AssetType, Fee, ExecutionType}; +use hydradx_traits::router::ExecutionTypeStack; +use hydradx_traits::router::{AssetType, ExecutionType, Fee}; use orml_traits::{GetByKey, MultiCurrency}; #[cfg(feature = "try-runtime")] use primitive_types::U256; use scale_info::TypeInfo; +use sp_runtime::traits::{AccountIdConversion, AtLeast32BitUnsigned, One}; +use sp_runtime::traits::{CheckedAdd, CheckedSub, Zero}; use sp_runtime::{ArithmeticError, DispatchError, FixedPointNumber, FixedU128, Permill}; +use sp_std::ops::{Add, Sub}; +use sp_std::prelude::*; #[cfg(test)] mod tests; @@ -375,7 +375,7 @@ pub mod pallet { HubAmountUpdated { hub_amount_in: Balance, hub_amount_out: Balance, - operation_id: Vec> + operation_id: Vec>, }, } @@ -1107,7 +1107,7 @@ pub mod pallet { Self::deposit_event(Event::HubAmountUpdated { hub_amount_in: *state_changes.asset_in.delta_hub_reserve, hub_amount_out: *state_changes.asset_out.delta_hub_reserve, - operation_id: T::OperationIdProvider::get() + operation_id: T::OperationIdProvider::get(), }); pallet_amm_support::Pallet::::deposit_trade_event( @@ -1342,7 +1342,7 @@ pub mod pallet { Self::deposit_event(crate::pallet::Event::HubAmountUpdated { hub_amount_in: *state_changes.asset_in.delta_hub_reserve, hub_amount_out: *state_changes.asset_out.delta_hub_reserve, - operation_id: T::OperationIdProvider::get() + operation_id: T::OperationIdProvider::get(), }); pallet_amm_support::Pallet::::deposit_trade_event( diff --git a/pallets/stableswap/src/lib.rs b/pallets/stableswap/src/lib.rs index 986e83bab..30e6df17c 100644 --- a/pallets/stableswap/src/lib.rs +++ b/pallets/stableswap/src/lib.rs @@ -103,11 +103,11 @@ pub mod pallet { use core::ops::RangeInclusive; use frame_support::pallet_prelude::*; use hydradx_traits::pools::DustRemovalAccountWhitelist; + use hydradx_traits::router::{AssetType, Fee}; use sp_runtime::traits::{BlockNumberProvider, Zero}; use sp_runtime::ArithmeticError; use sp_runtime::Permill; use sp_std::num::NonZeroU16; - use hydradx_traits::router::{AssetType, Fee}; #[pallet::pallet] pub struct Pallet(_); diff --git a/runtime/hydradx/src/assets.rs b/runtime/hydradx/src/assets.rs index 0d40f50b1..2e8162ba3 100644 --- a/runtime/hydradx/src/assets.rs +++ b/runtime/hydradx/src/assets.rs @@ -874,6 +874,7 @@ impl pallet_dca::Config for Runtime { type RetryOnError = RetryOnErrorForDca; type PolkadotNativeAssetId = DotAssetId; type SwappablePaymentAssetSupport = XykPaymentAssetSupport; + type AmmUnifiedEventSupport = AmmSupport; } // Provides weight info for the router. Router extrinsics can be executed with different AMMs, so we split the router weights into two parts: From 07231948080784ee031d62f16bd77bd1b56c1363 Mon Sep 17 00:00:00 2001 From: dmoka Date: Thu, 7 Nov 2024 20:46:00 +0100 Subject: [PATCH 047/142] formatting --- pallets/dca/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/dca/src/lib.rs b/pallets/dca/src/lib.rs index 81b8d76bd..516c1df46 100644 --- a/pallets/dca/src/lib.rs +++ b/pallets/dca/src/lib.rs @@ -123,7 +123,7 @@ pub mod pallet { use frame_system::pallet_prelude::OriginFor; use hydra_dx_math::ema::EmaPrice; use hydradx_traits::fee::SwappablePaymentAssetTrader; - use hydradx_traits::router::{ExecutionTypeStack}; + use hydradx_traits::router::ExecutionTypeStack; use hydradx_traits::{IncrementalIdProvider, NativePriceOracle, PriceOracle}; use orml_traits::NamedMultiReservableCurrency; use sp_runtime::Percent; From 2b812332faa8da2dcb0febf88a669dc6b859e3cf Mon Sep 17 00:00:00 2001 From: dmoka Date: Thu, 7 Nov 2024 20:46:12 +0100 Subject: [PATCH 048/142] update lock --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 7567b4b33..4f247e01d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12229,7 +12229,7 @@ dependencies = [ [[package]] name = "runtime-integration-tests" -version = "1.25.0" +version = "1.25.1" dependencies = [ "cumulus-pallet-aura-ext", "cumulus-pallet-parachain-system", From 1045fc8dd53cfad32da47d4a1d1e118753193726 Mon Sep 17 00:00:00 2001 From: dmoka Date: Mon, 11 Nov 2024 11:07:44 +0100 Subject: [PATCH 049/142] add stableswap swapped events --- Cargo.lock | 1 + pallets/stableswap/Cargo.toml | 1 + pallets/stableswap/src/lib.rs | 59 ++++++++++++++++++- pallets/stableswap/src/tests/add_liquidity.rs | 35 +++++++++++ pallets/stableswap/src/tests/mock.rs | 24 ++++++++ .../stableswap/src/tests/remove_liquidity.rs | 35 +++++++++++ 6 files changed, 152 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4f247e01d..4dd0cba09 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9139,6 +9139,7 @@ dependencies = [ "orml-traits", "pallet-amm-support", "parity-scale-codec", + "pretty_assertions", "proptest", "scale-info", "serde", diff --git a/pallets/stableswap/Cargo.toml b/pallets/stableswap/Cargo.toml index 18d00c2cb..9eeaf431e 100644 --- a/pallets/stableswap/Cargo.toml +++ b/pallets/stableswap/Cargo.toml @@ -48,6 +48,7 @@ sp-tracing = { workspace = true } orml-tokens = { workspace = true, features = ["std"] } proptest = { workspace = true } test-utils = { workspace = true } +pretty_assertions = "1.4.0" [features] default = ['std'] diff --git a/pallets/stableswap/src/lib.rs b/pallets/stableswap/src/lib.rs index 30e6df17c..8de561e86 100644 --- a/pallets/stableswap/src/lib.rs +++ b/pallets/stableswap/src/lib.rs @@ -76,6 +76,7 @@ use hydra_dx_math::stableswap::types::AssetReserve; use hydradx_traits::pools::DustRemovalAccountWhitelist; use orml_traits::MultiCurrency; use sp_std::collections::btree_map::BTreeMap; +use hydradx_traits::router::{AssetType, Fee}; pub use weights::WeightInfo; #[cfg(test)] @@ -617,12 +618,27 @@ pub mod pallet { Self::deposit_event(Event::LiquidityRemoved { pool_id, - who, + who: who.clone(), shares: share_amount, amounts: vec![AssetAmount { asset_id, amount }], fee, }); + //TODO: ask Martin to double check it + pallet_amm_support::Pallet::::deposit_trade_event( + who, + pool_account.clone(), + pallet_amm_support::Filler::Stableswap(pool_id.into()), + pallet_amm_support::TradeOperation::ExactIn, + vec![(AssetType::Fungible(pool_id.into()), share_amount)], + vec![(AssetType::Fungible(asset_id.into()), amount)], + vec![Fee { + asset: pool_id.into(), + amount: fee, + recipient: pool_account, + }], + ); + #[cfg(feature = "try-runtime")] Self::ensure_remove_liquidity_invariant(pool_id, &initial_reserves); @@ -699,12 +715,22 @@ pub mod pallet { Self::deposit_event(Event::LiquidityRemoved { pool_id, - who, + who: who.clone(), shares, amounts: vec![AssetAmount { asset_id, amount }], fee: 0u128, // dev note: figure out the actual fee amount in this case. For now, we dont need it. }); + pallet_amm_support::Pallet::::deposit_trade_event( + who, + pool_account.clone(), + pallet_amm_support::Filler::Stableswap(pool_id.into()), + pallet_amm_support::TradeOperation::ExactOut, + vec![(AssetType::Fungible(pool_id.into()), shares)], + vec![(AssetType::Fungible(asset_id.into()), amount)], + vec![], + ); + Ok(()) } @@ -1225,6 +1251,18 @@ impl Pallet { #[cfg(feature = "try-runtime")] Self::ensure_add_liquidity_invariant(pool_id, &initial_reserves); + let inputs = assets.iter().map(|asset| (AssetType::Fungible(asset.asset_id.into()), asset.amount)).collect(); + + pallet_amm_support::Pallet::::deposit_trade_event( + who.clone(), + pool_account.clone(), + pallet_amm_support::Filler::Stableswap(pool_id.into()), + pallet_amm_support::TradeOperation::ExactIn, + inputs, + vec![(AssetType::Fungible(pool_id.into()), share_amount)], + vec![],//TODO: ask Martin what will be the fee? + ); + Ok(share_amount) } @@ -1254,7 +1292,7 @@ impl Pallet { ensure!(!reserve.amount.is_zero(), Error::::InvalidInitialLiquidity); } - let (amount_in, _) = hydra_dx_math::stableswap::calculate_add_one_asset::( + let (amount_in, fee) = hydra_dx_math::stableswap::calculate_add_one_asset::( &initial_reserves, shares, asset_idx, @@ -1280,6 +1318,21 @@ impl Pallet { //All done and update. let's call the on_liquidity_changed hook. Self::call_on_liquidity_change_hook(pool_id, &initial_reserves, share_issuance)?; + pallet_amm_support::Pallet::::deposit_trade_event( + who.clone(), + pool_account.clone(), + pallet_amm_support::Filler::Stableswap(pool_id.into()), + pallet_amm_support::TradeOperation::ExactOut, + vec![(AssetType::Fungible(asset_id.into()), amount_in)], + vec![(AssetType::Fungible(pool_id.into()), shares)], + vec![Fee { + asset: pool_id.into(), + amount: fee, + recipient: pool_account, + }], + ); + + Ok(amount_in) } diff --git a/pallets/stableswap/src/tests/add_liquidity.rs b/pallets/stableswap/src/tests/add_liquidity.rs index 81fc88e48..623e24366 100644 --- a/pallets/stableswap/src/tests/add_liquidity.rs +++ b/pallets/stableswap/src/tests/add_liquidity.rs @@ -4,6 +4,7 @@ use crate::{assert_balance, to_precision, Error}; use frame_support::{assert_noop, assert_ok}; use sp_runtime::Permill; use std::num::NonZeroU16; +use hydradx_traits::router::{AssetType, Fee}; #[test] fn add_initial_liquidity_should_work_when_called_first_time() { @@ -50,6 +51,23 @@ fn add_initial_liquidity_should_work_when_called_first_time() { assert_balance!(BOB, pool_id, 200 * ONE * 1_000_000); assert_balance!(pool_account, asset_a, 100 * ONE); assert_balance!(pool_account, asset_b, 100 * ONE); + + pretty_assertions::assert_eq!( + *get_last_swapped_events().last().unwrap(), + RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + swapper: BOB, + filler: pool_account, + filler_type: pallet_amm_support::Filler::Stableswap(pool_id), + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![ + (AssetType::Fungible(asset_a), 100 * ONE), + (AssetType::Fungible(asset_b), 100 * ONE), + ], + outputs: vec![(AssetType::Fungible(pool_id), 200000000 * ONE)], + fees: vec![], + operation_id: vec![], + }) + ) }); } @@ -634,6 +652,23 @@ fn add_liquidity_should_work_correctly_when_providing_exact_amount_of_shares() { let used = Tokens::free_balance(asset_a, &BOB); assert_eq!(used, 0); + + let pool_account = pool_account(pool_id); + pretty_assertions::assert_eq!( + *get_last_swapped_events().last().unwrap(), + RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + swapper: BOB, + filler: pool_account, + filler_type: pallet_amm_support::Filler::Stableswap(pool_id), + operation: pallet_amm_support::TradeOperation::ExactOut, + inputs: vec![ + (AssetType::Fungible(asset_a), 2000000000000000003), + ], + outputs: vec![(AssetType::Fungible(pool_id), 1947597621401945851)], + fees: vec![Fee::new(pool_id, 0, pool_account)], + operation_id: vec![], + }) + ) }); } diff --git a/pallets/stableswap/src/tests/mock.rs b/pallets/stableswap/src/tests/mock.rs index 8b3197d30..2dc049ff0 100644 --- a/pallets/stableswap/src/tests/mock.rs +++ b/pallets/stableswap/src/tests/mock.rs @@ -452,3 +452,27 @@ pub(crate) fn last_trade_hook_state() -> Option<(AssetId, AssetId, AssetId, Pool pub(crate) fn expect_events(e: Vec) { e.into_iter().for_each(frame_system::Pallet::::assert_has_event); } + +pub fn get_last_swapped_events() -> Vec { + let last_events: Vec = last_hydra_events(1000); + let mut swapped_events = vec![]; + + for event in last_events { + let e = event.clone(); + if let RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { .. }) = e { + swapped_events.push(e); + } + } + + swapped_events +} + +pub fn last_hydra_events(n: usize) -> Vec { + frame_system::Pallet::::events() + .into_iter() + .rev() + .take(n) + .rev() + .map(|e| e.event) + .collect() +} \ No newline at end of file diff --git a/pallets/stableswap/src/tests/remove_liquidity.rs b/pallets/stableswap/src/tests/remove_liquidity.rs index f70b6f8a7..c996268dc 100644 --- a/pallets/stableswap/src/tests/remove_liquidity.rs +++ b/pallets/stableswap/src/tests/remove_liquidity.rs @@ -5,6 +5,7 @@ use frame_support::traits::Contains; use frame_support::{assert_noop, assert_ok, BoundedVec}; use sp_runtime::Permill; use std::num::NonZeroU16; +use hydradx_traits::router::{AssetType, Fee}; #[test] fn remove_liquidity_should_work_when_withdrawing_all_shares() { @@ -71,6 +72,22 @@ fn remove_liquidity_should_work_when_withdrawing_all_shares() { assert_balance!(BOB, pool_id, 0u128); assert_balance!(pool_account, asset_a, 100 * ONE + amount_added); assert_balance!(pool_account, asset_c, 300 * ONE - amount_received); + + pretty_assertions::assert_eq!( + *get_last_swapped_events().last().unwrap(), + RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + swapper: BOB, + filler: pool_account, + filler_type: pallet_amm_support::Filler::Stableswap(pool_id), + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![ + (AssetType::Fungible(pool_id), 200516043533380244763), + ], + outputs: vec![(AssetType::Fungible(asset_c), 199999999999999)], + fees: vec![Fee::new(pool_id, 0, pool_account)], + operation_id: vec![], + }) + ); }); } @@ -848,10 +865,28 @@ fn removing_liquidity_with_exact_amount_should_work() { )); // ASSERT + let received = Tokens::free_balance(pool_id, &BOB); assert_eq!(received, 0); let balance = Tokens::free_balance(asset_a, &BOB); assert_eq!(balance, 1_999_999_999_999_999_999); + + let pool_account = pool_account(pool_id); + pretty_assertions::assert_eq!( + *get_last_swapped_events().last().unwrap(), + RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + swapper: BOB, + filler: pool_account, + filler_type: pallet_amm_support::Filler::Stableswap(4), + operation: pallet_amm_support::TradeOperation::ExactOut, + inputs: vec![(AssetType::Fungible(pool_id), 1947597621401945851)], + outputs: vec![ + (AssetType::Fungible(asset_a), 1999999999999999999), + ], + fees: vec![], + operation_id: vec![], + }) + ); }); } From fb03a185c2d5b294c6ef0067f712c6651ccca2b2 Mon Sep 17 00:00:00 2001 From: dmoka Date: Mon, 11 Nov 2024 11:52:32 +0100 Subject: [PATCH 050/142] formatting --- pallets/stableswap/src/lib.rs | 10 ++++++---- pallets/stableswap/src/tests/add_liquidity.rs | 8 +++----- pallets/stableswap/src/tests/mock.rs | 2 +- pallets/stableswap/src/tests/remove_liquidity.rs | 12 ++++-------- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/pallets/stableswap/src/lib.rs b/pallets/stableswap/src/lib.rs index 8de561e86..1c09c0e85 100644 --- a/pallets/stableswap/src/lib.rs +++ b/pallets/stableswap/src/lib.rs @@ -74,9 +74,9 @@ pub mod weights; use crate::types::{AssetAmount, Balance, PoolInfo, PoolState, StableswapHooks, Tradability}; use hydra_dx_math::stableswap::types::AssetReserve; use hydradx_traits::pools::DustRemovalAccountWhitelist; +use hydradx_traits::router::{AssetType, Fee}; use orml_traits::MultiCurrency; use sp_std::collections::btree_map::BTreeMap; -use hydradx_traits::router::{AssetType, Fee}; pub use weights::WeightInfo; #[cfg(test)] @@ -1251,7 +1251,10 @@ impl Pallet { #[cfg(feature = "try-runtime")] Self::ensure_add_liquidity_invariant(pool_id, &initial_reserves); - let inputs = assets.iter().map(|asset| (AssetType::Fungible(asset.asset_id.into()), asset.amount)).collect(); + let inputs = assets + .iter() + .map(|asset| (AssetType::Fungible(asset.asset_id.into()), asset.amount)) + .collect(); pallet_amm_support::Pallet::::deposit_trade_event( who.clone(), @@ -1260,7 +1263,7 @@ impl Pallet { pallet_amm_support::TradeOperation::ExactIn, inputs, vec![(AssetType::Fungible(pool_id.into()), share_amount)], - vec![],//TODO: ask Martin what will be the fee? + vec![], //TODO: ask Martin what will be the fee? ); Ok(share_amount) @@ -1332,7 +1335,6 @@ impl Pallet { }], ); - Ok(amount_in) } diff --git a/pallets/stableswap/src/tests/add_liquidity.rs b/pallets/stableswap/src/tests/add_liquidity.rs index 623e24366..9a5fd4ee8 100644 --- a/pallets/stableswap/src/tests/add_liquidity.rs +++ b/pallets/stableswap/src/tests/add_liquidity.rs @@ -2,9 +2,9 @@ use crate::tests::mock::*; use crate::types::{AssetAmount, PoolInfo}; use crate::{assert_balance, to_precision, Error}; use frame_support::{assert_noop, assert_ok}; +use hydradx_traits::router::{AssetType, Fee}; use sp_runtime::Permill; use std::num::NonZeroU16; -use hydradx_traits::router::{AssetType, Fee}; #[test] fn add_initial_liquidity_should_work_when_called_first_time() { @@ -61,7 +61,7 @@ fn add_initial_liquidity_should_work_when_called_first_time() { operation: pallet_amm_support::TradeOperation::ExactIn, inputs: vec![ (AssetType::Fungible(asset_a), 100 * ONE), - (AssetType::Fungible(asset_b), 100 * ONE), + (AssetType::Fungible(asset_b), 100 * ONE), ], outputs: vec![(AssetType::Fungible(pool_id), 200000000 * ONE)], fees: vec![], @@ -661,9 +661,7 @@ fn add_liquidity_should_work_correctly_when_providing_exact_amount_of_shares() { filler: pool_account, filler_type: pallet_amm_support::Filler::Stableswap(pool_id), operation: pallet_amm_support::TradeOperation::ExactOut, - inputs: vec![ - (AssetType::Fungible(asset_a), 2000000000000000003), - ], + inputs: vec![(AssetType::Fungible(asset_a), 2000000000000000003),], outputs: vec![(AssetType::Fungible(pool_id), 1947597621401945851)], fees: vec![Fee::new(pool_id, 0, pool_account)], operation_id: vec![], diff --git a/pallets/stableswap/src/tests/mock.rs b/pallets/stableswap/src/tests/mock.rs index 2dc049ff0..9fc422c3f 100644 --- a/pallets/stableswap/src/tests/mock.rs +++ b/pallets/stableswap/src/tests/mock.rs @@ -475,4 +475,4 @@ pub fn last_hydra_events(n: usize) -> Vec { .rev() .map(|e| e.event) .collect() -} \ No newline at end of file +} diff --git a/pallets/stableswap/src/tests/remove_liquidity.rs b/pallets/stableswap/src/tests/remove_liquidity.rs index c996268dc..816232cd1 100644 --- a/pallets/stableswap/src/tests/remove_liquidity.rs +++ b/pallets/stableswap/src/tests/remove_liquidity.rs @@ -3,9 +3,9 @@ use crate::types::{AssetAmount, PoolInfo}; use crate::{assert_balance, Error, Event, Pools}; use frame_support::traits::Contains; use frame_support::{assert_noop, assert_ok, BoundedVec}; +use hydradx_traits::router::{AssetType, Fee}; use sp_runtime::Permill; use std::num::NonZeroU16; -use hydradx_traits::router::{AssetType, Fee}; #[test] fn remove_liquidity_should_work_when_withdrawing_all_shares() { @@ -80,10 +80,8 @@ fn remove_liquidity_should_work_when_withdrawing_all_shares() { filler: pool_account, filler_type: pallet_amm_support::Filler::Stableswap(pool_id), operation: pallet_amm_support::TradeOperation::ExactIn, - inputs: vec![ - (AssetType::Fungible(pool_id), 200516043533380244763), - ], - outputs: vec![(AssetType::Fungible(asset_c), 199999999999999)], + inputs: vec![(AssetType::Fungible(pool_id), 200516043533380244763),], + outputs: vec![(AssetType::Fungible(asset_c), 199999999999999)], fees: vec![Fee::new(pool_id, 0, pool_account)], operation_id: vec![], }) @@ -880,9 +878,7 @@ fn removing_liquidity_with_exact_amount_should_work() { filler_type: pallet_amm_support::Filler::Stableswap(4), operation: pallet_amm_support::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(pool_id), 1947597621401945851)], - outputs: vec![ - (AssetType::Fungible(asset_a), 1999999999999999999), - ], + outputs: vec![(AssetType::Fungible(asset_a), 1999999999999999999),], fees: vec![], operation_id: vec![], }) From 9e33836b07ea949fe3b835995c9111b3cf224d9b Mon Sep 17 00:00:00 2001 From: dmoka Date: Mon, 11 Nov 2024 12:18:07 +0100 Subject: [PATCH 051/142] remove unused run to block method --- integration-tests/src/dca.rs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/integration-tests/src/dca.rs b/integration-tests/src/dca.rs index deb930c50..496bd19ac 100644 --- a/integration-tests/src/dca.rs +++ b/integration-tests/src/dca.rs @@ -214,7 +214,7 @@ mod omnipool { create_schedule(ALICE, schedule1); //Act - run_to_block2(11, 12); + run_to_block(11, 12); //Assert let swapped_events = get_last_swapped_events(); @@ -235,7 +235,7 @@ mod omnipool { }) ); - run_to_block2(13, 17); + run_to_block(13, 17); let swapped_events = get_last_swapped_events(); pretty_assertions::assert_eq!( *swapped_events.last().unwrap(), @@ -663,7 +663,7 @@ mod omnipool { create_schedule(ALICE, schedule1); //Act - run_to_block2(11, 12); + run_to_block(11, 12); //Assert let swapped_events = get_last_swapped_events(); @@ -684,7 +684,7 @@ mod omnipool { }) ); - run_to_block2(13, 17); + run_to_block(13, 17); let swapped_events = get_last_swapped_events(); pretty_assertions::assert_eq!( @@ -4150,16 +4150,9 @@ pub fn run_to_block(from: BlockNumber, to: BlockNumber) { for b in from..=to { do_trade_to_populate_oracle(DAI, HDX, UNITS); set_relaychain_block_number(b); - do_trade_to_populate_oracle(DAI, HDX, UNITS); } } -pub fn run_to_block2(from: BlockNumber, to: BlockNumber) { - for b in from..=to { - do_trade_to_populate_oracle(DAI, HDX, UNITS); - set_relaychain_block_number(b); - } -} pub fn check_if_no_failed_events() { let failed_events = count_failed_trade_events(); From 8dc92ed4dfec8a0e7bd7abe15527c57a0b79bf96 Mon Sep 17 00:00:00 2001 From: dmoka Date: Mon, 11 Nov 2024 12:25:42 +0100 Subject: [PATCH 052/142] simplify amm support dependencies --- pallets/dca/src/tests/mock.rs | 3 +-- .../proptest-regressions/tests/invariants.txt | 11 ----------- pallets/otc-settlements/src/mock.rs | 3 +-- pallets/route-executor/src/lib.rs | 19 ++++++++----------- pallets/route-executor/src/tests/mock.rs | 3 +-- runtime/adapters/src/tests/mock.rs | 3 +-- runtime/hydradx/src/assets.rs | 3 +-- 7 files changed, 13 insertions(+), 32 deletions(-) delete mode 100644 pallets/omnipool/proptest-regressions/tests/invariants.txt diff --git a/pallets/dca/src/tests/mock.rs b/pallets/dca/src/tests/mock.rs index 49a6c5609..2d28bd6dc 100644 --- a/pallets/dca/src/tests/mock.rs +++ b/pallets/dca/src/tests/mock.rs @@ -378,8 +378,7 @@ impl pallet_route_executor::Config for Test { type EdToRefundCalculator = MockedEdCalculator; type OraclePriceProvider = PriceProviderMock; type OraclePeriod = RouteValidationOraclePeriod; - type BatchIdProvider = AmmSupport; - type OperationIdProvider = AmmSupport; + type AmmUnifiedEventSupport = AmmSupport; type WeightInfo = (); } diff --git a/pallets/omnipool/proptest-regressions/tests/invariants.txt b/pallets/omnipool/proptest-regressions/tests/invariants.txt deleted file mode 100644 index db60fd566..000000000 --- a/pallets/omnipool/proptest-regressions/tests/invariants.txt +++ /dev/null @@ -1,11 +0,0 @@ -#cc f8078da4f7e354090cbce1f1a7385338da411cfc9b8e31660d006c18b233ebafcc e6296fe0e28dc7b0e9fb030d015ffa1104b23979493073d03116e93da420ef6f # shrinks to amount = 2024942073354000, stable_price = FixedU128(0.100000000000000000), stable_reserve = 100000000000000000, native_reserve = 100000000000000000, token_1 = PoolToken { asset_id: 100, amount: 100000000000000000, price: FixedU128(0.100000000000000000) }, token_2 = PoolToken { asset_id: 200, amount: 3910846008399793737, price: FixedU128(1.632227559602352896) }, token_3 = PoolToken { asset_id: 300, amount: 100000000000000000, price: FixedU128(0.100000000000000000) }, token_4 = PoolToken { asset_id: 400, amount: 100000000036539132, price: FixedU128(0.388222853715546176) }, asset_fee = 1.3%, protocol_fee = 0.009%, imbalance = SimpleImbalance { value: 489292488996053, negative: true }cc 601a6a9695df7cd7f85426e6a59f455f3f5ce6350f61ff3bd30295e8923825a7 # shrinks to amount = 1000, stable_price = FixedU128(0.100000000000000000), stable_reserve = 100000000000000000, native_reserve = 100000000000000000, token_1 = PoolToken { asset_id: 100, amount: 100000000000000000, price: FixedU128(0.100000000000000000) }, token_2 = PoolToken { asset_id: 200, amount: 100000000000000000, price: FixedU128(0.100000000000000000) }, token_3 = PoolToken { asset_id: 300, amount: 100000000000000000, price: FixedU128(0.100000000000000000) }, token_4 = PoolToken { asset_id: 400, amount: 100000000243762059, price: FixedU128(1.925871849496510464) }, asset_fee = 0%, protocol_fee = 2.4%, imbalance = SimpleImbalance { value: 9024424855798144, negative: true } -cc 06cfb566dd8ff64790996cdd0d9375b4fd30f827063743b2fb04cb925b5e4508 # shrinks to amount = 1000, stable_price = FixedU128(0.100000000000000000), stable_reserve = 100000000000000000, native_reserve = 100000000000000000, token_1 = PoolToken { asset_id: 100, amount: 100000000000000000, price: FixedU128(0.100000000000000000) }, token_2 = PoolToken { asset_id: 200, amount: 100000000000000000, price: FixedU128(0.100000000000000000) }, token_3 = PoolToken { asset_id: 300, amount: 100000000000000000, price: FixedU128(0.100000000000000000) }, token_4 = PoolToken { asset_id: 400, amount: 100000003210303870, price: FixedU128(1.964999347026830592) }, asset_fee = 2.4%, protocol_fee = 0.13% -cc 3a77a4705302585b88b85d7871dddcb7f6855b17e99163936a9828ac094bfeb6 # shrinks to amount = 1000, stable_price = FixedU128(0.100000000000000000), stable_reserve = 100000000000000000, native_reserve = 100000000000000000, token_1 = PoolToken { asset_id: 100, amount: 100000000000000000, price: FixedU128(0.100000000000000000) }, token_2 = PoolToken { asset_id: 200, amount: 100000000000000000, price: FixedU128(0.100000000000000000) }, token_3 = PoolToken { asset_id: 300, amount: 100000000000000000, price: FixedU128(0.100000000000000000) }, token_4 = PoolToken { asset_id: 400, amount: 100000001205909582, price: FixedU128(1.375333091762539008) }, asset_fee = 0.013%, protocol_fee = 0.017% -cc 70e03e4225e3021cabf6b0e49a35085bb86b2d6944ee95919ffd6c20b1f7069e # shrinks to amount = 1000, stable_price = FixedU128(0.100000000000000000), stable_reserve = 100000000000000000, native_reserve = 100000000000000000, token_1 = PoolToken { asset_id: 100, amount: 100000000000000000, price: FixedU128(0.100000000000000000) }, token_2 = PoolToken { asset_id: 200, amount: 100000000000000000, price: FixedU128(0.100000000000000000) }, token_3 = PoolToken { asset_id: 300, amount: 100000000000000000, price: FixedU128(0.100000000000000000) }, token_4 = PoolToken { asset_id: 400, amount: 100000000162914670, price: FixedU128(0.603279094613239552) } -cc 4576393644577b85ca338bc23bbd62654b67f2ec002f8b20aca5cbc777f71262 # shrinks to amount = 1000, stable_price = FixedU128(0.100000000000000000), stable_reserve = 100000000000000000, native_reserve = 100000000000000000, token_1 = PoolToken { asset_id: 100, amount: 100000000000000000, price: FixedU128(0.100000000000000000) }, token_2 = PoolToken { asset_id: 200, amount: 100000000000000000, price: FixedU128(0.100000000000000000) }, token_3 = PoolToken { asset_id: 300, amount: 100000000000000000, price: FixedU128(0.100000000000000000) }, token_4 = PoolToken { asset_id: 400, amount: 100000000278135672, price: FixedU128(1.100514086879039744) }, asset_fee = 0.21%, protocol_fee = 0.2%, imbalance = SimpleImbalance { value: 5028780583433078, negative: true } -cc 9c93a0fcb3f78b42d2bf75b1f971cc0a367264902e29cc35fca7b4d7b4317487 # shrinks to amount = 1000, stable_price = FixedU128(0.100000000000000000), stable_reserve = 100000000000000000, native_reserve = 100000000000000000, token_1 = PoolToken { asset_id: 100, amount: 100000000000000000, price: FixedU128(0.100000000000000000) }, token_2 = PoolToken { asset_id: 200, amount: 100000000000000000, price: FixedU128(0.100000000000000000) }, token_3 = PoolToken { asset_id: 300, amount: 100000000000000000, price: FixedU128(0.100000000000000000) }, token_4 = PoolToken { asset_id: 400, amount: 100000001282698657, price: FixedU128(1.083766836630893184) }, asset_fee = 2%, protocol_fee = 0.02% -cc 2d65c1f11dd2874cf4869c6bc28ed925478e57ed73a617b1d5dc1a8fe7d7ae59 # shrinks to amount = 1000, stable_price = FixedU128(0.100000000000000000), stable_reserve = 100000000000000000, native_reserve = 100000000000000000, token_1 = PoolToken { asset_id: 100, amount: 100000000000000000, price: FixedU128(0.100000000000000000) }, token_2 = PoolToken { asset_id: 200, amount: 100000000000000000, price: FixedU128(0.100000000000000000) }, token_3 = PoolToken { asset_id: 300, amount: 100000000000000000, price: FixedU128(0.100000000000000000) }, token_4 = PoolToken { asset_id: 400, amount: 100000000019336595, price: FixedU128(0.733249215167427072) }, asset_fee = 0.6%, protocol_fee = 0.004% -cc 5b0408b0d514dc33832f2a374aa9e3c479d0c84e58f4b88077c24387c4c8ef70 # shrinks to amount = 1000, stable_price = FixedU128(0.100000000000000000), stable_reserve = 100000000000000000, native_reserve = 100000000000000000, token_1 = PoolToken { asset_id: 100, amount: 100000000000000000, price: FixedU128(0.100000000000000000) }, token_2 = PoolToken { asset_id: 200, amount: 100000000000000000, price: FixedU128(0.100000000000000000) }, token_3 = PoolToken { asset_id: 300, amount: 100000000000000000, price: FixedU128(0.100000000000000000) }, token_4 = PoolToken { asset_id: 400, amount: 100000000597801771, price: FixedU128(1.458237645282841600) }, asset_fee = 0.28%, protocol_fee = 0.11%, buy_amount = 3276492019627632 -cc 47648d8c0c8f9c6b40fe9eefa80179540c1d386175531a36c3a825777402ce83 # shrinks to amount = 1000, stable_price = FixedU128(0.100000000000000000), stable_reserve = 100000000000000000, native_reserve = 100000000000000000, token_1 = PoolToken { asset_id: 100, amount: 100000000000000000, price: FixedU128(0.100000000000000000) }, token_2 = PoolToken { asset_id: 200, amount: 100000000000000000, price: FixedU128(0.100000000000000000) }, token_3 = PoolToken { asset_id: 300, amount: 100000000000000000, price: FixedU128(0.100000000000000000) }, token_4 = PoolToken { asset_id: 400, amount: 100000000000467280, price: FixedU128(0.943083786844469504) }, asset_fee = 0.17%, protocol_fee = 0.025%, buy_amount = 3545063556811621, min_withdraw_fee = 100%, (price_adjustment, denom, direction) = (4, 10000, false) -cc f1f5ebb8a88a3db4df5dcf4170496ef8dffffbb61bb6991226a597f95ae22ca5 # shrinks to amount = 1000, stable_price = FixedU128(0.100000000000000000), stable_reserve = 100000000000000000, native_reserve = 100000000000000000, token_1 = PoolToken { asset_id: 100, amount: 100000000000000000, price: FixedU128(0.100000000000000000) }, token_2 = PoolToken { asset_id: 200, amount: 100000000000000000, price: FixedU128(0.100000000000000000) }, token_3 = PoolToken { asset_id: 300, amount: 100000000000000000, price: FixedU128(0.100000000000000000) }, token_4 = PoolToken { asset_id: 400, amount: 100000000068367115, price: FixedU128(0.481724750982654144) }, asset_fee = 0.29%, protocol_fee = 0.03%, buy_amount = 986312481009315 -cc 2591d2b97991eebcad60c25b3d7ef318ad8651bf0e1f6f064eccee110d645305 # shrinks to amount = 1000, stable_price = FixedU128(0.100000000000000000), stable_reserve = 100000000000000000, native_reserve = 100000000000000000, token_1 = PoolToken { asset_id: 100, amount: 100000000000000000, price: FixedU128(0.100000000000000000) }, token_2 = PoolToken { asset_id: 200, amount: 100000000000000000, price: FixedU128(0.100000000000000000) }, token_3 = PoolToken { asset_id: 300, amount: 100000000000000000, price: FixedU128(0.100000000000000000) }, token_4 = PoolToken { asset_id: 400, amount: 100000000001763682, price: FixedU128(0.513377270830019968) } diff --git a/pallets/otc-settlements/src/mock.rs b/pallets/otc-settlements/src/mock.rs index fa0ea4461..0dffe9481 100644 --- a/pallets/otc-settlements/src/mock.rs +++ b/pallets/otc-settlements/src/mock.rs @@ -157,8 +157,7 @@ impl pallet_route_executor::Config for Test { type OraclePeriod = RouteValidationOraclePeriod; type DefaultRoutePoolType = DefaultRoutePoolType; type TechnicalOrigin = EnsureRoot; - type BatchIdProvider = AmmSupport; - type OperationIdProvider = AmmSupport; + type AmmUnifiedEventSupport = AmmSupport; type WeightInfo = (); } diff --git a/pallets/route-executor/src/lib.rs b/pallets/route-executor/src/lib.rs index 0a064c167..fb1ce8672 100644 --- a/pallets/route-executor/src/lib.rs +++ b/pallets/route-executor/src/lib.rs @@ -130,11 +130,8 @@ pub mod pallet { /// Origin able to set route without validation type TechnicalOrigin: EnsureOrigin; - /// Event id provider for unified events - type BatchIdProvider: IncrementalIdProvider; - - /// Operation id provider for unified events - type OperationIdProvider: ExecutionTypeStack; + /// AMM Unified event support + type AmmUnifiedEventSupport: IncrementalIdProvider + ExecutionTypeStack; /// Weight information for the extrinsics. type WeightInfo: AmmTradeWeights>; @@ -266,8 +263,8 @@ pub mod pallet { let route_length = route.len(); - let next_event_id = T::BatchIdProvider::next_id().map_err(|_| ArithmeticError::Overflow)?; - T::OperationIdProvider::push(ExecutionType::Router(next_event_id))?; + let next_event_id = T::AmmUnifiedEventSupport::next_id().map_err(|_| ArithmeticError::Overflow)?; + T::AmmUnifiedEventSupport::push(ExecutionType::Router(next_event_id))?; for (trade_index, (trade_amount, trade)) in trade_amounts.iter().rev().zip(route).enumerate() { Self::disable_ed_handling_for_insufficient_assets(route_length, trade_index, trade); @@ -311,7 +308,7 @@ pub mod pallet { event_id: next_event_id, }); - let _ = T::OperationIdProvider::pop()?; + let _ = T::AmmUnifiedEventSupport::pop()?; Ok(()) } @@ -504,8 +501,8 @@ impl Pallet { let route_length = route.len(); - let next_event_id = T::BatchIdProvider::next_id().map_err(|_| ArithmeticError::Overflow)?; - T::OperationIdProvider::push(ExecutionType::Router(next_event_id))?; + let next_event_id = T::AmmUnifiedEventSupport::next_id().map_err(|_| ArithmeticError::Overflow)?; + T::AmmUnifiedEventSupport::push(ExecutionType::Router(next_event_id))?; for (trade_index, (trade_amount, trade)) in trade_amounts.iter().zip(route.clone()).enumerate() { Self::disable_ed_handling_for_insufficient_assets(route_length, trade_index, trade); @@ -550,7 +547,7 @@ impl Pallet { event_id: next_event_id, }); - let _ = T::OperationIdProvider::pop()?; + let _ = T::AmmUnifiedEventSupport::pop()?; Ok(()) } diff --git a/pallets/route-executor/src/tests/mock.rs b/pallets/route-executor/src/tests/mock.rs index cc9d1c417..968fb6bfd 100644 --- a/pallets/route-executor/src/tests/mock.rs +++ b/pallets/route-executor/src/tests/mock.rs @@ -170,8 +170,7 @@ impl Config for Test { type OraclePeriod = RouteValidationOraclePeriod; type DefaultRoutePoolType = DefaultRoutePoolType; type TechnicalOrigin = EnsureRoot; - type BatchIdProvider = AmmSupport; - type OperationIdProvider = AmmSupport; + type AmmUnifiedEventSupport = AmmSupport; type WeightInfo = (); } diff --git a/runtime/adapters/src/tests/mock.rs b/runtime/adapters/src/tests/mock.rs index 0d773584d..59e4ad328 100644 --- a/runtime/adapters/src/tests/mock.rs +++ b/runtime/adapters/src/tests/mock.rs @@ -348,9 +348,8 @@ impl pallet_route_executor::Config for Test { type DefaultRoutePoolType = DefaultRoutePoolType; type TechnicalOrigin = EnsureRoot; type OraclePeriod = RouteValidationOraclePeriod; - type BatchIdProvider = AmmSupport; + type AmmUnifiedEventSupport = AmmSupport; type WeightInfo = (); - type OperationIdProvider = AmmSupport; } pub struct MockedEdCalculator; diff --git a/runtime/hydradx/src/assets.rs b/runtime/hydradx/src/assets.rs index 2e8162ba3..37abc8ffc 100644 --- a/runtime/hydradx/src/assets.rs +++ b/runtime/hydradx/src/assets.rs @@ -1215,9 +1215,8 @@ impl pallet_route_executor::Config for Runtime { type TechnicalOrigin = SuperMajorityTechCommittee; type EdToRefundCalculator = RefundAndLockedEdCalculator; type OraclePriceProvider = hydradx_adapters::OraclePriceProvider; - type BatchIdProvider = AmmSupport; type OraclePeriod = RouteValidationOraclePeriod; - type OperationIdProvider = AmmSupport; + type AmmUnifiedEventSupport = AmmSupport; } parameter_types! { From f17bcdd60be3f15c6d52c5520808914f3a76233d Mon Sep 17 00:00:00 2001 From: dmoka Date: Mon, 11 Nov 2024 12:59:46 +0100 Subject: [PATCH 053/142] add missing comments --- pallets/stableswap/src/lib.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pallets/stableswap/src/lib.rs b/pallets/stableswap/src/lib.rs index 1c09c0e85..a21bf7da8 100644 --- a/pallets/stableswap/src/lib.rs +++ b/pallets/stableswap/src/lib.rs @@ -476,6 +476,7 @@ pub mod pallet { /// - `assets`: asset id and liquidity amount provided /// /// Emits `LiquidityAdded` event when successful. + /// Emits `pallet_amm_support::Swapped` event when successful. #[pallet::call_index(3)] #[pallet::weight(::WeightInfo::add_liquidity() .saturating_add(T::Hooks::on_liquidity_changed_weight(MAX_ASSETS_IN_POOL as usize)))] @@ -513,6 +514,7 @@ pub mod pallet { /// - `max_asset_amount`: slippage limit. Max amount of asset. /// /// Emits `LiquidityAdded` event when successful. + /// Emits `pallet_amm_support::Swapped` event when successful. #[pallet::call_index(4)] #[pallet::weight(::WeightInfo::add_liquidity_shares() .saturating_add(T::Hooks::on_liquidity_changed_weight(MAX_ASSETS_IN_POOL as usize)))] @@ -552,6 +554,7 @@ pub mod pallet { /// - 'min_amount_out': minimum amount to receive /// /// Emits `LiquidityRemoved` event when successful. + /// Emits `pallet_amm_support::Swapped` event when successful. #[pallet::call_index(5)] #[pallet::weight(::WeightInfo::remove_liquidity_one_asset() .saturating_add(T::Hooks::on_liquidity_changed_weight(MAX_ASSETS_IN_POOL as usize)))] @@ -657,6 +660,7 @@ pub mod pallet { /// - 'max_share_amount': Slippage limit. Max amount of shares to burn. /// /// Emits `LiquidityRemoved` event when successful. + /// Emits `pallet_amm_support::Swapped` event when successful. #[pallet::call_index(6)] #[pallet::weight(::WeightInfo::withdraw_asset_amount() .saturating_add(T::Hooks::on_liquidity_changed_weight(MAX_ASSETS_IN_POOL as usize)))] From e6209660e7a6c1f0c7c3090a97f74e76d5e930cf Mon Sep 17 00:00:00 2001 From: dmoka Date: Mon, 11 Nov 2024 13:01:10 +0100 Subject: [PATCH 054/142] add comments explaining thre why --- pallets/omnipool/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pallets/omnipool/src/lib.rs b/pallets/omnipool/src/lib.rs index b19e3a2fc..9ba6818b6 100644 --- a/pallets/omnipool/src/lib.rs +++ b/pallets/omnipool/src/lib.rs @@ -1891,7 +1891,7 @@ impl Pallet { }); //No need to deposit `HubAmountUpdated` event as hub amounts are zero - + //No protocol fee in case of selling hub asset pallet_amm_support::Pallet::::deposit_trade_event( who.clone(), Self::protocol_account(), @@ -2021,7 +2021,7 @@ impl Pallet { }); //No need to deposit `HubAmountUpdated` event as hub amounts are zero - + //No protocol fee in case of buying asset for hub asset pallet_amm_support::Pallet::::deposit_trade_event( who.clone(), Self::protocol_account(), From d2324493ce0ad3dec70df981d8cff64dd04949e0 Mon Sep 17 00:00:00 2001 From: dmoka Date: Thu, 14 Nov 2024 08:25:20 +0100 Subject: [PATCH 055/142] add fees to swappedevents from stabeswap share calculation --- math/src/stableswap/math.rs | 68 ++++++++------ math/src/stableswap/tests/invariants.rs | 5 +- math/src/stableswap/tests/multi_assets.rs | 88 ++++++++++++------- math/src/stableswap/tests/two_assets.rs | 16 ++-- pallets/stableswap/src/lib.rs | 66 +++++++++----- pallets/stableswap/src/tests/add_liquidity.rs | 64 ++++++++++++-- pallets/stableswap/src/trade_execution.rs | 6 +- pallets/stableswap/src/types.rs | 21 ++++- 8 files changed, 232 insertions(+), 102 deletions(-) diff --git a/math/src/stableswap/math.rs b/math/src/stableswap/math.rs index 992c70a01..94dda6269 100644 --- a/math/src/stableswap/math.rs +++ b/math/src/stableswap/math.rs @@ -125,12 +125,12 @@ pub fn calculate_in_given_out_with_fee( /// Calculate amount of shares to be given to LP after LP provided liquidity of some assets to the pool. pub fn calculate_shares( initial_reserves: &[AssetReserve], - updated_reserves: &[AssetReserve], + updated_asset_reserves: &[(AssetId, AssetReserve)], amplification: Balance, share_issuance: Balance, fee: Permill, -) -> Option { - if initial_reserves.len() != updated_reserves.len() { +) -> Option<(Balance, Vec<(AssetId, Balance)>)> { + if initial_reserves.len() != updated_asset_reserves.len() { return None; } let n_coins = initial_reserves.len(); @@ -141,7 +141,8 @@ pub fn calculate_shares( // We must make sure the updated_d is rounded *down* so that we are not giving the new position too many shares. // calculate_d can return a D value that is above the correct D value by up to 2, so we subtract 2. - let updated_d = calculate_d::(updated_reserves, amplification)?.checked_sub(2_u128)?; + let updated_reserves = updated_asset_reserves.iter().map(|(_,r)|r.clone()).collect::>(); + let updated_d = calculate_d::(&updated_reserves, amplification)?.checked_sub(2_u128)?; if updated_d < initial_d { return None; } @@ -152,18 +153,20 @@ pub fn calculate_shares( let (d0, d1) = to_u256!(initial_d, updated_d); + let mut fees = vec![]; let adjusted_reserves = if share_issuance > 0 { - updated_reserves + updated_asset_reserves .iter() .enumerate() .map(|(idx, asset_reserve)| -> Option { - let (initial_reserve, updated_reserve) = to_u256!(initial_reserves[idx].amount, asset_reserve.amount); + let (initial_reserve, updated_reserve) = to_u256!(initial_reserves[idx].amount, asset_reserve.1.amount); let ideal_balance = d1.checked_mul(initial_reserve)?.checked_div(d0)?; let diff = Balance::try_from(updated_reserve.abs_diff(ideal_balance)).ok()?; let fee_amount = fee.checked_mul_int(diff)?; + fees.push((asset_reserve.0, fee_amount.into())); Some(AssetReserve::new( - asset_reserve.amount.saturating_sub(fee_amount), - asset_reserve.decimals, + asset_reserve.1.amount.saturating_sub(fee_amount), + asset_reserve.1.decimals, )) }) .collect::>>()? @@ -174,24 +177,26 @@ pub fn calculate_shares( if share_issuance == 0 { // if first liquidity added - Some(updated_d) + Some((updated_d, fees)) } else { let (issuance_hp, d_diff, d0) = to_u256!(share_issuance, adjusted_d.checked_sub(initial_d)?, initial_d); let share_amount = issuance_hp.checked_mul(d_diff)?.checked_div(d0)?; - Balance::try_from(share_amount).ok() + let shares_amount = Balance::try_from(share_amount).ok()?; + + Some((shares_amount, fees)) } } /// Calculate amount of shares to be given to LP after LP provided liquidity of one asset with given amount. pub fn calculate_shares_for_amount( - initial_reserves: &[AssetReserve], + initial_asset_reserves: &[(AssetId, AssetReserve)], asset_idx: usize, amount: Balance, amplification: Balance, share_issuance: Balance, fee: Permill, -) -> Option { - let n_coins = initial_reserves.len(); +) -> Option<(Balance, Vec<(AssetId, Balance)>)> { + let n_coins = initial_asset_reserves.len(); if n_coins <= 1 { return None; } @@ -203,32 +208,36 @@ pub fn calculate_shares_for_amount( .checked_mul(&FixedU128::from(n_coins as u128))? .checked_div(&FixedU128::from(4 * (n_coins - 1) as u128))?; - let updated_reserves: Vec = initial_reserves + let updated_asset_reserves: Vec<(AssetId, AssetReserve)> = initial_asset_reserves .iter() .enumerate() - .map(|(idx, v)| -> Option { + .map(|(idx, v)| -> Option<(AssetId, AssetReserve)> { if idx == asset_idx { - Some(AssetReserve::new(v.amount.checked_sub(amount)?, v.decimals)) + Some((v.0, AssetReserve::new(v.1.amount.checked_sub(amount)?, v.1.decimals))) } else { - Some(*v) + Some((v.0, v.1)) } }) - .collect::>>()?; + .collect::>>()?; - let initial_d = calculate_d::(initial_reserves, amplification)?; + let initial_reserves = initial_asset_reserves.iter().map(|(_,r)|r.clone()).collect::>(); + let updated_reserves = updated_asset_reserves.iter().map(|(_,r)|r.clone()).collect::>(); + let initial_d = calculate_d::(&initial_reserves, amplification)?; let updated_d = calculate_d::(&updated_reserves, amplification)?; let (d1, d0) = to_u256!(updated_d, initial_d); - let adjusted_reserves: Vec = updated_reserves + let mut fees = vec![]; + let adjusted_reserves: Vec = updated_asset_reserves .iter() .enumerate() .map(|(idx, asset_reserve)| -> Option { - let (initial_reserve, updated_reserve) = to_u256!(initial_reserves[idx].amount, asset_reserve.amount); + let (initial_reserve, updated_reserve) = to_u256!(initial_reserves[idx].amount, asset_reserve.1.amount); let ideal_balance = d1.checked_mul(initial_reserve)?.checked_div(d0)?; let diff = Balance::try_from(updated_reserve.abs_diff(ideal_balance)).ok()?; let fee_amount = fee.checked_mul_int(diff)?; + fees.push((asset_reserve.0, fee_amount.into())); Some(AssetReserve::new( - asset_reserve.amount.saturating_sub(fee_amount), - asset_reserve.decimals, + asset_reserve.1.amount.saturating_sub(fee_amount), + asset_reserve.1.decimals, )) }) .collect::>>()?; @@ -239,7 +248,9 @@ pub fn calculate_shares_for_amount( .checked_mul(d_diff)? .checked_div(d0)? .checked_add(U256::one())?; - Balance::try_from(share_amount).ok() + let shares = Balance::try_from(share_amount).ok()?; + + Some((shares, fees)) } pub fn calculate_liquidity_out(reserve: Balance, share_amount: Balance, share_issuance: Balance) -> Option { @@ -793,8 +804,8 @@ pub fn calculate_spot_price( } (SHARE_ASSET, STABLE_ASSET) => { let asset_out_idx = asset_reserves.iter().position(|r| r.0 == asset_out)?; - let shares = calculate_shares_for_amount::( - &reserves, + let (shares, _fees) = calculate_shares_for_amount::( + &asset_reserves, asset_out_idx, min_trade_amount, amplification, @@ -814,10 +825,9 @@ pub fn calculate_spot_price( } } - let update_reserves: &Vec = &updated_reserves.into_iter().map(|(_, v)| v).collect::>(); - let shares_for_min_trade = calculate_shares::( + let (shares_for_min_trade, _fees) = calculate_shares::( &reserves, - update_reserves, + &updated_reserves[..], amplification, share_issuance, fee.unwrap_or(Permill::zero()), diff --git a/math/src/stableswap/tests/invariants.rs b/math/src/stableswap/tests/invariants.rs index 98122f94b..a50151233 100644 --- a/math/src/stableswap/tests/invariants.rs +++ b/math/src/stableswap/tests/invariants.rs @@ -404,10 +404,11 @@ proptest! { let issuance = balances.iter().sum(); let amount = to_precision(amount, pool[0].decimals); - let result = calculate_shares_for_amount::(&pool, 0, amount, amp, issuance, Permill::zero()).unwrap(); + let pool_with_id = pool.iter().map(|v| (1u32,v.clone())).collect::>(); + let result = calculate_shares_for_amount::(&pool_with_id[..], 0, amount, amp, issuance, Permill::zero()).unwrap(); let received = - calculate_withdraw_one_asset::(&pool, result, 0, issuance, amp, Permill::zero()) + calculate_withdraw_one_asset::(&pool, result.0, 0, issuance, amp, Permill::zero()) .unwrap(); // LP should not receive more than provided. assert!(received.0 <= amount); diff --git a/math/src/stableswap/tests/multi_assets.rs b/math/src/stableswap/tests/multi_assets.rs index dfa7a3c36..aafd4bbfe 100644 --- a/math/src/stableswap/tests/multi_assets.rs +++ b/math/src/stableswap/tests/multi_assets.rs @@ -1,10 +1,11 @@ -const D_ITERATIONS: u8 = 128; -const Y_ITERATIONS: u8 = 64; +use sp_arithmetic::Permill; -use crate::stableswap::types::AssetReserve; use crate::stableswap::*; -use crate::types::Balance; -use sp_arithmetic::Permill; +use crate::stableswap::types::AssetReserve; +use crate::types::{Balance}; + +const D_ITERATIONS: u8 = 128; +const Y_ITERATIONS: u8 = 64; const MAX_BALANCES: usize = 5; @@ -84,7 +85,7 @@ fn calculate_in_given_out_should_fail_when_asset_idx_is_incorrect() { fn calculate_share_for_amount_should_return_correct_shares() { let amp = 100_u128; - let balances = [AssetReserve::new(10_000_000_000_000_000, 12); MAX_BALANCES]; + let balances = (0..MAX_BALANCES).map(|i| ((i+1) as u32, AssetReserve::new(10_000_000_000_000_000, 12))).collect::>(); let amount: Balance = 100_000_000_000_000; let issuance: Balance = 20_000_000_000_000_000_000_000; @@ -92,11 +93,12 @@ fn calculate_share_for_amount_should_return_correct_shares() { let result = calculate_shares_for_amount::(&balances, 0, amount, amp, issuance, Permill::zero()).unwrap(); - assert_eq!(result, 40001593768209443008); + assert_eq!(result.0, 40001593768209443008); + let balances = balances.iter().map(|(_,amounts)| amounts.clone()).collect::>(); let result = calculate_withdraw_one_asset::( &balances, - result, + result.0, 0, issuance, amp, @@ -112,17 +114,19 @@ fn calculate_share_for_amount_should_return_correct_shares_when_fee_applied() { let fee = Permill::from_float(0.001); - let balances = [AssetReserve::new(10_000_000_000_000_000, 12); MAX_BALANCES]; + //let balances = [AssetReserve::new(10_000_000_000_000_000, 12); MAX_BALANCES]; + let balances = (0..MAX_BALANCES).map(|i| ((i+1) as u32, AssetReserve::new(10_000_000_000_000_000, 12))).collect::>(); let amount: Balance = 100_000_000_000_000; let issuance: Balance = 20_000_000_000_000_000_000_000; let result = calculate_shares_for_amount::(&balances, 0, amount, amp, issuance, fee).unwrap(); - assert_eq!(result, 40021594667568399481); + assert_eq!(result.0, 40021594667568399481); + let balances = balances.iter().map(|(_,amounts)| amounts.clone()).collect::>(); let result = - calculate_withdraw_one_asset::(&balances, result, 0, issuance, amp, fee).unwrap(); + calculate_withdraw_one_asset::(&balances, result.0, 0, issuance, amp, fee).unwrap(); assert_eq!(result, (99999975001371, 50023249592)); } @@ -131,8 +135,8 @@ fn calculate_shares_should_work_when_correct_input_provided() { let amp = 100_u128; let initial_balances = [AssetReserve::new(10_000, 12); MAX_BALANCES]; - let mut updated_balances = [AssetReserve::new(10_000, 12); MAX_BALANCES]; - updated_balances[2].amount += 5000u128; + let mut updated_balances = (0..MAX_BALANCES).map(|i| ((i+1) as u32, AssetReserve::new(10_000, 12))).collect::>(); + updated_balances[2].1.amount += 5000u128; let issuance: Balance = 100_000; @@ -142,7 +146,26 @@ fn calculate_shares_should_work_when_correct_input_provided() { let result = result.unwrap(); - assert_eq!(result, 9983u128); + assert_eq!(result.0, 9983u128); +} + +#[test] +fn calculate_shares_should_return_fees_for_all_assets() { + let amp = 100_u128; + + let initial_balances = [AssetReserve::new(10_000, 12); MAX_BALANCES]; + let mut updated_balances = (0..MAX_BALANCES).map(|i| ((i+1) as u32, AssetReserve::new(10_000, 12))).collect::>(); + updated_balances[2].1.amount += 5000u128; + + let issuance: Balance = 100_000; + + let result = calculate_shares::(&initial_balances, &updated_balances, amp, issuance, Permill::from_percent(1)); + + assert!(result.is_some()); + + let result = result.unwrap(); + + assert_eq!(result.1, vec![(1,3), (2,3), (3,12), (4,3), (5,3)]); } #[test] @@ -150,8 +173,8 @@ fn calculate_shares_should_work_when_share_issuance_is_zero() { let amp = 100_u128; let initial_balances = [AssetReserve::new(0, 12); MAX_BALANCES]; - let mut updated_balances = [AssetReserve::new(10_000, 12); MAX_BALANCES]; - updated_balances[2].amount += 5000u128; + let mut updated_balances = (0..MAX_BALANCES).map(|i| ((i+1) as u32, AssetReserve::new(10_000, 12))).collect::>(); + updated_balances[2].1.amount += 5000u128; let issuance: Balance = 0; @@ -161,7 +184,7 @@ fn calculate_shares_should_work_when_share_issuance_is_zero() { let result = result.unwrap(); - assert_eq!(result, 54991983151); + assert_eq!(result.0, 54991983151); } #[test] @@ -169,8 +192,8 @@ fn calculate_shares_should_fail_when_balances_len_is_not_equal() { let amp = 100_u128; let initial_balances = [AssetReserve::new(10_000, 12); MAX_BALANCES + 1]; - let mut updated_balances = [AssetReserve::new(10_000, 12); MAX_BALANCES]; - updated_balances[2].amount += 5000u128; + let mut updated_balances = (0..MAX_BALANCES).map(|i| ((i+1) as u32, AssetReserve::new(10_000, 12))).collect::>(); + updated_balances[2].1.amount += 5000u128; let issuance: Balance = 100_000; @@ -184,8 +207,8 @@ fn calculate_shares_should_fail_when_updated_balances_are_less() { let amp = 100_u128; let initial_balances = [AssetReserve::new(10_000, 12); MAX_BALANCES]; - let mut updated_balances = [AssetReserve::new(10_000, 12); MAX_BALANCES]; - updated_balances[2].amount -= 5000u128; + let mut updated_balances = (0..MAX_BALANCES).map(|i| ((i+1) as u32, AssetReserve::new(10_000, 12))).collect::>(); + updated_balances[2].1.amount -= 5000u128; let issuance: Balance = 100_000; @@ -358,13 +381,14 @@ fn calculate_withdraw_should_return_correct_amount_when_removing_provided_shares let fee = Permill::from_percent(0); let initial_balances = [AssetReserve::new(10_000, 12); MAX_BALANCES]; - let mut updated_balances = [AssetReserve::new(10_000, 12); MAX_BALANCES]; - updated_balances[2].amount += 5000u128; + let mut updated_balances_for_calculate_shares = (0..MAX_BALANCES).map(|i| ((i+1) as u32, AssetReserve::new(10_000, 12))).collect::>(); + updated_balances_for_calculate_shares[2].1.amount += 5000u128; + let updated_balances = updated_balances_for_calculate_shares.iter().map(|(_,amounts)| amounts.clone()).collect::>(); let issuance: Balance = 100_000; - let result = calculate_shares::(&initial_balances, &updated_balances, amp, issuance, Permill::zero()); - let shares = result.unwrap(); + let result = calculate_shares::(&initial_balances, &updated_balances_for_calculate_shares, amp, issuance, Permill::zero()); + let shares = result.unwrap().0; let result = calculate_withdraw_one_asset::( &updated_balances, @@ -699,13 +723,14 @@ fn calculate_exact_amount_of_shares() { let asset_idx = 2; let initial_balances = [AssetReserve::new(10_000_000_000_000_000, 12); MAX_BALANCES]; - let mut updated_balances = initial_balances; - updated_balances[asset_idx].amount += 1_000_000_000_000_000u128; + let mut updated_balances = (0..MAX_BALANCES).map(|i| ((i+1) as u32, AssetReserve::new(10_000_000_000_000_000, 12))).collect::>(); + updated_balances[asset_idx].1.amount += 1_000_000_000_000_000u128; let issuance: Balance = 20_000_000_000_000_000_000_000; let result = calculate_shares::(&initial_balances, &updated_balances, amp, issuance, Permill::zero()); - assert_eq!(result, Some(399850144492663029649)); + let shares = result.unwrap().0; + assert_eq!(shares, 399850144492663029649); let result = calculate_add_one_asset::( &initial_balances, 399850144492663029649, @@ -724,8 +749,8 @@ fn calculate_exact_amount_of_shares_with_fee() { let asset_idx = 2; let initial_balances = [AssetReserve::new(10_000_000_000_000_000, 12); MAX_BALANCES]; - let mut updated_balances = initial_balances; - updated_balances[asset_idx].amount += 1_000_000_000_000_000u128; + let mut updated_balances = (0..MAX_BALANCES).map(|i| ((i+1) as u32, AssetReserve::new(10_000_000_000_000_000, 12))).collect::>(); + updated_balances[asset_idx].1.amount += 1_000_000_000_000_000u128; let issuance: Balance = 20_000_000_000_000_000_000_000; @@ -736,7 +761,8 @@ fn calculate_exact_amount_of_shares_with_fee() { issuance, Permill::from_percent(0), ); - assert_eq!(result, Some(399850144492663029649)); + let shares = result.unwrap().0; + assert_eq!(shares, 399850144492663029649); let result = calculate_add_one_asset::( &initial_balances, 399850144492663029649, diff --git a/math/src/stableswap/tests/two_assets.rs b/math/src/stableswap/tests/two_assets.rs index 2ee1983b4..01d776e9e 100644 --- a/math/src/stableswap/tests/two_assets.rs +++ b/math/src/stableswap/tests/two_assets.rs @@ -1,10 +1,12 @@ -const D_ITERATIONS: u8 = 128; -const Y_ITERATIONS: u8 = 64; +use sp_arithmetic::Permill; -use super::*; -use crate::stableswap::types::AssetReserve; use crate::stableswap::*; -use sp_arithmetic::Permill; +use crate::stableswap::types::AssetReserve; + +use super::*; + +const D_ITERATIONS: u8 = 128; +const Y_ITERATIONS: u8 = 64; #[test] fn test_d() { @@ -103,12 +105,12 @@ fn test_shares() { let amp = 100u128; let initial_reserves = &[AssetReserve::new(0, 12); 2]; - let updated_reserves = &[AssetReserve::new(1000 * ONE, 12), AssetReserve::new(500, 12)]; + let updated_reserves = &[(1, AssetReserve::new(1000 * ONE, 12)),(2, AssetReserve::new(500, 12))]; let result = calculate_shares::(initial_reserves, updated_reserves, amp, 0u128, Permill::zero()); assert!(result.is_some()); - assert_eq!(result.unwrap(), 736626243363217809); + assert_eq!(result.unwrap().0, 736626243363217809); } #[test] fn remove_one_asset_should_work() { diff --git a/pallets/stableswap/src/lib.rs b/pallets/stableswap/src/lib.rs index a21bf7da8..9a18e6891 100644 --- a/pallets/stableswap/src/lib.rs +++ b/pallets/stableswap/src/lib.rs @@ -685,14 +685,16 @@ pub mod pallet { let asset_idx = pool.find_asset(asset_id).ok_or(Error::::AssetNotInPool)?; let pool_account = Self::pool_account(pool_id); let initial_reserves = pool - .reserves_with_decimals::(&pool_account) + .asset_reserves_with_decimals::(&pool_account) .ok_or(Error::::UnknownDecimals)?; + + let initial_reserves = initial_reserves.iter().map(|(r)| (r.0.into(), r.1)).collect::>(); let share_issuance = T::Currency::total_issuance(pool_id); let amplification = Self::get_amplification(&pool); // Calculate how much shares user needs to provide to receive `amount` of asset. - let shares = hydra_dx_math::stableswap::calculate_shares_for_amount::( - &initial_reserves, + let (shares, fees) = hydra_dx_math::stableswap::calculate_shares_for_amount::( + &initial_reserves[..], asset_idx, amount, amplification, @@ -715,6 +717,7 @@ pub mod pallet { T::Currency::transfer(asset_id, &pool_account, &who, amount)?; // All done and updated. let's call the on_liquidity_changed hook. + let initial_reserves = initial_reserves.iter().map(|r| r.1).collect::>(); Self::call_on_liquidity_change_hook(pool_id, &initial_reserves, share_issuance)?; Self::deposit_event(Event::LiquidityRemoved { @@ -1207,17 +1210,23 @@ impl Pallet { }); if let Some(liq_added) = added_assets.remove(pool_asset) { let inc_reserve = reserve.checked_add(liq_added).ok_or(ArithmeticError::Overflow)?; - updated_reserves.push(AssetReserve { - amount: inc_reserve, - decimals, - }); + updated_reserves.push(( + (*pool_asset).into(), + AssetReserve { + amount: inc_reserve, + decimals, + }, + )); added_amounts.push(liq_added); } else { ensure!(!reserve.is_zero(), Error::::InvalidInitialLiquidity); - updated_reserves.push(AssetReserve { - amount: reserve, - decimals, - }); + updated_reserves.push(( + (*pool_asset).into(), + AssetReserve { + amount: reserve, + decimals, + }, + )); added_amounts.push(0); } } @@ -1226,7 +1235,7 @@ impl Pallet { let amplification = Self::get_amplification(&pool); let share_issuance = T::Currency::total_issuance(pool_id); - let share_amount = hydra_dx_math::stableswap::calculate_shares::( + let (share_amount, fees) = hydra_dx_math::stableswap::calculate_shares::( &initial_reserves, &updated_reserves, amplification, @@ -1259,7 +1268,10 @@ impl Pallet { .iter() .map(|asset| (AssetType::Fungible(asset.asset_id.into()), asset.amount)) .collect(); - + let fees = fees + .iter() + .map(|(asset_id, balance)| Fee::new(*asset_id, *balance, pool_account.clone())) + .collect::>(); pallet_amm_support::Pallet::::deposit_trade_event( who.clone(), pool_account.clone(), @@ -1267,7 +1279,7 @@ impl Pallet { pallet_amm_support::TradeOperation::ExactIn, inputs, vec![(AssetType::Fungible(pool_id.into()), share_amount)], - vec![], //TODO: ask Martin what will be the fee? + fees, ); Ok(share_amount) @@ -1403,24 +1415,30 @@ impl Pallet { }); if let Some(liq_added) = added_assets.remove(pool_asset) { let inc_reserve = reserve.checked_add(liq_added).ok_or(ArithmeticError::Overflow)?; - updated_reserves.push(AssetReserve { - amount: inc_reserve, - decimals, - }); + updated_reserves.push(( + (*pool_asset).into(), + AssetReserve { + amount: inc_reserve, + decimals, + }, + )); } else { ensure!(!reserve.is_zero(), Error::::InvalidInitialLiquidity); - updated_reserves.push(AssetReserve { - amount: reserve, - decimals, - }); + updated_reserves.push(( + (*pool_asset).into(), + AssetReserve { + amount: reserve, + decimals, + }, + )); } } let amplification = Self::get_amplification(&pool); let share_issuance = T::Currency::total_issuance(pool_id); - let share_amount = hydra_dx_math::stableswap::calculate_shares::( + let (share_amount, _fees) = hydra_dx_math::stableswap::calculate_shares::( &initial_reserves, - &updated_reserves, + &updated_reserves[..], amplification, share_issuance, pool.fee, diff --git a/pallets/stableswap/src/tests/add_liquidity.rs b/pallets/stableswap/src/tests/add_liquidity.rs index 9a5fd4ee8..29fe5ca80 100644 --- a/pallets/stableswap/src/tests/add_liquidity.rs +++ b/pallets/stableswap/src/tests/add_liquidity.rs @@ -51,6 +51,59 @@ fn add_initial_liquidity_should_work_when_called_first_time() { assert_balance!(BOB, pool_id, 200 * ONE * 1_000_000); assert_balance!(pool_account, asset_a, 100 * ONE); assert_balance!(pool_account, asset_b, 100 * ONE); + }); +} + +#[test] +fn add_liquidity_should_emit_swapped_events() { + let asset_a: AssetId = 1; + let asset_b: AssetId = 2; + let asset_c: AssetId = 3; + + ExtBuilder::default() + .with_endowed_accounts(vec![ + (BOB, asset_a, 2_000_000_000_000_000_000), + (ALICE, asset_a, 52425995641788588073263117), + (ALICE, asset_b, 52033213790329), + (ALICE, asset_c, 119135337044269), + ]) + .with_registered_asset("one".as_bytes().to_vec(), asset_a, 18) + .with_registered_asset("two".as_bytes().to_vec(), asset_b, 6) + .with_registered_asset("three".as_bytes().to_vec(), asset_c, 6) + .with_pool( + ALICE, + PoolInfo:: { + assets: vec![asset_a, asset_b, asset_c].try_into().unwrap(), + initial_amplification: NonZeroU16::new(2000).unwrap(), + final_amplification: NonZeroU16::new(2000).unwrap(), + initial_block: 0, + final_block: 0, + fee: Permill::from_float(0.0001), + }, + InitialLiquidity { + account: ALICE, + assets: vec![ + AssetAmount::new(asset_a, 52425995641788588073263117), + AssetAmount::new(asset_b, 52033213790329), + AssetAmount::new(asset_c, 119135337044269), + ], + }, + ) + .build() + .execute_with(|| { + let pool_id = get_pool_id_at(0); + let amount = 2_000_000_000_000_000_000; + Tokens::withdraw(pool_id, &ALICE, 5906657405945079804575283).unwrap(); + assert_ok!(Stableswap::add_liquidity( + RuntimeOrigin::signed(BOB), + pool_id, + vec![AssetAmount::new(asset_a, amount),] + )); + + let received = Tokens::free_balance(pool_id, &BOB); + assert_eq!(received, 1947487201901031408); + + let pool_account = pool_account(pool_id); pretty_assertions::assert_eq!( *get_last_swapped_events().last().unwrap(), @@ -59,12 +112,13 @@ fn add_initial_liquidity_should_work_when_called_first_time() { filler: pool_account, filler_type: pallet_amm_support::Filler::Stableswap(pool_id), operation: pallet_amm_support::TradeOperation::ExactIn, - inputs: vec![ - (AssetType::Fungible(asset_a), 100 * ONE), - (AssetType::Fungible(asset_b), 100 * ONE), + inputs: vec![(AssetType::Fungible(asset_a), 2000000000000000000),], + outputs: vec![(AssetType::Fungible(pool_id), 1947487201901031408)], + fees: vec![ + Fee::new(asset_a, 57410103828678, pool_account), + Fee::new(asset_b, 17, pool_account), + Fee::new(asset_c, 39, pool_account) ], - outputs: vec![(AssetType::Fungible(pool_id), 200000000 * ONE)], - fees: vec![], operation_id: vec![], }) ) diff --git a/pallets/stableswap/src/trade_execution.rs b/pallets/stableswap/src/trade_execution.rs index 53d54e25a..99fb9c1d6 100644 --- a/pallets/stableswap/src/trade_execution.rs +++ b/pallets/stableswap/src/trade_execution.rs @@ -105,7 +105,7 @@ where .ok_or_else(|| ExecutorError::Error(Error::::AssetNotInPool.into()))?; let pool_account = Self::pool_account(pool_id); let balances = pool - .reserves_with_decimals::(&pool_account) + .asset_reserves_with_decimals::(&pool_account) .ok_or_else(|| ExecutorError::Error(Error::::UnknownDecimals.into()))?; let share_issuance = T::Currency::total_issuance(pool_id); let amplification = Self::get_amplification(&pool); @@ -113,7 +113,9 @@ where let pool = Pools::::get(pool_id) .ok_or_else(|| ExecutorError::Error(Error::::PoolNotFound.into()))?; - let shares_amount = hydra_dx_math::stableswap::calculate_shares_for_amount::( + let balances = balances.iter().map(|(r)| (r.0.into(), r.1)).collect::>(); + + let (shares_amount, _fees) = hydra_dx_math::stableswap::calculate_shares_for_amount::( &balances, asset_idx, amount_out, diff --git a/pallets/stableswap/src/types.rs b/pallets/stableswap/src/types.rs index 17a8002d0..07c0ffaf8 100644 --- a/pallets/stableswap/src/types.rs +++ b/pallets/stableswap/src/types.rs @@ -56,9 +56,26 @@ where self.assets.len() >= 2 && has_unique_elements(&mut self.assets.iter()) } + pub(crate) fn asset_reserves_with_decimals(&self, account: &T::AccountId) -> Option> + where + T::AssetId: Into, ::AssetId: From + { + self.assets + .iter() + .map(|asset| { + let reserve = T::Currency::free_balance((*asset).into(), account); + let decimals = Pallet::::retrieve_decimals((*asset).into())?; + Some((*asset, AssetReserve { + amount: reserve, + decimals, + })) + }) + .collect() + } + pub(crate) fn reserves_with_decimals(&self, account: &T::AccountId) -> Option> - where - T::AssetId: From, + where + T::AssetId: From, { self.assets .iter() From 9895a68dee5ad558bc71d4695f386fb20feef5e5 Mon Sep 17 00:00:00 2001 From: dmoka Date: Thu, 14 Nov 2024 08:27:08 +0100 Subject: [PATCH 056/142] formatting --- pallets/stableswap/src/lib.rs | 5 ++++- pallets/stableswap/src/trade_execution.rs | 26 +++++++++++++---------- pallets/stableswap/src/types.rs | 25 ++++++++++++++-------- 3 files changed, 35 insertions(+), 21 deletions(-) diff --git a/pallets/stableswap/src/lib.rs b/pallets/stableswap/src/lib.rs index 9a18e6891..16657630f 100644 --- a/pallets/stableswap/src/lib.rs +++ b/pallets/stableswap/src/lib.rs @@ -688,7 +688,10 @@ pub mod pallet { .asset_reserves_with_decimals::(&pool_account) .ok_or(Error::::UnknownDecimals)?; - let initial_reserves = initial_reserves.iter().map(|(r)| (r.0.into(), r.1)).collect::>(); + let initial_reserves = initial_reserves + .iter() + .map(|(r)| (r.0.into(), r.1)) + .collect::>(); let share_issuance = T::Currency::total_issuance(pool_id); let amplification = Self::get_amplification(&pool); diff --git a/pallets/stableswap/src/trade_execution.rs b/pallets/stableswap/src/trade_execution.rs index 99fb9c1d6..dbdbfc302 100644 --- a/pallets/stableswap/src/trade_execution.rs +++ b/pallets/stableswap/src/trade_execution.rs @@ -113,17 +113,21 @@ where let pool = Pools::::get(pool_id) .ok_or_else(|| ExecutorError::Error(Error::::PoolNotFound.into()))?; - let balances = balances.iter().map(|(r)| (r.0.into(), r.1)).collect::>(); - - let (shares_amount, _fees) = hydra_dx_math::stableswap::calculate_shares_for_amount::( - &balances, - asset_idx, - amount_out, - amplification, - share_issuance, - pool.fee, - ) - .ok_or_else(|| ExecutorError::Error(ArithmeticError::Overflow.into()))?; + let balances = balances + .iter() + .map(|(r)| (r.0.into(), r.1)) + .collect::>(); + + let (shares_amount, _fees) = + hydra_dx_math::stableswap::calculate_shares_for_amount::( + &balances, + asset_idx, + amount_out, + amplification, + share_issuance, + pool.fee, + ) + .ok_or_else(|| ExecutorError::Error(ArithmeticError::Overflow.into()))?; Ok(shares_amount) } else { diff --git a/pallets/stableswap/src/types.rs b/pallets/stableswap/src/types.rs index 07c0ffaf8..985a8a793 100644 --- a/pallets/stableswap/src/types.rs +++ b/pallets/stableswap/src/types.rs @@ -56,26 +56,33 @@ where self.assets.len() >= 2 && has_unique_elements(&mut self.assets.iter()) } - pub(crate) fn asset_reserves_with_decimals(&self, account: &T::AccountId) -> Option> - where - T::AssetId: Into, ::AssetId: From + pub(crate) fn asset_reserves_with_decimals( + &self, + account: &T::AccountId, + ) -> Option> + where + T::AssetId: Into, + ::AssetId: From, { self.assets .iter() .map(|asset| { let reserve = T::Currency::free_balance((*asset).into(), account); let decimals = Pallet::::retrieve_decimals((*asset).into())?; - Some((*asset, AssetReserve { - amount: reserve, - decimals, - })) + Some(( + *asset, + AssetReserve { + amount: reserve, + decimals, + }, + )) }) .collect() } pub(crate) fn reserves_with_decimals(&self, account: &T::AccountId) -> Option> - where - T::AssetId: From, + where + T::AssetId: From, { self.assets .iter() From efe4ceb6a03e7602f4ab48aecf9e2ca5144901d5 Mon Sep 17 00:00:00 2001 From: dmoka Date: Thu, 14 Nov 2024 08:47:04 +0100 Subject: [PATCH 057/142] add missing fee info to swapped event when removing exact amount of liquidity --- pallets/stableswap/src/lib.rs | 8 +- .../stableswap/src/tests/remove_liquidity.rs | 101 +++++++++++++++--- pallets/stableswap/src/trade_execution.rs | 3 +- 3 files changed, 94 insertions(+), 18 deletions(-) diff --git a/pallets/stableswap/src/lib.rs b/pallets/stableswap/src/lib.rs index 16657630f..ceeac8e87 100644 --- a/pallets/stableswap/src/lib.rs +++ b/pallets/stableswap/src/lib.rs @@ -690,7 +690,7 @@ pub mod pallet { let initial_reserves = initial_reserves .iter() - .map(|(r)| (r.0.into(), r.1)) + .map(|r| (r.0.into(), r.1)) .collect::>(); let share_issuance = T::Currency::total_issuance(pool_id); let amplification = Self::get_amplification(&pool); @@ -731,6 +731,10 @@ pub mod pallet { fee: 0u128, // dev note: figure out the actual fee amount in this case. For now, we dont need it. }); + let fees = fees + .iter() + .map(|(asset_id, balance)| Fee::new(*asset_id, *balance, pool_account.clone())) + .collect::>(); pallet_amm_support::Pallet::::deposit_trade_event( who, pool_account.clone(), @@ -738,7 +742,7 @@ pub mod pallet { pallet_amm_support::TradeOperation::ExactOut, vec![(AssetType::Fungible(pool_id.into()), shares)], vec![(AssetType::Fungible(asset_id.into()), amount)], - vec![], + fees, ); Ok(()) diff --git a/pallets/stableswap/src/tests/remove_liquidity.rs b/pallets/stableswap/src/tests/remove_liquidity.rs index 816232cd1..51783027c 100644 --- a/pallets/stableswap/src/tests/remove_liquidity.rs +++ b/pallets/stableswap/src/tests/remove_liquidity.rs @@ -868,21 +868,6 @@ fn removing_liquidity_with_exact_amount_should_work() { assert_eq!(received, 0); let balance = Tokens::free_balance(asset_a, &BOB); assert_eq!(balance, 1_999_999_999_999_999_999); - - let pool_account = pool_account(pool_id); - pretty_assertions::assert_eq!( - *get_last_swapped_events().last().unwrap(), - RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { - swapper: BOB, - filler: pool_account, - filler_type: pallet_amm_support::Filler::Stableswap(4), - operation: pallet_amm_support::TradeOperation::ExactOut, - inputs: vec![(AssetType::Fungible(pool_id), 1947597621401945851)], - outputs: vec![(AssetType::Fungible(asset_a), 1999999999999999999),], - fees: vec![], - operation_id: vec![], - }) - ); }); } @@ -1025,6 +1010,92 @@ fn removing_liquidity_with_exact_amount_should_apply_fee() { }); } +#[test] +fn removing_liquidity_with_exact_amount_should_emit_swapped_event() { + let asset_a: AssetId = 1; + let asset_b: AssetId = 2; + let asset_c: AssetId = 3; + + ExtBuilder::default() + .with_endowed_accounts(vec![ + (BOB, asset_a, 3_000_000_000_000_000_003), + (ALICE, asset_a, 52425995641788588073263117), + (ALICE, asset_b, 52033213790329), + (ALICE, asset_c, 119135337044269), + ]) + .with_registered_asset("one".as_bytes().to_vec(), asset_a, 18) + .with_registered_asset("two".as_bytes().to_vec(), asset_b, 6) + .with_registered_asset("three".as_bytes().to_vec(), asset_c, 6) + .with_pool( + ALICE, + PoolInfo:: { + assets: vec![asset_a, asset_b, asset_c].try_into().unwrap(), + initial_amplification: NonZeroU16::new(2000).unwrap(), + final_amplification: NonZeroU16::new(2000).unwrap(), + initial_block: 0, + final_block: 0, + fee: Permill::from_percent(1), + }, + InitialLiquidity { + account: ALICE, + assets: vec![ + AssetAmount::new(asset_a, 52425995641788588073263117), + AssetAmount::new(asset_b, 52033213790329), + AssetAmount::new(asset_c, 119135337044269), + ], + }, + ) + .build() + .execute_with(|| { + let pool_id = get_pool_id_at(0); + let amount = 2_000_000_000_000_000_000; + Tokens::withdraw(pool_id, &ALICE, 5906657405945079804575283).unwrap(); + let desired_shares = 1947597621401945851; + assert_ok!(Stableswap::add_liquidity_shares( + RuntimeOrigin::signed(BOB), + pool_id, + desired_shares, + asset_a, + amount * 2, // add liquidity for shares uses slightly more + )); + let received = Tokens::free_balance(pool_id, &BOB); + assert_eq!(received, desired_shares); + let balance = Tokens::free_balance(asset_a, &BOB); + let amount_used = 3_000_000_000_000_000_003 - balance; + assert_eq!(amount_used, 2011482020765837587); + // ACT + assert_ok!(Stableswap::withdraw_asset_amount( + RuntimeOrigin::signed(BOB), + pool_id, + asset_a, + 1_000_000_000_000_000_000, + desired_shares, + )); + + // ASSERT + let shares_left = Tokens::free_balance(pool_id, &BOB); + assert_eq!(shares_left, 968209693349892648); + let balance = Tokens::free_balance(asset_a, &BOB); + assert_eq!(balance, 1988517979234162416); + let pool_account = pool_account(pool_id); + + pretty_assertions::assert_eq!( + *get_last_swapped_events().last().unwrap(), + RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + swapper: BOB, + filler: pool_account, + filler_type: pallet_amm_support::Filler::Stableswap(4), + operation: pallet_amm_support::TradeOperation::ExactOut, + inputs: vec![(AssetType::Fungible(pool_id), 979387928052053203)], + outputs: vec![(AssetType::Fungible(asset_a), 1000000000000000000),], + fees: vec![Fee::new(asset_a, 2870505165609705, pool_account), Fee::new(asset_b, 872, pool_account), Fee::new(asset_c, 1998, pool_account)], + operation_id: vec![], + }) + ); + }); +} + + #[test] fn remove_multi_asset_liquidity_should_work_when_withdrawing_some_shares() { let asset_a: AssetId = 1; diff --git a/pallets/stableswap/src/trade_execution.rs b/pallets/stableswap/src/trade_execution.rs index dbdbfc302..92367a097 100644 --- a/pallets/stableswap/src/trade_execution.rs +++ b/pallets/stableswap/src/trade_execution.rs @@ -6,6 +6,7 @@ use orml_traits::MultiCurrency; use sp_core::Get; use sp_runtime::{ArithmeticError, DispatchError, FixedU128}; use sp_std::vec; +use sp_std::vec::Vec; impl TradeExecution for Pallet where @@ -115,7 +116,7 @@ where let balances = balances .iter() - .map(|(r)| (r.0.into(), r.1)) + .map(|r| (r.0.into(), r.1)) .collect::>(); let (shares_amount, _fees) = From ed3852a6211257b8c7700e2ff918c339f6b54c8c Mon Sep 17 00:00:00 2001 From: dmoka Date: Thu, 14 Nov 2024 18:26:25 +0100 Subject: [PATCH 058/142] add hooks for utility batch calls so can have proper Swapped events --- Cargo.lock | 554 +++++------ Cargo.toml | 890 +++++++++--------- integration-tests/src/dca.rs | 14 - integration-tests/src/lib.rs | 1 + integration-tests/src/polkadot_test_net.rs | 17 +- integration-tests/src/router.rs | 4 +- integration-tests/src/utility.rs | 225 +++++ pallets/transaction-multi-payment/src/mock.rs | 2 + runtime/hydradx/src/system.rs | 28 + 9 files changed, 996 insertions(+), 739 deletions(-) create mode 100644 integration-tests/src/utility.rs diff --git a/Cargo.lock b/Cargo.lock index 4dd0cba09..05f03ec55 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -939,7 +939,7 @@ dependencies = [ [[package]] name = "binary-merkle-tree" version = "13.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "hash-db", "log", @@ -1170,7 +1170,7 @@ dependencies = [ [[package]] name = "bp-xcm-bridge-hub-router" version = "0.6.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "parity-scale-codec", "scale-info", @@ -2032,7 +2032,7 @@ dependencies = [ [[package]] name = "cumulus-client-cli" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "clap 4.5.4", "parity-scale-codec", @@ -2049,7 +2049,7 @@ dependencies = [ [[package]] name = "cumulus-client-collator" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "cumulus-client-consensus-common", "cumulus-client-network", @@ -2072,7 +2072,7 @@ dependencies = [ [[package]] name = "cumulus-client-consensus-aura" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "async-trait", "cumulus-client-collator", @@ -2114,7 +2114,7 @@ dependencies = [ [[package]] name = "cumulus-client-consensus-common" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "async-trait", "cumulus-client-pov-recovery", @@ -2143,7 +2143,7 @@ dependencies = [ [[package]] name = "cumulus-client-consensus-proposer" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "anyhow", "async-trait", @@ -2158,7 +2158,7 @@ dependencies = [ [[package]] name = "cumulus-client-network" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "async-trait", "cumulus-relay-chain-interface", @@ -2181,7 +2181,7 @@ dependencies = [ [[package]] name = "cumulus-client-parachain-inherent" version = "0.1.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "async-trait", "cumulus-primitives-core", @@ -2205,7 +2205,7 @@ dependencies = [ [[package]] name = "cumulus-client-pov-recovery" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "async-trait", "cumulus-primitives-core", @@ -2229,7 +2229,7 @@ dependencies = [ [[package]] name = "cumulus-client-service" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "cumulus-client-cli", "cumulus-client-collator", @@ -2266,7 +2266,7 @@ dependencies = [ [[package]] name = "cumulus-pallet-aura-ext" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "cumulus-pallet-parachain-system", "frame-support", @@ -2284,7 +2284,7 @@ dependencies = [ [[package]] name = "cumulus-pallet-parachain-system" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "bytes", "cumulus-pallet-parachain-system-proc-macro", @@ -2319,7 +2319,7 @@ dependencies = [ [[package]] name = "cumulus-pallet-parachain-system-proc-macro" version = "0.6.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", @@ -2330,7 +2330,7 @@ dependencies = [ [[package]] name = "cumulus-pallet-xcm" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "cumulus-primitives-core", "frame-support", @@ -2346,7 +2346,7 @@ dependencies = [ [[package]] name = "cumulus-pallet-xcmp-queue" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "bounded-collections", "bp-xcm-bridge-hub-router", @@ -2371,7 +2371,7 @@ dependencies = [ [[package]] name = "cumulus-primitives-aura" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "parity-scale-codec", "polkadot-core-primitives", @@ -2385,7 +2385,7 @@ dependencies = [ [[package]] name = "cumulus-primitives-core" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "parity-scale-codec", "polkadot-core-primitives", @@ -2402,7 +2402,7 @@ dependencies = [ [[package]] name = "cumulus-primitives-parachain-inherent" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "async-trait", "cumulus-primitives-core", @@ -2419,7 +2419,7 @@ dependencies = [ [[package]] name = "cumulus-primitives-proof-size-hostfunction" version = "0.2.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "sp-externalities", "sp-runtime-interface", @@ -2429,7 +2429,7 @@ dependencies = [ [[package]] name = "cumulus-primitives-timestamp" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "cumulus-primitives-core", "futures", @@ -2442,7 +2442,7 @@ dependencies = [ [[package]] name = "cumulus-primitives-utility" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "cumulus-primitives-core", "frame-support", @@ -2462,7 +2462,7 @@ dependencies = [ [[package]] name = "cumulus-relay-chain-inprocess-interface" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "async-trait", "cumulus-primitives-core", @@ -2486,7 +2486,7 @@ dependencies = [ [[package]] name = "cumulus-relay-chain-interface" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "async-trait", "cumulus-primitives-core", @@ -2504,7 +2504,7 @@ dependencies = [ [[package]] name = "cumulus-relay-chain-minimal-node" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "array-bytes 6.2.2", "async-trait", @@ -2546,7 +2546,7 @@ dependencies = [ [[package]] name = "cumulus-relay-chain-rpc-interface" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "async-trait", "cumulus-primitives-core", @@ -2585,7 +2585,7 @@ dependencies = [ [[package]] name = "cumulus-test-relay-sproof-builder" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "cumulus-primitives-core", "parity-scale-codec", @@ -3761,7 +3761,7 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "fork-tree" version = "12.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "parity-scale-codec", ] @@ -3877,7 +3877,7 @@ checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" [[package]] name = "frame-benchmarking" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-support", "frame-support-procedural", @@ -3902,7 +3902,7 @@ dependencies = [ [[package]] name = "frame-benchmarking-cli" version = "32.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "Inflector", "array-bytes 6.2.2", @@ -3952,7 +3952,7 @@ dependencies = [ [[package]] name = "frame-election-provider-solution-type" version = "13.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", @@ -3963,7 +3963,7 @@ dependencies = [ [[package]] name = "frame-election-provider-support" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-election-provider-solution-type", "frame-support", @@ -3980,7 +3980,7 @@ dependencies = [ [[package]] name = "frame-executive" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "aquamarine 0.3.3", "frame-support", @@ -4011,7 +4011,7 @@ dependencies = [ [[package]] name = "frame-metadata-hash-extension" version = "0.1.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "array-bytes 6.2.2", "docify", @@ -4026,7 +4026,7 @@ dependencies = [ [[package]] name = "frame-remote-externalities" version = "0.35.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "futures", "indicatif", @@ -4048,7 +4048,7 @@ dependencies = [ [[package]] name = "frame-support" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "aquamarine 0.5.0", "array-bytes 6.2.2", @@ -4089,7 +4089,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "23.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "Inflector", "cfg-expr", @@ -4108,7 +4108,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "10.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate 3.1.0", @@ -4120,7 +4120,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "11.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "proc-macro2", "quote", @@ -4130,7 +4130,7 @@ dependencies = [ [[package]] name = "frame-system" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "cfg-if", "docify", @@ -4150,7 +4150,7 @@ dependencies = [ [[package]] name = "frame-system-benchmarking" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-benchmarking", "frame-support", @@ -4165,7 +4165,7 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "26.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "parity-scale-codec", "sp-api", @@ -4174,7 +4174,7 @@ dependencies = [ [[package]] name = "frame-try-runtime" version = "0.34.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-support", "parity-scale-codec", @@ -6598,7 +6598,7 @@ dependencies = [ [[package]] name = "mmr-gadget" version = "29.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "futures", "log", @@ -6617,7 +6617,7 @@ dependencies = [ [[package]] name = "mmr-rpc" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -7516,7 +7516,7 @@ dependencies = [ [[package]] name = "pallet-asset-conversion" version = "10.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-benchmarking", "frame-support", @@ -7535,7 +7535,7 @@ dependencies = [ [[package]] name = "pallet-asset-rate" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-benchmarking", "frame-support", @@ -7578,7 +7578,7 @@ dependencies = [ [[package]] name = "pallet-asset-tx-payment" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-benchmarking", "frame-support", @@ -7596,7 +7596,7 @@ dependencies = [ [[package]] name = "pallet-assets" version = "29.1.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-benchmarking", "frame-support", @@ -7612,7 +7612,7 @@ dependencies = [ [[package]] name = "pallet-aura" version = "27.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-support", "frame-system", @@ -7629,7 +7629,7 @@ dependencies = [ [[package]] name = "pallet-authority-discovery" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-support", "frame-system", @@ -7645,7 +7645,7 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-support", "frame-system", @@ -7659,7 +7659,7 @@ dependencies = [ [[package]] name = "pallet-babe" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-benchmarking", "frame-support", @@ -7683,7 +7683,7 @@ dependencies = [ [[package]] name = "pallet-bags-list" version = "27.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "aquamarine 0.5.0", "docify", @@ -7705,7 +7705,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "docify", "frame-benchmarking", @@ -7721,7 +7721,7 @@ dependencies = [ [[package]] name = "pallet-beefy" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-support", "frame-system", @@ -7741,7 +7741,7 @@ dependencies = [ [[package]] name = "pallet-beefy-mmr" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "array-bytes 6.2.2", "binary-merkle-tree", @@ -7790,7 +7790,7 @@ dependencies = [ [[package]] name = "pallet-bounties" version = "27.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-benchmarking", "frame-support", @@ -7808,7 +7808,7 @@ dependencies = [ [[package]] name = "pallet-broker" version = "0.6.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "bitvec", "frame-benchmarking", @@ -7827,7 +7827,7 @@ dependencies = [ [[package]] name = "pallet-child-bounties" version = "27.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-benchmarking", "frame-support", @@ -7918,7 +7918,7 @@ dependencies = [ [[package]] name = "pallet-collator-selection" version = "9.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-benchmarking", "frame-support", @@ -7938,7 +7938,7 @@ dependencies = [ [[package]] name = "pallet-collective" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-benchmarking", "frame-support", @@ -7955,7 +7955,7 @@ dependencies = [ [[package]] name = "pallet-conviction-voting" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "assert_matches", "frame-benchmarking", @@ -8063,7 +8063,7 @@ dependencies = [ [[package]] name = "pallet-democracy" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-benchmarking", "frame-support", @@ -8151,7 +8151,7 @@ dependencies = [ [[package]] name = "pallet-election-provider-multi-phase" version = "27.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -8174,7 +8174,7 @@ dependencies = [ [[package]] name = "pallet-election-provider-support-benchmarking" version = "27.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -8188,7 +8188,7 @@ dependencies = [ [[package]] name = "pallet-elections-phragmen" version = "29.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-benchmarking", "frame-support", @@ -8395,7 +8395,7 @@ dependencies = [ [[package]] name = "pallet-fast-unstake" version = "27.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "docify", "frame-benchmarking", @@ -8432,7 +8432,7 @@ dependencies = [ [[package]] name = "pallet-grandpa" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-benchmarking", "frame-support", @@ -8455,7 +8455,7 @@ dependencies = [ [[package]] name = "pallet-identity" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "enumflags2", "frame-benchmarking", @@ -8472,7 +8472,7 @@ dependencies = [ [[package]] name = "pallet-im-online" version = "27.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-benchmarking", "frame-support", @@ -8492,7 +8492,7 @@ dependencies = [ [[package]] name = "pallet-indices" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-benchmarking", "frame-support", @@ -8561,7 +8561,7 @@ dependencies = [ [[package]] name = "pallet-membership" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-benchmarking", "frame-support", @@ -8578,7 +8578,7 @@ dependencies = [ [[package]] name = "pallet-message-queue" version = "31.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "environmental", "frame-benchmarking", @@ -8598,7 +8598,7 @@ dependencies = [ [[package]] name = "pallet-mmr" version = "27.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-benchmarking", "frame-support", @@ -8616,7 +8616,7 @@ dependencies = [ [[package]] name = "pallet-multisig" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-benchmarking", "frame-support", @@ -8652,7 +8652,7 @@ dependencies = [ [[package]] name = "pallet-nis" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-benchmarking", "frame-support", @@ -8668,7 +8668,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools" version = "25.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-support", "frame-system", @@ -8687,7 +8687,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools-benchmarking" version = "26.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -8707,7 +8707,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools-runtime-api" version = "23.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "pallet-nomination-pools", "parity-scale-codec", @@ -8718,7 +8718,7 @@ dependencies = [ [[package]] name = "pallet-offences" version = "27.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-support", "frame-system", @@ -8735,7 +8735,7 @@ dependencies = [ [[package]] name = "pallet-offences-benchmarking" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -8872,7 +8872,7 @@ dependencies = [ [[package]] name = "pallet-parameters" version = "0.1.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "docify", "frame-benchmarking", @@ -8890,7 +8890,7 @@ dependencies = [ [[package]] name = "pallet-preimage" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-benchmarking", "frame-support", @@ -8907,7 +8907,7 @@ dependencies = [ [[package]] name = "pallet-proxy" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-benchmarking", "frame-support", @@ -8922,7 +8922,7 @@ dependencies = [ [[package]] name = "pallet-ranked-collective" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-benchmarking", "frame-support", @@ -8941,7 +8941,7 @@ dependencies = [ [[package]] name = "pallet-recovery" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-benchmarking", "frame-support", @@ -8956,7 +8956,7 @@ dependencies = [ [[package]] name = "pallet-referenda" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "assert_matches", "frame-benchmarking", @@ -9011,7 +9011,7 @@ dependencies = [ [[package]] name = "pallet-root-testing" version = "4.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-support", "frame-system", @@ -9053,7 +9053,7 @@ dependencies = [ [[package]] name = "pallet-scheduler" version = "29.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "docify", "frame-benchmarking", @@ -9071,7 +9071,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-support", "frame-system", @@ -9093,7 +9093,7 @@ dependencies = [ [[package]] name = "pallet-session-benchmarking" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-benchmarking", "frame-support", @@ -9110,7 +9110,7 @@ dependencies = [ [[package]] name = "pallet-society" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-benchmarking", "frame-support", @@ -9179,7 +9179,7 @@ dependencies = [ [[package]] name = "pallet-staking" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -9202,7 +9202,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-curve" version = "11.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", @@ -9213,7 +9213,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-fn" version = "19.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "log", "sp-arithmetic", @@ -9222,7 +9222,7 @@ dependencies = [ [[package]] name = "pallet-staking-runtime-api" version = "14.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "parity-scale-codec", "sp-api", @@ -9232,7 +9232,7 @@ dependencies = [ [[package]] name = "pallet-state-trie-migration" version = "29.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-benchmarking", "frame-support", @@ -9249,7 +9249,7 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "docify", "frame-benchmarking", @@ -9265,7 +9265,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "27.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "docify", "frame-benchmarking", @@ -9285,7 +9285,7 @@ dependencies = [ [[package]] name = "pallet-tips" version = "27.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-benchmarking", "frame-support", @@ -9353,7 +9353,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-support", "frame-system", @@ -9369,7 +9369,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "30.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "jsonrpsee", "pallet-transaction-payment-rpc-runtime-api", @@ -9385,7 +9385,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "pallet-transaction-payment", "parity-scale-codec", @@ -9397,7 +9397,7 @@ dependencies = [ [[package]] name = "pallet-treasury" version = "27.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "docify", "frame-benchmarking", @@ -9416,7 +9416,7 @@ dependencies = [ [[package]] name = "pallet-uniques" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-benchmarking", "frame-support", @@ -9431,7 +9431,7 @@ dependencies = [ [[package]] name = "pallet-utility" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-benchmarking", "frame-support", @@ -9447,7 +9447,7 @@ dependencies = [ [[package]] name = "pallet-vesting" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-benchmarking", "frame-support", @@ -9462,7 +9462,7 @@ dependencies = [ [[package]] name = "pallet-whitelist" version = "27.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-benchmarking", "frame-support", @@ -9477,7 +9477,7 @@ dependencies = [ [[package]] name = "pallet-xcm" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "bounded-collections", "frame-benchmarking", @@ -9501,7 +9501,7 @@ dependencies = [ [[package]] name = "pallet-xcm-benchmarks" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-benchmarking", "frame-support", @@ -9572,7 +9572,7 @@ dependencies = [ [[package]] name = "parachains-common" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "cumulus-primitives-core", "cumulus-primitives-utility", @@ -9944,7 +9944,7 @@ dependencies = [ [[package]] name = "polkadot-approval-distribution" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "bitvec", "futures", @@ -9964,7 +9964,7 @@ dependencies = [ [[package]] name = "polkadot-availability-bitfield-distribution" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "always-assert", "futures", @@ -9980,7 +9980,7 @@ dependencies = [ [[package]] name = "polkadot-availability-distribution" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "derive_more", "fatality", @@ -10003,7 +10003,7 @@ dependencies = [ [[package]] name = "polkadot-availability-recovery" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "async-trait", "fatality", @@ -10026,7 +10026,7 @@ dependencies = [ [[package]] name = "polkadot-cli" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "cfg-if", "clap 4.5.4", @@ -10054,7 +10054,7 @@ dependencies = [ [[package]] name = "polkadot-collator-protocol" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "bitvec", "fatality", @@ -10076,7 +10076,7 @@ dependencies = [ [[package]] name = "polkadot-core-primitives" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "parity-scale-codec", "scale-info", @@ -10088,7 +10088,7 @@ dependencies = [ [[package]] name = "polkadot-dispute-distribution" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "derive_more", "fatality", @@ -10113,7 +10113,7 @@ dependencies = [ [[package]] name = "polkadot-erasure-coding" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "parity-scale-codec", "polkadot-node-primitives", @@ -10127,7 +10127,7 @@ dependencies = [ [[package]] name = "polkadot-gossip-support" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "futures", "futures-timer", @@ -10149,7 +10149,7 @@ dependencies = [ [[package]] name = "polkadot-network-bridge" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "always-assert", "async-trait", @@ -10172,7 +10172,7 @@ dependencies = [ [[package]] name = "polkadot-node-collation-generation" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "futures", "parity-scale-codec", @@ -10190,7 +10190,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-approval-voting" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "bitvec", "derive_more", @@ -10223,7 +10223,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-av-store" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "bitvec", "futures", @@ -10245,7 +10245,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-backing" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "bitvec", "fatality", @@ -10265,7 +10265,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-bitfield-signing" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "futures", "polkadot-node-subsystem", @@ -10280,7 +10280,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-candidate-validation" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "async-trait", "futures", @@ -10301,7 +10301,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-chain-api" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "futures", "polkadot-node-metrics", @@ -10315,7 +10315,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-chain-selection" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "futures", "futures-timer", @@ -10332,7 +10332,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-dispute-coordinator" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "fatality", "futures", @@ -10351,7 +10351,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-parachains-inherent" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "async-trait", "futures", @@ -10368,7 +10368,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-prospective-parachains" version = "6.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "bitvec", "fatality", @@ -10385,7 +10385,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-provisioner" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "bitvec", "fatality", @@ -10403,7 +10403,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-pvf" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "always-assert", "array-bytes 6.2.2", @@ -10432,7 +10432,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-pvf-checker" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "futures", "polkadot-node-primitives", @@ -10448,7 +10448,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-pvf-common" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "cpu-time", "futures", @@ -10474,7 +10474,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-runtime-api" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "futures", "polkadot-node-metrics", @@ -10489,7 +10489,7 @@ dependencies = [ [[package]] name = "polkadot-node-jaeger" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "lazy_static", "log", @@ -10508,7 +10508,7 @@ dependencies = [ [[package]] name = "polkadot-node-metrics" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "bs58 0.5.0", "futures", @@ -10527,7 +10527,7 @@ dependencies = [ [[package]] name = "polkadot-node-network-protocol" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "async-channel 1.9.0", "async-trait", @@ -10553,7 +10553,7 @@ dependencies = [ [[package]] name = "polkadot-node-primitives" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "bitvec", "bounded-vec", @@ -10576,7 +10576,7 @@ dependencies = [ [[package]] name = "polkadot-node-subsystem" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "polkadot-node-jaeger", "polkadot-node-subsystem-types", @@ -10586,7 +10586,7 @@ dependencies = [ [[package]] name = "polkadot-node-subsystem-types" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "async-trait", "bitvec", @@ -10615,7 +10615,7 @@ dependencies = [ [[package]] name = "polkadot-node-subsystem-util" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "async-trait", "derive_more", @@ -10650,7 +10650,7 @@ dependencies = [ [[package]] name = "polkadot-overseer" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "async-trait", "futures", @@ -10672,7 +10672,7 @@ dependencies = [ [[package]] name = "polkadot-parachain-primitives" version = "6.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "bounded-collections", "derive_more", @@ -10689,7 +10689,7 @@ dependencies = [ [[package]] name = "polkadot-primitives" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "bitvec", "hex-literal", @@ -10716,7 +10716,7 @@ dependencies = [ [[package]] name = "polkadot-rpc" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "jsonrpsee", "mmr-rpc", @@ -10749,7 +10749,7 @@ dependencies = [ [[package]] name = "polkadot-runtime-common" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "bitvec", "frame-benchmarking", @@ -10800,7 +10800,7 @@ dependencies = [ [[package]] name = "polkadot-runtime-metrics" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "bs58 0.5.0", "frame-benchmarking", @@ -10813,7 +10813,7 @@ dependencies = [ [[package]] name = "polkadot-runtime-parachains" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "bitflags 1.3.2", "bitvec", @@ -10862,7 +10862,7 @@ dependencies = [ [[package]] name = "polkadot-service" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "async-trait", "frame-benchmarking", @@ -10980,7 +10980,7 @@ dependencies = [ [[package]] name = "polkadot-statement-distribution" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "arrayvec 0.7.4", "bitvec", @@ -11003,7 +11003,7 @@ dependencies = [ [[package]] name = "polkadot-statement-table" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "parity-scale-codec", "polkadot-primitives", @@ -12059,7 +12059,7 @@ dependencies = [ [[package]] name = "rococo-runtime" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "binary-merkle-tree", "bitvec", @@ -12160,7 +12160,7 @@ dependencies = [ [[package]] name = "rococo-runtime-constants" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-support", "polkadot-primitives", @@ -12628,7 +12628,7 @@ dependencies = [ [[package]] name = "sc-allocator" version = "23.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "log", "sp-core", @@ -12639,7 +12639,7 @@ dependencies = [ [[package]] name = "sc-authority-discovery" version = "0.34.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "async-trait", "futures", @@ -12670,7 +12670,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.34.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "futures", "futures-timer", @@ -12692,7 +12692,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.33.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "parity-scale-codec", "sp-api", @@ -12707,7 +12707,7 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "array-bytes 6.2.2", "docify", @@ -12734,7 +12734,7 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "11.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", @@ -12745,7 +12745,7 @@ dependencies = [ [[package]] name = "sc-cli" version = "0.36.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "array-bytes 6.2.2", "chrono", @@ -12786,7 +12786,7 @@ dependencies = [ [[package]] name = "sc-client-api" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "fnv", "futures", @@ -12813,7 +12813,7 @@ dependencies = [ [[package]] name = "sc-client-db" version = "0.35.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "hash-db", "kvdb", @@ -12839,7 +12839,7 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.33.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "async-trait", "futures", @@ -12864,7 +12864,7 @@ dependencies = [ [[package]] name = "sc-consensus-aura" version = "0.34.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "async-trait", "futures", @@ -12893,7 +12893,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe" version = "0.34.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "async-trait", "fork-tree", @@ -12929,7 +12929,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe-rpc" version = "0.34.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "futures", "jsonrpsee", @@ -12951,7 +12951,7 @@ dependencies = [ [[package]] name = "sc-consensus-beefy" version = "13.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "array-bytes 6.2.2", "async-channel 1.9.0", @@ -12988,7 +12988,7 @@ dependencies = [ [[package]] name = "sc-consensus-beefy-rpc" version = "13.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "futures", "jsonrpsee", @@ -13007,7 +13007,7 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" version = "0.33.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "fork-tree", "parity-scale-codec", @@ -13020,7 +13020,7 @@ dependencies = [ [[package]] name = "sc-consensus-grandpa" version = "0.19.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "ahash 0.8.6", "array-bytes 6.2.2", @@ -13064,7 +13064,7 @@ dependencies = [ [[package]] name = "sc-consensus-grandpa-rpc" version = "0.19.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "finality-grandpa", "futures", @@ -13084,7 +13084,7 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.33.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "async-trait", "futures", @@ -13107,7 +13107,7 @@ dependencies = [ [[package]] name = "sc-executor" version = "0.32.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "parity-scale-codec", "parking_lot 0.12.3", @@ -13130,7 +13130,7 @@ dependencies = [ [[package]] name = "sc-executor-common" version = "0.29.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "polkavm", "sc-allocator", @@ -13143,7 +13143,7 @@ dependencies = [ [[package]] name = "sc-executor-polkavm" version = "0.29.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "log", "polkavm", @@ -13154,7 +13154,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmtime" version = "0.29.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "anyhow", "cfg-if", @@ -13172,7 +13172,7 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.33.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "ansi_term", "futures", @@ -13189,7 +13189,7 @@ dependencies = [ [[package]] name = "sc-keystore" version = "25.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "array-bytes 6.2.2", "parking_lot 0.12.3", @@ -13203,7 +13203,7 @@ dependencies = [ [[package]] name = "sc-mixnet" version = "0.4.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "array-bytes 4.2.0", "arrayvec 0.7.4", @@ -13232,7 +13232,7 @@ dependencies = [ [[package]] name = "sc-network" version = "0.34.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "array-bytes 6.2.2", "async-channel 1.9.0", @@ -13283,7 +13283,7 @@ dependencies = [ [[package]] name = "sc-network-common" version = "0.33.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "async-trait", "bitflags 1.3.2", @@ -13301,7 +13301,7 @@ dependencies = [ [[package]] name = "sc-network-gossip" version = "0.34.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "ahash 0.8.6", "futures", @@ -13321,7 +13321,7 @@ dependencies = [ [[package]] name = "sc-network-light" version = "0.33.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "array-bytes 6.2.2", "async-channel 1.9.0", @@ -13342,7 +13342,7 @@ dependencies = [ [[package]] name = "sc-network-sync" version = "0.33.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "array-bytes 6.2.2", "async-channel 1.9.0", @@ -13379,7 +13379,7 @@ dependencies = [ [[package]] name = "sc-network-transactions" version = "0.33.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "array-bytes 6.2.2", "futures", @@ -13399,7 +13399,7 @@ dependencies = [ [[package]] name = "sc-network-types" version = "0.10.0-dev" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "bs58 0.4.0", "libp2p-identity", @@ -13413,7 +13413,7 @@ dependencies = [ [[package]] name = "sc-offchain" version = "29.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "array-bytes 6.2.2", "bytes", @@ -13448,7 +13448,7 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.17.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -13457,7 +13457,7 @@ dependencies = [ [[package]] name = "sc-rpc" version = "29.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "futures", "jsonrpsee", @@ -13489,7 +13489,7 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.33.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -13509,7 +13509,7 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "11.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "futures", "governor", @@ -13527,7 +13527,7 @@ dependencies = [ [[package]] name = "sc-rpc-spec-v2" version = "0.34.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "array-bytes 6.2.2", "futures", @@ -13559,7 +13559,7 @@ dependencies = [ [[package]] name = "sc-service" version = "0.35.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "async-trait", "directories", @@ -13623,7 +13623,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.30.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "log", "parity-scale-codec", @@ -13634,7 +13634,7 @@ dependencies = [ [[package]] name = "sc-storage-monitor" version = "0.16.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "clap 4.5.4", "fs4", @@ -13647,7 +13647,7 @@ dependencies = [ [[package]] name = "sc-sync-state-rpc" version = "0.34.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -13666,7 +13666,7 @@ dependencies = [ [[package]] name = "sc-sysinfo" version = "27.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "derive_more", "futures", @@ -13687,7 +13687,7 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "15.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "chrono", "futures", @@ -13707,7 +13707,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "ansi_term", "chrono", @@ -13737,7 +13737,7 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "11.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", @@ -13748,7 +13748,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "async-trait", "futures", @@ -13775,7 +13775,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool-api" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "async-trait", "futures", @@ -13791,7 +13791,7 @@ dependencies = [ [[package]] name = "sc-utils" version = "14.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "async-channel 1.9.0", "futures", @@ -14330,7 +14330,7 @@ dependencies = [ [[package]] name = "slot-range-helper" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "enumn", "parity-scale-codec", @@ -14524,7 +14524,7 @@ dependencies = [ [[package]] name = "sp-api" version = "26.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "hash-db", "log", @@ -14546,7 +14546,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "15.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "Inflector", "blake2 0.10.6", @@ -14560,7 +14560,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "30.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "parity-scale-codec", "scale-info", @@ -14573,7 +14573,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "23.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "docify", "integer-sqrt", @@ -14606,7 +14606,7 @@ dependencies = [ [[package]] name = "sp-authority-discovery" version = "26.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "parity-scale-codec", "scale-info", @@ -14618,7 +14618,7 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "26.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "sp-api", "sp-inherents", @@ -14628,7 +14628,7 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "futures", "log", @@ -14646,7 +14646,7 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.32.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "async-trait", "futures", @@ -14661,7 +14661,7 @@ dependencies = [ [[package]] name = "sp-consensus-aura" version = "0.32.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "async-trait", "parity-scale-codec", @@ -14677,7 +14677,7 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.32.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "async-trait", "parity-scale-codec", @@ -14695,7 +14695,7 @@ dependencies = [ [[package]] name = "sp-consensus-beefy" version = "13.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "lazy_static", "parity-scale-codec", @@ -14715,7 +14715,7 @@ dependencies = [ [[package]] name = "sp-consensus-grandpa" version = "13.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "finality-grandpa", "log", @@ -14732,7 +14732,7 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.32.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "parity-scale-codec", "scale-info", @@ -14743,7 +14743,7 @@ dependencies = [ [[package]] name = "sp-core" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "array-bytes 6.2.2", "bandersnatch_vrfs", @@ -14810,7 +14810,7 @@ dependencies = [ [[package]] name = "sp-crypto-hashing" version = "0.1.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "blake2b_simd", "byteorder", @@ -14823,7 +14823,7 @@ dependencies = [ [[package]] name = "sp-crypto-hashing-proc-macro" version = "0.1.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "quote", "sp-crypto-hashing", @@ -14833,7 +14833,7 @@ dependencies = [ [[package]] name = "sp-database" version = "10.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "kvdb", "parking_lot 0.12.3", @@ -14842,7 +14842,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "14.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "proc-macro2", "quote", @@ -14852,7 +14852,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.25.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "environmental", "parity-scale-codec", @@ -14862,7 +14862,7 @@ dependencies = [ [[package]] name = "sp-genesis-builder" version = "0.8.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "parity-scale-codec", "scale-info", @@ -14874,7 +14874,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "26.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -14887,7 +14887,7 @@ dependencies = [ [[package]] name = "sp-io" version = "30.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "bytes", "ed25519-dalek 2.1.0", @@ -14913,7 +14913,7 @@ dependencies = [ [[package]] name = "sp-keyring" version = "31.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "sp-core", "sp-runtime", @@ -14923,7 +14923,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.34.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "parity-scale-codec", "parking_lot 0.12.3", @@ -14934,7 +14934,7 @@ dependencies = [ [[package]] name = "sp-maybe-compressed-blob" version = "11.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "thiserror", "zstd 0.12.4", @@ -14943,7 +14943,7 @@ dependencies = [ [[package]] name = "sp-metadata-ir" version = "0.6.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-metadata", "parity-scale-codec", @@ -14953,7 +14953,7 @@ dependencies = [ [[package]] name = "sp-mixnet" version = "0.4.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "parity-scale-codec", "scale-info", @@ -14964,7 +14964,7 @@ dependencies = [ [[package]] name = "sp-mmr-primitives" version = "26.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "ckb-merkle-mountain-range", "log", @@ -14981,7 +14981,7 @@ dependencies = [ [[package]] name = "sp-npos-elections" version = "26.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "parity-scale-codec", "scale-info", @@ -14994,7 +14994,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "26.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "sp-api", "sp-core", @@ -15004,7 +15004,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "13.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "backtrace", "lazy_static", @@ -15014,7 +15014,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "26.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "rustc-hash", "serde", @@ -15024,7 +15024,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "31.0.1" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "docify", "either", @@ -15048,7 +15048,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "24.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -15067,7 +15067,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "17.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "Inflector", "expander 2.0.0", @@ -15080,7 +15080,7 @@ dependencies = [ [[package]] name = "sp-session" version = "27.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "parity-scale-codec", "scale-info", @@ -15094,7 +15094,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "26.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -15107,7 +15107,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.35.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "hash-db", "log", @@ -15127,7 +15127,7 @@ dependencies = [ [[package]] name = "sp-statement-store" version = "10.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "aes-gcm", "curve25519-dalek 4.1.1", @@ -15151,12 +15151,12 @@ dependencies = [ [[package]] name = "sp-std" version = "14.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" [[package]] name = "sp-storage" version = "19.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "impl-serde", "parity-scale-codec", @@ -15168,7 +15168,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "26.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "async-trait", "parity-scale-codec", @@ -15180,7 +15180,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "16.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "parity-scale-codec", "tracing", @@ -15191,7 +15191,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "26.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "sp-api", "sp-runtime", @@ -15200,7 +15200,7 @@ dependencies = [ [[package]] name = "sp-transaction-storage-proof" version = "26.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "async-trait", "parity-scale-codec", @@ -15214,7 +15214,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "29.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "ahash 0.8.6", "hash-db", @@ -15237,7 +15237,7 @@ dependencies = [ [[package]] name = "sp-version" version = "29.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "impl-serde", "parity-scale-codec", @@ -15254,7 +15254,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "13.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -15265,7 +15265,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "20.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "anyhow", "impl-trait-for-tuples", @@ -15277,7 +15277,7 @@ dependencies = [ [[package]] name = "sp-weights" version = "27.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "bounded-collections", "parity-scale-codec", @@ -15354,7 +15354,7 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "staging-parachain-info" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "cumulus-primitives-core", "frame-support", @@ -15368,7 +15368,7 @@ dependencies = [ [[package]] name = "staging-xcm" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "array-bytes 6.2.2", "bounded-collections", @@ -15386,7 +15386,7 @@ dependencies = [ [[package]] name = "staging-xcm-builder" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-support", "frame-system", @@ -15408,7 +15408,7 @@ dependencies = [ [[package]] name = "staging-xcm-executor" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "environmental", "frame-benchmarking", @@ -15565,7 +15565,7 @@ dependencies = [ [[package]] name = "substrate-bip39" version = "0.4.7" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "hmac 0.12.1", "pbkdf2", @@ -15590,12 +15590,12 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "11.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" [[package]] name = "substrate-frame-rpc-system" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-system-rpc-runtime-api", "futures", @@ -15614,7 +15614,7 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.17.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "hyper", "log", @@ -15626,7 +15626,7 @@ dependencies = [ [[package]] name = "substrate-rpc-client" version = "0.33.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "async-trait", "jsonrpsee", @@ -15639,7 +15639,7 @@ dependencies = [ [[package]] name = "substrate-state-trie-migration-rpc" version = "27.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -15656,7 +15656,7 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" version = "17.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "array-bytes 6.2.2", "build-helper", @@ -16286,7 +16286,7 @@ dependencies = [ [[package]] name = "tracing-gum" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "coarsetime", "polkadot-primitives", @@ -16297,7 +16297,7 @@ dependencies = [ [[package]] name = "tracing-gum-proc-macro" version = "5.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "expander 2.0.0", "proc-macro-crate 3.1.0", @@ -17160,7 +17160,7 @@ dependencies = [ [[package]] name = "westend-runtime" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "binary-merkle-tree", "bitvec", @@ -17267,7 +17267,7 @@ dependencies = [ [[package]] name = "westend-runtime-constants" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-support", "polkadot-primitives", @@ -17669,7 +17669,7 @@ dependencies = [ [[package]] name = "xcm-emulator" version = "0.5.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "cumulus-pallet-parachain-system", "cumulus-pallet-xcmp-queue", @@ -17703,7 +17703,7 @@ dependencies = [ [[package]] name = "xcm-fee-payment-runtime-api" version = "0.1.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "frame-support", "parity-scale-codec", @@ -17718,7 +17718,7 @@ dependencies = [ [[package]] name = "xcm-procedural" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch2#77fcc2b7dbe98a1c589ff699e1c3c37bf2d516bd" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utils-hooks#96a04d6f1cb476d4187680055cdc71168fab7a42" dependencies = [ "Inflector", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 8f9e32fba..bfdae842e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -157,108 +157,108 @@ pallet-evm-precompile-call-permit = { path = "precompiles/call-permit", default- precompile-utils = { path = "precompiles/utils", default-features = false } # Frame -frame-benchmarking = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -frame-benchmarking-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -frame-executive = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -frame-remote-externalities = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -frame-support = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false, features = ["tuples-96"] } -frame-system = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -frame-system-benchmarking = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -frame-system-rpc-runtime-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -frame-try-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -frame-metadata-hash-extension = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sp-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sp-arithmetic = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sp-authority-discovery = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sp-block-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sp-genesis-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sp-blockchain = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sp-consensus = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sp-consensus-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sp-consensus-babe = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sp-consensus-beefy = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-core = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sp-externalities = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sp-inherents = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sp-io = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sp-keystore = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sp-npos-elections = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sp-offchain = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sc-offchain = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sp-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sp-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sp-runtime-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sp-runtime-interface-proc-macro = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sp-session = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sp-staking = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sp-std = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sp-storage = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sp-state-machine = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sp-timestamp = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sp-tracing = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sp-transaction-pool = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sp-trie = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sp-version = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sp-weights = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sp-crypto-hashing = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sp-crypto-ec-utils = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sp-wasm-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } - - -sc-basic-authorship = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sc-chain-spec = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sc-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sc-client-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sc-client-db = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sc-consensus = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sc-consensus-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sc-consensus-grandpa = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sc-executor = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sc-keystore = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sc-network = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sc-network-sync = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sc-network-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sc-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sc-rpc-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sc-service = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sc-telemetry = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sc-tracing = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sc-transaction-pool = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sc-transaction-pool-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -sc-sysinfo = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } +frame-benchmarking = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +frame-benchmarking-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +frame-executive = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +frame-remote-externalities = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +frame-support = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false, features = ["tuples-96"] } +frame-system = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +frame-system-benchmarking = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +frame-system-rpc-runtime-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +frame-try-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +frame-metadata-hash-extension = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sp-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sp-arithmetic = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sp-authority-discovery = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sp-block-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sp-genesis-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sp-blockchain = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sp-consensus = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sp-consensus-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sp-consensus-babe = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sp-consensus-beefy = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-core = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sp-externalities = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sp-inherents = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sp-io = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sp-keystore = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sp-npos-elections = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sp-offchain = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sc-offchain = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sp-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sp-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sp-runtime-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sp-runtime-interface-proc-macro = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sp-session = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sp-staking = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sp-std = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sp-storage = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sp-state-machine = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sp-timestamp = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sp-tracing = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sp-transaction-pool = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sp-trie = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sp-version = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sp-weights = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sp-crypto-hashing = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sp-crypto-ec-utils = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sp-wasm-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } + + +sc-basic-authorship = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sc-chain-spec = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sc-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sc-client-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sc-client-db = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sc-consensus = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sc-consensus-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sc-consensus-grandpa = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sc-executor = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sc-keystore = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sc-network = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sc-network-sync = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sc-network-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sc-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sc-rpc-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sc-service = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sc-telemetry = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sc-tracing = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sc-transaction-pool = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sc-transaction-pool-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +sc-sysinfo = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } # Substrate Pallets -pallet-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -pallet-authorship = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -pallet-balances = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -pallet-bags-list = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -pallet-collective = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -pallet-elections-phragmen = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -pallet-identity = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -pallet-multisig = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -pallet-preimage = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -pallet-proxy = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -pallet-scheduler = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -pallet-session = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -pallet-sudo = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -pallet-timestamp = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -pallet-tips = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -pallet-transaction-payment = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -pallet-transaction-payment-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -pallet-treasury = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -pallet-uniques = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -pallet-utility = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -pallet-im-online = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -pallet-message-queue = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -pallet-state-trie-migration = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } - -substrate-build-script-utils = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -substrate-frame-rpc-system = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -substrate-prometheus-endpoint = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -substrate-rpc-client = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -substrate-wasm-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -substrate-state-trie-migration-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } +pallet-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +pallet-authorship = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +pallet-balances = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +pallet-bags-list = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +pallet-collective = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +pallet-elections-phragmen = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +pallet-identity = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +pallet-multisig = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +pallet-preimage = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +pallet-proxy = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +pallet-scheduler = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +pallet-session = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +pallet-sudo = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +pallet-timestamp = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +pallet-tips = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +pallet-transaction-payment = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +pallet-transaction-payment-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +pallet-treasury = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +pallet-uniques = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +pallet-utility = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +pallet-im-online = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +pallet-message-queue = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +pallet-state-trie-migration = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } + +substrate-build-script-utils = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +substrate-frame-rpc-system = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +substrate-prometheus-endpoint = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +substrate-rpc-client = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +substrate-wasm-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +substrate-state-trie-migration-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } #TODO: We use our custom ORML as it contains the fix of bug for reducible_balance check, for Preserve mode. Once the official ORML pushes a new version with the fix, we can use that again # ORML dependencies @@ -276,30 +276,30 @@ orml-xcm-support = { git = "https://github.com/galacticcouncil/open-runtime-modu orml-xtokens = { git = "https://github.com/galacticcouncil/open-runtime-module-library", branch = "polkadot-v1.11.0", default-features = false } # Cumulus dependencies -cumulus-client-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -cumulus-client-collator = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -cumulus-client-consensus-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -cumulus-client-consensus-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -cumulus-client-consensus-proposer = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -cumulus-client-network = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -cumulus-client-service = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -cumulus-pallet-aura-ext = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -cumulus-pallet-parachain-system = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -cumulus-pallet-xcm = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -cumulus-pallet-xcmp-queue = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -cumulus-primitives-core = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -cumulus-primitives-parachain-inherent = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -cumulus-primitives-timestamp = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -cumulus-primitives-utility = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -cumulus-relay-chain-inprocess-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -cumulus-relay-chain-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -cumulus-relay-chain-minimal-node = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -cumulus-test-relay-sproof-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -pallet-collator-selection = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -staging-parachain-info = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -xcm-emulator = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -xcm-fee-payment-runtime-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -parachains-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } +cumulus-client-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +cumulus-client-collator = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +cumulus-client-consensus-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +cumulus-client-consensus-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +cumulus-client-consensus-proposer = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +cumulus-client-network = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +cumulus-client-service = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +cumulus-pallet-aura-ext = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +cumulus-pallet-parachain-system = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +cumulus-pallet-xcm = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +cumulus-pallet-xcmp-queue = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +cumulus-primitives-core = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +cumulus-primitives-parachain-inherent = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +cumulus-primitives-timestamp = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +cumulus-primitives-utility = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +cumulus-relay-chain-inprocess-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +cumulus-relay-chain-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +cumulus-relay-chain-minimal-node = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +cumulus-test-relay-sproof-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +pallet-collator-selection = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +staging-parachain-info = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +xcm-emulator = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +xcm-fee-payment-runtime-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +parachains-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } # Frontier fc-consensus = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v1.11.0", default-features = false } @@ -332,35 +332,35 @@ module-evm-utility-macro = { path = "runtime/hydradx/src/evm/evm-utility/macro", ethereum = { version = "0.15.0", default-features = false, features = ["with-codec"] } # Polkadot dependencies -pallet-xcm = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -polkadot-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -polkadot-core-primitives = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -polkadot-parachain = { package = "polkadot-parachain-primitives", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false, features = [ +pallet-xcm = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +polkadot-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +polkadot-core-primitives = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +polkadot-parachain = { package = "polkadot-parachain-primitives", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false, features = [ "wasm-api", ] } -polkadot-primitives = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -polkadot-runtime-parachains = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -polkadot-service = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -polkadot-xcm = { package = "staging-xcm", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -xcm = { package = "staging-xcm", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } - -polkadot-client = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -polkadot-node-core-pvf = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -polkadot-node-network-protocol = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -polkadot-node-primitives = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -polkadot-node-subsystem = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -polkadot-node-subsystem-util = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -polkadot-overseer = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -polkadot-runtime-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2", default-features = false } -polkadot-statement-table = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -rococo-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -westend-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } - -cumulus-client-pov-recovery = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-pallet-parachain-system-proc-macro = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-relay-chain-rpc-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } +polkadot-primitives = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +polkadot-runtime-parachains = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +polkadot-service = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +polkadot-xcm = { package = "staging-xcm", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +xcm = { package = "staging-xcm", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } + +polkadot-client = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +polkadot-node-core-pvf = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +polkadot-node-network-protocol = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +polkadot-node-primitives = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +polkadot-node-subsystem = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +polkadot-node-subsystem-util = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +polkadot-overseer = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +polkadot-runtime-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks", default-features = false } +polkadot-statement-table = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +rococo-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +westend-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } + +cumulus-client-pov-recovery = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-pallet-parachain-system-proc-macro = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-relay-chain-rpc-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } [patch."https://github.com/moonbeam-foundation/open-runtime-module-library"] @@ -376,312 +376,312 @@ orml-xcm-support = { git = "https://github.com/galacticcouncil/open-runtime-modu orml-xtokens = { git = "https://github.com/galacticcouncil/open-runtime-module-library", branch = "polkadot-v1.11.0" } [patch."https://github.com/moonbeam-foundation/polkadot-sdk"] -frame-benchmarking = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -frame-benchmarking-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -frame-executive = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -frame-remote-externalities = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -frame-support = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -frame-system = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -frame-system-benchmarking = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -frame-system-rpc-runtime-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -frame-try-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -frame-metadata-hash-extension = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-arithmetic = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-authority-discovery = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-block-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-genesis-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-blockchain = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-consensus = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-consensus-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-consensus-babe = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-core = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-externalities = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-inherents = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-io = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-keystore = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-npos-elections = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-offchain = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-offchain = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-runtime-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-runtime-interface-proc-macro = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-wasm-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-panic-handler = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-database = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-session = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-staking = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-std = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-storage = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-timestamp = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-tracing = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-transaction-pool = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-trie = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-version = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-basic-authorship = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-chain-spec = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-client-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-client-db = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-consensus = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-consensus-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-consensus-grandpa = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-executor = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-keystore = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-network = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-network-sync = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-network-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-rpc-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-service = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-telemetry = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-tracing = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-transaction-pool = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-transaction-pool-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-sysinfo = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-utils = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-state-machine = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-weights = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-crypto-hashing = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } +frame-benchmarking = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +frame-benchmarking-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +frame-executive = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +frame-remote-externalities = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +frame-support = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +frame-system = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +frame-system-benchmarking = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +frame-system-rpc-runtime-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +frame-try-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +frame-metadata-hash-extension = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-arithmetic = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-authority-discovery = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-block-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-genesis-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-blockchain = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-consensus = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-consensus-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-consensus-babe = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-core = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-externalities = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-inherents = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-io = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-keystore = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-npos-elections = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-offchain = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-offchain = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-runtime-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-runtime-interface-proc-macro = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-wasm-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-panic-handler = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-database = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-session = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-staking = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-std = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-storage = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-timestamp = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-tracing = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-transaction-pool = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-trie = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-version = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-basic-authorship = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-chain-spec = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-client-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-client-db = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-consensus = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-consensus-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-consensus-grandpa = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-executor = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-keystore = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-network = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-network-sync = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-network-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-rpc-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-service = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-telemetry = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-tracing = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-transaction-pool = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-transaction-pool-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-sysinfo = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-utils = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-state-machine = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-weights = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-crypto-hashing = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } # Substrate Pallets -pallet-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-authorship = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-balances = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-collective = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-elections-phragmen = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-identity = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-multisig = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-preimage = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-proxy = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-scheduler = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-session = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-sudo = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-timestamp = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-tips = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-transaction-payment = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-transaction-payment-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-treasury = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-uniques = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-utility = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-im-online = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-message-queue = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-state-trie-migration = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } - -substrate-build-script-utils = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -substrate-frame-rpc-system = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -substrate-prometheus-endpoint = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -substrate-rpc-client = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -substrate-wasm-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -substrate-state-trie-migration-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } +pallet-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-authorship = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-balances = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-collective = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-elections-phragmen = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-identity = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-multisig = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-preimage = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-proxy = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-scheduler = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-session = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-sudo = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-timestamp = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-tips = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-transaction-payment = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-transaction-payment-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-treasury = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-uniques = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-utility = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-im-online = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-message-queue = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-state-trie-migration = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } + +substrate-build-script-utils = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +substrate-frame-rpc-system = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +substrate-prometheus-endpoint = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +substrate-rpc-client = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +substrate-wasm-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +substrate-state-trie-migration-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } # Cumulus dependencies -cumulus-client-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-client-collator = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-client-consensus-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-client-consensus-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-client-consensus-proposer = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-client-network = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-client-service = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-pallet-aura-ext = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-pallet-parachain-system = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-pallet-xcm = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-pallet-xcmp-queue = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-primitives-core = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-primitives-parachain-inherent = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-primitives-timestamp = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-primitives-utility = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-relay-chain-inprocess-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-relay-chain-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-relay-chain-minimal-node = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-test-relay-sproof-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-collator-selection = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -staging-parachain-info = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -xcm-emulator = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -parachains-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -xcm-fee-payment-runtime-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } +cumulus-client-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-client-collator = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-client-consensus-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-client-consensus-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-client-consensus-proposer = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-client-network = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-client-service = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-pallet-aura-ext = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-pallet-parachain-system = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-pallet-xcm = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-pallet-xcmp-queue = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-primitives-core = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-primitives-parachain-inherent = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-primitives-timestamp = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-primitives-utility = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-relay-chain-inprocess-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-relay-chain-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-relay-chain-minimal-node = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-test-relay-sproof-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-collator-selection = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +staging-parachain-info = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +xcm-emulator = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +parachains-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +xcm-fee-payment-runtime-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } # Polkadot dependencies -pallet-xcm = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -polkadot-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -polkadot-core-primitives = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -polkadot-parachain = { package = "polkadot-parachain-primitives", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -polkadot-primitives = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -polkadot-runtime-parachains = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -polkadot-service = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -xcm = { package = "staging-xcm", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } - -polkadot-node-core-pvf = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -polkadot-node-network-protocol = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -polkadot-node-primitives = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -polkadot-node-subsystem = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -polkadot-node-subsystem-util = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -polkadot-overseer = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -polkadot-runtime-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -polkadot-statement-table = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -rococo-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -westend-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } - -cumulus-client-pov-recovery = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-pallet-parachain-system-proc-macro = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-relay-chain-rpc-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } +pallet-xcm = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +polkadot-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +polkadot-core-primitives = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +polkadot-parachain = { package = "polkadot-parachain-primitives", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +polkadot-primitives = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +polkadot-runtime-parachains = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +polkadot-service = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +xcm = { package = "staging-xcm", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } + +polkadot-node-core-pvf = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +polkadot-node-network-protocol = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +polkadot-node-primitives = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +polkadot-node-subsystem = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +polkadot-node-subsystem-util = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +polkadot-overseer = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +polkadot-runtime-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +polkadot-statement-table = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +rococo-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +westend-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } + +cumulus-client-pov-recovery = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-pallet-parachain-system-proc-macro = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-relay-chain-rpc-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } [patch."https://github.com/paritytech/polkadot-sdk"] -frame-benchmarking = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -frame-benchmarking-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -frame-executive = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -frame-remote-externalities = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -frame-support = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -frame-system = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -frame-system-benchmarking = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -frame-system-rpc-runtime-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -frame-try-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -frame-metadata-hash-extension = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-arithmetic = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-authority-discovery = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-block-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-genesis-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-blockchain = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-consensus = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-consensus-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-consensus-babe = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-core = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-externalities = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-inherents = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-io = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-keystore = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-npos-elections = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-offchain = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-offchain = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-runtime-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-runtime-interface-proc-macro = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-wasm-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-panic-handler = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-database = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-session = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-staking = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-std = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-storage = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-timestamp = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-tracing = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-transaction-pool = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-trie = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-version = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-basic-authorship = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-chain-spec = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-client-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-client-db = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-consensus = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-consensus-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-consensus-grandpa = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-executor = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-keystore = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-network = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-network-sync = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-network-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-rpc-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-service = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-telemetry = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-tracing = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-transaction-pool = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-transaction-pool-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-sysinfo = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sc-utils = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-state-machine = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-weights = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -sp-crypto-hashing = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } +frame-benchmarking = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +frame-benchmarking-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +frame-executive = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +frame-remote-externalities = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +frame-support = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +frame-system = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +frame-system-benchmarking = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +frame-system-rpc-runtime-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +frame-try-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +frame-metadata-hash-extension = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-arithmetic = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-authority-discovery = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-block-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-genesis-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-blockchain = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-consensus = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-consensus-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-consensus-babe = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-core = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-externalities = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-inherents = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-io = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-keystore = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-npos-elections = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-offchain = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-offchain = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-runtime-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-runtime-interface-proc-macro = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-wasm-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-panic-handler = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-database = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-session = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-staking = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-std = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-storage = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-timestamp = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-tracing = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-transaction-pool = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-trie = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-version = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-basic-authorship = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-chain-spec = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-client-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-client-db = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-consensus = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-consensus-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-consensus-grandpa = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-executor = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-keystore = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-network = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-network-sync = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-network-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-rpc-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-service = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-telemetry = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-tracing = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-transaction-pool = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-transaction-pool-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-sysinfo = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sc-utils = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-state-machine = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-weights = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +sp-crypto-hashing = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } # Substrate Pallets -pallet-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-authorship = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-balances = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-collective = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-elections-phragmen = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-identity = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-multisig = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-preimage = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-proxy = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-scheduler = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-session = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-sudo = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-timestamp = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-tips = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-transaction-payment = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-transaction-payment-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-treasury = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-uniques = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-utility = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-im-online = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-message-queue = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-state-trie-migration = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } - -substrate-build-script-utils = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -substrate-frame-rpc-system = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -substrate-prometheus-endpoint = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -substrate-rpc-client = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -substrate-wasm-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -substrate-state-trie-migration-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } +pallet-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-authorship = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-balances = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-collective = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-elections-phragmen = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-identity = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-multisig = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-preimage = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-proxy = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-scheduler = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-session = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-sudo = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-timestamp = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-tips = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-transaction-payment = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-transaction-payment-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-treasury = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-uniques = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-utility = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-im-online = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-message-queue = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-state-trie-migration = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } + +substrate-build-script-utils = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +substrate-frame-rpc-system = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +substrate-prometheus-endpoint = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +substrate-rpc-client = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +substrate-wasm-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +substrate-state-trie-migration-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } # Cumulus dependencies -cumulus-client-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-client-collator = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-client-consensus-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-client-consensus-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-client-consensus-proposer = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-client-network = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-client-service = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-pallet-aura-ext = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-pallet-parachain-system = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-pallet-xcm = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-pallet-xcmp-queue = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-primitives-core = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-primitives-parachain-inherent = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-primitives-timestamp = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-primitives-utility = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-relay-chain-inprocess-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-relay-chain-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-relay-chain-minimal-node = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-test-relay-sproof-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -pallet-collator-selection = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -staging-parachain-info = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -xcm-emulator = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -parachains-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -xcm-fee-payment-runtime-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } +cumulus-client-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-client-collator = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-client-consensus-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-client-consensus-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-client-consensus-proposer = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-client-network = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-client-service = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-pallet-aura-ext = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-pallet-parachain-system = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-pallet-xcm = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-pallet-xcmp-queue = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-primitives-core = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-primitives-parachain-inherent = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-primitives-timestamp = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-primitives-utility = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-relay-chain-inprocess-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-relay-chain-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-relay-chain-minimal-node = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-test-relay-sproof-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +pallet-collator-selection = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +staging-parachain-info = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +xcm-emulator = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +parachains-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +xcm-fee-payment-runtime-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } # Polkadot dependencies -pallet-xcm = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -polkadot-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -polkadot-core-primitives = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -polkadot-parachain = { package = "polkadot-parachain-primitives", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -polkadot-primitives = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -polkadot-runtime-parachains = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -polkadot-service = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -xcm = { package = "staging-xcm", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } - -polkadot-node-core-pvf = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -polkadot-node-network-protocol = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -polkadot-node-primitives = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -polkadot-node-subsystem = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -polkadot-node-subsystem-util = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -polkadot-overseer = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -polkadot-runtime-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -polkadot-statement-table = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -rococo-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -westend-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } - -cumulus-client-pov-recovery = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-pallet-parachain-system-proc-macro = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } -cumulus-relay-chain-rpc-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch2" } +pallet-xcm = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +polkadot-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +polkadot-core-primitives = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +polkadot-parachain = { package = "polkadot-parachain-primitives", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +polkadot-primitives = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +polkadot-runtime-parachains = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +polkadot-service = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +xcm = { package = "staging-xcm", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } + +polkadot-node-core-pvf = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +polkadot-node-network-protocol = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +polkadot-node-primitives = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +polkadot-node-subsystem = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +polkadot-node-subsystem-util = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +polkadot-overseer = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +polkadot-runtime-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +polkadot-statement-table = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +rococo-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +westend-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } + +cumulus-client-pov-recovery = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-pallet-parachain-system-proc-macro = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } +cumulus-relay-chain-rpc-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utils-hooks" } diff --git a/integration-tests/src/dca.rs b/integration-tests/src/dca.rs index 496bd19ac..c3d66d542 100644 --- a/integration-tests/src/dca.rs +++ b/integration-tests/src/dca.rs @@ -4188,20 +4188,6 @@ pub fn get_last_schedule_ids_from_trade_executed_events() -> Vec { schedule_ids } -pub fn get_last_swapped_events() -> Vec { - let last_events: Vec = last_hydra_events(1000); - let mut swapped_events = vec![]; - - for event in last_events { - let e = event.clone(); - if let RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { .. }) = e { - swapped_events.push(e); - } - } - - swapped_events -} - pub fn count_failed_trade_events() -> u32 { count_dca_event!(pallet_dca::Event::TradeFailed { .. }) } diff --git a/integration-tests/src/lib.rs b/integration-tests/src/lib.rs index b6a64ba7c..0d71637e9 100644 --- a/integration-tests/src/lib.rs +++ b/integration-tests/src/lib.rs @@ -29,6 +29,7 @@ mod referrals; mod router; mod staking; mod transact_call_filter; +mod utility; pub mod utils; mod vesting; mod xyk; diff --git a/integration-tests/src/polkadot_test_net.rs b/integration-tests/src/polkadot_test_net.rs index 9dd0a38c4..b35d0a788 100644 --- a/integration-tests/src/polkadot_test_net.rs +++ b/integration-tests/src/polkadot_test_net.rs @@ -15,7 +15,7 @@ use cumulus_primitives_core::ParaId; use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder; pub use frame_system::RawOrigin; use hex_literal::hex; -use hydradx_runtime::{evm::WETH_ASSET_LOCATION, Referrals, RuntimeOrigin}; +use hydradx_runtime::{evm::WETH_ASSET_LOCATION, Referrals, RuntimeEvent, RuntimeOrigin}; pub use hydradx_traits::{ evm::InspectEvmAccounts, registry::Mutate, @@ -897,3 +897,18 @@ pub fn assert_xcm_message_processing_passed() { hydradx_runtime::RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success: true, .. }) ))); } + + +pub fn get_last_swapped_events() -> Vec { + let last_events: Vec = last_hydra_events(1000); + let mut swapped_events = vec![]; + + for event in last_events { + let e = event.clone(); + if let RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { .. }) = e { + swapped_events.push(e); + } + } + + swapped_events +} \ No newline at end of file diff --git a/integration-tests/src/router.rs b/integration-tests/src/router.rs index fdb3c4fc3..ee3541f9d 100644 --- a/integration-tests/src/router.rs +++ b/integration-tests/src/router.rs @@ -5957,7 +5957,7 @@ mod sell_all { } } -fn create_lbp_pool(accumulated_asset: u32, distributed_asset: u32) { +pub fn create_lbp_pool(accumulated_asset: u32, distributed_asset: u32) { assert_ok!(Currencies::update_balance( hydradx_runtime::RuntimeOrigin::root(), DAVE.into(), @@ -6013,7 +6013,7 @@ fn start_lbp_campaign() { set_relaychain_block_number(LBP_SALE_START + 1); } -fn create_xyk_pool(asset_a: u32, asset_b: u32) { +pub fn create_xyk_pool(asset_a: u32, asset_b: u32) { assert_ok!(XYK::create_pool( RuntimeOrigin::signed(ALICE.into()), asset_a, diff --git a/integration-tests/src/utility.rs b/integration-tests/src/utility.rs new file mode 100644 index 000000000..dd0081f30 --- /dev/null +++ b/integration-tests/src/utility.rs @@ -0,0 +1,225 @@ +#![cfg(test)] + +use crate::polkadot_test_net::*; +use frame_support::assert_ok; + +use crate::{assert_balance}; +use hydradx_runtime::LBP; +use hydradx_runtime::XYK; +use hydradx_runtime::{RuntimeCall, Utility}; +use hydradx_runtime::{Currencies, Omnipool, Runtime, RuntimeEvent}; +use hydradx_traits::router::PoolType; +use xcm_emulator::TestExt; + +use hydradx_traits::router::ExecutionType; +use hydradx_traits::router::Trade; +use hydradx_traits::AMM; +use orml_traits::MultiCurrency; + +#[test] +fn batch_execution_type_should_be_included_in_batch() { + TestNet::reset(); + + Hydra::execute_with(|| { + //Arrange + init_omnipool(); + crate::router::create_lbp_pool(DAI, LRNA); + crate::router::create_xyk_pool(HDX, DOT); + + let amount_to_sell = UNITS / 100; + let limit = 0; + let trades = vec![ + Trade { + pool: PoolType::LBP, + asset_in: DAI, + asset_out: LRNA, + }, + Trade { + pool: PoolType::Omnipool, + asset_in: LRNA, + asset_out: HDX, + }, + Trade { + pool: PoolType::XYK, + asset_in: HDX, + asset_out: DOT, + }, + ]; + + start_lbp_campaign(); + + //Act + let router_call = RuntimeCall::Router(pallet_route_executor::Call::sell { + asset_in: DAI, + asset_out: DOT, + amount_in: amount_to_sell, + min_amount_out: limit, + route: trades.clone(), + }); + assert_ok!(Utility::batch( + hydradx_runtime::RuntimeOrigin::signed(BOB.into()), + vec![router_call.clone()] + )); + + //Assert + assert_balance!(BOB.into(), DAI, 1_000_000_000 * UNITS - amount_to_sell); + + let swapped_events = get_last_swapped_events(); + + pretty_assertions::assert_eq!( + swapped_events, + vec![ + RuntimeEvent::AmmSupport(pallet_amm_support::Event::::Swapped { + swapper: BOB.into(), + filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA)), + filler_type: pallet_amm_support::Filler::LBP, + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(DAI), 9980000000)], + outputs: vec![(AssetType::Fungible(LRNA), 5640664064)], + fees: vec![Fee::new( + DAI, + 20000000, + LBP::pool_data(LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA))) + .unwrap() + .fee_collector, + )], + operation_id: vec![ExecutionType::Batch(0), ExecutionType::Router(1)], + }), + RuntimeEvent::AmmSupport(pallet_amm_support::Event::::Swapped { + swapper: BOB.into(), + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::Filler::Omnipool, + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(LRNA), 5640664064)], + outputs: vec![(AssetType::Fungible(HDX), 4682924837974)], + fees: vec![Fee::new(HDX, 11736653730, Omnipool::protocol_account())], + operation_id: vec![ExecutionType::Batch(0), ExecutionType::Router(1)], + }), + RuntimeEvent::AmmSupport(pallet_amm_support::Event::::Swapped { + swapper: BOB.into(), + filler: XYK::get_pair_id(pallet_xyk::types::AssetPair { + asset_in: HDX, + asset_out: DOT, + }), + filler_type: pallet_amm_support::Filler::XYK(XYK::share_token(XYK::get_pair_id( + pallet_xyk::types::AssetPair { + asset_in: HDX, + asset_out: DOT, + }, + ))), + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(HDX), 4682924837974)], + outputs: vec![(AssetType::Fungible(DOT), 2230008413831)], + fees: vec![Fee::new( + DOT, + 6710155707, + XYK::get_pair_id(pallet_xyk::types::AssetPair { + asset_in: HDX, + asset_out: DOT, + }), + )], + operation_id: vec![ExecutionType::Batch(0), ExecutionType::Router(1)], + }) + ] + ); + }); +} + +#[test] +fn batch_execution_type_should_be_popped_when_multiple_batch_calls_happen() { + TestNet::reset(); + + Hydra::execute_with(|| { + //Arrange + init_omnipool(); + crate::router::create_lbp_pool(DAI, LRNA); + crate::router::create_xyk_pool(HDX, DOT); + + let amount_to_sell = UNITS / 100; + let limit = 0; + let trades = vec![ + Trade { + pool: PoolType::LBP, + asset_in: DAI, + asset_out: LRNA, + }, + Trade { + pool: PoolType::Omnipool, + asset_in: LRNA, + asset_out: HDX, + }, + Trade { + pool: PoolType::XYK, + asset_in: HDX, + asset_out: DOT, + }, + ]; + + start_lbp_campaign(); + + let router_call = RuntimeCall::Router(pallet_route_executor::Call::sell { + asset_in: DAI, + asset_out: DOT, + amount_in: amount_to_sell, + min_amount_out: limit, + route: trades.clone(), + }); + assert_ok!(Utility::batch( + hydradx_runtime::RuntimeOrigin::signed(BOB.into()), + vec![router_call.clone()] + )); + + //Act + let trades = vec![Trade { + pool: PoolType::XYK, + asset_in: HDX, + asset_out: DOT, + }]; + let router_call = RuntimeCall::Router(pallet_route_executor::Call::sell { + asset_in: HDX, + asset_out: DOT, + amount_in: amount_to_sell, + min_amount_out: limit, + route: trades.clone(), + }); + assert_ok!(Utility::batch( + hydradx_runtime::RuntimeOrigin::signed(BOB.into()), + vec![router_call.clone()] + )); + + //Assert + pretty_assertions::assert_eq!( + *get_last_swapped_events().last().unwrap(), + RuntimeEvent::AmmSupport(pallet_amm_support::Event::::Swapped { + swapper: BOB.into(), + filler: XYK::get_pair_id(pallet_xyk::types::AssetPair { + asset_in: HDX, + asset_out: DOT, + }), + filler_type: pallet_amm_support::Filler::XYK(XYK::share_token(XYK::get_pair_id( + pallet_xyk::types::AssetPair { + asset_in: HDX, + asset_out: DOT, + }, + ))), + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(HDX), amount_to_sell)], + outputs: vec![(AssetType::Fungible(DOT), 4549178628)], + fees: vec![Fee::new( + DOT, + 13688601, + XYK::get_pair_id(pallet_xyk::types::AssetPair { + asset_in: HDX, + asset_out: DOT, + }), + )], + operation_id: vec![ExecutionType::Batch(2), ExecutionType::Router(3)], + }) + ); + }); +} + +fn start_lbp_campaign() { + set_relaychain_block_number(crate::router::LBP_SALE_START + 1); +} + diff --git a/pallets/transaction-multi-payment/src/mock.rs b/pallets/transaction-multi-payment/src/mock.rs index ad3cf3bcb..c3b0d9b62 100644 --- a/pallets/transaction-multi-payment/src/mock.rs +++ b/pallets/transaction-multi-payment/src/mock.rs @@ -392,6 +392,8 @@ impl pallet_utility::Config for Test { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; type PalletsOrigin = OriginCaller; + type BatchPreHook = (); + type BatchPostHook = (); type WeightInfo = (); } diff --git a/runtime/hydradx/src/system.rs b/runtime/hydradx/src/system.rs index f0da22297..b530c5efe 100644 --- a/runtime/hydradx/src/system.rs +++ b/runtime/hydradx/src/system.rs @@ -41,8 +41,13 @@ use frame_support::{ PalletId, }; use frame_system::EnsureRoot; +use pallet_utility::{BatchPostHook, BatchPreHook}; use hydradx_adapters::{OraclePriceProvider, RelayChainBlockNumberProvider}; use scale_info::TypeInfo; +use sp_runtime::{ArithmeticError, DispatchResult}; +use hydradx_traits::router::ExecutionType; +use hydradx_traits::IncrementalIdProvider; +use pallet_amm_support::ExecutionTypeStack; pub struct CallFilter; impl Contains for CallFilter { @@ -305,9 +310,32 @@ impl pallet_utility::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; type PalletsOrigin = OriginCaller; + type BatchPreHook = PushBatchExecutionTypeForUnifiedEvent; + type BatchPostHook = PopBatchExecutionTypeForUnifiedEvent; type WeightInfo = weights::pallet_utility::HydraWeight; } +pub struct PushBatchExecutionTypeForUnifiedEvent; + +impl BatchPreHook for PushBatchExecutionTypeForUnifiedEvent { + fn on_batch_start() -> DispatchResult { + let next_event_id = AmmSupport::next_id().map_err(|_| ArithmeticError::Overflow)?; + AmmSupport::push(ExecutionType::Batch(next_event_id))?; + + Ok(()) + } +} + +pub struct PopBatchExecutionTypeForUnifiedEvent; + +impl BatchPostHook for PopBatchExecutionTypeForUnifiedEvent { + fn on_batch_end() -> DispatchResult { + AmmSupport::pop()?; + + Ok(()) + } +} + parameter_types! { pub const BasicDeposit: Balance = 5 * DOLLARS; pub const ByteDeposit: Balance = DOLLARS / 10; From 66fbe9cf8a783968e0bbcc5e468c05c54160498a Mon Sep 17 00:00:00 2001 From: dmoka Date: Thu, 14 Nov 2024 19:05:53 +0100 Subject: [PATCH 059/142] revert changes in math as we can solve it simpler way without changing math APIs --- math/src/stableswap/math.rs | 53 ++++++------ math/src/stableswap/tests/invariants.rs | 3 +- math/src/stableswap/tests/multi_assets.rs | 99 +++++++++++------------ math/src/stableswap/tests/two_assets.rs | 14 ++-- pallets/stableswap/src/lib.rs | 35 ++++---- pallets/stableswap/src/trade_execution.rs | 7 +- pallets/stableswap/src/types.rs | 24 ------ 7 files changed, 97 insertions(+), 138 deletions(-) diff --git a/math/src/stableswap/math.rs b/math/src/stableswap/math.rs index 94dda6269..9bd48de90 100644 --- a/math/src/stableswap/math.rs +++ b/math/src/stableswap/math.rs @@ -125,12 +125,12 @@ pub fn calculate_in_given_out_with_fee( /// Calculate amount of shares to be given to LP after LP provided liquidity of some assets to the pool. pub fn calculate_shares( initial_reserves: &[AssetReserve], - updated_asset_reserves: &[(AssetId, AssetReserve)], + updated_reserves: &[AssetReserve], amplification: Balance, share_issuance: Balance, fee: Permill, -) -> Option<(Balance, Vec<(AssetId, Balance)>)> { - if initial_reserves.len() != updated_asset_reserves.len() { +) -> Option<(Balance, Vec)> { + if initial_reserves.len() != updated_reserves.len() { return None; } let n_coins = initial_reserves.len(); @@ -141,7 +141,6 @@ pub fn calculate_shares( // We must make sure the updated_d is rounded *down* so that we are not giving the new position too many shares. // calculate_d can return a D value that is above the correct D value by up to 2, so we subtract 2. - let updated_reserves = updated_asset_reserves.iter().map(|(_,r)|r.clone()).collect::>(); let updated_d = calculate_d::(&updated_reserves, amplification)?.checked_sub(2_u128)?; if updated_d < initial_d { return None; @@ -153,20 +152,20 @@ pub fn calculate_shares( let (d0, d1) = to_u256!(initial_d, updated_d); - let mut fees = vec![]; + let mut fees = vec![]; let adjusted_reserves = if share_issuance > 0 { - updated_asset_reserves + updated_reserves .iter() .enumerate() .map(|(idx, asset_reserve)| -> Option { - let (initial_reserve, updated_reserve) = to_u256!(initial_reserves[idx].amount, asset_reserve.1.amount); + let (initial_reserve, updated_reserve) = to_u256!(initial_reserves[idx].amount, asset_reserve.amount); let ideal_balance = d1.checked_mul(initial_reserve)?.checked_div(d0)?; let diff = Balance::try_from(updated_reserve.abs_diff(ideal_balance)).ok()?; let fee_amount = fee.checked_mul_int(diff)?; - fees.push((asset_reserve.0, fee_amount.into())); + fees.push(fee_amount.into()); Some(AssetReserve::new( - asset_reserve.1.amount.saturating_sub(fee_amount), - asset_reserve.1.decimals, + asset_reserve.amount.saturating_sub(fee_amount), + asset_reserve.decimals, )) }) .collect::>>()? @@ -189,14 +188,14 @@ pub fn calculate_shares( /// Calculate amount of shares to be given to LP after LP provided liquidity of one asset with given amount. pub fn calculate_shares_for_amount( - initial_asset_reserves: &[(AssetId, AssetReserve)], + initial_reserves: &[AssetReserve], asset_idx: usize, amount: Balance, amplification: Balance, share_issuance: Balance, fee: Permill, -) -> Option<(Balance, Vec<(AssetId, Balance)>)> { - let n_coins = initial_asset_reserves.len(); +) -> Option<(Balance, Vec)> { + let n_coins = initial_reserves.len(); if n_coins <= 1 { return None; } @@ -208,36 +207,34 @@ pub fn calculate_shares_for_amount( .checked_mul(&FixedU128::from(n_coins as u128))? .checked_div(&FixedU128::from(4 * (n_coins - 1) as u128))?; - let updated_asset_reserves: Vec<(AssetId, AssetReserve)> = initial_asset_reserves + let updated_reserves: Vec = initial_reserves .iter() .enumerate() - .map(|(idx, v)| -> Option<(AssetId, AssetReserve)> { + .map(|(idx, v)| -> Option { if idx == asset_idx { - Some((v.0, AssetReserve::new(v.1.amount.checked_sub(amount)?, v.1.decimals))) + Some(AssetReserve::new(v.amount.checked_sub(amount)?, v.decimals)) } else { - Some((v.0, v.1)) + Some(*v) } }) - .collect::>>()?; + .collect::>>()?; - let initial_reserves = initial_asset_reserves.iter().map(|(_,r)|r.clone()).collect::>(); - let updated_reserves = updated_asset_reserves.iter().map(|(_,r)|r.clone()).collect::>(); let initial_d = calculate_d::(&initial_reserves, amplification)?; let updated_d = calculate_d::(&updated_reserves, amplification)?; let (d1, d0) = to_u256!(updated_d, initial_d); let mut fees = vec![]; - let adjusted_reserves: Vec = updated_asset_reserves + let adjusted_reserves: Vec = updated_reserves .iter() .enumerate() .map(|(idx, asset_reserve)| -> Option { - let (initial_reserve, updated_reserve) = to_u256!(initial_reserves[idx].amount, asset_reserve.1.amount); + let (initial_reserve, updated_reserve) = to_u256!(initial_reserves[idx].amount, asset_reserve.amount); let ideal_balance = d1.checked_mul(initial_reserve)?.checked_div(d0)?; let diff = Balance::try_from(updated_reserve.abs_diff(ideal_balance)).ok()?; let fee_amount = fee.checked_mul_int(diff)?; - fees.push((asset_reserve.0, fee_amount.into())); + fees.push(fee_amount.into()); Some(AssetReserve::new( - asset_reserve.1.amount.saturating_sub(fee_amount), - asset_reserve.1.decimals, + asset_reserve.amount.saturating_sub(fee_amount), + asset_reserve.decimals, )) }) .collect::>>()?; @@ -805,7 +802,7 @@ pub fn calculate_spot_price( (SHARE_ASSET, STABLE_ASSET) => { let asset_out_idx = asset_reserves.iter().position(|r| r.0 == asset_out)?; let (shares, _fees) = calculate_shares_for_amount::( - &asset_reserves, + &reserves, asset_out_idx, min_trade_amount, amplification, @@ -825,9 +822,11 @@ pub fn calculate_spot_price( } } + let updated_reserves: &Vec = + &updated_reserves.into_iter().map(|(_, v)| v).collect::>(); let (shares_for_min_trade, _fees) = calculate_shares::( &reserves, - &updated_reserves[..], + updated_reserves, amplification, share_issuance, fee.unwrap_or(Permill::zero()), diff --git a/math/src/stableswap/tests/invariants.rs b/math/src/stableswap/tests/invariants.rs index a50151233..5cf3cae5b 100644 --- a/math/src/stableswap/tests/invariants.rs +++ b/math/src/stableswap/tests/invariants.rs @@ -404,8 +404,7 @@ proptest! { let issuance = balances.iter().sum(); let amount = to_precision(amount, pool[0].decimals); - let pool_with_id = pool.iter().map(|v| (1u32,v.clone())).collect::>(); - let result = calculate_shares_for_amount::(&pool_with_id[..], 0, amount, amp, issuance, Permill::zero()).unwrap(); + let result = calculate_shares_for_amount::(&pool, 0, amount, amp, issuance, Permill::zero()).unwrap(); let received = calculate_withdraw_one_asset::(&pool, result.0, 0, issuance, amp, Permill::zero()) diff --git a/math/src/stableswap/tests/multi_assets.rs b/math/src/stableswap/tests/multi_assets.rs index aafd4bbfe..998ecd5a9 100644 --- a/math/src/stableswap/tests/multi_assets.rs +++ b/math/src/stableswap/tests/multi_assets.rs @@ -1,12 +1,11 @@ -use sp_arithmetic::Permill; - -use crate::stableswap::*; -use crate::stableswap::types::AssetReserve; -use crate::types::{Balance}; - const D_ITERATIONS: u8 = 128; const Y_ITERATIONS: u8 = 64; +use crate::stableswap::types::AssetReserve; +use crate::stableswap::*; +use crate::types::Balance; +use sp_arithmetic::Permill; + const MAX_BALANCES: usize = 5; #[test] @@ -85,7 +84,7 @@ fn calculate_in_given_out_should_fail_when_asset_idx_is_incorrect() { fn calculate_share_for_amount_should_return_correct_shares() { let amp = 100_u128; - let balances = (0..MAX_BALANCES).map(|i| ((i+1) as u32, AssetReserve::new(10_000_000_000_000_000, 12))).collect::>(); + let balances = [AssetReserve::new(10_000_000_000_000_000, 12); MAX_BALANCES]; let amount: Balance = 100_000_000_000_000; let issuance: Balance = 20_000_000_000_000_000_000_000; @@ -95,7 +94,6 @@ fn calculate_share_for_amount_should_return_correct_shares() { assert_eq!(result.0, 40001593768209443008); - let balances = balances.iter().map(|(_,amounts)| amounts.clone()).collect::>(); let result = calculate_withdraw_one_asset::( &balances, result.0, @@ -114,8 +112,7 @@ fn calculate_share_for_amount_should_return_correct_shares_when_fee_applied() { let fee = Permill::from_float(0.001); - //let balances = [AssetReserve::new(10_000_000_000_000_000, 12); MAX_BALANCES]; - let balances = (0..MAX_BALANCES).map(|i| ((i+1) as u32, AssetReserve::new(10_000_000_000_000_000, 12))).collect::>(); + let balances = [AssetReserve::new(10_000_000_000_000_000, 12); MAX_BALANCES]; let amount: Balance = 100_000_000_000_000; let issuance: Balance = 20_000_000_000_000_000_000_000; @@ -124,7 +121,6 @@ fn calculate_share_for_amount_should_return_correct_shares_when_fee_applied() { assert_eq!(result.0, 40021594667568399481); - let balances = balances.iter().map(|(_,amounts)| amounts.clone()).collect::>(); let result = calculate_withdraw_one_asset::(&balances, result.0, 0, issuance, amp, fee).unwrap(); assert_eq!(result, (99999975001371, 50023249592)); @@ -135,8 +131,8 @@ fn calculate_shares_should_work_when_correct_input_provided() { let amp = 100_u128; let initial_balances = [AssetReserve::new(10_000, 12); MAX_BALANCES]; - let mut updated_balances = (0..MAX_BALANCES).map(|i| ((i+1) as u32, AssetReserve::new(10_000, 12))).collect::>(); - updated_balances[2].1.amount += 5000u128; + let mut updated_balances = [AssetReserve::new(10_000, 12); MAX_BALANCES]; + updated_balances[2].amount += 5000u128; let issuance: Balance = 100_000; @@ -149,32 +145,13 @@ fn calculate_shares_should_work_when_correct_input_provided() { assert_eq!(result.0, 9983u128); } -#[test] -fn calculate_shares_should_return_fees_for_all_assets() { - let amp = 100_u128; - - let initial_balances = [AssetReserve::new(10_000, 12); MAX_BALANCES]; - let mut updated_balances = (0..MAX_BALANCES).map(|i| ((i+1) as u32, AssetReserve::new(10_000, 12))).collect::>(); - updated_balances[2].1.amount += 5000u128; - - let issuance: Balance = 100_000; - - let result = calculate_shares::(&initial_balances, &updated_balances, amp, issuance, Permill::from_percent(1)); - - assert!(result.is_some()); - - let result = result.unwrap(); - - assert_eq!(result.1, vec![(1,3), (2,3), (3,12), (4,3), (5,3)]); -} - #[test] fn calculate_shares_should_work_when_share_issuance_is_zero() { let amp = 100_u128; let initial_balances = [AssetReserve::new(0, 12); MAX_BALANCES]; - let mut updated_balances = (0..MAX_BALANCES).map(|i| ((i+1) as u32, AssetReserve::new(10_000, 12))).collect::>(); - updated_balances[2].1.amount += 5000u128; + let mut updated_balances = [AssetReserve::new(10_000, 12); MAX_BALANCES]; + updated_balances[2].amount += 5000u128; let issuance: Balance = 0; @@ -192,8 +169,8 @@ fn calculate_shares_should_fail_when_balances_len_is_not_equal() { let amp = 100_u128; let initial_balances = [AssetReserve::new(10_000, 12); MAX_BALANCES + 1]; - let mut updated_balances = (0..MAX_BALANCES).map(|i| ((i+1) as u32, AssetReserve::new(10_000, 12))).collect::>(); - updated_balances[2].1.amount += 5000u128; + let mut updated_balances = [AssetReserve::new(10_000, 12); MAX_BALANCES]; + updated_balances[2].amount += 5000u128; let issuance: Balance = 100_000; @@ -207,8 +184,8 @@ fn calculate_shares_should_fail_when_updated_balances_are_less() { let amp = 100_u128; let initial_balances = [AssetReserve::new(10_000, 12); MAX_BALANCES]; - let mut updated_balances = (0..MAX_BALANCES).map(|i| ((i+1) as u32, AssetReserve::new(10_000, 12))).collect::>(); - updated_balances[2].1.amount -= 5000u128; + let mut updated_balances = [AssetReserve::new(10_000, 12); MAX_BALANCES]; + updated_balances[2].amount -= 5000u128; let issuance: Balance = 100_000; @@ -381,13 +358,12 @@ fn calculate_withdraw_should_return_correct_amount_when_removing_provided_shares let fee = Permill::from_percent(0); let initial_balances = [AssetReserve::new(10_000, 12); MAX_BALANCES]; - let mut updated_balances_for_calculate_shares = (0..MAX_BALANCES).map(|i| ((i+1) as u32, AssetReserve::new(10_000, 12))).collect::>(); - updated_balances_for_calculate_shares[2].1.amount += 5000u128; - let updated_balances = updated_balances_for_calculate_shares.iter().map(|(_,amounts)| amounts.clone()).collect::>(); + let mut updated_balances = [AssetReserve::new(10_000, 12); MAX_BALANCES]; + updated_balances[2].amount += 5000u128; let issuance: Balance = 100_000; - let result = calculate_shares::(&initial_balances, &updated_balances_for_calculate_shares, amp, issuance, Permill::zero()); + let result = calculate_shares::(&initial_balances, &updated_balances, amp, issuance, Permill::zero()); let shares = result.unwrap().0; let result = calculate_withdraw_one_asset::( @@ -723,14 +699,13 @@ fn calculate_exact_amount_of_shares() { let asset_idx = 2; let initial_balances = [AssetReserve::new(10_000_000_000_000_000, 12); MAX_BALANCES]; - let mut updated_balances = (0..MAX_BALANCES).map(|i| ((i+1) as u32, AssetReserve::new(10_000_000_000_000_000, 12))).collect::>(); - updated_balances[asset_idx].1.amount += 1_000_000_000_000_000u128; + let mut updated_balances = initial_balances; + updated_balances[asset_idx].amount += 1_000_000_000_000_000u128; let issuance: Balance = 20_000_000_000_000_000_000_000; let result = calculate_shares::(&initial_balances, &updated_balances, amp, issuance, Permill::zero()); - let shares = result.unwrap().0; - assert_eq!(shares, 399850144492663029649); + assert_eq!(result.unwrap().0, 399850144492663029649); let result = calculate_add_one_asset::( &initial_balances, 399850144492663029649, @@ -749,8 +724,8 @@ fn calculate_exact_amount_of_shares_with_fee() { let asset_idx = 2; let initial_balances = [AssetReserve::new(10_000_000_000_000_000, 12); MAX_BALANCES]; - let mut updated_balances = (0..MAX_BALANCES).map(|i| ((i+1) as u32, AssetReserve::new(10_000_000_000_000_000, 12))).collect::>(); - updated_balances[asset_idx].1.amount += 1_000_000_000_000_000u128; + let mut updated_balances = initial_balances; + updated_balances[asset_idx].amount += 1_000_000_000_000_000u128; let issuance: Balance = 20_000_000_000_000_000_000_000; @@ -761,8 +736,7 @@ fn calculate_exact_amount_of_shares_with_fee() { issuance, Permill::from_percent(0), ); - let shares = result.unwrap().0; - assert_eq!(shares, 399850144492663029649); + assert_eq!(result.unwrap().0, 399850144492663029649); let result = calculate_add_one_asset::( &initial_balances, 399850144492663029649, @@ -831,3 +805,28 @@ fn share_price_calculation_should_work_with_6_decimals() { Some((279206572581786940496760242, 279158579738033226972960348441675415837)) ); } + +#[test] +fn calculate_shares_should_return_fees_for_all_assets() { + let amp = 100_u128; + + let initial_balances = [AssetReserve::new(10_000, 12); MAX_BALANCES]; + let mut updated_balances = [AssetReserve::new(10_000, 12); MAX_BALANCES]; + updated_balances[2].amount += 5000u128; + + let issuance: Balance = 100_000; + + let result = calculate_shares::( + &initial_balances, + &updated_balances, + amp, + issuance, + Permill::from_percent(1), + ); + + assert!(result.is_some()); + + let result = result.unwrap(); + + assert_eq!(result.1, vec![(3), (3), (12), (3), (3)]); +} diff --git a/math/src/stableswap/tests/two_assets.rs b/math/src/stableswap/tests/two_assets.rs index 01d776e9e..45f919f18 100644 --- a/math/src/stableswap/tests/two_assets.rs +++ b/math/src/stableswap/tests/two_assets.rs @@ -1,13 +1,11 @@ -use sp_arithmetic::Permill; - -use crate::stableswap::*; -use crate::stableswap::types::AssetReserve; - -use super::*; - const D_ITERATIONS: u8 = 128; const Y_ITERATIONS: u8 = 64; +use super::*; +use crate::stableswap::types::AssetReserve; +use crate::stableswap::*; +use sp_arithmetic::Permill; + #[test] fn test_d() { let reserves = [1000u128, 1000u128]; @@ -105,7 +103,7 @@ fn test_shares() { let amp = 100u128; let initial_reserves = &[AssetReserve::new(0, 12); 2]; - let updated_reserves = &[(1, AssetReserve::new(1000 * ONE, 12)),(2, AssetReserve::new(500, 12))]; + let updated_reserves = &[AssetReserve::new(1000 * ONE, 12), AssetReserve::new(500, 12)]; let result = calculate_shares::(initial_reserves, updated_reserves, amp, 0u128, Permill::zero()); diff --git a/pallets/stableswap/src/lib.rs b/pallets/stableswap/src/lib.rs index ceeac8e87..93a721ae8 100644 --- a/pallets/stableswap/src/lib.rs +++ b/pallets/stableswap/src/lib.rs @@ -685,19 +685,15 @@ pub mod pallet { let asset_idx = pool.find_asset(asset_id).ok_or(Error::::AssetNotInPool)?; let pool_account = Self::pool_account(pool_id); let initial_reserves = pool - .asset_reserves_with_decimals::(&pool_account) + .reserves_with_decimals::(&pool_account) .ok_or(Error::::UnknownDecimals)?; - let initial_reserves = initial_reserves - .iter() - .map(|r| (r.0.into(), r.1)) - .collect::>(); let share_issuance = T::Currency::total_issuance(pool_id); let amplification = Self::get_amplification(&pool); // Calculate how much shares user needs to provide to receive `amount` of asset. let (shares, fees) = hydra_dx_math::stableswap::calculate_shares_for_amount::( - &initial_reserves[..], + &initial_reserves, asset_idx, amount, amplification, @@ -720,7 +716,6 @@ pub mod pallet { T::Currency::transfer(asset_id, &pool_account, &who, amount)?; // All done and updated. let's call the on_liquidity_changed hook. - let initial_reserves = initial_reserves.iter().map(|r| r.1).collect::>(); Self::call_on_liquidity_change_hook(pool_id, &initial_reserves, share_issuance)?; Self::deposit_event(Event::LiquidityRemoved { @@ -733,7 +728,8 @@ pub mod pallet { let fees = fees .iter() - .map(|(asset_id, balance)| Fee::new(*asset_id, *balance, pool_account.clone())) + .zip(pool.assets.iter()) + .map(|(balance, asset_id)| Fee::new((*asset_id).into(), *balance, pool_account.clone())) .collect::>(); pallet_amm_support::Pallet::::deposit_trade_event( who, @@ -1217,23 +1213,21 @@ impl Pallet { }); if let Some(liq_added) = added_assets.remove(pool_asset) { let inc_reserve = reserve.checked_add(liq_added).ok_or(ArithmeticError::Overflow)?; - updated_reserves.push(( - (*pool_asset).into(), + updated_reserves.push( AssetReserve { amount: inc_reserve, decimals, }, - )); + ); added_amounts.push(liq_added); } else { ensure!(!reserve.is_zero(), Error::::InvalidInitialLiquidity); - updated_reserves.push(( - (*pool_asset).into(), + updated_reserves.push( AssetReserve { amount: reserve, decimals, }, - )); + ); added_amounts.push(0); } } @@ -1277,7 +1271,8 @@ impl Pallet { .collect(); let fees = fees .iter() - .map(|(asset_id, balance)| Fee::new(*asset_id, *balance, pool_account.clone())) + .zip(pool.assets.iter()) + .map(|(balance, asset_id)| Fee::new((*asset_id).into(), *balance, pool_account.clone())) .collect::>(); pallet_amm_support::Pallet::::deposit_trade_event( who.clone(), @@ -1422,22 +1417,20 @@ impl Pallet { }); if let Some(liq_added) = added_assets.remove(pool_asset) { let inc_reserve = reserve.checked_add(liq_added).ok_or(ArithmeticError::Overflow)?; - updated_reserves.push(( - (*pool_asset).into(), + updated_reserves.push( AssetReserve { amount: inc_reserve, decimals, }, - )); + ); } else { ensure!(!reserve.is_zero(), Error::::InvalidInitialLiquidity); - updated_reserves.push(( - (*pool_asset).into(), + updated_reserves.push( AssetReserve { amount: reserve, decimals, }, - )); + ); } } diff --git a/pallets/stableswap/src/trade_execution.rs b/pallets/stableswap/src/trade_execution.rs index 92367a097..2d7e13c4a 100644 --- a/pallets/stableswap/src/trade_execution.rs +++ b/pallets/stableswap/src/trade_execution.rs @@ -106,7 +106,7 @@ where .ok_or_else(|| ExecutorError::Error(Error::::AssetNotInPool.into()))?; let pool_account = Self::pool_account(pool_id); let balances = pool - .asset_reserves_with_decimals::(&pool_account) + .reserves_with_decimals::(&pool_account) .ok_or_else(|| ExecutorError::Error(Error::::UnknownDecimals.into()))?; let share_issuance = T::Currency::total_issuance(pool_id); let amplification = Self::get_amplification(&pool); @@ -114,11 +114,6 @@ where let pool = Pools::::get(pool_id) .ok_or_else(|| ExecutorError::Error(Error::::PoolNotFound.into()))?; - let balances = balances - .iter() - .map(|r| (r.0.into(), r.1)) - .collect::>(); - let (shares_amount, _fees) = hydra_dx_math::stableswap::calculate_shares_for_amount::( &balances, diff --git a/pallets/stableswap/src/types.rs b/pallets/stableswap/src/types.rs index 985a8a793..17a8002d0 100644 --- a/pallets/stableswap/src/types.rs +++ b/pallets/stableswap/src/types.rs @@ -56,30 +56,6 @@ where self.assets.len() >= 2 && has_unique_elements(&mut self.assets.iter()) } - pub(crate) fn asset_reserves_with_decimals( - &self, - account: &T::AccountId, - ) -> Option> - where - T::AssetId: Into, - ::AssetId: From, - { - self.assets - .iter() - .map(|asset| { - let reserve = T::Currency::free_balance((*asset).into(), account); - let decimals = Pallet::::retrieve_decimals((*asset).into())?; - Some(( - *asset, - AssetReserve { - amount: reserve, - decimals, - }, - )) - }) - .collect() - } - pub(crate) fn reserves_with_decimals(&self, account: &T::AccountId) -> Option> where T::AssetId: From, From d4227a3e562e3244d275df88bf6841fb61719ba2 Mon Sep 17 00:00:00 2001 From: dmoka Date: Thu, 14 Nov 2024 19:09:56 +0100 Subject: [PATCH 060/142] cleaning up --- math/src/stableswap/math.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/math/src/stableswap/math.rs b/math/src/stableswap/math.rs index 9bd48de90..b016f39b7 100644 --- a/math/src/stableswap/math.rs +++ b/math/src/stableswap/math.rs @@ -141,7 +141,7 @@ pub fn calculate_shares( // We must make sure the updated_d is rounded *down* so that we are not giving the new position too many shares. // calculate_d can return a D value that is above the correct D value by up to 2, so we subtract 2. - let updated_d = calculate_d::(&updated_reserves, amplification)?.checked_sub(2_u128)?; + let updated_d = calculate_d::(updated_reserves, amplification)?.checked_sub(2_u128)?; if updated_d < initial_d { return None; } @@ -219,7 +219,7 @@ pub fn calculate_shares_for_amount( }) .collect::>>()?; - let initial_d = calculate_d::(&initial_reserves, amplification)?; + let initial_d = calculate_d::(initial_reserves, amplification)?; let updated_d = calculate_d::(&updated_reserves, amplification)?; let (d1, d0) = to_u256!(updated_d, initial_d); let mut fees = vec![]; @@ -822,11 +822,11 @@ pub fn calculate_spot_price( } } - let updated_reserves: &Vec = + let update_reserves: &Vec = &updated_reserves.into_iter().map(|(_, v)| v).collect::>(); let (shares_for_min_trade, _fees) = calculate_shares::( &reserves, - updated_reserves, + update_reserves, amplification, share_issuance, fee.unwrap_or(Permill::zero()), From a122029543391d4a53b67ae21c33b1700648a3ff Mon Sep 17 00:00:00 2001 From: dmoka Date: Thu, 14 Nov 2024 19:22:05 +0100 Subject: [PATCH 061/142] make clippy happy --- math/src/stableswap/math.rs | 4 ++-- pallets/amm-support/src/lib.rs | 3 --- pallets/stableswap/src/trade_execution.rs | 1 - 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/math/src/stableswap/math.rs b/math/src/stableswap/math.rs index b016f39b7..d2fe186bc 100644 --- a/math/src/stableswap/math.rs +++ b/math/src/stableswap/math.rs @@ -162,7 +162,7 @@ pub fn calculate_shares( let ideal_balance = d1.checked_mul(initial_reserve)?.checked_div(d0)?; let diff = Balance::try_from(updated_reserve.abs_diff(ideal_balance)).ok()?; let fee_amount = fee.checked_mul_int(diff)?; - fees.push(fee_amount.into()); + fees.push(fee_amount); Some(AssetReserve::new( asset_reserve.amount.saturating_sub(fee_amount), asset_reserve.decimals, @@ -231,7 +231,7 @@ pub fn calculate_shares_for_amount( let ideal_balance = d1.checked_mul(initial_reserve)?.checked_div(d0)?; let diff = Balance::try_from(updated_reserve.abs_diff(ideal_balance)).ok()?; let fee_amount = fee.checked_mul_int(diff)?; - fees.push(fee_amount.into()); + fees.push(fee_amount); Some(AssetReserve::new( asset_reserve.amount.saturating_sub(fee_amount), asset_reserve.decimals, diff --git a/pallets/amm-support/src/lib.rs b/pallets/amm-support/src/lib.rs index e2a63f0f9..51e577545 100644 --- a/pallets/amm-support/src/lib.rs +++ b/pallets/amm-support/src/lib.rs @@ -56,9 +56,6 @@ impl ExecutionIdStack { self.0.into_inner() } - fn is_empty(&self) -> bool { - self.0.is_empty() - } } #[frame_support::pallet] diff --git a/pallets/stableswap/src/trade_execution.rs b/pallets/stableswap/src/trade_execution.rs index 2d7e13c4a..2a0749421 100644 --- a/pallets/stableswap/src/trade_execution.rs +++ b/pallets/stableswap/src/trade_execution.rs @@ -6,7 +6,6 @@ use orml_traits::MultiCurrency; use sp_core::Get; use sp_runtime::{ArithmeticError, DispatchError, FixedU128}; use sp_std::vec; -use sp_std::vec::Vec; impl TradeExecution for Pallet where From 458ae3aea55479472786819153a136c64e166c67 Mon Sep 17 00:00:00 2001 From: dmoka Date: Thu, 14 Nov 2024 19:22:16 +0100 Subject: [PATCH 062/142] formatting --- integration-tests/src/dca.rs | 1 - integration-tests/src/polkadot_test_net.rs | 3 +- integration-tests/src/utility.rs | 5 +-- math/src/stableswap/math.rs | 3 +- pallets/amm-support/src/lib.rs | 1 - pallets/stableswap/src/lib.rs | 40 ++++++++----------- .../stableswap/src/tests/remove_liquidity.rs | 7 +++- runtime/hydradx/src/system.rs | 6 +-- 8 files changed, 28 insertions(+), 38 deletions(-) diff --git a/integration-tests/src/dca.rs b/integration-tests/src/dca.rs index c3d66d542..78464a609 100644 --- a/integration-tests/src/dca.rs +++ b/integration-tests/src/dca.rs @@ -4153,7 +4153,6 @@ pub fn run_to_block(from: BlockNumber, to: BlockNumber) { } } - pub fn check_if_no_failed_events() { let failed_events = count_failed_trade_events(); assert_eq!(0, failed_events); diff --git a/integration-tests/src/polkadot_test_net.rs b/integration-tests/src/polkadot_test_net.rs index b35d0a788..2d119beaa 100644 --- a/integration-tests/src/polkadot_test_net.rs +++ b/integration-tests/src/polkadot_test_net.rs @@ -898,7 +898,6 @@ pub fn assert_xcm_message_processing_passed() { ))); } - pub fn get_last_swapped_events() -> Vec { let last_events: Vec = last_hydra_events(1000); let mut swapped_events = vec![]; @@ -911,4 +910,4 @@ pub fn get_last_swapped_events() -> Vec { } swapped_events -} \ No newline at end of file +} diff --git a/integration-tests/src/utility.rs b/integration-tests/src/utility.rs index dd0081f30..b24e73d43 100644 --- a/integration-tests/src/utility.rs +++ b/integration-tests/src/utility.rs @@ -3,11 +3,11 @@ use crate::polkadot_test_net::*; use frame_support::assert_ok; -use crate::{assert_balance}; +use crate::assert_balance; use hydradx_runtime::LBP; use hydradx_runtime::XYK; -use hydradx_runtime::{RuntimeCall, Utility}; use hydradx_runtime::{Currencies, Omnipool, Runtime, RuntimeEvent}; +use hydradx_runtime::{RuntimeCall, Utility}; use hydradx_traits::router::PoolType; use xcm_emulator::TestExt; @@ -222,4 +222,3 @@ fn batch_execution_type_should_be_popped_when_multiple_batch_calls_happen() { fn start_lbp_campaign() { set_relaychain_block_number(crate::router::LBP_SALE_START + 1); } - diff --git a/math/src/stableswap/math.rs b/math/src/stableswap/math.rs index d2fe186bc..efe41df6b 100644 --- a/math/src/stableswap/math.rs +++ b/math/src/stableswap/math.rs @@ -822,8 +822,7 @@ pub fn calculate_spot_price( } } - let update_reserves: &Vec = - &updated_reserves.into_iter().map(|(_, v)| v).collect::>(); + let update_reserves: &Vec = &updated_reserves.into_iter().map(|(_, v)| v).collect::>(); let (shares_for_min_trade, _fees) = calculate_shares::( &reserves, update_reserves, diff --git a/pallets/amm-support/src/lib.rs b/pallets/amm-support/src/lib.rs index 51e577545..d6915e493 100644 --- a/pallets/amm-support/src/lib.rs +++ b/pallets/amm-support/src/lib.rs @@ -55,7 +55,6 @@ impl ExecutionIdStack { fn get(self) -> Vec> { self.0.into_inner() } - } #[frame_support::pallet] diff --git a/pallets/stableswap/src/lib.rs b/pallets/stableswap/src/lib.rs index 93a721ae8..61bb94f35 100644 --- a/pallets/stableswap/src/lib.rs +++ b/pallets/stableswap/src/lib.rs @@ -1213,21 +1213,17 @@ impl Pallet { }); if let Some(liq_added) = added_assets.remove(pool_asset) { let inc_reserve = reserve.checked_add(liq_added).ok_or(ArithmeticError::Overflow)?; - updated_reserves.push( - AssetReserve { - amount: inc_reserve, - decimals, - }, - ); + updated_reserves.push(AssetReserve { + amount: inc_reserve, + decimals, + }); added_amounts.push(liq_added); } else { ensure!(!reserve.is_zero(), Error::::InvalidInitialLiquidity); - updated_reserves.push( - AssetReserve { - amount: reserve, - decimals, - }, - ); + updated_reserves.push(AssetReserve { + amount: reserve, + decimals, + }); added_amounts.push(0); } } @@ -1417,20 +1413,16 @@ impl Pallet { }); if let Some(liq_added) = added_assets.remove(pool_asset) { let inc_reserve = reserve.checked_add(liq_added).ok_or(ArithmeticError::Overflow)?; - updated_reserves.push( - AssetReserve { - amount: inc_reserve, - decimals, - }, - ); + updated_reserves.push(AssetReserve { + amount: inc_reserve, + decimals, + }); } else { ensure!(!reserve.is_zero(), Error::::InvalidInitialLiquidity); - updated_reserves.push( - AssetReserve { - amount: reserve, - decimals, - }, - ); + updated_reserves.push(AssetReserve { + amount: reserve, + decimals, + }); } } diff --git a/pallets/stableswap/src/tests/remove_liquidity.rs b/pallets/stableswap/src/tests/remove_liquidity.rs index 51783027c..3e3992109 100644 --- a/pallets/stableswap/src/tests/remove_liquidity.rs +++ b/pallets/stableswap/src/tests/remove_liquidity.rs @@ -1088,14 +1088,17 @@ fn removing_liquidity_with_exact_amount_should_emit_swapped_event() { operation: pallet_amm_support::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(pool_id), 979387928052053203)], outputs: vec![(AssetType::Fungible(asset_a), 1000000000000000000),], - fees: vec![Fee::new(asset_a, 2870505165609705, pool_account), Fee::new(asset_b, 872, pool_account), Fee::new(asset_c, 1998, pool_account)], + fees: vec![ + Fee::new(asset_a, 2870505165609705, pool_account), + Fee::new(asset_b, 872, pool_account), + Fee::new(asset_c, 1998, pool_account) + ], operation_id: vec![], }) ); }); } - #[test] fn remove_multi_asset_liquidity_should_work_when_withdrawing_some_shares() { let asset_a: AssetId = 1; diff --git a/runtime/hydradx/src/system.rs b/runtime/hydradx/src/system.rs index b530c5efe..b18af1cf9 100644 --- a/runtime/hydradx/src/system.rs +++ b/runtime/hydradx/src/system.rs @@ -41,13 +41,13 @@ use frame_support::{ PalletId, }; use frame_system::EnsureRoot; -use pallet_utility::{BatchPostHook, BatchPreHook}; use hydradx_adapters::{OraclePriceProvider, RelayChainBlockNumberProvider}; -use scale_info::TypeInfo; -use sp_runtime::{ArithmeticError, DispatchResult}; use hydradx_traits::router::ExecutionType; use hydradx_traits::IncrementalIdProvider; use pallet_amm_support::ExecutionTypeStack; +use pallet_utility::{BatchPostHook, BatchPreHook}; +use scale_info::TypeInfo; +use sp_runtime::{ArithmeticError, DispatchResult}; pub struct CallFilter; impl Contains for CallFilter { From a2f3ad30dfd18a6d0affddf2473f3f7cc0670ea9 Mon Sep 17 00:00:00 2001 From: dmoka Date: Thu, 14 Nov 2024 21:03:57 +0100 Subject: [PATCH 063/142] rebenchmark utility pallet --- runtime/hydradx/src/weights/pallet_utility.rs | 64 ++++++++++++------- 1 file changed, 41 insertions(+), 23 deletions(-) diff --git a/runtime/hydradx/src/weights/pallet_utility.rs b/runtime/hydradx/src/weights/pallet_utility.rs index e30a8a166..8a8f113db 100644 --- a/runtime/hydradx/src/weights/pallet_utility.rs +++ b/runtime/hydradx/src/weights/pallet_utility.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for `pallet_utility` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-09-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-11-14, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bench-bot`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` @@ -51,48 +51,66 @@ pub struct WeightInfo(PhantomData); /// Weights for `pallet_utility` using the HydraDX node and recommended hardware. pub struct HydraWeight(PhantomData); impl pallet_utility::WeightInfo for HydraWeight { + /// Storage: `AmmSupport::IncrementalId` (r:1 w:1) + /// Proof: `AmmSupport::IncrementalId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::IdStack` (r:1 w:1) + /// Proof: `AmmSupport::IdStack` (`max_values`: Some(1), `max_size`: Some(51), added: 546, mode: `MaxEncodedLen`) /// The range of component `c` is `[0, 1000]`. fn batch(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 6_275_000 picoseconds. - Weight::from_parts(6_413_000, 0) - // Standard Error: 1_609 - .saturating_add(Weight::from_parts(3_722_278, 0).saturating_mul(c.into())) + // Measured: `109` + // Estimated: `1536` + // Minimum execution time: 11_565_000 picoseconds. + Weight::from_parts(1_469_920, 1536) + // Standard Error: 2_956 + .saturating_add(Weight::from_parts(4_030_477, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } fn as_derivative() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_401_000 picoseconds. - Weight::from_parts(6_546_000, 0) + // Minimum execution time: 6_183_000 picoseconds. + Weight::from_parts(6_383_000, 0) } + /// Storage: `AmmSupport::IncrementalId` (r:1 w:1) + /// Proof: `AmmSupport::IncrementalId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::IdStack` (r:1 w:1) + /// Proof: `AmmSupport::IdStack` (`max_values`: Some(1), `max_size`: Some(51), added: 546, mode: `MaxEncodedLen`) /// The range of component `c` is `[0, 1000]`. fn batch_all(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 6_281_000 picoseconds. - Weight::from_parts(6_139_425, 0) - // Standard Error: 2_538 - .saturating_add(Weight::from_parts(4_015_708, 0).saturating_mul(c.into())) + // Measured: `109` + // Estimated: `1536` + // Minimum execution time: 11_377_000 picoseconds. + Weight::from_parts(12_184_543, 1536) + // Standard Error: 2_950 + .saturating_add(Weight::from_parts(4_283_377, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } fn dispatch_as() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_731_000 picoseconds. - Weight::from_parts(8_957_000, 0) + // Minimum execution time: 8_714_000 picoseconds. + Weight::from_parts(8_898_000, 0) } + /// Storage: `AmmSupport::IncrementalId` (r:1 w:1) + /// Proof: `AmmSupport::IncrementalId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::IdStack` (r:1 w:1) + /// Proof: `AmmSupport::IdStack` (`max_values`: Some(1), `max_size`: Some(51), added: 546, mode: `MaxEncodedLen`) /// The range of component `c` is `[0, 1000]`. fn force_batch(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 6_152_000 picoseconds. - Weight::from_parts(8_319_759, 0) - // Standard Error: 2_825 - .saturating_add(Weight::from_parts(3_699_376, 0).saturating_mul(c.into())) + // Measured: `109` + // Estimated: `1536` + // Minimum execution time: 11_519_000 picoseconds. + Weight::from_parts(11_090_812, 1536) + // Standard Error: 2_756 + .saturating_add(Weight::from_parts(4_001_584, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } } \ No newline at end of file From 04c19428d8b76eb13dbccfd0bbaf1fc95d77cbf0 Mon Sep 17 00:00:00 2001 From: dmoka Date: Fri, 15 Nov 2024 15:05:51 +0100 Subject: [PATCH 064/142] bump versions --- Cargo.lock | 26 ++++++++++---------- integration-tests/Cargo.toml | 2 +- math/Cargo.toml | 2 +- pallets/circuit-breaker/Cargo.toml | 2 +- pallets/dca/Cargo.toml | 2 +- pallets/liquidity-mining/Cargo.toml | 2 +- pallets/omnipool-liquidity-mining/Cargo.toml | 2 +- pallets/otc-settlements/Cargo.toml | 2 +- pallets/transaction-multi-payment/Cargo.toml | 2 +- pallets/xyk/Cargo.toml | 2 +- primitives/Cargo.toml | 2 +- runtime/adapters/Cargo.toml | 2 +- runtime/hydradx/Cargo.toml | 2 +- runtime/hydradx/src/lib.rs | 2 +- traits/Cargo.toml | 2 +- 15 files changed, 27 insertions(+), 27 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 05f03ec55..d2961ef2f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4754,7 +4754,7 @@ dependencies = [ [[package]] name = "hydra-dx-math" -version = "8.2.0" +version = "8.3.0" dependencies = [ "approx", "criterion", @@ -4868,7 +4868,7 @@ dependencies = [ [[package]] name = "hydradx-adapters" -version = "1.3.8" +version = "1.3.9" dependencies = [ "cumulus-pallet-parachain-system", "cumulus-primitives-core", @@ -4919,7 +4919,7 @@ dependencies = [ [[package]] name = "hydradx-runtime" -version = "271.0.0" +version = "272.0.0" dependencies = [ "cumulus-pallet-aura-ext", "cumulus-pallet-parachain-system", @@ -5059,7 +5059,7 @@ dependencies = [ [[package]] name = "hydradx-traits" -version = "3.9.0" +version = "3.10.0" dependencies = [ "frame-support", "impl-trait-for-tuples", @@ -7845,7 +7845,7 @@ dependencies = [ [[package]] name = "pallet-circuit-breaker" -version = "1.1.26" +version = "1.1.27" dependencies = [ "frame-benchmarking", "frame-support", @@ -8002,7 +8002,7 @@ dependencies = [ [[package]] name = "pallet-dca" -version = "1.6.3" +version = "1.7.0" dependencies = [ "cumulus-pallet-parachain-system", "cumulus-primitives-core", @@ -8534,7 +8534,7 @@ dependencies = [ [[package]] name = "pallet-liquidity-mining" -version = "4.4.3" +version = "4.4.4" dependencies = [ "fixed", "frame-support", @@ -8786,7 +8786,7 @@ dependencies = [ [[package]] name = "pallet-omnipool-liquidity-mining" -version = "2.4.0" +version = "2.4.1" dependencies = [ "frame-benchmarking", "frame-support", @@ -8838,7 +8838,7 @@ dependencies = [ [[package]] name = "pallet-otc-settlements" -version = "1.0.5" +version = "1.1.0" dependencies = [ "frame-benchmarking", "frame-support", @@ -9303,7 +9303,7 @@ dependencies = [ [[package]] name = "pallet-transaction-multi-payment" -version = "10.1.3" +version = "10.1.4" dependencies = [ "frame-support", "frame-system", @@ -9519,7 +9519,7 @@ dependencies = [ [[package]] name = "pallet-xyk" -version = "6.6.2" +version = "6.7.0" dependencies = [ "frame-benchmarking", "frame-support", @@ -11303,7 +11303,7 @@ dependencies = [ [[package]] name = "primitives" -version = "6.1.0" +version = "6.1.1" dependencies = [ "frame-support", "hex-literal", @@ -12230,7 +12230,7 @@ dependencies = [ [[package]] name = "runtime-integration-tests" -version = "1.25.1" +version = "1.26.0" dependencies = [ "cumulus-pallet-aura-ext", "cumulus-pallet-parachain-system", diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index 96323fd4b..a34a68fa5 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "runtime-integration-tests" -version = "1.25.1" +version = "1.26.0" description = "Integration tests" authors = ["GalacticCouncil"] edition = "2021" diff --git a/math/Cargo.toml b/math/Cargo.toml index e18fb4add..30af6ef33 100644 --- a/math/Cargo.toml +++ b/math/Cargo.toml @@ -6,7 +6,7 @@ license = 'Apache-2.0' name = "hydra-dx-math" description = "A collection of utilities to make performing liquidity pool calculations more convenient." repository = 'https://github.com/galacticcouncil/hydradx-math' -version = "8.2.0" +version = "8.3.0" [dependencies] primitive-types = { workspace = true } diff --git a/pallets/circuit-breaker/Cargo.toml b/pallets/circuit-breaker/Cargo.toml index 1b838af2c..b81f27db5 100644 --- a/pallets/circuit-breaker/Cargo.toml +++ b/pallets/circuit-breaker/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-circuit-breaker" -version = "1.1.26" +version = "1.1.27" authors = ["GalacticCouncil "] edition = "2021" license = "Apache-2.0" diff --git a/pallets/dca/Cargo.toml b/pallets/dca/Cargo.toml index ab72dd8ca..7c92ebf3d 100644 --- a/pallets/dca/Cargo.toml +++ b/pallets/dca/Cargo.toml @@ -1,6 +1,6 @@ [package] name = 'pallet-dca' -version = "1.6.3" +version = "1.7.0" description = 'A pallet to manage DCA scheduling' authors = ['GalacticCouncil'] edition = '2021' diff --git a/pallets/liquidity-mining/Cargo.toml b/pallets/liquidity-mining/Cargo.toml index fb26b3282..e37f2471a 100644 --- a/pallets/liquidity-mining/Cargo.toml +++ b/pallets/liquidity-mining/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-liquidity-mining" -version = "4.4.3" +version = "4.4.4" description = "Liquidity mining" authors = ["GalacticCouncil"] edition = "2021" diff --git a/pallets/omnipool-liquidity-mining/Cargo.toml b/pallets/omnipool-liquidity-mining/Cargo.toml index 766187100..43a98096d 100644 --- a/pallets/omnipool-liquidity-mining/Cargo.toml +++ b/pallets/omnipool-liquidity-mining/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-omnipool-liquidity-mining" -version = "2.4.0" +version = "2.4.1" authors = ['GalacticCouncil'] edition = "2021" license = "Apache-2.0" diff --git a/pallets/otc-settlements/Cargo.toml b/pallets/otc-settlements/Cargo.toml index af12316ce..e48f38f74 100644 --- a/pallets/otc-settlements/Cargo.toml +++ b/pallets/otc-settlements/Cargo.toml @@ -1,6 +1,6 @@ [package] name = 'pallet-otc-settlements' -version = '1.0.5' +version = '1.1.0' description = 'A pallet with offchain worker closing OTC arbs' authors = ['GalacticCouncil'] edition = '2021' diff --git a/pallets/transaction-multi-payment/Cargo.toml b/pallets/transaction-multi-payment/Cargo.toml index a5c9d5237..7e7121a8c 100644 --- a/pallets/transaction-multi-payment/Cargo.toml +++ b/pallets/transaction-multi-payment/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-transaction-multi-payment" -version = "10.1.3" +version = "10.1.4" description = "Transaction multi currency payment support module" authors = ["GalacticCoucil"] edition = "2021" diff --git a/pallets/xyk/Cargo.toml b/pallets/xyk/Cargo.toml index f7a723515..b78d11c10 100644 --- a/pallets/xyk/Cargo.toml +++ b/pallets/xyk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = 'pallet-xyk' -version = "6.6.2" +version = "6.7.0" description = 'XYK automated market maker' authors = ['GalacticCouncil'] edition = '2021' diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml index 4892f5f2b..f8c1797e4 100644 --- a/primitives/Cargo.toml +++ b/primitives/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "primitives" -version = "6.1.0" +version = "6.1.1" authors = ["GalacticCouncil"] edition = "2021" repository = "https://github.com/galacticcouncil/HydraDX-node" diff --git a/runtime/adapters/Cargo.toml b/runtime/adapters/Cargo.toml index 95f763857..0fc8221ea 100644 --- a/runtime/adapters/Cargo.toml +++ b/runtime/adapters/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hydradx-adapters" -version = "1.3.8" +version = "1.3.9" description = "Structs and other generic types for building runtimes." authors = ["GalacticCouncil"] edition = "2021" diff --git a/runtime/hydradx/Cargo.toml b/runtime/hydradx/Cargo.toml index 29af89acc..64476b9f0 100644 --- a/runtime/hydradx/Cargo.toml +++ b/runtime/hydradx/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hydradx-runtime" -version = "271.0.0" +version = "272.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 824f04dcc..d1299694d 100644 --- a/runtime/hydradx/src/lib.rs +++ b/runtime/hydradx/src/lib.rs @@ -111,7 +111,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("hydradx"), impl_name: create_runtime_str!("hydradx"), authoring_version: 1, - spec_version: 271, + spec_version: 272, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, diff --git a/traits/Cargo.toml b/traits/Cargo.toml index fcf3fd4b9..e1cd13374 100644 --- a/traits/Cargo.toml +++ b/traits/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hydradx-traits" -version = "3.9.0" +version = "3.10.0" description = "Shared traits" authors = ["GalacticCouncil"] edition = "2021" From 2d829b63137170e29acf8800d6e6b28f0adf9b7f Mon Sep 17 00:00:00 2001 From: dmoka Date: Tue, 3 Dec 2024 17:27:10 +0100 Subject: [PATCH 065/142] add liquidty add and moreve to stableswap relevant swapped events --- pallets/stableswap/src/lib.rs | 8 ++++---- pallets/stableswap/src/tests/add_liquidity.rs | 4 ++-- pallets/stableswap/src/tests/remove_liquidity.rs | 4 ++-- traits/src/router.rs | 2 ++ 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/pallets/stableswap/src/lib.rs b/pallets/stableswap/src/lib.rs index 61bb94f35..53445858a 100644 --- a/pallets/stableswap/src/lib.rs +++ b/pallets/stableswap/src/lib.rs @@ -632,7 +632,7 @@ pub mod pallet { who, pool_account.clone(), pallet_amm_support::Filler::Stableswap(pool_id.into()), - pallet_amm_support::TradeOperation::ExactIn, + pallet_amm_support::TradeOperation::LiquidityRemove, vec![(AssetType::Fungible(pool_id.into()), share_amount)], vec![(AssetType::Fungible(asset_id.into()), amount)], vec![Fee { @@ -735,7 +735,7 @@ pub mod pallet { who, pool_account.clone(), pallet_amm_support::Filler::Stableswap(pool_id.into()), - pallet_amm_support::TradeOperation::ExactOut, + pallet_amm_support::TradeOperation::LiquidityRemove, vec![(AssetType::Fungible(pool_id.into()), shares)], vec![(AssetType::Fungible(asset_id.into()), amount)], fees, @@ -1274,7 +1274,7 @@ impl Pallet { who.clone(), pool_account.clone(), pallet_amm_support::Filler::Stableswap(pool_id.into()), - pallet_amm_support::TradeOperation::ExactIn, + pallet_amm_support::TradeOperation::LiquidityAdd, inputs, vec![(AssetType::Fungible(pool_id.into()), share_amount)], fees, @@ -1339,7 +1339,7 @@ impl Pallet { who.clone(), pool_account.clone(), pallet_amm_support::Filler::Stableswap(pool_id.into()), - pallet_amm_support::TradeOperation::ExactOut, + pallet_amm_support::TradeOperation::LiquidityAdd, vec![(AssetType::Fungible(asset_id.into()), amount_in)], vec![(AssetType::Fungible(pool_id.into()), shares)], vec![Fee { diff --git a/pallets/stableswap/src/tests/add_liquidity.rs b/pallets/stableswap/src/tests/add_liquidity.rs index 29fe5ca80..da2ebba02 100644 --- a/pallets/stableswap/src/tests/add_liquidity.rs +++ b/pallets/stableswap/src/tests/add_liquidity.rs @@ -111,7 +111,7 @@ fn add_liquidity_should_emit_swapped_events() { swapper: BOB, filler: pool_account, filler_type: pallet_amm_support::Filler::Stableswap(pool_id), - operation: pallet_amm_support::TradeOperation::ExactIn, + operation: pallet_amm_support::TradeOperation::LiquidityAdd, inputs: vec![(AssetType::Fungible(asset_a), 2000000000000000000),], outputs: vec![(AssetType::Fungible(pool_id), 1947487201901031408)], fees: vec![ @@ -714,7 +714,7 @@ fn add_liquidity_should_work_correctly_when_providing_exact_amount_of_shares() { swapper: BOB, filler: pool_account, filler_type: pallet_amm_support::Filler::Stableswap(pool_id), - operation: pallet_amm_support::TradeOperation::ExactOut, + operation: pallet_amm_support::TradeOperation::LiquidityAdd, inputs: vec![(AssetType::Fungible(asset_a), 2000000000000000003),], outputs: vec![(AssetType::Fungible(pool_id), 1947597621401945851)], fees: vec![Fee::new(pool_id, 0, pool_account)], diff --git a/pallets/stableswap/src/tests/remove_liquidity.rs b/pallets/stableswap/src/tests/remove_liquidity.rs index 3e3992109..8b5c8f497 100644 --- a/pallets/stableswap/src/tests/remove_liquidity.rs +++ b/pallets/stableswap/src/tests/remove_liquidity.rs @@ -79,7 +79,7 @@ fn remove_liquidity_should_work_when_withdrawing_all_shares() { swapper: BOB, filler: pool_account, filler_type: pallet_amm_support::Filler::Stableswap(pool_id), - operation: pallet_amm_support::TradeOperation::ExactIn, + operation: pallet_amm_support::TradeOperation::LiquidityRemove, inputs: vec![(AssetType::Fungible(pool_id), 200516043533380244763),], outputs: vec![(AssetType::Fungible(asset_c), 199999999999999)], fees: vec![Fee::new(pool_id, 0, pool_account)], @@ -1085,7 +1085,7 @@ fn removing_liquidity_with_exact_amount_should_emit_swapped_event() { swapper: BOB, filler: pool_account, filler_type: pallet_amm_support::Filler::Stableswap(4), - operation: pallet_amm_support::TradeOperation::ExactOut, + operation: pallet_amm_support::TradeOperation::LiquidityRemove, inputs: vec![(AssetType::Fungible(pool_id), 979387928052053203)], outputs: vec![(AssetType::Fungible(asset_a), 1000000000000000000),], fees: vec![ diff --git a/traits/src/router.rs b/traits/src/router.rs index 9d70e3812..b3dab0beb 100644 --- a/traits/src/router.rs +++ b/traits/src/router.rs @@ -92,6 +92,8 @@ pub enum TradeOperation { ExactIn, ExactOut, Limit, + LiquidityAdd, + LiquidityRemove, } #[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] From 30cdafde55df92c075801b3aac4244b237cd22b2 Mon Sep 17 00:00:00 2001 From: dmoka Date: Fri, 6 Dec 2024 12:24:39 +0100 Subject: [PATCH 066/142] split up swapped in omnipool sell --- integration-tests/src/dca.rs | 48 +++++++++--- integration-tests/src/router.rs | 40 ++++++---- pallets/circuit-breaker/src/tests/mock.rs | 2 +- pallets/dca/src/tests/mock.rs | 2 +- .../src/tests/mock.rs | 2 +- pallets/omnipool/src/lib.rs | 43 +++++++---- pallets/omnipool/src/tests/buy.rs | 59 --------------- pallets/omnipool/src/tests/mock.rs | 2 +- pallets/omnipool/src/tests/sell.rs | 73 +++++++++++++++++++ pallets/otc-settlements/src/mock.rs | 2 +- runtime/adapters/src/tests/mock.rs | 2 +- runtime/hydradx/src/assets.rs | 2 +- traits/src/router.rs | 1 + 13 files changed, 174 insertions(+), 104 deletions(-) diff --git a/integration-tests/src/dca.rs b/integration-tests/src/dca.rs index 78464a609..b479803f0 100644 --- a/integration-tests/src/dca.rs +++ b/integration-tests/src/dca.rs @@ -667,41 +667,65 @@ mod omnipool { //Assert let swapped_events = get_last_swapped_events(); + let last_two_swapped_events = &get_last_swapped_events()[swapped_events.len() - 2..]; pretty_assertions::assert_eq!( - *swapped_events.last().unwrap(), - RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + last_two_swapped_events, + vec![RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { swapper: ALICE.into(), filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::Filler::Omnipool, operation: pallet_amm_support::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(HDX), amount_to_sell)], - outputs: vec![(AssetType::Fungible(DAI), 71214372624126)], + outputs: vec![(AssetType::Fungible(LRNA), 49999999159957)], fees: vec![ - Fee::new(DAI, 178482136903, Omnipool::protocol_account()), Fee::new(LRNA, 24999999579, Omnipool::protocol_account()), ], - operation_id: vec![ExecutionType::DCA(0), ExecutionType::Router(1)], - }) + operation_id: vec![ExecutionType::DCA(0), ExecutionType::Router(1), ExecutionType::Omnipool(2)], + }), + RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + swapper: ALICE.into(), + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::Filler::Omnipool, + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(LRNA), 49974999160378)], + outputs: vec![(AssetType::Fungible(DAI), 71214372624126)], + fees: vec![ + Fee::new(DAI, 178482136903, Omnipool::protocol_account()), + ], + operation_id: vec![ExecutionType::DCA(0), ExecutionType::Router(1), ExecutionType::Omnipool(2)], + })] ); run_to_block(13, 17); let swapped_events = get_last_swapped_events(); + let last_two_swapped_events = &get_last_swapped_events()[swapped_events.len() - 2..]; pretty_assertions::assert_eq!( - *swapped_events.last().unwrap(), - RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + last_two_swapped_events, + vec![RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { swapper: ALICE.into(), filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::Filler::Omnipool, operation: pallet_amm_support::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(HDX), amount_to_sell)], - outputs: vec![(AssetType::Fungible(DAI), 71214367826179)], + outputs: vec![(AssetType::Fungible(LRNA), 49999997360044)], fees: vec![ - Fee::new(DAI, 178482124878, Omnipool::protocol_account()), Fee::new(LRNA, 24999998680, Omnipool::protocol_account()), ], - operation_id: vec![ExecutionType::DCA(2), ExecutionType::Router(3)], - }) + operation_id: vec![ExecutionType::DCA(3), ExecutionType::Router(4), ExecutionType::Omnipool(5)], + }), + RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + swapper: ALICE.into(), + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::Filler::Omnipool, + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(LRNA), 49974997361364)], + outputs: vec![(AssetType::Fungible(DAI), 71214367826179)], + fees: vec![ + Fee::new(DAI, 178482124878, Omnipool::protocol_account()), + ], + operation_id: vec![ExecutionType::DCA(3), ExecutionType::Router(4), ExecutionType::Omnipool(5)], + })] ); }); } diff --git a/integration-tests/src/router.rs b/integration-tests/src/router.rs index ee3541f9d..458322d04 100644 --- a/integration-tests/src/router.rs +++ b/integration-tests/src/router.rs @@ -2395,22 +2395,29 @@ mod omnipool_router_tests { assert_balance!(BOB.into(), DAI, BOB_INITIAL_DAI_BALANCE + amount_out); expect_hydra_last_events(vec![ - pallet_omnipool::Event::HubAmountUpdated { - hub_amount_in: 12014871681, - hub_amount_out: 12008864246, + pallet_amm_support::Event::Swapped { + swapper: BOB.into(), + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::Filler::Omnipool, + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(HDX), amount_to_sell)], + outputs: vec![(AssetType::Fungible(LRNA), 12014871681)], + fees: vec![ + Fee::new(LRNA, 6007435, Omnipool::protocol_account()), + ], operation_id: vec![ExecutionType::Router(0)], } - .into(), + .into(), + pallet_amm_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::Filler::Omnipool, operation: pallet_amm_support::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(HDX), amount_to_sell)], + inputs: vec![(AssetType::Fungible(LRNA), 12008864246)], outputs: vec![(AssetType::Fungible(DAI), amount_out)], fees: vec![ Fee::new(DAI, 667155563986401, Omnipool::protocol_account()), - Fee::new(LRNA, 6007435, Omnipool::protocol_account()), ], operation_id: vec![ExecutionType::Router(0)], } @@ -2455,26 +2462,33 @@ mod omnipool_router_tests { protocol_fee_amount: 6_007_435, } .into(), - pallet_omnipool::Event::HubAmountUpdated { - hub_amount_in: 12014871681, - hub_amount_out: 12008864246, + pallet_amm_support::Event::Swapped { + swapper: BOB.into(), + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::Filler::Omnipool, + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(HDX), amount_to_sell)], + outputs: vec![(AssetType::Fungible(LRNA), 12014871681)], + fees: vec![ + Fee::new(LRNA, 6007435, Omnipool::protocol_account()), + ], operation_id: vec![], } - .into(), + .into(), + pallet_amm_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::Filler::Omnipool, operation: pallet_amm_support::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(HDX), amount_to_sell)], + inputs: vec![(AssetType::Fungible(LRNA), 12008864246)], outputs: vec![(AssetType::Fungible(DAI), amount_out)], fees: vec![ Fee::new(DAI, 667155563986401, Omnipool::protocol_account()), - Fee::new(LRNA, 6007435, Omnipool::protocol_account()), ], operation_id: vec![], } - .into(), + .into(), ]); assert_balance!(BOB.into(), HDX, BOB_INITIAL_NATIVE_BALANCE - amount_to_sell); diff --git a/pallets/circuit-breaker/src/tests/mock.rs b/pallets/circuit-breaker/src/tests/mock.rs index f38aa5b3c..377c43ae3 100644 --- a/pallets/circuit-breaker/src/tests/mock.rs +++ b/pallets/circuit-breaker/src/tests/mock.rs @@ -230,7 +230,7 @@ impl pallet_omnipool::Config for Test { type MinWithdrawalFee = MinWithdrawFee; type ExternalPriceOracle = WithdrawFeePriceOracle; type Fee = FeeProvider; - type OperationIdProvider = AmmSupport; + type AmmUnifiedEventSupport = AmmSupport; } impl pallet_amm_support::Config for Test { diff --git a/pallets/dca/src/tests/mock.rs b/pallets/dca/src/tests/mock.rs index 2d28bd6dc..f2503d12c 100644 --- a/pallets/dca/src/tests/mock.rs +++ b/pallets/dca/src/tests/mock.rs @@ -265,7 +265,7 @@ impl pallet_omnipool::Config for Test { type MinWithdrawalFee = (); type ExternalPriceOracle = WithdrawFeePriceOracle; type Fee = FeeProvider; - type OperationIdProvider = AmmSupport; + type AmmUnifiedEventSupport = AmmSupport; } pub struct WithdrawFeePriceOracle; diff --git a/pallets/omnipool-liquidity-mining/src/tests/mock.rs b/pallets/omnipool-liquidity-mining/src/tests/mock.rs index 105146c2b..032bb4e7d 100644 --- a/pallets/omnipool-liquidity-mining/src/tests/mock.rs +++ b/pallets/omnipool-liquidity-mining/src/tests/mock.rs @@ -306,7 +306,7 @@ impl pallet_omnipool::Config for Test { type MinWithdrawalFee = MinWithdrawFee; type ExternalPriceOracle = WithdrawFeePriceOracle; type Fee = FeeProvider; - type OperationIdProvider = AmmSupport; + type AmmUnifiedEventSupport = AmmSupport; } impl pallet_amm_support::Config for Test { diff --git a/pallets/omnipool/src/lib.rs b/pallets/omnipool/src/lib.rs index 9ba6818b6..6c78143d5 100644 --- a/pallets/omnipool/src/lib.rs +++ b/pallets/omnipool/src/lib.rs @@ -138,6 +138,7 @@ pub mod pallet { use orml_traits::GetByKey; use pallet_amm_support::IncrementalIdType; use sp_runtime::ArithmeticError; + use hydradx_traits::IncrementalIdProvider; #[pallet::pallet] pub struct Pallet(_); @@ -236,7 +237,7 @@ pub mod pallet { type ExternalPriceOracle: ExternalPriceProvider; /// Operation id provider for unified events - type OperationIdProvider: ExecutionTypeStack; + type AmmUnifiedEventSupport: IncrementalIdProvider + ExecutionTypeStack; } #[pallet::storage] @@ -371,6 +372,7 @@ pub mod pallet { /// Asset's weight cap has been updated. AssetWeightCapUpdated { asset_id: T::AssetId, cap: Permill }, + //TODO: DELETE /// Amount of the Hub asset has been updated. HubAmountUpdated { hub_amount_in: Balance, @@ -1104,18 +1106,35 @@ pub mod pallet { protocol_fee_amount: state_changes.fee.protocol_fee, }); - Self::deposit_event(Event::HubAmountUpdated { - hub_amount_in: *state_changes.asset_in.delta_hub_reserve, - hub_amount_out: *state_changes.asset_out.delta_hub_reserve, - operation_id: T::OperationIdProvider::get(), - }); + let next_event_id = T::AmmUnifiedEventSupport::next_id().map_err(|_| ArithmeticError::Overflow)?; + T::AmmUnifiedEventSupport::push(ExecutionType::Omnipool(next_event_id))?; + //Swapped event for AssetA to HubAsset + pallet_amm_support::Pallet::::deposit_trade_event( + who.clone(), + Self::protocol_account(), + pallet_amm_support::Filler::Omnipool, + pallet_amm_support::TradeOperation::ExactIn, + vec![(AssetType::Fungible(asset_in.into()), amount)], + vec![( + AssetType::Fungible(T::HubAssetId::get().into()), + *state_changes.asset_in.delta_hub_reserve, + )], + vec![ + Fee::new( + T::HubAssetId::get().into(), + state_changes.fee.protocol_fee, + Self::protocol_account(), + ), + ], + ); + //Swapped event for HubAsset to AssetB pallet_amm_support::Pallet::::deposit_trade_event( who, Self::protocol_account(), pallet_amm_support::Filler::Omnipool, pallet_amm_support::TradeOperation::ExactIn, - vec![(AssetType::Fungible(asset_in.into()), amount)], + vec![(AssetType::Fungible(T::HubAssetId::get().into()), *state_changes.asset_out.delta_hub_reserve)], vec![( AssetType::Fungible(asset_out.into()), *state_changes.asset_out.delta_reserve, @@ -1126,14 +1145,11 @@ pub mod pallet { amount: state_changes.fee.asset_fee, recipient: Self::protocol_account(), }, - Fee::new( - T::HubAssetId::get().into(), - state_changes.fee.protocol_fee, - Self::protocol_account(), - ), ], ); + T::AmmUnifiedEventSupport::pop()?; + #[cfg(feature = "try-runtime")] Self::ensure_trade_invariant( (asset_in, asset_in_state, new_asset_in_state), @@ -1342,9 +1358,10 @@ pub mod pallet { Self::deposit_event(crate::pallet::Event::HubAmountUpdated { hub_amount_in: *state_changes.asset_in.delta_hub_reserve, hub_amount_out: *state_changes.asset_out.delta_hub_reserve, - operation_id: T::OperationIdProvider::get(), + operation_id: T::AmmUnifiedEventSupport::get(), }); + pallet_amm_support::Pallet::::deposit_trade_event( who, Self::protocol_account(), diff --git a/pallets/omnipool/src/tests/buy.rs b/pallets/omnipool/src/tests/buy.rs index 13df0c331..0fce0ff61 100644 --- a/pallets/omnipool/src/tests/buy.rs +++ b/pallets/omnipool/src/tests/buy.rs @@ -516,65 +516,6 @@ fn buy_should_emit_event_with_correct_protocol_fee_amount() { }); } -#[test] -fn sell_should_get_same_amount() { - ExtBuilder::default() - .with_endowed_accounts(vec![ - (Omnipool::protocol_account(), DAI, 1000 * ONE), - (Omnipool::protocol_account(), HDX, NATIVE_AMOUNT), - (LP2, 100, 2000 * ONE), - (LP3, 200, 2000 * ONE), - (LP1, 100, 1000 * ONE), - ]) - .with_registered_asset(100) - .with_registered_asset(200) - .with_asset_fee(Permill::from_percent(10)) - .with_initial_pool(FixedU128::from(1), FixedU128::from(1)) - .with_token(100, FixedU128::from(1), LP2, 2000 * ONE) - .with_token(200, FixedU128::from(1), LP3, 2000 * ONE) - .build() - .execute_with(|| { - let buy_amount = 50 * ONE; - let expected_sold_amount = 58_823_529_411_766; - - assert_ok!(Omnipool::sell( - RuntimeOrigin::signed(LP1), - 100, - 200, - expected_sold_amount, - 0 - )); - - expect_events(vec![ - Event::SellExecuted { - who: LP1, - asset_in: 100, - asset_out: 200, - amount_in: expected_sold_amount, - amount_out: buy_amount, - hub_amount_in: 57142857142858, - hub_amount_out: 57142857142858, - asset_fee_amount: 5555555555556, - protocol_fee_amount: 0, - } - .into(), - pallet_amm_support::Event::Swapped { - swapper: LP1, - filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(100), expected_sold_amount)], - outputs: vec![(AssetType::Fungible(200), buy_amount)], - fees: vec![ - Fee::new(200, 5555555555556, Omnipool::protocol_account()), - Fee::new(LRNA, 0, Omnipool::protocol_account()), - ], - operation_id: vec![], - } - .into(), - ]); - }); -} #[test] fn buy_should_fail_when_buying_more_than_in_pool() { diff --git a/pallets/omnipool/src/tests/mock.rs b/pallets/omnipool/src/tests/mock.rs index 09e155818..32bf18cc8 100644 --- a/pallets/omnipool/src/tests/mock.rs +++ b/pallets/omnipool/src/tests/mock.rs @@ -211,7 +211,7 @@ impl Config for Test { type MinWithdrawalFee = MinWithdrawFee; type ExternalPriceOracle = WithdrawFeePriceOracle; type Fee = FeeProvider; - type OperationIdProvider = AmmSupport; + type AmmUnifiedEventSupport = AmmSupport; } pub struct ExtBuilder { diff --git a/pallets/omnipool/src/tests/sell.rs b/pallets/omnipool/src/tests/sell.rs index 74cbeedee..ccfda6166 100644 --- a/pallets/omnipool/src/tests/sell.rs +++ b/pallets/omnipool/src/tests/sell.rs @@ -701,3 +701,76 @@ fn sell_lrna_should_fail_when_exceeds_max_out_ratio() { ); }); } + + +#[test] +fn sell_should_get_same_amount() { + ExtBuilder::default() + .with_endowed_accounts(vec![ + (Omnipool::protocol_account(), DAI, 1000 * ONE), + (Omnipool::protocol_account(), HDX, NATIVE_AMOUNT), + (LP2, 100, 2000 * ONE), + (LP3, 200, 2000 * ONE), + (LP1, 100, 1000 * ONE), + ]) + .with_registered_asset(100) + .with_registered_asset(200) + .with_asset_fee(Permill::from_percent(10)) + .with_initial_pool(FixedU128::from(1), FixedU128::from(1)) + .with_token(100, FixedU128::from(1), LP2, 2000 * ONE) + .with_token(200, FixedU128::from(1), LP3, 2000 * ONE) + .build() + .execute_with(|| { + let buy_amount = 50 * ONE; + let expected_sold_amount = 58_823_529_411_766; + + assert_ok!(Omnipool::sell( + RuntimeOrigin::signed(LP1), + 100, + 200, + expected_sold_amount, + 0 + )); + + expect_events(vec![ + Event::SellExecuted { + who: LP1, + asset_in: 100, + asset_out: 200, + amount_in: expected_sold_amount, + amount_out: buy_amount, + hub_amount_in: 57142857142858, + hub_amount_out: 57142857142858, + asset_fee_amount: 5555555555556, + protocol_fee_amount: 0, + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: LP1, + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::Filler::Omnipool, + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(100), expected_sold_amount)], + outputs: vec![(AssetType::Fungible(LRNA), 57142857142858)], + fees: vec![ + Fee::new(LRNA, 0, Omnipool::protocol_account()), + ], + operation_id: vec![ExecutionType::Omnipool(0)], + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: LP1, + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::Filler::Omnipool, + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(LRNA), 57142857142858)], + outputs: vec![(AssetType::Fungible(200), buy_amount)], + fees: vec![ + Fee::new(200, 5555555555556, Omnipool::protocol_account()), + ], + operation_id: vec![ExecutionType::Omnipool(0)], + } + .into() + ]); + }); +} \ No newline at end of file diff --git a/pallets/otc-settlements/src/mock.rs b/pallets/otc-settlements/src/mock.rs index 0dffe9481..a95614e03 100644 --- a/pallets/otc-settlements/src/mock.rs +++ b/pallets/otc-settlements/src/mock.rs @@ -352,7 +352,7 @@ impl pallet_omnipool::Config for Test { type MinWithdrawalFee = (); type ExternalPriceOracle = WithdrawFeePriceOracle; type Fee = FeeProvider; - type OperationIdProvider = AmmSupport; + type AmmUnifiedEventSupport = AmmSupport; } pub struct DummyNFT; diff --git a/runtime/adapters/src/tests/mock.rs b/runtime/adapters/src/tests/mock.rs index 59e4ad328..07278a582 100644 --- a/runtime/adapters/src/tests/mock.rs +++ b/runtime/adapters/src/tests/mock.rs @@ -217,7 +217,7 @@ impl pallet_omnipool::Config for Test { ); type MinWithdrawalFee = MinWithdrawFee; type ExternalPriceOracle = WithdrawFeePriceOracle; - type OperationIdProvider = AmmSupport; + type AmmUnifiedEventSupport = AmmSupport; } pub struct FeeProvider; diff --git a/runtime/hydradx/src/assets.rs b/runtime/hydradx/src/assets.rs index 37abc8ffc..c3adadda5 100644 --- a/runtime/hydradx/src/assets.rs +++ b/runtime/hydradx/src/assets.rs @@ -530,7 +530,7 @@ impl pallet_omnipool::Config for Runtime { ); type ExternalPriceOracle = EmaOraclePriceAdapter; type Fee = pallet_dynamic_fees::UpdateAndRetrieveFees; - type OperationIdProvider = AmmSupport; + type AmmUnifiedEventSupport = AmmSupport; } pub struct CircuitBreakerWhitelist; diff --git a/traits/src/router.rs b/traits/src/router.rs index b3dab0beb..782813d14 100644 --- a/traits/src/router.rs +++ b/traits/src/router.rs @@ -85,6 +85,7 @@ pub enum ExecutionType { DCA(IncrementalId), ICE(IncrementalId), Batch(IncrementalId), + Omnipool(IncrementalId) } #[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] From 8d98ceb33b0333ea303ecaa00a1d780b6bb12795 Mon Sep 17 00:00:00 2001 From: dmoka Date: Fri, 6 Dec 2024 12:50:35 +0100 Subject: [PATCH 067/142] split up swapped in omnipool buy --- Cargo.lock | 1 + integration-tests/src/dca.rs | 185 +++++++++++++++++------------ integration-tests/src/router.rs | 24 ++-- pallets/amm-support/src/lib.rs | 1 + pallets/omnipool/Cargo.toml | 1 + pallets/omnipool/src/lib.rs | 44 +++++-- pallets/omnipool/src/tests/buy.rs | 87 +++++++++++++- pallets/omnipool/src/tests/mock.rs | 4 + 8 files changed, 235 insertions(+), 112 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d2961ef2f..d2a8912a9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8782,6 +8782,7 @@ dependencies = [ "sp-runtime", "sp-std", "sp-tracing", + "test-utils", ] [[package]] diff --git a/integration-tests/src/dca.rs b/integration-tests/src/dca.rs index b479803f0..a297b58c0 100644 --- a/integration-tests/src/dca.rs +++ b/integration-tests/src/dca.rs @@ -218,40 +218,61 @@ mod omnipool { //Assert let swapped_events = get_last_swapped_events(); + let last_two_swapped_events = &get_last_swapped_events()[swapped_events.len() - 2..]; pretty_assertions::assert_eq!( - *swapped_events.last().unwrap(), - RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { - swapper: ALICE.into(), - filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::ExactOut, - inputs: vec![(AssetType::Fungible(HDX), 140421094367051)], - outputs: vec![(AssetType::Fungible(DAI), amount_out)], - fees: vec![ - Fee::new(DAI, 250626566417, Omnipool::protocol_account()), - Fee::new(LRNA, 35105272718, Omnipool::protocol_account()), - ], - operation_id: vec![ExecutionType::DCA(0), ExecutionType::Router(1)], - }) + last_two_swapped_events, + vec![ + RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + swapper: ALICE.into(), + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::Filler::Omnipool, + operation: pallet_amm_support::TradeOperation::ExactOut, + inputs: vec![(AssetType::Fungible(HDX), 140421094367051)], + outputs: vec![(AssetType::Fungible(LRNA), 70210545436437)], + fees: vec![Fee::new(LRNA, 35105272718, Omnipool::protocol_account()),], + operation_id: vec![ExecutionType::DCA(0), ExecutionType::Router(1), ExecutionType::Omnipool(2)] + }), + RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + swapper: ALICE.into(), + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::Filler::Omnipool, + operation: pallet_amm_support::TradeOperation::ExactOut, + inputs: vec![(AssetType::Fungible(LRNA), 70175440163719)], + outputs: vec![(AssetType::Fungible(DAI), amount_out)], + fees: vec![Fee::new(DAI, 250626566417, Omnipool::protocol_account()),], + operation_id: vec![ExecutionType::DCA(0), ExecutionType::Router(1), ExecutionType::Omnipool(2)], + }) + ] ); run_to_block(13, 17); + let swapped_events = get_last_swapped_events(); + let last_two_swapped_events = &get_last_swapped_events()[swapped_events.len() - 2..]; pretty_assertions::assert_eq!( - *swapped_events.last().unwrap(), - RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { - swapper: ALICE.into(), - filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::ExactOut, - inputs: vec![(AssetType::Fungible(HDX), 140421107716515)], - outputs: vec![(AssetType::Fungible(DAI), amount_out)], - fees: vec![ - Fee::new(DAI, 250626566417, Omnipool::protocol_account()), - Fee::new(LRNA, 35105274224, Omnipool::protocol_account()), - ], - operation_id: vec![ExecutionType::DCA(2), ExecutionType::Router(3)], - }) + last_two_swapped_events, + vec![ + RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + swapper: ALICE.into(), + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::Filler::Omnipool, + operation: pallet_amm_support::TradeOperation::ExactOut, + inputs: vec![(AssetType::Fungible(HDX), 140421107716515)], + outputs: vec![(AssetType::Fungible(LRNA), 70210548448729)], + fees: vec![Fee::new(LRNA, 35105274224, Omnipool::protocol_account()),], + operation_id: vec![ExecutionType::DCA(3), ExecutionType::Router(4), ExecutionType::Omnipool(5)], + }), + RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + swapper: ALICE.into(), + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::Filler::Omnipool, + operation: pallet_amm_support::TradeOperation::ExactOut, + inputs: vec![(AssetType::Fungible(LRNA), 70175443174505)], + outputs: vec![(AssetType::Fungible(DAI), amount_out)], + fees: vec![Fee::new(DAI, 250626566417, Omnipool::protocol_account()),], + operation_id: vec![ExecutionType::DCA(3), ExecutionType::Router(4), ExecutionType::Omnipool(5)], + }) + ] ); }); } @@ -670,30 +691,36 @@ mod omnipool { let last_two_swapped_events = &get_last_swapped_events()[swapped_events.len() - 2..]; pretty_assertions::assert_eq!( last_two_swapped_events, - vec![RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { - swapper: ALICE.into(), - filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(HDX), amount_to_sell)], - outputs: vec![(AssetType::Fungible(LRNA), 49999999159957)], - fees: vec![ - Fee::new(LRNA, 24999999579, Omnipool::protocol_account()), - ], - operation_id: vec![ExecutionType::DCA(0), ExecutionType::Router(1), ExecutionType::Omnipool(2)], - }), - RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { - swapper: ALICE.into(), - filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(LRNA), 49974999160378)], - outputs: vec![(AssetType::Fungible(DAI), 71214372624126)], - fees: vec![ - Fee::new(DAI, 178482136903, Omnipool::protocol_account()), - ], - operation_id: vec![ExecutionType::DCA(0), ExecutionType::Router(1), ExecutionType::Omnipool(2)], - })] + vec![ + RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + swapper: ALICE.into(), + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::Filler::Omnipool, + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(HDX), amount_to_sell)], + outputs: vec![(AssetType::Fungible(LRNA), 49999999159957)], + fees: vec![Fee::new(LRNA, 24999999579, Omnipool::protocol_account()),], + operation_id: vec![ + ExecutionType::DCA(0), + ExecutionType::Router(1), + ExecutionType::Omnipool(2) + ], + }), + RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + swapper: ALICE.into(), + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::Filler::Omnipool, + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(LRNA), 49974999160378)], + outputs: vec![(AssetType::Fungible(DAI), 71214372624126)], + fees: vec![Fee::new(DAI, 178482136903, Omnipool::protocol_account()),], + operation_id: vec![ + ExecutionType::DCA(0), + ExecutionType::Router(1), + ExecutionType::Omnipool(2) + ], + }) + ] ); run_to_block(13, 17); @@ -702,30 +729,36 @@ mod omnipool { let last_two_swapped_events = &get_last_swapped_events()[swapped_events.len() - 2..]; pretty_assertions::assert_eq!( last_two_swapped_events, - vec![RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { - swapper: ALICE.into(), - filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(HDX), amount_to_sell)], - outputs: vec![(AssetType::Fungible(LRNA), 49999997360044)], - fees: vec![ - Fee::new(LRNA, 24999998680, Omnipool::protocol_account()), - ], - operation_id: vec![ExecutionType::DCA(3), ExecutionType::Router(4), ExecutionType::Omnipool(5)], - }), - RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { - swapper: ALICE.into(), - filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(LRNA), 49974997361364)], - outputs: vec![(AssetType::Fungible(DAI), 71214367826179)], - fees: vec![ - Fee::new(DAI, 178482124878, Omnipool::protocol_account()), - ], - operation_id: vec![ExecutionType::DCA(3), ExecutionType::Router(4), ExecutionType::Omnipool(5)], - })] + vec![ + RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + swapper: ALICE.into(), + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::Filler::Omnipool, + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(HDX), amount_to_sell)], + outputs: vec![(AssetType::Fungible(LRNA), 49999997360044)], + fees: vec![Fee::new(LRNA, 24999998680, Omnipool::protocol_account()),], + operation_id: vec![ + ExecutionType::DCA(3), + ExecutionType::Router(4), + ExecutionType::Omnipool(5) + ], + }), + RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + swapper: ALICE.into(), + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::Filler::Omnipool, + operation: pallet_amm_support::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(LRNA), 49974997361364)], + outputs: vec![(AssetType::Fungible(DAI), 71214367826179)], + fees: vec![Fee::new(DAI, 178482124878, Omnipool::protocol_account()),], + operation_id: vec![ + ExecutionType::DCA(3), + ExecutionType::Router(4), + ExecutionType::Omnipool(5) + ], + }) + ] ); }); } diff --git a/integration-tests/src/router.rs b/integration-tests/src/router.rs index 458322d04..da68a0bed 100644 --- a/integration-tests/src/router.rs +++ b/integration-tests/src/router.rs @@ -2402,13 +2402,10 @@ mod omnipool_router_tests { operation: pallet_amm_support::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(HDX), amount_to_sell)], outputs: vec![(AssetType::Fungible(LRNA), 12014871681)], - fees: vec![ - Fee::new(LRNA, 6007435, Omnipool::protocol_account()), - ], + fees: vec![Fee::new(LRNA, 6007435, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Router(0)], } - .into(), - + .into(), pallet_amm_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), @@ -2416,9 +2413,7 @@ mod omnipool_router_tests { operation: pallet_amm_support::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(LRNA), 12008864246)], outputs: vec![(AssetType::Fungible(DAI), amount_out)], - fees: vec![ - Fee::new(DAI, 667155563986401, Omnipool::protocol_account()), - ], + fees: vec![Fee::new(DAI, 667155563986401, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Router(0)], } .into(), @@ -2469,13 +2464,10 @@ mod omnipool_router_tests { operation: pallet_amm_support::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(HDX), amount_to_sell)], outputs: vec![(AssetType::Fungible(LRNA), 12014871681)], - fees: vec![ - Fee::new(LRNA, 6007435, Omnipool::protocol_account()), - ], + fees: vec![Fee::new(LRNA, 6007435, Omnipool::protocol_account())], operation_id: vec![], } - .into(), - + .into(), pallet_amm_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), @@ -2483,12 +2475,10 @@ mod omnipool_router_tests { operation: pallet_amm_support::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(LRNA), 12008864246)], outputs: vec![(AssetType::Fungible(DAI), amount_out)], - fees: vec![ - Fee::new(DAI, 667155563986401, Omnipool::protocol_account()), - ], + fees: vec![Fee::new(DAI, 667155563986401, Omnipool::protocol_account())], operation_id: vec![], } - .into(), + .into(), ]); assert_balance!(BOB.into(), HDX, BOB_INITIAL_NATIVE_BALANCE - amount_to_sell); diff --git a/pallets/amm-support/src/lib.rs b/pallets/amm-support/src/lib.rs index d6915e493..2b47da66c 100644 --- a/pallets/amm-support/src/lib.rs +++ b/pallets/amm-support/src/lib.rs @@ -132,6 +132,7 @@ impl Pallet { outputs: Vec<(AssetType, Balance)>, fees: Vec>, ) { + let s = >::get(); Self::deposit_event(Event::::Swapped { swapper, filler, diff --git a/pallets/omnipool/Cargo.toml b/pallets/omnipool/Cargo.toml index 36479e19d..1226b3a9b 100644 --- a/pallets/omnipool/Cargo.toml +++ b/pallets/omnipool/Cargo.toml @@ -54,6 +54,7 @@ frame-benchmarking = { workspace = true } orml-tokens = { workspace = true } proptest = { workspace = true } pretty_assertions = { workspace = true } +test-utils = { workspace = true } [features] default = ["std"] diff --git a/pallets/omnipool/src/lib.rs b/pallets/omnipool/src/lib.rs index 6c78143d5..56e498ac3 100644 --- a/pallets/omnipool/src/lib.rs +++ b/pallets/omnipool/src/lib.rs @@ -1108,6 +1108,7 @@ pub mod pallet { let next_event_id = T::AmmUnifiedEventSupport::next_id().map_err(|_| ArithmeticError::Overflow)?; T::AmmUnifiedEventSupport::push(ExecutionType::Omnipool(next_event_id))?; + //Swapped event for AssetA to HubAsset pallet_amm_support::Pallet::::deposit_trade_event( who.clone(), @@ -1355,15 +1356,12 @@ pub mod pallet { protocol_fee_amount: state_changes.fee.protocol_fee, }); - Self::deposit_event(crate::pallet::Event::HubAmountUpdated { - hub_amount_in: *state_changes.asset_in.delta_hub_reserve, - hub_amount_out: *state_changes.asset_out.delta_hub_reserve, - operation_id: T::AmmUnifiedEventSupport::get(), - }); - + let next_event_id = T::AmmUnifiedEventSupport::next_id().map_err(|_| ArithmeticError::Overflow)?; + T::AmmUnifiedEventSupport::push(ExecutionType::Omnipool(next_event_id))?; + //Swapped even from AssetA to HubAsset pallet_amm_support::Pallet::::deposit_trade_event( - who, + who.clone(), Self::protocol_account(), pallet_amm_support::Filler::Omnipool, pallet_amm_support::TradeOperation::ExactOut, @@ -1371,6 +1369,29 @@ pub mod pallet { AssetType::Fungible(asset_in.into()), *state_changes.asset_in.delta_reserve, )], + vec![( + AssetType::Fungible(T::HubAssetId::get().into()), + *state_changes.asset_in.delta_hub_reserve, + )], + vec![ + Fee::new( + T::HubAssetId::get().into(), + state_changes.fee.protocol_fee, + Self::protocol_account(), + ), + ], + ); + + //Swapped even from HubAsset to AssetB + pallet_amm_support::Pallet::::deposit_trade_event( + who, + Self::protocol_account(), + pallet_amm_support::Filler::Omnipool, + pallet_amm_support::TradeOperation::ExactOut, + vec![( + AssetType::Fungible(T::HubAssetId::get().into()), + *state_changes.asset_out.delta_hub_reserve, + )], vec![( AssetType::Fungible(asset_out.into()), *state_changes.asset_out.delta_reserve, @@ -1381,14 +1402,11 @@ pub mod pallet { amount: state_changes.fee.asset_fee, recipient: Self::protocol_account(), }, - Fee::new( - T::HubAssetId::get().into(), - state_changes.fee.protocol_fee, - Self::protocol_account(), - ), ], ); + T::AmmUnifiedEventSupport::pop()?; + #[cfg(feature = "try-runtime")] Self::ensure_trade_invariant( (asset_in, asset_in_state, new_asset_in_state), @@ -1907,8 +1925,8 @@ impl Pallet { protocol_fee_amount: state_changes.fee.protocol_fee, }); - //No need to deposit `HubAmountUpdated` event as hub amounts are zero //No protocol fee in case of selling hub asset + //TODO: we need to split up too, and in the other place too pallet_amm_support::Pallet::::deposit_trade_event( who.clone(), Self::protocol_account(), diff --git a/pallets/omnipool/src/tests/buy.rs b/pallets/omnipool/src/tests/buy.rs index 0fce0ff61..e44384394 100644 --- a/pallets/omnipool/src/tests/buy.rs +++ b/pallets/omnipool/src/tests/buy.rs @@ -424,7 +424,7 @@ fn buy_should_emit_event_with_correct_asset_fee_amount() { max_limit )); - expect_events(vec![ + expect_last_events(vec![ Event::BuyExecuted { who: LP1, asset_in: 100, @@ -443,14 +443,77 @@ fn buy_should_emit_event_with_correct_asset_fee_amount() { filler_type: pallet_amm_support::Filler::Omnipool, operation: pallet_amm_support::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(100), expected_sold_amount)], + outputs: vec![(AssetType::Fungible(1), 57142857142858)], + fees: vec![ + Fee::new(LRNA, 0, Omnipool::protocol_account()), + ], + operation_id: vec![ExecutionType::Omnipool(0)], + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: LP1, + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::Filler::Omnipool, + operation: pallet_amm_support::TradeOperation::ExactOut, + inputs: vec![(AssetType::Fungible(1), 57142857142858)], outputs: vec![(AssetType::Fungible(200), buy_amount)], fees: vec![ Fee::new(200, 5555555555556, Omnipool::protocol_account()), + ], + operation_id: vec![ExecutionType::Omnipool(0)], + } + .into(), + ]); + + let other_buy_amount = buy_amount + 100; + //We check again to see if the operation id is correct + assert_ok!(Omnipool::buy( + RuntimeOrigin::signed(LP1), + 200, + 100, + other_buy_amount, + max_limit + )); + + expect_last_events(vec![ + Event::BuyExecuted { + who: LP1, + asset_in: 100, + asset_out: 200, + amount_in: 65976185738813, + amount_out: other_buy_amount, + hub_amount_in: 60326770004314, + hub_amount_out: 60326770004314, + asset_fee_amount: 5555555555567, + protocol_fee_amount: 0, + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: LP1, + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::Filler::Omnipool, + operation: pallet_amm_support::TradeOperation::ExactOut, + inputs: vec![(AssetType::Fungible(100), 65976185738813)], + outputs: vec![(AssetType::Fungible(1), 60326770004314)], + fees: vec![ Fee::new(LRNA, 0, Omnipool::protocol_account()), ], - operation_id: vec![], + operation_id: vec![ExecutionType::Omnipool(1)], } - .into(), + .into(), + pallet_amm_support::Event::Swapped { + swapper: LP1, + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::Filler::Omnipool, + operation: pallet_amm_support::TradeOperation::ExactOut, + inputs: vec![(AssetType::Fungible(1), 60326770004314)], + outputs: vec![(AssetType::Fungible(200), other_buy_amount)], + fees: vec![ + Fee::new(200, 5555555555567, Omnipool::protocol_account()), + ], + operation_id: vec![ExecutionType::Omnipool(1)], + } + .into(), ]); }); } @@ -504,14 +567,26 @@ fn buy_should_emit_event_with_correct_protocol_fee_amount() { filler_type: pallet_amm_support::Filler::Omnipool, operation: pallet_amm_support::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(100), expected_sold_amount)], - outputs: vec![(AssetType::Fungible(200), buy_amount)], + outputs: vec![(AssetType::Fungible(1), 56980056980057)], fees: vec![ - Fee::new(200, 0, Omnipool::protocol_account()), Fee::new(LRNA, 5698005698005, Omnipool::protocol_account()), ], - operation_id: vec![], + operation_id: vec![ExecutionType::Omnipool(0)], } .into(), + pallet_amm_support::Event::Swapped { + swapper: LP1, + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::Filler::Omnipool, + operation: pallet_amm_support::TradeOperation::ExactOut, + inputs: vec![(AssetType::Fungible(1), 51282051282052)], + outputs: vec![(AssetType::Fungible(200), buy_amount)], + fees: vec![ + Fee::new(200, 0, Omnipool::protocol_account()), + ], + operation_id: vec![ExecutionType::Omnipool(0)], + } + .into(), ]); }); } diff --git a/pallets/omnipool/src/tests/mock.rs b/pallets/omnipool/src/tests/mock.rs index 32bf18cc8..b4d4a645f 100644 --- a/pallets/omnipool/src/tests/mock.rs +++ b/pallets/omnipool/src/tests/mock.rs @@ -690,6 +690,10 @@ pub(crate) fn expect_events(e: Vec) { e.into_iter().for_each(frame_system::Pallet::::assert_has_event); } +pub fn expect_last_events(e: Vec) { + test_utils::expect_events::(e); +} + pub struct MockHooks; impl OmnipoolHooks for MockHooks { From 5291f1c5428ae9b51477378b756985c92ee3ac51 Mon Sep 17 00:00:00 2001 From: dmoka Date: Fri, 6 Dec 2024 12:51:36 +0100 Subject: [PATCH 068/142] cleaning up --- pallets/amm-support/src/lib.rs | 1 - pallets/omnipool/src/lib.rs | 8 -------- 2 files changed, 9 deletions(-) diff --git a/pallets/amm-support/src/lib.rs b/pallets/amm-support/src/lib.rs index 2b47da66c..d6915e493 100644 --- a/pallets/amm-support/src/lib.rs +++ b/pallets/amm-support/src/lib.rs @@ -132,7 +132,6 @@ impl Pallet { outputs: Vec<(AssetType, Balance)>, fees: Vec>, ) { - let s = >::get(); Self::deposit_event(Event::::Swapped { swapper, filler, diff --git a/pallets/omnipool/src/lib.rs b/pallets/omnipool/src/lib.rs index 56e498ac3..92bfb618f 100644 --- a/pallets/omnipool/src/lib.rs +++ b/pallets/omnipool/src/lib.rs @@ -371,14 +371,6 @@ pub mod pallet { /// Asset's weight cap has been updated. AssetWeightCapUpdated { asset_id: T::AssetId, cap: Permill }, - - //TODO: DELETE - /// Amount of the Hub asset has been updated. - HubAmountUpdated { - hub_amount_in: Balance, - hub_amount_out: Balance, - operation_id: Vec>, - }, } #[pallet::error] From 64e0b9b020be5ba27a772c02ffd23362b12156e1 Mon Sep 17 00:00:00 2001 From: dmoka Date: Fri, 6 Dec 2024 13:15:55 +0100 Subject: [PATCH 069/142] fix some tests --- integration-tests/src/referrals.rs | 45 +++++++++++++++++++----------- integration-tests/src/router.rs | 8 +++--- pallets/omnipool/src/lib.rs | 1 - 3 files changed, 33 insertions(+), 21 deletions(-) diff --git a/integration-tests/src/referrals.rs b/integration-tests/src/referrals.rs index 853b21a15..5d974ff6b 100644 --- a/integration-tests/src/referrals.rs +++ b/integration-tests/src/referrals.rs @@ -352,10 +352,17 @@ fn buying_hdx_in_omnipool_should_transfer_correct_fee() { protocol_fee_amount: 604_873, } .into(), - pallet_omnipool::Event::HubAmountUpdated { - hub_amount_in: 1_209_746_177, - hub_amount_out: 1_209_141_304, - operation_id: vec![], + pallet_amm_support::Event::Swapped { + swapper: BOB.into(), + filler: Omnipool::protocol_account(), + filler_type: Filler::Omnipool, + operation: TradeOperation::ExactOut, + inputs: vec![(AssetType::Fungible(DAI), 26_835_579_541_620_354)], + outputs: vec![(AssetType::Fungible(LRNA), 1_209_746_177)], + fees: vec![ + Fee::new(LRNA, 604_873, Omnipool::protocol_account()), + ], + operation_id: vec![ExecutionType::Omnipool(0)], } .into(), pallet_amm_support::Event::Swapped { @@ -363,15 +370,14 @@ fn buying_hdx_in_omnipool_should_transfer_correct_fee() { filler: Omnipool::protocol_account(), filler_type: Filler::Omnipool, operation: TradeOperation::ExactOut, - inputs: vec![(AssetType::Fungible(DAI), 26_835_579_541_620_354)], + inputs: vec![(AssetType::Fungible(LRNA), 1_209_141_304)], outputs: vec![(AssetType::Fungible(HDX), 1_000_000_000_000)], fees: vec![ Fee::new(HDX, 2_794_789_078, Omnipool::protocol_account()), - Fee::new(LRNA, 604_873, Omnipool::protocol_account()), ], - operation_id: vec![], + operation_id: vec![ExecutionType::Omnipool(0)], } - .into(), + .into(), ]); let ref_dai_balance = Currencies::free_balance(DAI, &ref_account); @@ -411,10 +417,17 @@ fn buying_with_hdx_in_omnipool_should_transfer_correct_fee() { protocol_fee_amount: 22_611_356, } .into(), - pallet_omnipool::Event::HubAmountUpdated { - hub_amount_in: 45_222_713_080, - hub_amount_out: 45_200_101_724, - operation_id: vec![], + pallet_amm_support::Event::Swapped { + swapper: BOB.into(), + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::Filler::Omnipool, + operation: pallet_amm_support::TradeOperation::ExactOut, + inputs: vec![(AssetType::Fungible(HDX), 37_506_757_329_085)], + outputs: vec![(AssetType::Fungible(LRNA), 45_222_713_080)], + fees: vec![ + Fee::new(LRNA, 22_611_356, Omnipool::protocol_account()), + ], + operation_id: vec![ExecutionType::Omnipool(0)], } .into(), pallet_amm_support::Event::Swapped { @@ -422,15 +435,14 @@ fn buying_with_hdx_in_omnipool_should_transfer_correct_fee() { filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::Filler::Omnipool, operation: pallet_amm_support::TradeOperation::ExactOut, - inputs: vec![(AssetType::Fungible(HDX), 37_506_757_329_085)], + inputs: vec![(AssetType::Fungible(LRNA), 45_200_101_724)], outputs: vec![(AssetType::Fungible(DAI), 1_000_000_000_000_000_000)], fees: vec![ Fee::new(DAI, 2_644_977_450_514_458, Omnipool::protocol_account()), - Fee::new(LRNA, 22_611_356, Omnipool::protocol_account()), ], - operation_id: vec![], + operation_id: vec![ExecutionType::Omnipool(0)], } - .into(), + .into(), ]); let ref_dai_balance = Currencies::free_balance(DAI, &ref_account); @@ -567,6 +579,7 @@ fn seed_pot_account() { use scraper::ALICE; use sp_core::crypto::Ss58Codec; +use hydradx_traits::router::ExecutionType; pub const PARACHAIN_CODES: [(&str, &str); 12] = [ ("MOONBEAM", "7LCt6dFmtiRrwZv2YyEgQWW3GxsGX3Krmgzv9Xj7GQ9tG2j8"), diff --git a/integration-tests/src/router.rs b/integration-tests/src/router.rs index da68a0bed..0aaed5f14 100644 --- a/integration-tests/src/router.rs +++ b/integration-tests/src/router.rs @@ -2403,7 +2403,7 @@ mod omnipool_router_tests { inputs: vec![(AssetType::Fungible(HDX), amount_to_sell)], outputs: vec![(AssetType::Fungible(LRNA), 12014871681)], fees: vec![Fee::new(LRNA, 6007435, Omnipool::protocol_account())], - operation_id: vec![ExecutionType::Router(0)], + operation_id: vec![ExecutionType::Router(0), ExecutionType::Omnipool(1)], } .into(), pallet_amm_support::Event::Swapped { @@ -2414,7 +2414,7 @@ mod omnipool_router_tests { inputs: vec![(AssetType::Fungible(LRNA), 12008864246)], outputs: vec![(AssetType::Fungible(DAI), amount_out)], fees: vec![Fee::new(DAI, 667155563986401, Omnipool::protocol_account())], - operation_id: vec![ExecutionType::Router(0)], + operation_id: vec![ExecutionType::Router(0), ExecutionType::Omnipool(1)], } .into(), pallet_route_executor::Event::Executed { @@ -2465,7 +2465,7 @@ mod omnipool_router_tests { inputs: vec![(AssetType::Fungible(HDX), amount_to_sell)], outputs: vec![(AssetType::Fungible(LRNA), 12014871681)], fees: vec![Fee::new(LRNA, 6007435, Omnipool::protocol_account())], - operation_id: vec![], + operation_id: vec![ExecutionType::Omnipool(0)], } .into(), pallet_amm_support::Event::Swapped { @@ -2476,7 +2476,7 @@ mod omnipool_router_tests { inputs: vec![(AssetType::Fungible(LRNA), 12008864246)], outputs: vec![(AssetType::Fungible(DAI), amount_out)], fees: vec![Fee::new(DAI, 667155563986401, Omnipool::protocol_account())], - operation_id: vec![], + operation_id: vec![ExecutionType::Omnipool(0)], } .into(), ]); diff --git a/pallets/omnipool/src/lib.rs b/pallets/omnipool/src/lib.rs index 92bfb618f..58e5b1906 100644 --- a/pallets/omnipool/src/lib.rs +++ b/pallets/omnipool/src/lib.rs @@ -2047,7 +2047,6 @@ impl Pallet { protocol_fee_amount: state_changes.fee.protocol_fee, }); - //No need to deposit `HubAmountUpdated` event as hub amounts are zero //No protocol fee in case of buying asset for hub asset pallet_amm_support::Pallet::::deposit_trade_event( who.clone(), From b31de5da0dd835b101c73f0cc5d84c6fb2b0643c Mon Sep 17 00:00:00 2001 From: dmoka Date: Mon, 9 Dec 2024 10:30:26 +0400 Subject: [PATCH 070/142] formatting --- integration-tests/src/dca.rs | 24 ++++++++++--- integration-tests/src/referrals.rs | 22 ++++-------- pallets/omnipool/src/lib.rs | 55 ++++++++++++++---------------- pallets/omnipool/src/tests/buy.rs | 37 +++++++------------- pallets/omnipool/src/tests/sell.rs | 17 ++++----- traits/src/router.rs | 2 +- 6 files changed, 71 insertions(+), 86 deletions(-) diff --git a/integration-tests/src/dca.rs b/integration-tests/src/dca.rs index a297b58c0..f155e6ac8 100644 --- a/integration-tests/src/dca.rs +++ b/integration-tests/src/dca.rs @@ -230,7 +230,11 @@ mod omnipool { inputs: vec![(AssetType::Fungible(HDX), 140421094367051)], outputs: vec![(AssetType::Fungible(LRNA), 70210545436437)], fees: vec![Fee::new(LRNA, 35105272718, Omnipool::protocol_account()),], - operation_id: vec![ExecutionType::DCA(0), ExecutionType::Router(1), ExecutionType::Omnipool(2)] + operation_id: vec![ + ExecutionType::DCA(0), + ExecutionType::Router(1), + ExecutionType::Omnipool(2) + ] }), RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { swapper: ALICE.into(), @@ -240,7 +244,11 @@ mod omnipool { inputs: vec![(AssetType::Fungible(LRNA), 70175440163719)], outputs: vec![(AssetType::Fungible(DAI), amount_out)], fees: vec![Fee::new(DAI, 250626566417, Omnipool::protocol_account()),], - operation_id: vec![ExecutionType::DCA(0), ExecutionType::Router(1), ExecutionType::Omnipool(2)], + operation_id: vec![ + ExecutionType::DCA(0), + ExecutionType::Router(1), + ExecutionType::Omnipool(2) + ], }) ] ); @@ -260,7 +268,11 @@ mod omnipool { inputs: vec![(AssetType::Fungible(HDX), 140421107716515)], outputs: vec![(AssetType::Fungible(LRNA), 70210548448729)], fees: vec![Fee::new(LRNA, 35105274224, Omnipool::protocol_account()),], - operation_id: vec![ExecutionType::DCA(3), ExecutionType::Router(4), ExecutionType::Omnipool(5)], + operation_id: vec![ + ExecutionType::DCA(3), + ExecutionType::Router(4), + ExecutionType::Omnipool(5) + ], }), RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { swapper: ALICE.into(), @@ -270,7 +282,11 @@ mod omnipool { inputs: vec![(AssetType::Fungible(LRNA), 70175443174505)], outputs: vec![(AssetType::Fungible(DAI), amount_out)], fees: vec![Fee::new(DAI, 250626566417, Omnipool::protocol_account()),], - operation_id: vec![ExecutionType::DCA(3), ExecutionType::Router(4), ExecutionType::Omnipool(5)], + operation_id: vec![ + ExecutionType::DCA(3), + ExecutionType::Router(4), + ExecutionType::Omnipool(5) + ], }) ] ); diff --git a/integration-tests/src/referrals.rs b/integration-tests/src/referrals.rs index 5d974ff6b..e2b8ca9bc 100644 --- a/integration-tests/src/referrals.rs +++ b/integration-tests/src/referrals.rs @@ -359,9 +359,7 @@ fn buying_hdx_in_omnipool_should_transfer_correct_fee() { operation: TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(DAI), 26_835_579_541_620_354)], outputs: vec![(AssetType::Fungible(LRNA), 1_209_746_177)], - fees: vec![ - Fee::new(LRNA, 604_873, Omnipool::protocol_account()), - ], + fees: vec![Fee::new(LRNA, 604_873, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Omnipool(0)], } .into(), @@ -372,12 +370,10 @@ fn buying_hdx_in_omnipool_should_transfer_correct_fee() { operation: TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(LRNA), 1_209_141_304)], outputs: vec![(AssetType::Fungible(HDX), 1_000_000_000_000)], - fees: vec![ - Fee::new(HDX, 2_794_789_078, Omnipool::protocol_account()), - ], + fees: vec![Fee::new(HDX, 2_794_789_078, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Omnipool(0)], } - .into(), + .into(), ]); let ref_dai_balance = Currencies::free_balance(DAI, &ref_account); @@ -424,9 +420,7 @@ fn buying_with_hdx_in_omnipool_should_transfer_correct_fee() { operation: pallet_amm_support::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(HDX), 37_506_757_329_085)], outputs: vec![(AssetType::Fungible(LRNA), 45_222_713_080)], - fees: vec![ - Fee::new(LRNA, 22_611_356, Omnipool::protocol_account()), - ], + fees: vec![Fee::new(LRNA, 22_611_356, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Omnipool(0)], } .into(), @@ -437,12 +431,10 @@ fn buying_with_hdx_in_omnipool_should_transfer_correct_fee() { operation: pallet_amm_support::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(LRNA), 45_200_101_724)], outputs: vec![(AssetType::Fungible(DAI), 1_000_000_000_000_000_000)], - fees: vec![ - Fee::new(DAI, 2_644_977_450_514_458, Omnipool::protocol_account()), - ], + fees: vec![Fee::new(DAI, 2_644_977_450_514_458, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Omnipool(0)], } - .into(), + .into(), ]); let ref_dai_balance = Currencies::free_balance(DAI, &ref_account); @@ -577,9 +569,9 @@ fn seed_pot_account() { )); } +use hydradx_traits::router::ExecutionType; use scraper::ALICE; use sp_core::crypto::Ss58Codec; -use hydradx_traits::router::ExecutionType; pub const PARACHAIN_CODES: [(&str, &str); 12] = [ ("MOONBEAM", "7LCt6dFmtiRrwZv2YyEgQWW3GxsGX3Krmgzv9Xj7GQ9tG2j8"), diff --git a/pallets/omnipool/src/lib.rs b/pallets/omnipool/src/lib.rs index 58e5b1906..8013565eb 100644 --- a/pallets/omnipool/src/lib.rs +++ b/pallets/omnipool/src/lib.rs @@ -135,10 +135,10 @@ pub mod pallet { use frame_system::pallet_prelude::*; use hydra_dx_math::ema::EmaPrice; use hydra_dx_math::omnipool::types::{BalanceUpdate, I129}; + use hydradx_traits::IncrementalIdProvider; use orml_traits::GetByKey; use pallet_amm_support::IncrementalIdType; use sp_runtime::ArithmeticError; - use hydradx_traits::IncrementalIdProvider; #[pallet::pallet] pub struct Pallet(_); @@ -1112,13 +1112,11 @@ pub mod pallet { AssetType::Fungible(T::HubAssetId::get().into()), *state_changes.asset_in.delta_hub_reserve, )], - vec![ - Fee::new( - T::HubAssetId::get().into(), - state_changes.fee.protocol_fee, - Self::protocol_account(), - ), - ], + vec![Fee::new( + T::HubAssetId::get().into(), + state_changes.fee.protocol_fee, + Self::protocol_account(), + )], ); //Swapped event for HubAsset to AssetB @@ -1127,18 +1125,19 @@ pub mod pallet { Self::protocol_account(), pallet_amm_support::Filler::Omnipool, pallet_amm_support::TradeOperation::ExactIn, - vec![(AssetType::Fungible(T::HubAssetId::get().into()), *state_changes.asset_out.delta_hub_reserve)], + vec![( + AssetType::Fungible(T::HubAssetId::get().into()), + *state_changes.asset_out.delta_hub_reserve, + )], vec![( AssetType::Fungible(asset_out.into()), *state_changes.asset_out.delta_reserve, )], - vec![ - Fee { - asset: asset_out.into(), - amount: state_changes.fee.asset_fee, - recipient: Self::protocol_account(), - }, - ], + vec![Fee { + asset: asset_out.into(), + amount: state_changes.fee.asset_fee, + recipient: Self::protocol_account(), + }], ); T::AmmUnifiedEventSupport::pop()?; @@ -1365,13 +1364,11 @@ pub mod pallet { AssetType::Fungible(T::HubAssetId::get().into()), *state_changes.asset_in.delta_hub_reserve, )], - vec![ - Fee::new( - T::HubAssetId::get().into(), - state_changes.fee.protocol_fee, - Self::protocol_account(), - ), - ], + vec![Fee::new( + T::HubAssetId::get().into(), + state_changes.fee.protocol_fee, + Self::protocol_account(), + )], ); //Swapped even from HubAsset to AssetB @@ -1388,13 +1385,11 @@ pub mod pallet { AssetType::Fungible(asset_out.into()), *state_changes.asset_out.delta_reserve, )], - vec![ - Fee { - asset: asset_out.into(), - amount: state_changes.fee.asset_fee, - recipient: Self::protocol_account(), - }, - ], + vec![Fee { + asset: asset_out.into(), + amount: state_changes.fee.asset_fee, + recipient: Self::protocol_account(), + }], ); T::AmmUnifiedEventSupport::pop()?; diff --git a/pallets/omnipool/src/tests/buy.rs b/pallets/omnipool/src/tests/buy.rs index e44384394..89661b676 100644 --- a/pallets/omnipool/src/tests/buy.rs +++ b/pallets/omnipool/src/tests/buy.rs @@ -444,9 +444,7 @@ fn buy_should_emit_event_with_correct_asset_fee_amount() { operation: pallet_amm_support::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(100), expected_sold_amount)], outputs: vec![(AssetType::Fungible(1), 57142857142858)], - fees: vec![ - Fee::new(LRNA, 0, Omnipool::protocol_account()), - ], + fees: vec![Fee::new(LRNA, 0, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Omnipool(0)], } .into(), @@ -457,15 +455,13 @@ fn buy_should_emit_event_with_correct_asset_fee_amount() { operation: pallet_amm_support::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(1), 57142857142858)], outputs: vec![(AssetType::Fungible(200), buy_amount)], - fees: vec![ - Fee::new(200, 5555555555556, Omnipool::protocol_account()), - ], + fees: vec![Fee::new(200, 5555555555556, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Omnipool(0)], } - .into(), + .into(), ]); - let other_buy_amount = buy_amount + 100; + let other_buy_amount = buy_amount + 100; //We check again to see if the operation id is correct assert_ok!(Omnipool::buy( RuntimeOrigin::signed(LP1), @@ -487,7 +483,7 @@ fn buy_should_emit_event_with_correct_asset_fee_amount() { asset_fee_amount: 5555555555567, protocol_fee_amount: 0, } - .into(), + .into(), pallet_amm_support::Event::Swapped { swapper: LP1, filler: Omnipool::protocol_account(), @@ -495,12 +491,10 @@ fn buy_should_emit_event_with_correct_asset_fee_amount() { operation: pallet_amm_support::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(100), 65976185738813)], outputs: vec![(AssetType::Fungible(1), 60326770004314)], - fees: vec![ - Fee::new(LRNA, 0, Omnipool::protocol_account()), - ], + fees: vec![Fee::new(LRNA, 0, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Omnipool(1)], } - .into(), + .into(), pallet_amm_support::Event::Swapped { swapper: LP1, filler: Omnipool::protocol_account(), @@ -508,12 +502,10 @@ fn buy_should_emit_event_with_correct_asset_fee_amount() { operation: pallet_amm_support::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(1), 60326770004314)], outputs: vec![(AssetType::Fungible(200), other_buy_amount)], - fees: vec![ - Fee::new(200, 5555555555567, Omnipool::protocol_account()), - ], + fees: vec![Fee::new(200, 5555555555567, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Omnipool(1)], } - .into(), + .into(), ]); }); } @@ -568,9 +560,7 @@ fn buy_should_emit_event_with_correct_protocol_fee_amount() { operation: pallet_amm_support::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(100), expected_sold_amount)], outputs: vec![(AssetType::Fungible(1), 56980056980057)], - fees: vec![ - Fee::new(LRNA, 5698005698005, Omnipool::protocol_account()), - ], + fees: vec![Fee::new(LRNA, 5698005698005, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Omnipool(0)], } .into(), @@ -581,17 +571,14 @@ fn buy_should_emit_event_with_correct_protocol_fee_amount() { operation: pallet_amm_support::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(1), 51282051282052)], outputs: vec![(AssetType::Fungible(200), buy_amount)], - fees: vec![ - Fee::new(200, 0, Omnipool::protocol_account()), - ], + fees: vec![Fee::new(200, 0, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Omnipool(0)], } - .into(), + .into(), ]); }); } - #[test] fn buy_should_fail_when_buying_more_than_in_pool() { ExtBuilder::default() diff --git a/pallets/omnipool/src/tests/sell.rs b/pallets/omnipool/src/tests/sell.rs index ccfda6166..8d22d213f 100644 --- a/pallets/omnipool/src/tests/sell.rs +++ b/pallets/omnipool/src/tests/sell.rs @@ -702,7 +702,6 @@ fn sell_lrna_should_fail_when_exceeds_max_out_ratio() { }); } - #[test] fn sell_should_get_same_amount() { ExtBuilder::default() @@ -744,7 +743,7 @@ fn sell_should_get_same_amount() { asset_fee_amount: 5555555555556, protocol_fee_amount: 0, } - .into(), + .into(), pallet_amm_support::Event::Swapped { swapper: LP1, filler: Omnipool::protocol_account(), @@ -752,12 +751,10 @@ fn sell_should_get_same_amount() { operation: pallet_amm_support::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(100), expected_sold_amount)], outputs: vec![(AssetType::Fungible(LRNA), 57142857142858)], - fees: vec![ - Fee::new(LRNA, 0, Omnipool::protocol_account()), - ], + fees: vec![Fee::new(LRNA, 0, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Omnipool(0)], } - .into(), + .into(), pallet_amm_support::Event::Swapped { swapper: LP1, filler: Omnipool::protocol_account(), @@ -765,12 +762,10 @@ fn sell_should_get_same_amount() { operation: pallet_amm_support::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(LRNA), 57142857142858)], outputs: vec![(AssetType::Fungible(200), buy_amount)], - fees: vec![ - Fee::new(200, 5555555555556, Omnipool::protocol_account()), - ], + fees: vec![Fee::new(200, 5555555555556, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Omnipool(0)], } - .into() + .into(), ]); }); -} \ No newline at end of file +} diff --git a/traits/src/router.rs b/traits/src/router.rs index 782813d14..1fce28024 100644 --- a/traits/src/router.rs +++ b/traits/src/router.rs @@ -85,7 +85,7 @@ pub enum ExecutionType { DCA(IncrementalId), ICE(IncrementalId), Batch(IncrementalId), - Omnipool(IncrementalId) + Omnipool(IncrementalId), } #[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] From 5202a70475218ffeeb9b81022bdcb589214226e2 Mon Sep 17 00:00:00 2001 From: dmoka Date: Mon, 9 Dec 2024 10:48:59 +0400 Subject: [PATCH 071/142] fix not compiling tests --- integration-tests/src/router.rs | 46 ++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/integration-tests/src/router.rs b/integration-tests/src/router.rs index 0aaed5f14..c9b18b8fe 100644 --- a/integration-tests/src/router.rs +++ b/integration-tests/src/router.rs @@ -1140,7 +1140,7 @@ mod omnipool_router_tests { use super::*; use frame_support::assert_noop; use hydradx_runtime::{Balances, XYK}; - use hydradx_traits::router::PoolType; + use hydradx_traits::router::{ExecutionType, PoolType}; use hydradx_traits::AssetKind; #[test] @@ -2625,10 +2625,15 @@ mod omnipool_router_tests { assert_balance!(BOB.into(), DAI, BOB_INITIAL_DAI_BALANCE + amount_to_buy); expect_hydra_last_events(vec![ - pallet_omnipool::Event::HubAmountUpdated { - hub_amount_in: 45135, - hub_amount_out: 45113, - operation_id: vec![ExecutionType::Router(0)], + pallet_amm_support::Event::Swapped { + swapper: BOB.into(), + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::Filler::Omnipool, + operation: pallet_amm_support::TradeOperation::ExactOut, + inputs: vec![(AssetType::Fungible(HDX), amount_in)], + outputs: vec![(AssetType::Fungible(LRNA), 45135)], + fees: vec![Fee::new(LRNA, 22, Omnipool::protocol_account())], + operation_id: vec![ExecutionType::Router(0), ExecutionType::Omnipool(1)], } .into(), pallet_amm_support::Event::Swapped { @@ -2636,13 +2641,10 @@ mod omnipool_router_tests { filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::Filler::Omnipool, operation: pallet_amm_support::TradeOperation::ExactOut, - inputs: vec![(AssetType::Fungible(HDX), amount_in)], + inputs: vec![(AssetType::Fungible(LRNA), 45113)], outputs: vec![(AssetType::Fungible(DAI), amount_to_buy)], - fees: vec![ - Fee::new(DAI, 2506265665, Omnipool::protocol_account()), - Fee::new(LRNA, 22, Omnipool::protocol_account()), - ], - operation_id: vec![ExecutionType::Router(0)], + fees: vec![Fee::new(DAI, 2506265665, Omnipool::protocol_account())], + operation_id: vec![ExecutionType::Router(0), ExecutionType::Omnipool(1)], } .into(), pallet_route_executor::Event::Executed { @@ -2685,10 +2687,15 @@ mod omnipool_router_tests { protocol_fee_amount: 22, } .into(), - pallet_omnipool::Event::HubAmountUpdated { - hub_amount_in: 45135, - hub_amount_out: 45113, - operation_id: vec![], + pallet_amm_support::Event::Swapped { + swapper: BOB.into(), + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::Filler::Omnipool, + operation: pallet_amm_support::TradeOperation::ExactOut, + inputs: vec![(AssetType::Fungible(HDX), amount_in)], + outputs: vec![(AssetType::Fungible(LRNA), 45135)], + fees: vec![Fee::new(LRNA, 22, Omnipool::protocol_account())], + operation_id: vec![ExecutionType::Omnipool(0)], } .into(), pallet_amm_support::Event::Swapped { @@ -2696,13 +2703,10 @@ mod omnipool_router_tests { filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::Filler::Omnipool, operation: pallet_amm_support::TradeOperation::ExactOut, - inputs: vec![(AssetType::Fungible(HDX), amount_in)], + inputs: vec![(AssetType::Fungible(LRNA), 45113)], outputs: vec![(AssetType::Fungible(DAI), amount_to_buy)], - fees: vec![ - Fee::new(DAI, 2_506_265_665, Omnipool::protocol_account()), - Fee::new(LRNA, 22, Omnipool::protocol_account()), - ], - operation_id: vec![], + fees: vec![Fee::new(DAI, 2506265665, Omnipool::protocol_account())], + operation_id: vec![ExecutionType::Omnipool(0)], } .into(), ]); From 0ee69af10d925fff25923362dff64bc0eec8986c Mon Sep 17 00:00:00 2001 From: dmoka Date: Mon, 9 Dec 2024 10:53:03 +0400 Subject: [PATCH 072/142] add missing assertion for swapped when ref code is used --- integration-tests/src/referrals.rs | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/integration-tests/src/referrals.rs b/integration-tests/src/referrals.rs index e2b8ca9bc..13579ef90 100644 --- a/integration-tests/src/referrals.rs +++ b/integration-tests/src/referrals.rs @@ -1,4 +1,5 @@ #![cfg(test)] + use crate::polkadot_test_net::*; use frame_support::assert_ok; use frame_system::RawOrigin; @@ -9,6 +10,7 @@ use primitives::AccountId; use sp_core::crypto::Ss58AddressFormat; use sp_runtime::FixedU128; use sp_runtime::Permill; +use std::vec; use xcm_emulator::TestExt; #[test] @@ -319,6 +321,36 @@ fn trading_in_omnipool_should_use_asset_rewards_when_set() { assert_eq!(external_shares, 1_095_625_113_667); let total_shares = Referrals::total_shares(); assert_eq!(total_shares, referrer_shares + trader_shares + external_shares); + + let swapped_events = get_last_swapped_events(); + let last_two_swapped_events = &swapped_events[swapped_events.len() - 2..]; + pretty_assertions::assert_eq!( + *last_two_swapped_events, + vec![ + pallet_amm_support::Event::Swapped { + swapper: BOB.into(), + filler: Omnipool::protocol_account(), + filler_type: Filler::Omnipool, + operation: TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(HDX), 1000000000000)], + outputs: vec![(AssetType::Fungible(LRNA), 1205768843)], + fees: vec![Fee::new(LRNA, 602884, Omnipool::protocol_account())], + operation_id: vec![ExecutionType::Omnipool(0)], + } + .into(), + pallet_amm_support::Event::Swapped { + swapper: BOB.into(), + filler: Omnipool::protocol_account(), + filler_type: Filler::Omnipool, + operation: TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(LRNA), 1205165959)], + outputs: vec![(AssetType::Fungible(DAI), 26663424573622008)], + fees: vec![Fee::new(DAI, 70524156750724, Omnipool::protocol_account())], + operation_id: vec![ExecutionType::Omnipool(0)], + } + .into(), + ] + ); }); } From 2b14d21d88c63f65bc895226ee35bf08a0308da0 Mon Sep 17 00:00:00 2001 From: dmoka Date: Mon, 9 Dec 2024 11:04:27 +0400 Subject: [PATCH 073/142] make setting global --- pallets/amm-support/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/amm-support/src/lib.rs b/pallets/amm-support/src/lib.rs index d6915e493..71a44eb93 100644 --- a/pallets/amm-support/src/lib.rs +++ b/pallets/amm-support/src/lib.rs @@ -16,6 +16,7 @@ // limitations under the License. #![cfg_attr(not(feature = "std"), no_std)] +#![allow(clippy::too_many_arguments)] type AssetId = u32; type Balance = u128; @@ -122,7 +123,6 @@ impl Pallet { }) } - #[allow(clippy::too_many_arguments)] pub fn deposit_trade_event( swapper: T::AccountId, filler: T::AccountId, From 24e54234780805c77b641d83285b872685d5845d Mon Sep 17 00:00:00 2001 From: dmoka Date: Mon, 9 Dec 2024 11:35:12 +0400 Subject: [PATCH 074/142] clear execution stack on init --- pallets/amm-support/src/lib.rs | 18 +++++++++++++++++- traits/src/router.rs | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/pallets/amm-support/src/lib.rs b/pallets/amm-support/src/lib.rs index 71a44eb93..76e0fd34e 100644 --- a/pallets/amm-support/src/lib.rs +++ b/pallets/amm-support/src/lib.rs @@ -24,6 +24,7 @@ type Balance = u128; use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::sp_runtime::app_crypto::sp_core; use frame_support::sp_runtime::{ArithmeticError, BoundedVec, DispatchError, DispatchResult}; +use frame_system::pallet_prelude::BlockNumberFor; pub use hydradx_traits::{ router::{AssetType, ExecutionType, ExecutionTypeStack, Fee, Filler, OtcOrderId, TradeOperation}, IncrementalIdProvider, @@ -33,7 +34,6 @@ use primitives::ItemId as NftId; use scale_info::TypeInfo; use sp_core::{ConstU32, RuntimeDebug}; use sp_std::vec::Vec; - #[cfg(test)] mod tests; @@ -109,6 +109,18 @@ pub mod pallet { }, } + #[pallet::hooks] + impl Hooks> for Pallet { + fn on_initialize(_n: BlockNumberFor) -> Weight { + let mut weight: Weight = Weight::zero(); + weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 1)); + + >::clear(); + + Weight::from_parts(weight.ref_time(), 0) + } + } + #[pallet::call] impl Pallet {} } @@ -163,6 +175,10 @@ impl ExecutionTypeStack for Pallet { fn get() -> Vec> { IdStack::::get().get() } + + fn clear() { + IdStack::::kill(); + } } impl IncrementalIdProvider for Pallet { fn next_id() -> Result { diff --git a/traits/src/router.rs b/traits/src/router.rs index 1fce28024..1ad12a672 100644 --- a/traits/src/router.rs +++ b/traits/src/router.rs @@ -127,6 +127,7 @@ pub trait ExecutionTypeStack { fn push(execution_type: ExecutionType) -> DispatchResult; fn pop() -> Result, DispatchError>; fn get() -> Vec>; + fn clear(); } #[derive(Debug, PartialEq, Eq)] From 39a2d9a478368b7dd90146b7d387789ac6a5424a Mon Sep 17 00:00:00 2001 From: dmoka Date: Mon, 9 Dec 2024 11:37:51 +0400 Subject: [PATCH 075/142] remove hanging todo comment --- pallets/amm-support/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/pallets/amm-support/src/lib.rs b/pallets/amm-support/src/lib.rs index 76e0fd34e..bda87f0bf 100644 --- a/pallets/amm-support/src/lib.rs +++ b/pallets/amm-support/src/lib.rs @@ -80,7 +80,6 @@ pub mod pallet { #[pallet::getter(fn incremental_id)] pub(super) type IncrementalId = StorageValue<_, IncrementalIdType, ValueQuery>; - // TODO: #[pallet::storage] /// Next available incremental ID #[pallet::getter(fn id_stack)] From 4a64061cbbfbf813de98c9282a82bffb31786bbb Mon Sep 17 00:00:00 2001 From: dmoka Date: Tue, 10 Dec 2024 18:13:22 +0400 Subject: [PATCH 076/142] add todo for stuff we discussed in a call about refactoring event deposit --- pallets/amm-support/README.md | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/pallets/amm-support/README.md b/pallets/amm-support/README.md index 702f20c02..f288b3143 100644 --- a/pallets/amm-support/README.md +++ b/pallets/amm-support/README.md @@ -1,3 +1,43 @@ # AMM support pallet Support pallet for AMMs. Includes the unified event that is emitted by all AMM pallets. + +TODO + +we should override the deposit event + +replace amm specific types i the pallet + +make the types specific in amm pallet + +OtcOrderId in filler etc and use u32 + +also for AssetFee, we need only account in as generic + +dont use associated type , use tighlty coopled it + +ExecutioonIdStack can be alias bounded vec + +and when we push pop, use increase_stack and decrase_decrase + +we ExecutionIdIdStack and ExecutionTypeStack does the same, we dont need the exetionTypeStack trait at all + +on_intialize should also directly + +we can make storagw=e non-persistent, so we dont need on initialize + +IncrementalIdProvuder is not needed + +otc pallet we dont need into<32>. instead use atleastu32Unsuged + + +remove nonfungibalbe asset type + + +input and output should be tpye instead of tuple, because asset fee is also + +having same strucutre for inputs, outputs and fees + +next inceremetnal id use overflwoing add + +call it context instead of stack \ No newline at end of file From e8d14dd7270abb04cb958f283d880cd56878aeb7 Mon Sep 17 00:00:00 2001 From: dmoka Date: Thu, 12 Dec 2024 12:43:17 +0100 Subject: [PATCH 077/142] replace amm related types to amm pallet as it belongs there --- Cargo.lock | 2 + integration-tests/src/dca.rs | 35 +++--- integration-tests/src/polkadot_test_net.rs | 6 +- integration-tests/src/referrals.rs | 12 +- integration-tests/src/router.rs | 110 +++++++++--------- integration-tests/src/utility.rs | 21 ++-- pallets/amm-support/Cargo.toml | 3 +- pallets/amm-support/src/lib.rs | 7 +- .../amm-support/src/tests/incremental_id.rs | 3 +- pallets/amm-support/src/types.rs | 78 +++++++++++++ pallets/dca/src/lib.rs | 10 +- pallets/lbp/src/lib.rs | 15 ++- pallets/lbp/src/tests.rs | 24 ++-- pallets/omnipool/src/lib.rs | 30 ++--- pallets/omnipool/src/tests/buy.rs | 24 ++-- pallets/omnipool/src/tests/sell.rs | 8 +- pallets/otc-settlements/src/tests.rs | 7 +- pallets/otc/src/lib.rs | 16 ++- pallets/otc/src/tests/fill_order.rs | 14 +-- pallets/otc/src/tests/partial_fill_order.rs | 6 +- pallets/route-executor/src/lib.rs | 7 +- pallets/stableswap/src/lib.rs | 28 ++--- pallets/stableswap/src/tests/add_liquidity.rs | 10 +- .../stableswap/src/tests/remove_liquidity.rs | 10 +- pallets/stableswap/src/tests/trades.rs | 10 +- pallets/xyk/src/lib.rs | 11 +- pallets/xyk/src/tests/fees.rs | 26 ++--- pallets/xyk/src/tests/trades.rs | 18 +-- runtime/hydradx/src/system.rs | 21 ++-- traits/src/lib.rs | 4 - traits/src/router.rs | 60 ---------- 31 files changed, 326 insertions(+), 310 deletions(-) create mode 100644 pallets/amm-support/src/types.rs diff --git a/Cargo.lock b/Cargo.lock index d2a8912a9..34966c962 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7507,7 +7507,9 @@ dependencies = [ "parity-scale-codec", "primitives", "scale-info", + "serde", "sp-api", + "sp-arithmetic", "sp-core", "sp-io", "sp-std", diff --git a/integration-tests/src/dca.rs b/integration-tests/src/dca.rs index f155e6ac8..e89b46861 100644 --- a/integration-tests/src/dca.rs +++ b/integration-tests/src/dca.rs @@ -20,6 +20,7 @@ use hydradx_traits::router::PoolType; use hydradx_traits::router::Trade; use orml_traits::MultiCurrency; use orml_traits::MultiReservableCurrency; +use pallet_amm_support::types::*; use pallet_dca::types::{Order, Schedule}; use pallet_omnipool::types::Tradability; use pallet_stableswap::types::AssetAmount; @@ -37,7 +38,7 @@ mod omnipool { use super::*; use frame_support::assert_ok; use hydradx_runtime::{DCA, XYK}; - use hydradx_traits::router::{ExecutionType, PoolType, Trade}; + use hydradx_traits::router::{PoolType, Trade}; use hydradx_traits::AssetKind; use sp_runtime::{FixedU128, TransactionOutcome}; @@ -225,8 +226,8 @@ mod omnipool { RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { swapper: ALICE.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::ExactOut, + filler_type: pallet_amm_support::types::Filler::Omnipool, + operation: pallet_amm_support::types::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(HDX), 140421094367051)], outputs: vec![(AssetType::Fungible(LRNA), 70210545436437)], fees: vec![Fee::new(LRNA, 35105272718, Omnipool::protocol_account()),], @@ -239,8 +240,8 @@ mod omnipool { RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { swapper: ALICE.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::ExactOut, + filler_type: pallet_amm_support::types::Filler::Omnipool, + operation: pallet_amm_support::types::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(LRNA), 70175440163719)], outputs: vec![(AssetType::Fungible(DAI), amount_out)], fees: vec![Fee::new(DAI, 250626566417, Omnipool::protocol_account()),], @@ -263,8 +264,8 @@ mod omnipool { RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { swapper: ALICE.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::ExactOut, + filler_type: pallet_amm_support::types::Filler::Omnipool, + operation: pallet_amm_support::types::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(HDX), 140421107716515)], outputs: vec![(AssetType::Fungible(LRNA), 70210548448729)], fees: vec![Fee::new(LRNA, 35105274224, Omnipool::protocol_account()),], @@ -277,8 +278,8 @@ mod omnipool { RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { swapper: ALICE.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::ExactOut, + filler_type: pallet_amm_support::types::Filler::Omnipool, + operation: pallet_amm_support::types::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(LRNA), 70175443174505)], outputs: vec![(AssetType::Fungible(DAI), amount_out)], fees: vec![Fee::new(DAI, 250626566417, Omnipool::protocol_account()),], @@ -711,8 +712,8 @@ mod omnipool { RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { swapper: ALICE.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::ExactIn, + filler_type: pallet_amm_support::types::Filler::Omnipool, + operation: pallet_amm_support::types::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(HDX), amount_to_sell)], outputs: vec![(AssetType::Fungible(LRNA), 49999999159957)], fees: vec![Fee::new(LRNA, 24999999579, Omnipool::protocol_account()),], @@ -725,8 +726,8 @@ mod omnipool { RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { swapper: ALICE.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::ExactIn, + filler_type: pallet_amm_support::types::Filler::Omnipool, + operation: pallet_amm_support::types::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(LRNA), 49974999160378)], outputs: vec![(AssetType::Fungible(DAI), 71214372624126)], fees: vec![Fee::new(DAI, 178482136903, Omnipool::protocol_account()),], @@ -749,8 +750,8 @@ mod omnipool { RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { swapper: ALICE.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::ExactIn, + filler_type: pallet_amm_support::types::Filler::Omnipool, + operation: pallet_amm_support::types::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(HDX), amount_to_sell)], outputs: vec![(AssetType::Fungible(LRNA), 49999997360044)], fees: vec![Fee::new(LRNA, 24999998680, Omnipool::protocol_account()),], @@ -763,8 +764,8 @@ mod omnipool { RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { swapper: ALICE.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::ExactIn, + filler_type: pallet_amm_support::types::Filler::Omnipool, + operation: pallet_amm_support::types::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(LRNA), 49974997361364)], outputs: vec![(AssetType::Fungible(DAI), 71214367826179)], fees: vec![Fee::new(DAI, 178482124878, Omnipool::protocol_account()),], diff --git a/integration-tests/src/polkadot_test_net.rs b/integration-tests/src/polkadot_test_net.rs index 2d119beaa..3e1d4f06a 100644 --- a/integration-tests/src/polkadot_test_net.rs +++ b/integration-tests/src/polkadot_test_net.rs @@ -16,11 +16,7 @@ use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder; pub use frame_system::RawOrigin; use hex_literal::hex; use hydradx_runtime::{evm::WETH_ASSET_LOCATION, Referrals, RuntimeEvent, RuntimeOrigin}; -pub use hydradx_traits::{ - evm::InspectEvmAccounts, - registry::Mutate, - router::{AssetType, ExecutionType, Fee, Filler, TradeOperation}, -}; +pub use hydradx_traits::{evm::InspectEvmAccounts, registry::Mutate}; use pallet_referrals::{FeeDistribution, Level}; pub use polkadot_primitives::v7::{BlockNumber, MAX_CODE_SIZE, MAX_POV_SIZE}; use polkadot_runtime_parachains::configuration::HostConfiguration; diff --git a/integration-tests/src/referrals.rs b/integration-tests/src/referrals.rs index 13579ef90..967f42e68 100644 --- a/integration-tests/src/referrals.rs +++ b/integration-tests/src/referrals.rs @@ -5,6 +5,7 @@ use frame_support::assert_ok; use frame_system::RawOrigin; use hydradx_runtime::{Currencies, Omnipool, Referrals, Runtime, RuntimeOrigin, Staking, Tokens}; use orml_traits::MultiCurrency; +use pallet_amm_support::types::*; use pallet_referrals::{FeeDistribution, ReferralCode}; use primitives::AccountId; use sp_core::crypto::Ss58AddressFormat; @@ -12,7 +13,6 @@ use sp_runtime::FixedU128; use sp_runtime::Permill; use std::vec; use xcm_emulator::TestExt; - #[test] fn registering_a_code_should_charge_registration_fee() { Hydra::execute_with(|| { @@ -448,8 +448,8 @@ fn buying_with_hdx_in_omnipool_should_transfer_correct_fee() { pallet_amm_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::ExactOut, + filler_type: pallet_amm_support::types::Filler::Omnipool, + operation: pallet_amm_support::types::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(HDX), 37_506_757_329_085)], outputs: vec![(AssetType::Fungible(LRNA), 45_222_713_080)], fees: vec![Fee::new(LRNA, 22_611_356, Omnipool::protocol_account())], @@ -459,8 +459,8 @@ fn buying_with_hdx_in_omnipool_should_transfer_correct_fee() { pallet_amm_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::ExactOut, + filler_type: pallet_amm_support::types::Filler::Omnipool, + operation: pallet_amm_support::types::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(LRNA), 45_200_101_724)], outputs: vec![(AssetType::Fungible(DAI), 1_000_000_000_000_000_000)], fees: vec![Fee::new(DAI, 2_644_977_450_514_458, Omnipool::protocol_account())], @@ -601,7 +601,7 @@ fn seed_pot_account() { )); } -use hydradx_traits::router::ExecutionType; +use pallet_amm_support::types::ExecutionType; use scraper::ALICE; use sp_core::crypto::Ss58Codec; diff --git a/integration-tests/src/router.rs b/integration-tests/src/router.rs index c9b18b8fe..41e45007a 100644 --- a/integration-tests/src/router.rs +++ b/integration-tests/src/router.rs @@ -7,24 +7,26 @@ use hydradx_runtime::{ AssetRegistry, BlockNumber, Currencies, Omnipool, Router, RouterWeightInfo, Runtime, RuntimeOrigin, Stableswap, LBP, XYK, }; -use hydradx_traits::router::AssetType; +use hydradx_traits::router::AssetPair as Pair; use hydradx_traits::router::RouteSpotPriceProvider; use hydradx_traits::{ registry::Create, router::{PoolType, Trade}, AssetKind, AMM, }; +use pallet_amm_support::types::AssetType; +use pallet_amm_support::types::ExecutionType; +use pallet_amm_support::types::Fee; +use pallet_amm_support::types::*; use pallet_lbp::weights::WeightInfo as LbpWeights; use pallet_lbp::WeightCurveType; use pallet_omnipool::traits::OmnipoolHooks; use pallet_omnipool::types::Tradability; use pallet_omnipool::weights::WeightInfo as OmnipoolWeights; use pallet_route_executor::AmmTradeWeights; -use std::convert::Into; - -use hydradx_traits::router::AssetPair as Pair; use primitives::AssetId; use sp_runtime::FixedPointNumber; +use std::convert::Into; use frame_support::{assert_noop, assert_ok}; use xcm_emulator::TestExt; @@ -54,7 +56,8 @@ fn router_weights_should_be_non_zero() { mod router_different_pools_tests { use super::*; - use hydradx_traits::router::{ExecutionType, PoolType}; + use hydradx_traits::router::PoolType; + use pallet_amm_support::types::ExecutionType; #[test] fn route_should_fail_when_route_is_not_consistent() { @@ -157,8 +160,8 @@ mod router_different_pools_tests { pallet_amm_support::Event::Swapped { swapper: BOB.into(), filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA)), - filler_type: pallet_amm_support::Filler::LBP, - operation: pallet_amm_support::TradeOperation::ExactIn, + filler_type: pallet_amm_support::types::Filler::LBP, + operation: pallet_amm_support::types::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(DAI), 9980000000)], outputs: vec![(AssetType::Fungible(LRNA), 5640664064)], fees: vec![Fee::new( @@ -174,8 +177,8 @@ mod router_different_pools_tests { pallet_amm_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::ExactIn, + filler_type: pallet_amm_support::types::Filler::Omnipool, + operation: pallet_amm_support::types::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(LRNA), 5640664064)], outputs: vec![(AssetType::Fungible(HDX), 4682924837974)], fees: vec![Fee::new(HDX, 11736653730, Omnipool::protocol_account())], @@ -188,13 +191,13 @@ mod router_different_pools_tests { asset_in: HDX, asset_out: DOT, }), - filler_type: pallet_amm_support::Filler::XYK(XYK::share_token(XYK::get_pair_id( + filler_type: pallet_amm_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: DOT, }, ))), - operation: pallet_amm_support::TradeOperation::ExactIn, + operation: pallet_amm_support::types::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(HDX), 4682924837974)], outputs: vec![(AssetType::Fungible(DOT), 2230008413831)], fees: vec![Fee::new( @@ -300,13 +303,13 @@ mod router_different_pools_tests { asset_in: HDX, asset_out: stable_asset_1, }), - filler_type: pallet_amm_support::Filler::XYK(XYK::share_token(XYK::get_pair_id( + filler_type: pallet_amm_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: stable_asset_1, }, ))), - operation: pallet_amm_support::TradeOperation::ExactIn, + operation: pallet_amm_support::types::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(HDX), 5640664064)], outputs: vec![(AssetType::Fungible(stable_asset_1), 2811712439)], fees: vec![Fee::new( @@ -326,7 +329,7 @@ mod router_different_pools_tests { &stable_pool_id, Some(pallet_stableswap::POOL_IDENTIFIER), ), - filler_type: pallet_amm_support::Filler::Stableswap(stable_pool_id), + filler_type: pallet_amm_support::types::Filler::Stableswap(stable_pool_id), operation: TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(stable_asset_1), 2811712439)], outputs: vec![(AssetType::Fungible(stable_asset_2), 2783595233)], @@ -410,8 +413,8 @@ mod router_different_pools_tests { pallet_amm_support::Event::Swapped { swapper: BOB.into(), filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA)), - filler_type: pallet_amm_support::Filler::LBP, - operation: pallet_amm_support::TradeOperation::ExactOut, + filler_type: pallet_amm_support::types::Filler::LBP, + operation: pallet_amm_support::types::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(DAI), 4362157193)], outputs: vec![(AssetType::Fungible(LRNA), 2465566245)], fees: vec![Fee::new( @@ -427,8 +430,8 @@ mod router_different_pools_tests { pallet_amm_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::ExactOut, + filler_type: pallet_amm_support::types::Filler::Omnipool, + operation: pallet_amm_support::types::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(LRNA), 2465566245)], outputs: vec![(AssetType::Fungible(HDX), 2046938775509)], fees: vec![Fee::new(HDX, 5130172370, Omnipool::protocol_account())], @@ -441,13 +444,13 @@ mod router_different_pools_tests { asset_in: HDX, asset_out: DOT, }), - filler_type: pallet_amm_support::Filler::XYK(XYK::share_token(XYK::get_pair_id( + filler_type: pallet_amm_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: DOT, }, ))), - operation: pallet_amm_support::TradeOperation::ExactOut, + operation: pallet_amm_support::types::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(HDX), 1000000000000)], outputs: vec![(AssetType::Fungible(DOT), 2040816326531)], fees: vec![Fee::new( @@ -533,8 +536,8 @@ mod router_different_pools_tests { pallet_amm_support::Event::Swapped { swapper: BOB.into(), filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX)), - filler_type: pallet_amm_support::Filler::LBP, - operation: pallet_amm_support::TradeOperation::ExactOut, + filler_type: pallet_amm_support::types::Filler::LBP, + operation: pallet_amm_support::types::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(DAI), 3746042043754)], outputs: vec![(AssetType::Fungible(HDX), 2067851065323)], fees: vec![Fee::new( @@ -553,13 +556,13 @@ mod router_different_pools_tests { asset_in: HDX, asset_out: stable_asset_1, }), - filler_type: pallet_amm_support::Filler::XYK(XYK::share_token(XYK::get_pair_id( + filler_type: pallet_amm_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: stable_asset_1, }, ))), - operation: pallet_amm_support::TradeOperation::ExactOut, + operation: pallet_amm_support::types::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(HDX), 1010010000114)], outputs: vec![(AssetType::Fungible(stable_asset_1), 2061666067122)], fees: vec![Fee::new( @@ -579,8 +582,8 @@ mod router_different_pools_tests { &stable_pool_id, Some(pallet_stableswap::POOL_IDENTIFIER), ), - filler_type: pallet_amm_support::Filler::Stableswap(stable_pool_id), - operation: pallet_amm_support::TradeOperation::ExactOut, + filler_type: pallet_amm_support::types::Filler::Stableswap(stable_pool_id), + operation: pallet_amm_support::types::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(stable_asset_1), 1010010000114)], outputs: vec![(AssetType::Fungible(stable_asset_2), 1000000000000)], fees: vec![Fee::new( @@ -661,13 +664,13 @@ mod router_different_pools_tests { asset_in: HDX, asset_out: DOT, }), - filler_type: pallet_amm_support::Filler::XYK(XYK::share_token(XYK::get_pair_id( + filler_type: pallet_amm_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: DOT, }, ))), - operation: pallet_amm_support::TradeOperation::ExactIn, + operation: pallet_amm_support::types::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(HDX), 10000000000)], outputs: vec![(AssetType::Fungible(DOT), 4984501549)], fees: vec![Fee::new( @@ -687,13 +690,13 @@ mod router_different_pools_tests { asset_in: HDX, asset_out: DOT, }), - filler_type: pallet_amm_support::Filler::XYK(XYK::share_token(XYK::get_pair_id( + filler_type: pallet_amm_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: DOT, }, ))), - operation: pallet_amm_support::TradeOperation::ExactOut, + operation: pallet_amm_support::types::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(HDX), 10000000000)], outputs: vec![(AssetType::Fungible(DOT), 20007996198)], fees: vec![Fee::new( @@ -713,13 +716,13 @@ mod router_different_pools_tests { asset_in: HDX, asset_out: DOT, }), - filler_type: pallet_amm_support::Filler::XYK(XYK::share_token(XYK::get_pair_id( + filler_type: pallet_amm_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: DOT, }, ))), - operation: pallet_amm_support::TradeOperation::ExactIn, + operation: pallet_amm_support::types::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(HDX), 10000000000)], outputs: vec![(AssetType::Fungible(DOT), 4981510054)], fees: vec![Fee::new( @@ -1140,8 +1143,9 @@ mod omnipool_router_tests { use super::*; use frame_support::assert_noop; use hydradx_runtime::{Balances, XYK}; - use hydradx_traits::router::{ExecutionType, PoolType}; + use hydradx_traits::router::PoolType; use hydradx_traits::AssetKind; + use pallet_amm_support::types::ExecutionType; #[test] fn sell_should_work_when_route_contains_single_trade() { @@ -2398,8 +2402,8 @@ mod omnipool_router_tests { pallet_amm_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::ExactIn, + filler_type: pallet_amm_support::types::Filler::Omnipool, + operation: pallet_amm_support::types::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(HDX), amount_to_sell)], outputs: vec![(AssetType::Fungible(LRNA), 12014871681)], fees: vec![Fee::new(LRNA, 6007435, Omnipool::protocol_account())], @@ -2409,8 +2413,8 @@ mod omnipool_router_tests { pallet_amm_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::ExactIn, + filler_type: pallet_amm_support::types::Filler::Omnipool, + operation: pallet_amm_support::types::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(LRNA), 12008864246)], outputs: vec![(AssetType::Fungible(DAI), amount_out)], fees: vec![Fee::new(DAI, 667155563986401, Omnipool::protocol_account())], @@ -2460,8 +2464,8 @@ mod omnipool_router_tests { pallet_amm_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::ExactIn, + filler_type: pallet_amm_support::types::Filler::Omnipool, + operation: pallet_amm_support::types::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(HDX), amount_to_sell)], outputs: vec![(AssetType::Fungible(LRNA), 12014871681)], fees: vec![Fee::new(LRNA, 6007435, Omnipool::protocol_account())], @@ -2471,8 +2475,8 @@ mod omnipool_router_tests { pallet_amm_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::ExactIn, + filler_type: pallet_amm_support::types::Filler::Omnipool, + operation: pallet_amm_support::types::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(LRNA), 12008864246)], outputs: vec![(AssetType::Fungible(DAI), amount_out)], fees: vec![Fee::new(DAI, 667155563986401, Omnipool::protocol_account())], @@ -2628,8 +2632,8 @@ mod omnipool_router_tests { pallet_amm_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::ExactOut, + filler_type: pallet_amm_support::types::Filler::Omnipool, + operation: pallet_amm_support::types::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(HDX), amount_in)], outputs: vec![(AssetType::Fungible(LRNA), 45135)], fees: vec![Fee::new(LRNA, 22, Omnipool::protocol_account())], @@ -2639,8 +2643,8 @@ mod omnipool_router_tests { pallet_amm_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::ExactOut, + filler_type: pallet_amm_support::types::Filler::Omnipool, + operation: pallet_amm_support::types::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(LRNA), 45113)], outputs: vec![(AssetType::Fungible(DAI), amount_to_buy)], fees: vec![Fee::new(DAI, 2506265665, Omnipool::protocol_account())], @@ -2690,8 +2694,8 @@ mod omnipool_router_tests { pallet_amm_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::ExactOut, + filler_type: pallet_amm_support::types::Filler::Omnipool, + operation: pallet_amm_support::types::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(HDX), amount_in)], outputs: vec![(AssetType::Fungible(LRNA), 45135)], fees: vec![Fee::new(LRNA, 22, Omnipool::protocol_account())], @@ -2701,8 +2705,8 @@ mod omnipool_router_tests { pallet_amm_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::ExactOut, + filler_type: pallet_amm_support::types::Filler::Omnipool, + operation: pallet_amm_support::types::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(LRNA), 45113)], outputs: vec![(AssetType::Fungible(DAI), amount_to_buy)], fees: vec![Fee::new(DAI, 2506265665, Omnipool::protocol_account())], @@ -2985,8 +2989,8 @@ mod lbp_router_tests { pallet_amm_support::Event::Swapped { swapper: BOB.into(), filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX)), - filler_type: pallet_amm_support::Filler::LBP, - operation: pallet_amm_support::TradeOperation::ExactIn, + filler_type: pallet_amm_support::types::Filler::LBP, + operation: pallet_amm_support::types::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(HDX), amount_to_sell - fee)], outputs: vec![(AssetType::Fungible(DAI), received_amount_out)], fees: vec![Fee::new( @@ -3041,8 +3045,8 @@ mod lbp_router_tests { pallet_amm_support::Event::Swapped { swapper: BOB.into(), filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX)), - filler_type: pallet_amm_support::Filler::LBP, - operation: pallet_amm_support::TradeOperation::ExactIn, + filler_type: pallet_amm_support::types::Filler::LBP, + operation: pallet_amm_support::types::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(HDX), 9_980_000_000_000)], outputs: vec![(AssetType::Fungible(DAI), received_amount_out)], fees: vec![Fee::new( diff --git a/integration-tests/src/utility.rs b/integration-tests/src/utility.rs index b24e73d43..053895dd6 100644 --- a/integration-tests/src/utility.rs +++ b/integration-tests/src/utility.rs @@ -11,11 +11,12 @@ use hydradx_runtime::{RuntimeCall, Utility}; use hydradx_traits::router::PoolType; use xcm_emulator::TestExt; -use hydradx_traits::router::ExecutionType; use hydradx_traits::router::Trade; use hydradx_traits::AMM; use orml_traits::MultiCurrency; - +use pallet_amm_support::types::AssetType; +use pallet_amm_support::types::ExecutionType; +use pallet_amm_support::types::Fee; #[test] fn batch_execution_type_should_be_included_in_batch() { TestNet::reset(); @@ -72,8 +73,8 @@ fn batch_execution_type_should_be_included_in_batch() { RuntimeEvent::AmmSupport(pallet_amm_support::Event::::Swapped { swapper: BOB.into(), filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA)), - filler_type: pallet_amm_support::Filler::LBP, - operation: pallet_amm_support::TradeOperation::ExactIn, + filler_type: pallet_amm_support::types::Filler::LBP, + operation: pallet_amm_support::types::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(DAI), 9980000000)], outputs: vec![(AssetType::Fungible(LRNA), 5640664064)], fees: vec![Fee::new( @@ -88,8 +89,8 @@ fn batch_execution_type_should_be_included_in_batch() { RuntimeEvent::AmmSupport(pallet_amm_support::Event::::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::ExactIn, + filler_type: pallet_amm_support::types::Filler::Omnipool, + operation: pallet_amm_support::types::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(LRNA), 5640664064)], outputs: vec![(AssetType::Fungible(HDX), 4682924837974)], fees: vec![Fee::new(HDX, 11736653730, Omnipool::protocol_account())], @@ -101,13 +102,13 @@ fn batch_execution_type_should_be_included_in_batch() { asset_in: HDX, asset_out: DOT, }), - filler_type: pallet_amm_support::Filler::XYK(XYK::share_token(XYK::get_pair_id( + filler_type: pallet_amm_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: DOT, }, ))), - operation: pallet_amm_support::TradeOperation::ExactIn, + operation: pallet_amm_support::types::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(HDX), 4682924837974)], outputs: vec![(AssetType::Fungible(DOT), 2230008413831)], fees: vec![Fee::new( @@ -196,13 +197,13 @@ fn batch_execution_type_should_be_popped_when_multiple_batch_calls_happen() { asset_in: HDX, asset_out: DOT, }), - filler_type: pallet_amm_support::Filler::XYK(XYK::share_token(XYK::get_pair_id( + filler_type: pallet_amm_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: DOT, }, ))), - operation: pallet_amm_support::TradeOperation::ExactIn, + operation: pallet_amm_support::types::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(HDX), amount_to_sell)], outputs: vec![(AssetType::Fungible(DOT), 4549178628)], fees: vec![Fee::new( diff --git a/pallets/amm-support/Cargo.toml b/pallets/amm-support/Cargo.toml index f03340955..95d412be9 100644 --- a/pallets/amm-support/Cargo.toml +++ b/pallets/amm-support/Cargo.toml @@ -12,7 +12,8 @@ readme = "README.md" [dependencies] codec = { default-features = false, features = ["derive"], package = "parity-scale-codec", version = "3.4.0" } scale-info = { version = "2.1.2", default-features = false, features = ["derive"] } - +serde = { workspace = true } +sp-arithmetic = { workspace = true } # HydraDX dependencies hydradx-traits = { workspace = true } primitives = { workspace = true } diff --git a/pallets/amm-support/src/lib.rs b/pallets/amm-support/src/lib.rs index bda87f0bf..e12e7781d 100644 --- a/pallets/amm-support/src/lib.rs +++ b/pallets/amm-support/src/lib.rs @@ -21,14 +21,11 @@ type AssetId = u32; type Balance = u128; +use crate::types::*; use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::sp_runtime::app_crypto::sp_core; use frame_support::sp_runtime::{ArithmeticError, BoundedVec, DispatchError, DispatchResult}; use frame_system::pallet_prelude::BlockNumberFor; -pub use hydradx_traits::{ - router::{AssetType, ExecutionType, ExecutionTypeStack, Fee, Filler, OtcOrderId, TradeOperation}, - IncrementalIdProvider, -}; pub use primitives::IncrementalId as IncrementalIdType; use primitives::ItemId as NftId; use scale_info::TypeInfo; @@ -37,6 +34,8 @@ use sp_std::vec::Vec; #[cfg(test)] mod tests; +pub mod types; + // Re-export pallet items so that they can be accessed from the crate namespace. pub use pallet::*; diff --git a/pallets/amm-support/src/tests/incremental_id.rs b/pallets/amm-support/src/tests/incremental_id.rs index 7be17510e..fe1d275e0 100644 --- a/pallets/amm-support/src/tests/incremental_id.rs +++ b/pallets/amm-support/src/tests/incremental_id.rs @@ -16,9 +16,8 @@ // limitations under the License. use crate::tests::mock::*; +use crate::types::*; use crate::Event; -use hydradx_traits::router::{AssetType, ExecutionType, Filler, TradeOperation}; - #[test] fn event_id_should_be_incremented() { ExtBuilder::default().build().execute_with(|| { diff --git a/pallets/amm-support/src/types.rs b/pallets/amm-support/src/types.rs new file mode 100644 index 000000000..0c0eaf864 --- /dev/null +++ b/pallets/amm-support/src/types.rs @@ -0,0 +1,78 @@ +use codec::{Decode, Encode, MaxEncodedLen}; +use frame_support::dispatch::DispatchResultWithPostInfo; +use frame_support::sp_runtime::{DispatchError, DispatchResult}; +use frame_support::weights::Weight; +use scale_info::TypeInfo; +#[cfg(feature = "std")] +use serde::{Deserialize, Serialize}; +use sp_arithmetic::FixedU128; +use sp_std::vec; +use sp_std::vec::Vec; + +//TODO: we dont need this, delete +pub trait IncrementalIdProvider { + fn next_id() -> Result; +} + +#[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] +pub enum AssetType { + Fungible(AssetId), + NFT(NFTId), +} + +pub type OtcOrderId = u32; + +#[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] +pub enum Filler { + Omnipool, + Stableswap(AssetId), // pool id + XYK(AssetId), // share token + LBP, + OTC(OtcOrderId), + XcmExchange, //TODO: do we need some info? + Xcm(Option<[u8; 32]>), //TODO: VERIFY + // ICE(solution_id/block id), swapper: alice, filler: solver +} + +pub trait ExecutionTypeStack { + fn push(execution_type: ExecutionType) -> DispatchResult; + fn pop() -> Result, DispatchError>; + fn get() -> Vec>; + fn clear(); +} + +#[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] +pub struct Fee { + pub asset: AssetId, + pub amount: Balance, + pub recipient: AccountId, +} +impl Fee { + pub fn new(asset: AssetId, amount: Balance, recipient: AccountId) -> Self { + Self { + asset, + amount, + recipient, + } + } +} + +#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] +#[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] +pub enum ExecutionType { + Router(IncrementalId), + DCA(IncrementalId), + ICE(IncrementalId), + Batch(IncrementalId), + Omnipool(IncrementalId), + XcmExchange(IncrementalId), +} + +#[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] +pub enum TradeOperation { + ExactIn, + ExactOut, + Limit, + LiquidityAdd, + LiquidityRemove, +} diff --git a/pallets/dca/src/lib.rs b/pallets/dca/src/lib.rs index 516c1df46..5ac966ad7 100644 --- a/pallets/dca/src/lib.rs +++ b/pallets/dca/src/lib.rs @@ -78,12 +78,13 @@ use frame_system::{ }; use hydradx_adapters::RelayChainBlockHashProvider; use hydradx_traits::fee::{InspectTransactionFeeCurrency, SwappablePaymentAssetTrader}; -use hydradx_traits::router::{inverse_route, ExecutionType, ExecutionTypeStack, RouteProvider}; +use hydradx_traits::router::{inverse_route, RouteProvider}; use hydradx_traits::router::{AmmTradeWeights, AmountInAndOut, RouterT, Trade}; +use hydradx_traits::NativePriceOracle; use hydradx_traits::OraclePeriod; use hydradx_traits::PriceOracle; -use hydradx_traits::{IncrementalIdProvider, NativePriceOracle}; use orml_traits::{arithmetic::CheckedAdd, MultiCurrency, NamedMultiReservableCurrency}; +use pallet_amm_support::types::{ExecutionType, ExecutionTypeStack, IncrementalIdProvider}; use pallet_amm_support::IncrementalIdType; use primitives::IncrementalId; use rand::rngs::StdRng; @@ -123,9 +124,10 @@ pub mod pallet { use frame_system::pallet_prelude::OriginFor; use hydra_dx_math::ema::EmaPrice; use hydradx_traits::fee::SwappablePaymentAssetTrader; - use hydradx_traits::router::ExecutionTypeStack; - use hydradx_traits::{IncrementalIdProvider, NativePriceOracle, PriceOracle}; + use hydradx_traits::{NativePriceOracle, PriceOracle}; use orml_traits::NamedMultiReservableCurrency; + use pallet_amm_support::types::ExecutionTypeStack; + use pallet_amm_support::types::IncrementalIdProvider; use sp_runtime::Percent; #[pallet::pallet] diff --git a/pallets/lbp/src/lib.rs b/pallets/lbp/src/lib.rs index cdbfbc8e3..bbd9b1b6d 100644 --- a/pallets/lbp/src/lib.rs +++ b/pallets/lbp/src/lib.rs @@ -36,10 +36,9 @@ use frame_support::{ use frame_system::ensure_signed; use frame_system::pallet_prelude::BlockNumberFor; use hydra_dx_math::types::LBPWeight; -use hydradx_traits::{ - router::{AssetType, Fee}, - AMMTransfer, AssetPairAccountIdFor, CanCreatePool, LockedBalance, AMM, -}; +use hydradx_traits::{AMMTransfer, AssetPairAccountIdFor, CanCreatePool, LockedBalance, AMM}; +use pallet_amm_support::types::{AssetType, Fee}; + use orml_traits::{MultiCurrency, MultiCurrencyExtended, MultiLockableCurrency}; use scale_info::TypeInfo; @@ -1125,8 +1124,8 @@ impl AMM> for Pallet::deposit_trade_event( transfer.origin.clone(), pool_account, - pallet_amm_support::Filler::LBP, - pallet_amm_support::TradeOperation::ExactIn, + pallet_amm_support::types::Filler::LBP, + pallet_amm_support::types::TradeOperation::ExactIn, vec![(AssetType::Fungible(transfer.assets.asset_in), transfer.amount)], vec![(AssetType::Fungible(transfer.assets.asset_out), transfer.amount_b)], vec![Fee { @@ -1280,8 +1279,8 @@ impl AMM> for Pallet::deposit_trade_event( transfer.origin.clone(), pool_account, - pallet_amm_support::Filler::LBP, - pallet_amm_support::TradeOperation::ExactOut, + pallet_amm_support::types::Filler::LBP, + pallet_amm_support::types::TradeOperation::ExactOut, vec![(AssetType::Fungible(transfer.assets.asset_in), transfer.amount)], vec![(AssetType::Fungible(transfer.assets.asset_out), transfer.amount_b)], vec![Fee { diff --git a/pallets/lbp/src/tests.rs b/pallets/lbp/src/tests.rs index 144f662a8..719ff2840 100644 --- a/pallets/lbp/src/tests.rs +++ b/pallets/lbp/src/tests.rs @@ -1846,8 +1846,8 @@ fn execute_sell_should_work() { pallet_amm_support::Event::Swapped { swapper: ALICE, filler: pool_id, - filler_type: pallet_amm_support::Filler::LBP, - operation: pallet_amm_support::TradeOperation::ExactIn, + filler_type: pallet_amm_support::types::Filler::LBP, + operation: pallet_amm_support::types::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(asset_in), amount_in)], outputs: vec![(AssetType::Fungible(asset_out), amount_b)], fees: vec![Fee::new(asset_in, 1_000, pool_data.fee_collector)], @@ -1989,8 +1989,8 @@ fn execute_buy_should_work() { pallet_amm_support::Event::Swapped { swapper: ALICE, filler: pool_id, - filler_type: pallet_amm_support::Filler::LBP, - operation: pallet_amm_support::TradeOperation::ExactOut, + filler_type: pallet_amm_support::types::Filler::LBP, + operation: pallet_amm_support::types::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(asset_in), amount_in)], outputs: vec![(AssetType::Fungible(asset_out), amount_b)], fees: vec![Fee::new(asset_in, 1_000, pool_data.fee_collector)], @@ -2318,8 +2318,8 @@ fn buy_should_work() { pallet_amm_support::Event::Swapped { swapper: buyer, filler: pool_id, - filler_type: pallet_amm_support::Filler::LBP, - operation: pallet_amm_support::TradeOperation::ExactOut, + filler_type: pallet_amm_support::types::Filler::LBP, + operation: pallet_amm_support::types::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(asset_in), 17_894_738)], outputs: vec![(AssetType::Fungible(asset_out), 10_000_000)], fees: vec![Fee::new(asset_in, 35860, pool_data.fee_collector)], @@ -2463,8 +2463,8 @@ fn buy_should_work_when_limit_is_set_above_account_balance() { pallet_amm_support::Event::Swapped { swapper: buyer, filler: pool_id, - filler_type: pallet_amm_support::Filler::LBP, - operation: pallet_amm_support::TradeOperation::ExactOut, + filler_type: pallet_amm_support::types::Filler::LBP, + operation: pallet_amm_support::types::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(asset_in), 17_894_738)], outputs: vec![(AssetType::Fungible(asset_out), 10_000_000)], fees: vec![Fee::new(asset_in, 35860, pool_data.fee_collector)], @@ -2497,8 +2497,8 @@ fn buy_should_work_when_limit_is_set_above_account_balance() { pallet_amm_support::Event::Swapped { swapper: buyer, filler: pool_id, - filler_type: pallet_amm_support::Filler::LBP, - operation: pallet_amm_support::TradeOperation::ExactOut, + filler_type: pallet_amm_support::types::Filler::LBP, + operation: pallet_amm_support::types::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(BSX), 5_560_304)], outputs: vec![(AssetType::Fungible(KUSD), 10_000_000)], @@ -2588,8 +2588,8 @@ fn sell_should_work() { pallet_amm_support::Event::Swapped { swapper: buyer, filler: pool_id, - filler_type: pallet_amm_support::Filler::LBP, - operation: pallet_amm_support::TradeOperation::ExactIn, + filler_type: pallet_amm_support::types::Filler::LBP, + operation: pallet_amm_support::types::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(asset_in), 9_980_000)], outputs: vec![(AssetType::Fungible(asset_out), 5_605_138)], fees: vec![Fee::new(asset_in, 20_000, pool_data.fee_collector)], diff --git a/pallets/omnipool/src/lib.rs b/pallets/omnipool/src/lib.rs index 8013565eb..c82008d4b 100644 --- a/pallets/omnipool/src/lib.rs +++ b/pallets/omnipool/src/lib.rs @@ -94,9 +94,9 @@ use frame_system::{ensure_signed, pallet_prelude::OriginFor}; use hydra_dx_math::ema::EmaPrice; use hydra_dx_math::omnipool::types::{AssetStateChange, BalanceUpdate, I129}; use hydradx_traits::registry::Inspect as RegistryInspect; -use hydradx_traits::router::ExecutionTypeStack; -use hydradx_traits::router::{AssetType, ExecutionType, Fee}; use orml_traits::{GetByKey, MultiCurrency}; +use pallet_amm_support::types::ExecutionTypeStack; +use pallet_amm_support::types::{AssetType, ExecutionType, Fee}; #[cfg(feature = "try-runtime")] use primitive_types::U256; use scale_info::TypeInfo; @@ -135,8 +135,8 @@ pub mod pallet { use frame_system::pallet_prelude::*; use hydra_dx_math::ema::EmaPrice; use hydra_dx_math::omnipool::types::{BalanceUpdate, I129}; - use hydradx_traits::IncrementalIdProvider; use orml_traits::GetByKey; + use pallet_amm_support::types::IncrementalIdProvider; use pallet_amm_support::IncrementalIdType; use sp_runtime::ArithmeticError; @@ -1105,8 +1105,8 @@ pub mod pallet { pallet_amm_support::Pallet::::deposit_trade_event( who.clone(), Self::protocol_account(), - pallet_amm_support::Filler::Omnipool, - pallet_amm_support::TradeOperation::ExactIn, + pallet_amm_support::types::Filler::Omnipool, + pallet_amm_support::types::TradeOperation::ExactIn, vec![(AssetType::Fungible(asset_in.into()), amount)], vec![( AssetType::Fungible(T::HubAssetId::get().into()), @@ -1123,8 +1123,8 @@ pub mod pallet { pallet_amm_support::Pallet::::deposit_trade_event( who, Self::protocol_account(), - pallet_amm_support::Filler::Omnipool, - pallet_amm_support::TradeOperation::ExactIn, + pallet_amm_support::types::Filler::Omnipool, + pallet_amm_support::types::TradeOperation::ExactIn, vec![( AssetType::Fungible(T::HubAssetId::get().into()), *state_changes.asset_out.delta_hub_reserve, @@ -1354,8 +1354,8 @@ pub mod pallet { pallet_amm_support::Pallet::::deposit_trade_event( who.clone(), Self::protocol_account(), - pallet_amm_support::Filler::Omnipool, - pallet_amm_support::TradeOperation::ExactOut, + pallet_amm_support::types::Filler::Omnipool, + pallet_amm_support::types::TradeOperation::ExactOut, vec![( AssetType::Fungible(asset_in.into()), *state_changes.asset_in.delta_reserve, @@ -1375,8 +1375,8 @@ pub mod pallet { pallet_amm_support::Pallet::::deposit_trade_event( who, Self::protocol_account(), - pallet_amm_support::Filler::Omnipool, - pallet_amm_support::TradeOperation::ExactOut, + pallet_amm_support::types::Filler::Omnipool, + pallet_amm_support::types::TradeOperation::ExactOut, vec![( AssetType::Fungible(T::HubAssetId::get().into()), *state_changes.asset_out.delta_hub_reserve, @@ -1917,8 +1917,8 @@ impl Pallet { pallet_amm_support::Pallet::::deposit_trade_event( who.clone(), Self::protocol_account(), - pallet_amm_support::Filler::Omnipool, - pallet_amm_support::TradeOperation::ExactIn, + pallet_amm_support::types::Filler::Omnipool, + pallet_amm_support::types::TradeOperation::ExactIn, vec![( AssetType::Fungible(T::HubAssetId::get().into()), *state_changes.asset.delta_hub_reserve, @@ -2046,8 +2046,8 @@ impl Pallet { pallet_amm_support::Pallet::::deposit_trade_event( who.clone(), Self::protocol_account(), - pallet_amm_support::Filler::Omnipool, - pallet_amm_support::TradeOperation::ExactOut, + pallet_amm_support::types::Filler::Omnipool, + pallet_amm_support::types::TradeOperation::ExactOut, vec![( AssetType::Fungible(T::HubAssetId::get().into()), *state_changes.asset.delta_hub_reserve, diff --git a/pallets/omnipool/src/tests/buy.rs b/pallets/omnipool/src/tests/buy.rs index 89661b676..f325fe087 100644 --- a/pallets/omnipool/src/tests/buy.rs +++ b/pallets/omnipool/src/tests/buy.rs @@ -440,8 +440,8 @@ fn buy_should_emit_event_with_correct_asset_fee_amount() { pallet_amm_support::Event::Swapped { swapper: LP1, filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::ExactOut, + filler_type: pallet_amm_support::types::Filler::Omnipool, + operation: pallet_amm_support::types::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(100), expected_sold_amount)], outputs: vec![(AssetType::Fungible(1), 57142857142858)], fees: vec![Fee::new(LRNA, 0, Omnipool::protocol_account())], @@ -451,8 +451,8 @@ fn buy_should_emit_event_with_correct_asset_fee_amount() { pallet_amm_support::Event::Swapped { swapper: LP1, filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::ExactOut, + filler_type: pallet_amm_support::types::Filler::Omnipool, + operation: pallet_amm_support::types::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(1), 57142857142858)], outputs: vec![(AssetType::Fungible(200), buy_amount)], fees: vec![Fee::new(200, 5555555555556, Omnipool::protocol_account())], @@ -487,8 +487,8 @@ fn buy_should_emit_event_with_correct_asset_fee_amount() { pallet_amm_support::Event::Swapped { swapper: LP1, filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::ExactOut, + filler_type: pallet_amm_support::types::Filler::Omnipool, + operation: pallet_amm_support::types::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(100), 65976185738813)], outputs: vec![(AssetType::Fungible(1), 60326770004314)], fees: vec![Fee::new(LRNA, 0, Omnipool::protocol_account())], @@ -498,8 +498,8 @@ fn buy_should_emit_event_with_correct_asset_fee_amount() { pallet_amm_support::Event::Swapped { swapper: LP1, filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::ExactOut, + filler_type: pallet_amm_support::types::Filler::Omnipool, + operation: pallet_amm_support::types::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(1), 60326770004314)], outputs: vec![(AssetType::Fungible(200), other_buy_amount)], fees: vec![Fee::new(200, 5555555555567, Omnipool::protocol_account())], @@ -556,8 +556,8 @@ fn buy_should_emit_event_with_correct_protocol_fee_amount() { pallet_amm_support::Event::Swapped { swapper: LP1, filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::ExactOut, + filler_type: pallet_amm_support::types::Filler::Omnipool, + operation: pallet_amm_support::types::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(100), expected_sold_amount)], outputs: vec![(AssetType::Fungible(1), 56980056980057)], fees: vec![Fee::new(LRNA, 5698005698005, Omnipool::protocol_account())], @@ -567,8 +567,8 @@ fn buy_should_emit_event_with_correct_protocol_fee_amount() { pallet_amm_support::Event::Swapped { swapper: LP1, filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::ExactOut, + filler_type: pallet_amm_support::types::Filler::Omnipool, + operation: pallet_amm_support::types::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(1), 51282051282052)], outputs: vec![(AssetType::Fungible(200), buy_amount)], fees: vec![Fee::new(200, 0, Omnipool::protocol_account())], diff --git a/pallets/omnipool/src/tests/sell.rs b/pallets/omnipool/src/tests/sell.rs index 8d22d213f..14be1d713 100644 --- a/pallets/omnipool/src/tests/sell.rs +++ b/pallets/omnipool/src/tests/sell.rs @@ -747,8 +747,8 @@ fn sell_should_get_same_amount() { pallet_amm_support::Event::Swapped { swapper: LP1, filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::ExactIn, + filler_type: pallet_amm_support::types::Filler::Omnipool, + operation: pallet_amm_support::types::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(100), expected_sold_amount)], outputs: vec![(AssetType::Fungible(LRNA), 57142857142858)], fees: vec![Fee::new(LRNA, 0, Omnipool::protocol_account())], @@ -758,8 +758,8 @@ fn sell_should_get_same_amount() { pallet_amm_support::Event::Swapped { swapper: LP1, filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::Filler::Omnipool, - operation: pallet_amm_support::TradeOperation::ExactIn, + filler_type: pallet_amm_support::types::Filler::Omnipool, + operation: pallet_amm_support::types::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(LRNA), 57142857142858)], outputs: vec![(AssetType::Fungible(200), buy_amount)], fees: vec![Fee::new(200, 5555555555556, Omnipool::protocol_account())], diff --git a/pallets/otc-settlements/src/tests.rs b/pallets/otc-settlements/src/tests.rs index 417fb57e5..849f458f7 100644 --- a/pallets/otc-settlements/src/tests.rs +++ b/pallets/otc-settlements/src/tests.rs @@ -22,10 +22,9 @@ use super::*; pub use crate::mock::*; use frame_support::{assert_ok, assert_storage_noop}; -use hydradx_traits::router::AssetType; -use hydradx_traits::router::Fee; use hydradx_traits::Inspect; use orml_traits::MultiCurrency; +use pallet_amm_support::types::{AssetType, Fee}; pub fn expect_events(e: Vec) { e.into_iter().for_each(frame_system::Pallet::::assert_has_event); } @@ -302,8 +301,8 @@ fn existing_arb_opportunity_should_trigger_trade_when_correct_amount_can_be_foun pallet_amm_support::Event::Swapped { swapper: OtcSettlements::account_id(), filler: otc.owner, - filler_type: pallet_amm_support::Filler::OTC(otc_id), - operation: pallet_amm_support::TradeOperation::ExactIn, + filler_type: pallet_amm_support::types::Filler::OTC(otc_id), + operation: pallet_amm_support::types::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(HDX), 2413749694825193)], outputs: vec![(AssetType::Fungible(DAI), 4948186874391645)], fees: vec![Fee::new( diff --git a/pallets/otc/src/lib.rs b/pallets/otc/src/lib.rs index ddc8986cd..97b70826e 100644 --- a/pallets/otc/src/lib.rs +++ b/pallets/otc/src/lib.rs @@ -37,11 +37,9 @@ use codec::MaxEncodedLen; use frame_support::{pallet_prelude::*, require_transactional}; use frame_system::{ensure_signed, pallet_prelude::OriginFor}; -use hydradx_traits::{ - router::{AssetType, Fee}, - Inspect, -}; +use hydradx_traits::Inspect; use orml_traits::{GetByKey, MultiCurrency, NamedMultiReservableCurrency}; +use pallet_amm_support::types::{AssetType, Fee}; use sp_core::U256; use sp_runtime::traits::{One, Zero}; use sp_runtime::Permill; @@ -61,7 +59,7 @@ pub use weights::WeightInfo; pub use pallet::*; pub type Balance = u128; -pub type OrderId = hydradx_traits::router::OtcOrderId; +pub type OrderId = pallet_amm_support::types::OtcOrderId; //TODO: just use exacty type pub type NamedReserveIdentifier = [u8; 8]; pub const NAMED_RESERVE_ID: NamedReserveIdentifier = *b"otcorder"; @@ -315,8 +313,8 @@ pub mod pallet { pallet_amm_support::Pallet::::deposit_trade_event( who, order.owner.clone(), - pallet_amm_support::Filler::OTC(order_id), - pallet_amm_support::TradeOperation::ExactIn, + pallet_amm_support::types::Filler::OTC(order_id), + pallet_amm_support::types::TradeOperation::ExactIn, vec![(AssetType::Fungible(order.asset_in.into()), amount_in)], vec![(AssetType::Fungible(order.asset_out.into()), amount_out)], vec![Fee { @@ -361,8 +359,8 @@ pub mod pallet { pallet_amm_support::Pallet::::deposit_trade_event( who, order.owner, - pallet_amm_support::Filler::OTC(order_id), - pallet_amm_support::TradeOperation::ExactIn, + pallet_amm_support::types::Filler::OTC(order_id), + pallet_amm_support::types::TradeOperation::ExactIn, vec![(AssetType::Fungible(order.asset_in.into()), order.amount_in)], vec![(AssetType::Fungible(order.asset_out.into()), order.amount_out)], vec![Fee { diff --git a/pallets/otc/src/tests/fill_order.rs b/pallets/otc/src/tests/fill_order.rs index f6d56bf45..fc9ca93e8 100644 --- a/pallets/otc/src/tests/fill_order.rs +++ b/pallets/otc/src/tests/fill_order.rs @@ -16,9 +16,9 @@ use crate as otc; use crate::tests::mock::*; use crate::Event; use frame_support::{assert_noop, assert_ok}; -use hydradx_traits::router::{AssetType, Fee}; use orml_tokens::Error::BalanceTooLow; use orml_traits::{MultiCurrency, NamedMultiReservableCurrency}; +use pallet_amm_support::types::{AssetType, Fee}; use pretty_assertions::assert_eq; #[test] @@ -83,8 +83,8 @@ fn complete_fill_order_should_work() { pallet_amm_support::Event::Swapped { swapper: BOB, filler: ALICE, - filler_type: pallet_amm_support::Filler::OTC(0), - operation: pallet_amm_support::TradeOperation::ExactIn, + filler_type: pallet_amm_support::types::Filler::OTC(0), + operation: pallet_amm_support::types::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(DAI), 20 * ONE)], outputs: vec![(AssetType::Fungible(HDX), 100 * ONE)], fees: vec![Fee::new(HDX, ONE, ::FeeReceiver::get())], @@ -159,8 +159,8 @@ fn complete_fill_order_should_work_when_order_is_not_partially_fillable() { pallet_amm_support::Event::Swapped { swapper: BOB, filler: ALICE, - filler_type: pallet_amm_support::Filler::OTC(order_id), - operation: pallet_amm_support::TradeOperation::ExactIn, + filler_type: pallet_amm_support::types::Filler::OTC(order_id), + operation: pallet_amm_support::types::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(DAI), 20 * ONE)], outputs: vec![(AssetType::Fungible(HDX), 100 * ONE)], fees: vec![Fee::new(HDX, ONE, ::FeeReceiver::get())], @@ -247,8 +247,8 @@ fn complete_fill_order_should_work_when_there_are_multiple_orders() { pallet_amm_support::Event::Swapped { swapper: BOB, filler: ALICE, - filler_type: pallet_amm_support::Filler::OTC(order_id), - operation: pallet_amm_support::TradeOperation::ExactIn, + filler_type: pallet_amm_support::types::Filler::OTC(order_id), + operation: pallet_amm_support::types::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(DAI), 20 * ONE)], outputs: vec![(AssetType::Fungible(HDX), 100 * ONE)], fees: vec![Fee::new(HDX, ONE, ::FeeReceiver::get())], diff --git a/pallets/otc/src/tests/partial_fill_order.rs b/pallets/otc/src/tests/partial_fill_order.rs index 02ed68795..aabf6bc08 100644 --- a/pallets/otc/src/tests/partial_fill_order.rs +++ b/pallets/otc/src/tests/partial_fill_order.rs @@ -16,9 +16,9 @@ use crate as otc; use crate::tests::mock::*; use crate::{Error, Event}; use frame_support::{assert_noop, assert_ok}; -use hydradx_traits::router::{AssetType, Fee}; use orml_tokens::Error::BalanceTooLow; use orml_traits::{MultiCurrency, NamedMultiReservableCurrency}; +use pallet_amm_support::types::{AssetType, Fee}; use pretty_assertions::assert_eq; #[test] @@ -97,8 +97,8 @@ fn partial_fill_order_should_work_when_order_is_partially_fillable() { pallet_amm_support::Event::Swapped { swapper: BOB, filler: order.owner, - filler_type: pallet_amm_support::Filler::OTC(order_id), - operation: pallet_amm_support::TradeOperation::ExactIn, + filler_type: pallet_amm_support::types::Filler::OTC(order_id), + operation: pallet_amm_support::types::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(order.asset_in), 5 * ONE)], outputs: vec![(AssetType::Fungible(order.asset_out), expected_amount_out)], fees: vec![Fee::new( diff --git a/pallets/route-executor/src/lib.rs b/pallets/route-executor/src/lib.rs index fb1ce8672..8f179cd64 100644 --- a/pallets/route-executor/src/lib.rs +++ b/pallets/route-executor/src/lib.rs @@ -35,11 +35,12 @@ use frame_system::{ensure_signed, Origin}; use hydradx_traits::registry::Inspect as RegistryInspect; use hydradx_traits::router::{inverse_route, AssetPair, RefundEdCalculator, RouteProvider, RouteSpotPriceProvider}; pub use hydradx_traits::router::{ - AmmTradeWeights, AmountInAndOut, AssetType, ExecutionType, ExecutionTypeStack, ExecutorError, Fee, PoolType, - RouterT, Trade, TradeExecution, + AmmTradeWeights, AmountInAndOut, ExecutorError, PoolType, RouterT, Trade, TradeExecution, }; -use hydradx_traits::IncrementalIdProvider; + use orml_traits::arithmetic::{CheckedAdd, CheckedSub}; +use pallet_amm_support::types::IncrementalIdProvider; +pub use pallet_amm_support::types::{AssetType, ExecutionType, ExecutionTypeStack, Fee}; use pallet_amm_support::IncrementalIdType; use primitives::IncrementalId; use sp_core::U512; diff --git a/pallets/stableswap/src/lib.rs b/pallets/stableswap/src/lib.rs index 53445858a..9baa47e9e 100644 --- a/pallets/stableswap/src/lib.rs +++ b/pallets/stableswap/src/lib.rs @@ -74,8 +74,8 @@ pub mod weights; use crate::types::{AssetAmount, Balance, PoolInfo, PoolState, StableswapHooks, Tradability}; use hydra_dx_math::stableswap::types::AssetReserve; use hydradx_traits::pools::DustRemovalAccountWhitelist; -use hydradx_traits::router::{AssetType, Fee}; use orml_traits::MultiCurrency; +use pallet_amm_support::types::{AssetType, Fee}; use sp_std::collections::btree_map::BTreeMap; pub use weights::WeightInfo; @@ -104,7 +104,7 @@ pub mod pallet { use core::ops::RangeInclusive; use frame_support::pallet_prelude::*; use hydradx_traits::pools::DustRemovalAccountWhitelist; - use hydradx_traits::router::{AssetType, Fee}; + use pallet_amm_support::types::{AssetType, Fee}; use sp_runtime::traits::{BlockNumberProvider, Zero}; use sp_runtime::ArithmeticError; use sp_runtime::Permill; @@ -631,8 +631,8 @@ pub mod pallet { pallet_amm_support::Pallet::::deposit_trade_event( who, pool_account.clone(), - pallet_amm_support::Filler::Stableswap(pool_id.into()), - pallet_amm_support::TradeOperation::LiquidityRemove, + pallet_amm_support::types::Filler::Stableswap(pool_id.into()), + pallet_amm_support::types::TradeOperation::LiquidityRemove, vec![(AssetType::Fungible(pool_id.into()), share_amount)], vec![(AssetType::Fungible(asset_id.into()), amount)], vec![Fee { @@ -734,8 +734,8 @@ pub mod pallet { pallet_amm_support::Pallet::::deposit_trade_event( who, pool_account.clone(), - pallet_amm_support::Filler::Stableswap(pool_id.into()), - pallet_amm_support::TradeOperation::LiquidityRemove, + pallet_amm_support::types::Filler::Stableswap(pool_id.into()), + pallet_amm_support::types::TradeOperation::LiquidityRemove, vec![(AssetType::Fungible(pool_id.into()), shares)], vec![(AssetType::Fungible(asset_id.into()), amount)], fees, @@ -817,8 +817,8 @@ pub mod pallet { pallet_amm_support::Pallet::::deposit_trade_event( who, pool_account.clone(), - pallet_amm_support::Filler::Stableswap(pool_id.into()), - pallet_amm_support::TradeOperation::ExactIn, + pallet_amm_support::types::Filler::Stableswap(pool_id.into()), + pallet_amm_support::types::TradeOperation::ExactIn, vec![(AssetType::Fungible(asset_in.into()), amount_in)], vec![(AssetType::Fungible(asset_out.into()), amount_out)], vec![Fee { @@ -910,8 +910,8 @@ pub mod pallet { pallet_amm_support::Pallet::::deposit_trade_event( who, pool_account.clone(), - pallet_amm_support::Filler::Stableswap(pool_id.into()), - pallet_amm_support::TradeOperation::ExactOut, + pallet_amm_support::types::Filler::Stableswap(pool_id.into()), + pallet_amm_support::types::TradeOperation::ExactOut, vec![(AssetType::Fungible(asset_in.into()), amount_in)], vec![(AssetType::Fungible(asset_out.into()), amount_out)], vec![Fee { @@ -1273,8 +1273,8 @@ impl Pallet { pallet_amm_support::Pallet::::deposit_trade_event( who.clone(), pool_account.clone(), - pallet_amm_support::Filler::Stableswap(pool_id.into()), - pallet_amm_support::TradeOperation::LiquidityAdd, + pallet_amm_support::types::Filler::Stableswap(pool_id.into()), + pallet_amm_support::types::TradeOperation::LiquidityAdd, inputs, vec![(AssetType::Fungible(pool_id.into()), share_amount)], fees, @@ -1338,8 +1338,8 @@ impl Pallet { pallet_amm_support::Pallet::::deposit_trade_event( who.clone(), pool_account.clone(), - pallet_amm_support::Filler::Stableswap(pool_id.into()), - pallet_amm_support::TradeOperation::LiquidityAdd, + pallet_amm_support::types::Filler::Stableswap(pool_id.into()), + pallet_amm_support::types::TradeOperation::LiquidityAdd, vec![(AssetType::Fungible(asset_id.into()), amount_in)], vec![(AssetType::Fungible(pool_id.into()), shares)], vec![Fee { diff --git a/pallets/stableswap/src/tests/add_liquidity.rs b/pallets/stableswap/src/tests/add_liquidity.rs index da2ebba02..857e7a5fa 100644 --- a/pallets/stableswap/src/tests/add_liquidity.rs +++ b/pallets/stableswap/src/tests/add_liquidity.rs @@ -2,7 +2,7 @@ use crate::tests::mock::*; use crate::types::{AssetAmount, PoolInfo}; use crate::{assert_balance, to_precision, Error}; use frame_support::{assert_noop, assert_ok}; -use hydradx_traits::router::{AssetType, Fee}; +use pallet_amm_support::types::*; use sp_runtime::Permill; use std::num::NonZeroU16; @@ -110,8 +110,8 @@ fn add_liquidity_should_emit_swapped_events() { RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { swapper: BOB, filler: pool_account, - filler_type: pallet_amm_support::Filler::Stableswap(pool_id), - operation: pallet_amm_support::TradeOperation::LiquidityAdd, + filler_type: pallet_amm_support::types::Filler::Stableswap(pool_id), + operation: pallet_amm_support::types::TradeOperation::LiquidityAdd, inputs: vec![(AssetType::Fungible(asset_a), 2000000000000000000),], outputs: vec![(AssetType::Fungible(pool_id), 1947487201901031408)], fees: vec![ @@ -713,8 +713,8 @@ fn add_liquidity_should_work_correctly_when_providing_exact_amount_of_shares() { RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { swapper: BOB, filler: pool_account, - filler_type: pallet_amm_support::Filler::Stableswap(pool_id), - operation: pallet_amm_support::TradeOperation::LiquidityAdd, + filler_type: pallet_amm_support::types::Filler::Stableswap(pool_id), + operation: pallet_amm_support::types::TradeOperation::LiquidityAdd, inputs: vec![(AssetType::Fungible(asset_a), 2000000000000000003),], outputs: vec![(AssetType::Fungible(pool_id), 1947597621401945851)], fees: vec![Fee::new(pool_id, 0, pool_account)], diff --git a/pallets/stableswap/src/tests/remove_liquidity.rs b/pallets/stableswap/src/tests/remove_liquidity.rs index 8b5c8f497..a6061525d 100644 --- a/pallets/stableswap/src/tests/remove_liquidity.rs +++ b/pallets/stableswap/src/tests/remove_liquidity.rs @@ -3,7 +3,7 @@ use crate::types::{AssetAmount, PoolInfo}; use crate::{assert_balance, Error, Event, Pools}; use frame_support::traits::Contains; use frame_support::{assert_noop, assert_ok, BoundedVec}; -use hydradx_traits::router::{AssetType, Fee}; +use pallet_amm_support::types::{AssetType, Fee}; use sp_runtime::Permill; use std::num::NonZeroU16; @@ -78,8 +78,8 @@ fn remove_liquidity_should_work_when_withdrawing_all_shares() { RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { swapper: BOB, filler: pool_account, - filler_type: pallet_amm_support::Filler::Stableswap(pool_id), - operation: pallet_amm_support::TradeOperation::LiquidityRemove, + filler_type: pallet_amm_support::types::Filler::Stableswap(pool_id), + operation: pallet_amm_support::types::TradeOperation::LiquidityRemove, inputs: vec![(AssetType::Fungible(pool_id), 200516043533380244763),], outputs: vec![(AssetType::Fungible(asset_c), 199999999999999)], fees: vec![Fee::new(pool_id, 0, pool_account)], @@ -1084,8 +1084,8 @@ fn removing_liquidity_with_exact_amount_should_emit_swapped_event() { RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { swapper: BOB, filler: pool_account, - filler_type: pallet_amm_support::Filler::Stableswap(4), - operation: pallet_amm_support::TradeOperation::LiquidityRemove, + filler_type: pallet_amm_support::types::Filler::Stableswap(4), + operation: pallet_amm_support::types::TradeOperation::LiquidityRemove, inputs: vec![(AssetType::Fungible(pool_id), 979387928052053203)], outputs: vec![(AssetType::Fungible(asset_a), 1000000000000000000),], fees: vec![ diff --git a/pallets/stableswap/src/tests/trades.rs b/pallets/stableswap/src/tests/trades.rs index af5db1837..070160bc3 100644 --- a/pallets/stableswap/src/tests/trades.rs +++ b/pallets/stableswap/src/tests/trades.rs @@ -4,7 +4,7 @@ use crate::{assert_balance, to_precision, Error, Event}; use std::num::NonZeroU16; use frame_support::{assert_noop, assert_ok}; -use hydradx_traits::router::{AssetType, Fee}; +use pallet_amm_support::types::{AssetType, Fee}; use sp_runtime::Permill; #[test] @@ -69,8 +69,8 @@ fn sell_should_work_when_correct_input_provided() { pallet_amm_support::Event::Swapped { swapper: BOB, filler: pool_account, - filler_type: pallet_amm_support::Filler::Stableswap(pool_id), - operation: pallet_amm_support::TradeOperation::ExactIn, + filler_type: pallet_amm_support::types::Filler::Stableswap(pool_id), + operation: pallet_amm_support::types::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(asset_a), 30000000000000)], outputs: vec![(AssetType::Fungible(asset_b), 29902625420922)], fees: vec![Fee::new(asset_b, 0, pool_account)], @@ -143,8 +143,8 @@ fn buy_should_work_when_correct_input_provided() { pallet_amm_support::Event::Swapped { swapper: BOB, filler: pool_account, - filler_type: pallet_amm_support::Filler::Stableswap(pool_id), - operation: pallet_amm_support::TradeOperation::ExactOut, + filler_type: pallet_amm_support::types::Filler::Stableswap(pool_id), + operation: pallet_amm_support::types::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(asset_a), 30098072706882)], outputs: vec![(AssetType::Fungible(asset_b), 30000000000000)], fees: vec![Fee::new(asset_a, 0, pool_account)], diff --git a/pallets/xyk/src/lib.rs b/pallets/xyk/src/lib.rs index 13f5c2c7c..eb9930741 100644 --- a/pallets/xyk/src/lib.rs +++ b/pallets/xyk/src/lib.rs @@ -33,10 +33,11 @@ use frame_support::{dispatch::DispatchResult, ensure, traits::Get, transactional use frame_system::ensure_signed; use frame_system::pallet_prelude::BlockNumberFor; use hydradx_traits::{ - router::{AssetType, Fee}, AMMPosition, AMMTransfer, AssetPairAccountIdFor, CanCreatePool, OnCreatePoolHandler, OnLiquidityChangedHandler, OnTradeHandler, AMM, }; +use pallet_amm_support::types::{AssetType, Fee}; + use sp_std::{vec, vec::Vec}; use crate::types::{Amount, AssetId, AssetPair, Balance}; @@ -920,8 +921,8 @@ impl AMM for Pallet { pallet_amm_support::Pallet::::deposit_trade_event( transfer.origin.clone(), pair_account.clone(), - pallet_amm_support::Filler::XYK(Self::share_token(&pair_account)), - pallet_amm_support::TradeOperation::ExactIn, + pallet_amm_support::types::Filler::XYK(Self::share_token(&pair_account)), + pallet_amm_support::types::TradeOperation::ExactIn, vec![(AssetType::Fungible(transfer.assets.asset_in), transfer.amount)], vec![(AssetType::Fungible(transfer.assets.asset_out), transfer.amount_b)], vec![Fee { @@ -1100,8 +1101,8 @@ impl AMM for Pallet { pallet_amm_support::Pallet::::deposit_trade_event( transfer.origin.clone(), pair_account.clone(), - pallet_amm_support::Filler::XYK(Self::share_token(&pair_account)), - pallet_amm_support::TradeOperation::ExactOut, + pallet_amm_support::types::Filler::XYK(Self::share_token(&pair_account)), + pallet_amm_support::types::TradeOperation::ExactOut, vec![(AssetType::Fungible(transfer.assets.asset_in), transfer.amount)], vec![(AssetType::Fungible(transfer.assets.asset_out), transfer.amount_b)], vec![Fee { diff --git a/pallets/xyk/src/tests/fees.rs b/pallets/xyk/src/tests/fees.rs index 0a1a51e5f..00c78c862 100644 --- a/pallets/xyk/src/tests/fees.rs +++ b/pallets/xyk/src/tests/fees.rs @@ -1,9 +1,9 @@ pub use super::mock::*; use crate::{Error, Event}; use frame_support::{assert_noop, assert_ok}; -use hydradx_traits::router::{AssetType, Fee}; use hydradx_traits::AMM as AmmPool; use orml_traits::MultiCurrency; +use pallet_amm_support::types::{AssetType, Fee}; use crate::types::AssetPair; @@ -149,8 +149,8 @@ fn discount_sell_fees_should_work() { pallet_amm_support::Event::Swapped { swapper: ALICE, filler: pair_account, - filler_type: pallet_amm_support::Filler::XYK(share_token), - operation: pallet_amm_support::TradeOperation::ExactIn, + filler_type: pallet_amm_support::types::Filler::XYK(share_token), + operation: pallet_amm_support::types::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(asset_a), 10_000_000)], outputs: vec![(AssetType::Fungible(asset_b), 19_986_006)], fees: vec![Fee::new(asset_b, 13_993, pair_account)], @@ -237,8 +237,8 @@ fn discount_sell_fees_should_work() { pallet_amm_support::Event::Swapped { swapper: ALICE, filler: pair_account, - filler_type: pallet_amm_support::Filler::XYK(share_token), - operation: pallet_amm_support::TradeOperation::ExactIn, + filler_type: pallet_amm_support::types::Filler::XYK(share_token), + operation: pallet_amm_support::types::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(asset_a), 10_000_000)], outputs: vec![(AssetType::Fungible(asset_b), 19_980_009)], fees: vec![Fee::new(asset_b, 19_990, pair_account)], @@ -320,8 +320,8 @@ fn discount_sell_fees_should_work() { pallet_amm_support::Event::Swapped { swapper: ALICE, filler: pair_account, - filler_type: pallet_amm_support::Filler::XYK(share_token), - operation: pallet_amm_support::TradeOperation::ExactIn, + filler_type: pallet_amm_support::types::Filler::XYK(share_token), + operation: pallet_amm_support::types::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(asset_a), 10_000_000)], outputs: vec![(AssetType::Fungible(asset_b), 19_999_999)], fees: vec![Fee::new(asset_b, 0, pair_account)], @@ -420,8 +420,8 @@ fn discount_buy_fees_should_work() { pallet_amm_support::Event::Swapped { swapper: ALICE, filler: pair_account, - filler_type: pallet_amm_support::Filler::XYK(share_token), - operation: pallet_amm_support::TradeOperation::ExactOut, + filler_type: pallet_amm_support::types::Filler::XYK(share_token), + operation: pallet_amm_support::types::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(asset_b), 10_000_000)], outputs: vec![(AssetType::Fungible(asset_a), 20_000_002)], fees: vec![Fee::new(asset_b, 14_000, pair_account)], @@ -512,8 +512,8 @@ fn discount_buy_fees_should_work() { pallet_amm_support::Event::Swapped { swapper: ALICE, filler: pair_account, - filler_type: pallet_amm_support::Filler::XYK(share_token), - operation: pallet_amm_support::TradeOperation::ExactOut, + filler_type: pallet_amm_support::types::Filler::XYK(share_token), + operation: pallet_amm_support::types::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(asset_b), 10_000_000)], outputs: vec![(AssetType::Fungible(asset_a), 20_000_002)], fees: vec![Fee::new(asset_b, 20_000, pair_account)], @@ -593,8 +593,8 @@ fn discount_buy_fees_should_work() { pallet_amm_support::Event::Swapped { swapper: ALICE, filler: pair_account, - filler_type: pallet_amm_support::Filler::XYK(share_token), - operation: pallet_amm_support::TradeOperation::ExactOut, + filler_type: pallet_amm_support::types::Filler::XYK(share_token), + operation: pallet_amm_support::types::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(asset_b), 10_000_000)], outputs: vec![(AssetType::Fungible(asset_a), 20_000_002)], fees: vec![Fee::new(asset_b, 0, pair_account)], diff --git a/pallets/xyk/src/tests/trades.rs b/pallets/xyk/src/tests/trades.rs index 86d8f4795..34d88c43f 100644 --- a/pallets/xyk/src/tests/trades.rs +++ b/pallets/xyk/src/tests/trades.rs @@ -1,9 +1,9 @@ pub use super::mock::*; use crate::{AMMTransfer, Error, Event}; use frame_support::{assert_noop, assert_ok}; -use hydradx_traits::router::{AssetType, Fee}; use hydradx_traits::AMM as AmmPool; use orml_traits::MultiCurrency; +use pallet_amm_support::types::{AssetType, Fee}; use crate::types::AssetPair; @@ -74,8 +74,8 @@ fn sell_test() { pallet_amm_support::Event::Swapped { swapper: ALICE, filler: pair_account, - filler_type: pallet_amm_support::Filler::XYK(share_token), - operation: pallet_amm_support::TradeOperation::ExactIn, + filler_type: pallet_amm_support::types::Filler::XYK(share_token), + operation: pallet_amm_support::types::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(asset_a), 456444678)], outputs: vec![(AssetType::Fungible(asset_b), 1363483591788)], fees: vec![Fee::new(asset_b, 2732432046, pair_account)], @@ -138,8 +138,8 @@ fn execute_sell_should_use_event_id() { pallet_amm_support::Event::Swapped { swapper: ALICE, filler: pair_account, - filler_type: pallet_amm_support::Filler::XYK(share_token), - operation: pallet_amm_support::TradeOperation::ExactIn, + filler_type: pallet_amm_support::types::Filler::XYK(share_token), + operation: pallet_amm_support::types::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(asset_a), 456444678)], outputs: vec![(AssetType::Fungible(asset_b), 1363483591788)], fees: vec![Fee::new(asset_b, 2732432046, pair_account)], @@ -445,8 +445,8 @@ fn sell_with_correct_fees_should_work() { pallet_amm_support::Event::Swapped { swapper: user_1, filler: pair_account, - filler_type: pallet_amm_support::Filler::XYK(share_token), - operation: pallet_amm_support::TradeOperation::ExactIn, + filler_type: pallet_amm_support::types::Filler::XYK(share_token), + operation: pallet_amm_support::types::TradeOperation::ExactIn, inputs: vec![(AssetType::Fungible(asset_a), 100_000)], outputs: vec![(AssetType::Fungible(asset_b), 19_762_378)], fees: vec![Fee::new(asset_b, 39_602, pair_account)], @@ -663,8 +663,8 @@ fn single_buy_should_work() { pallet_amm_support::Event::Swapped { swapper: user_1, filler: pair_account, - filler_type: pallet_amm_support::Filler::XYK(share_token), - operation: pallet_amm_support::TradeOperation::ExactOut, + filler_type: pallet_amm_support::types::Filler::XYK(share_token), + operation: pallet_amm_support::types::TradeOperation::ExactOut, inputs: vec![(AssetType::Fungible(asset_b), 6_666_666)], outputs: vec![(AssetType::Fungible(asset_a), 22_068_963_235)], fees: vec![Fee::new(asset_b, 44_137_926, pair_account)], diff --git a/runtime/hydradx/src/system.rs b/runtime/hydradx/src/system.rs index b18af1cf9..07f81a86b 100644 --- a/runtime/hydradx/src/system.rs +++ b/runtime/hydradx/src/system.rs @@ -17,14 +17,6 @@ use super::*; -use pallet_transaction_multi_payment::{DepositAll, TransferFees, WeightInfo}; -use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment}; -use primitives::constants::{ - chain::{CORE_ASSET_ID, MAXIMUM_BLOCK_WEIGHT}, - currency::{deposit, CENTS, DOLLARS, MILLICENTS}, - time::{DAYS, HOURS, SLOT_DURATION}, -}; - use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ dispatch::DispatchClass, @@ -42,10 +34,17 @@ use frame_support::{ }; use frame_system::EnsureRoot; use hydradx_adapters::{OraclePriceProvider, RelayChainBlockNumberProvider}; -use hydradx_traits::router::ExecutionType; -use hydradx_traits::IncrementalIdProvider; -use pallet_amm_support::ExecutionTypeStack; +use pallet_amm_support::types::ExecutionType; +use pallet_amm_support::types::ExecutionTypeStack; +use pallet_amm_support::types::IncrementalIdProvider; +use pallet_transaction_multi_payment::{DepositAll, TransferFees, WeightInfo}; +use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment}; use pallet_utility::{BatchPostHook, BatchPreHook}; +use primitives::constants::{ + chain::{CORE_ASSET_ID, MAXIMUM_BLOCK_WEIGHT}, + currency::{deposit, CENTS, DOLLARS, MILLICENTS}, + time::{DAYS, HOURS, SLOT_DURATION}, +}; use scale_info::TypeInfo; use sp_runtime::{ArithmeticError, DispatchResult}; diff --git a/traits/src/lib.rs b/traits/src/lib.rs index d9c3362a5..9bc526b2b 100644 --- a/traits/src/lib.rs +++ b/traits/src/lib.rs @@ -300,7 +300,3 @@ pub trait AccountFeeCurrencyBalanceInCurrency { type Output; fn get_balance_in_currency(to_currency: AssetId, account: &AccountId) -> Self::Output; } - -pub trait IncrementalIdProvider { - fn next_id() -> Result; -} diff --git a/traits/src/router.rs b/traits/src/router.rs index 1ad12a672..aeaf738f6 100644 --- a/traits/src/router.rs +++ b/traits/src/router.rs @@ -62,41 +62,6 @@ pub trait RouteProvider { } } -#[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] -pub struct Fee { - pub asset: AssetId, - pub amount: Balance, - pub recipient: AccountId, -} -impl Fee { - pub fn new(asset: AssetId, amount: Balance, recipient: AccountId) -> Self { - Self { - asset, - amount, - recipient, - } - } -} - -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] -pub enum ExecutionType { - Router(IncrementalId), - DCA(IncrementalId), - ICE(IncrementalId), - Batch(IncrementalId), - Omnipool(IncrementalId), -} - -#[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] -pub enum TradeOperation { - ExactIn, - ExactOut, - Limit, - LiquidityAdd, - LiquidityRemove, -} - #[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] pub enum PoolType { XYK, @@ -105,31 +70,6 @@ pub enum PoolType { Omnipool, } -#[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] -pub enum AssetType { - Fungible(AssetId), - NFT(NFTId), -} - -pub type OtcOrderId = u32; - -#[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] -pub enum Filler { - Omnipool, - Stableswap(AssetId), // pool id - XYK(AssetId), // share token - LBP, - OTC(OtcOrderId), - // ICE(solution_id/block id), swapper: alice, filler: solver -} - -pub trait ExecutionTypeStack { - fn push(execution_type: ExecutionType) -> DispatchResult; - fn pop() -> Result, DispatchError>; - fn get() -> Vec>; - fn clear(); -} - #[derive(Debug, PartialEq, Eq)] pub enum ExecutorError { NotSupported, From 64a19625f5915111bfd77035885f6cf168f17264 Mon Sep 17 00:00:00 2001 From: dmoka Date: Wed, 18 Dec 2024 09:02:52 +0100 Subject: [PATCH 078/142] add test for nested batch --- integration-tests/src/utility.rs | 113 +++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) diff --git a/integration-tests/src/utility.rs b/integration-tests/src/utility.rs index 053895dd6..69910ccf7 100644 --- a/integration-tests/src/utility.rs +++ b/integration-tests/src/utility.rs @@ -220,6 +220,119 @@ fn batch_execution_type_should_be_popped_when_multiple_batch_calls_happen() { }); } +#[test] +fn nested_batch_should_represent_embeddedness() { + TestNet::reset(); + + Hydra::execute_with(|| { + //Arrange + init_omnipool(); + crate::router::create_lbp_pool(DAI, LRNA); + crate::router::create_xyk_pool(HDX, DOT); + + let amount_to_sell = UNITS / 100; + let limit = 0; + let trades = vec![ + Trade { + pool: PoolType::LBP, + asset_in: DAI, + asset_out: LRNA, + }, + Trade { + pool: PoolType::Omnipool, + asset_in: LRNA, + asset_out: HDX, + }, + Trade { + pool: PoolType::XYK, + asset_in: HDX, + asset_out: DOT, + }, + ]; + + start_lbp_campaign(); + + //Act + + let sell_via_utility = RuntimeCall::Utility(pallet_utility::Call::batch { + calls: vec![RuntimeCall::Router(pallet_route_executor::Call::sell { + asset_in: DAI, + asset_out: DOT, + amount_in: amount_to_sell, + min_amount_out: limit, + route: trades.clone(), + })], + }); + + assert_ok!(Utility::batch( + hydradx_runtime::RuntimeOrigin::signed(BOB.into()), + vec![sell_via_utility.clone()] + )); + + //Assert + assert_balance!(BOB.into(), DAI, 1_000_000_000 * UNITS - amount_to_sell); + + let swapped_events = get_last_swapped_events(); + + pretty_assertions::assert_eq!( + swapped_events, + vec![ + RuntimeEvent::AmmSupport(pallet_amm_support::Event::::Swapped { + swapper: BOB.into(), + filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA)), + filler_type: pallet_amm_support::types::Filler::LBP, + operation: pallet_amm_support::types::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(DAI), 9980000000)], + outputs: vec![(AssetType::Fungible(LRNA), 5640664064)], + fees: vec![Fee::new( + DAI, + 20000000, + LBP::pool_data(LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA))) + .unwrap() + .fee_collector, + )], + operation_id: vec![ExecutionType::Batch(0), ExecutionType::Batch(1), ExecutionType::Router(2)], + }), + RuntimeEvent::AmmSupport(pallet_amm_support::Event::::Swapped { + swapper: BOB.into(), + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::types::Filler::Omnipool, + operation: pallet_amm_support::types::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(LRNA), 5640664064)], + outputs: vec![(AssetType::Fungible(HDX), 4682924837974)], + fees: vec![Fee::new(HDX, 11736653730, Omnipool::protocol_account())], + operation_id: vec![ExecutionType::Batch(0), ExecutionType::Batch(1), ExecutionType::Router(2)], + }), + RuntimeEvent::AmmSupport(pallet_amm_support::Event::::Swapped { + swapper: BOB.into(), + filler: XYK::get_pair_id(pallet_xyk::types::AssetPair { + asset_in: HDX, + asset_out: DOT, + }), + filler_type: pallet_amm_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( + pallet_xyk::types::AssetPair { + asset_in: HDX, + asset_out: DOT, + }, + ))), + operation: pallet_amm_support::types::TradeOperation::ExactIn, + inputs: vec![(AssetType::Fungible(HDX), 4682924837974)], + outputs: vec![(AssetType::Fungible(DOT), 2230008413831)], + fees: vec![Fee::new( + DOT, + 6710155707, + XYK::get_pair_id(pallet_xyk::types::AssetPair { + asset_in: HDX, + asset_out: DOT, + }), + )], + operation_id: vec![ExecutionType::Batch(0), ExecutionType::Batch(1), ExecutionType::Router(2)], + }) + ] + ); + }); +} + fn start_lbp_campaign() { set_relaychain_block_number(crate::router::LBP_SALE_START + 1); } From f1b11b5040765b8f0388d37b4e004717929e0496 Mon Sep 17 00:00:00 2001 From: dmoka Date: Wed, 18 Dec 2024 09:22:44 +0100 Subject: [PATCH 079/142] use amm support pallet directlyn instead of via traits --- pallets/amm-support/README.md | 2 +- pallets/amm-support/src/lib.rs | 29 ++++++++++++++++++- pallets/circuit-breaker/src/tests/mock.rs | 1 - pallets/dca/src/lib.rs | 10 ++----- pallets/dca/src/tests/mock.rs | 3 -- .../src/tests/mock.rs | 1 - pallets/omnipool/src/lib.rs | 13 +++------ pallets/omnipool/src/tests/mock.rs | 1 - pallets/otc-settlements/src/mock.rs | 2 -- pallets/route-executor/src/lib.rs | 15 ++++------ pallets/route-executor/src/tests/mock.rs | 1 - runtime/adapters/src/tests/mock.rs | 2 -- runtime/hydradx/src/assets.rs | 3 -- runtime/hydradx/src/system.rs | 5 ++-- 14 files changed, 43 insertions(+), 45 deletions(-) diff --git a/pallets/amm-support/README.md b/pallets/amm-support/README.md index f288b3143..0c72ac448 100644 --- a/pallets/amm-support/README.md +++ b/pallets/amm-support/README.md @@ -22,7 +22,7 @@ and when we push pop, use increase_stack and decrase_decrase we ExecutionIdIdStack and ExecutionTypeStack does the same, we dont need the exetionTypeStack trait at all -on_intialize should also directly +on_intialize should also directly. we can make storagw=e non-persistent, so we dont need on initialize diff --git a/pallets/amm-support/src/lib.rs b/pallets/amm-support/src/lib.rs index e12e7781d..645092ccd 100644 --- a/pallets/amm-support/src/lib.rs +++ b/pallets/amm-support/src/lib.rs @@ -79,6 +79,7 @@ pub mod pallet { #[pallet::getter(fn incremental_id)] pub(super) type IncrementalId = StorageValue<_, IncrementalIdType, ValueQuery>; + //TODO: add better name #[pallet::storage] /// Next available incremental ID #[pallet::getter(fn id_stack)] @@ -90,7 +91,6 @@ pub mod pallet { EmptyStack, } - // on initialize - clear operation_id stack if not empty #[pallet::event] #[pallet::generate_deposit(pub(crate) fn deposit_event)] pub enum Event { @@ -110,6 +110,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { fn on_initialize(_n: BlockNumberFor) -> Weight { + //TODO: we might not need it if we can make sotrage not persistable let mut weight: Weight = Weight::zero(); weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 1)); @@ -153,6 +154,32 @@ impl Pallet { operation_id: >::get(), }); } + + //TODO: rename + pub fn add_to_context(execution_type: fn(u32) -> ExecutionType) -> Result { + //TODO: double check what to do when these can fail, we dont really want failing due to this + let next_id = IncrementalId::::try_mutate(|current_id| -> Result { + let inc_id = *current_id; + *current_id = current_id.checked_add(1).ok_or(ArithmeticError::Overflow)?; + Ok(inc_id) + })?; + + IdStack::::try_mutate(|stack| -> DispatchResult { + stack + .push(execution_type(next_id)) + .map_err(|_| Error::::MaxStackSizeReached.into()) + })?; + + Ok(next_id) + } + + //TODO: rename to pop context + pub fn remove_from_context() -> Result, DispatchError> { + //TODO: check what to do when it fails, we might dont want to bloc ktrades becase of it + IdStack::::try_mutate(|stack| -> Result, DispatchError> { + stack.pop().map_err(|_| Error::::EmptyStack.into()) + }) + } } impl ExecutionTypeStack for Pallet { diff --git a/pallets/circuit-breaker/src/tests/mock.rs b/pallets/circuit-breaker/src/tests/mock.rs index 377c43ae3..4d196ba13 100644 --- a/pallets/circuit-breaker/src/tests/mock.rs +++ b/pallets/circuit-breaker/src/tests/mock.rs @@ -230,7 +230,6 @@ impl pallet_omnipool::Config for Test { type MinWithdrawalFee = MinWithdrawFee; type ExternalPriceOracle = WithdrawFeePriceOracle; type Fee = FeeProvider; - type AmmUnifiedEventSupport = AmmSupport; } impl pallet_amm_support::Config for Test { diff --git a/pallets/dca/src/lib.rs b/pallets/dca/src/lib.rs index 5ac966ad7..e288d1bff 100644 --- a/pallets/dca/src/lib.rs +++ b/pallets/dca/src/lib.rs @@ -210,7 +210,7 @@ pub mod pallet { } #[pallet::config] - pub trait Config: frame_system::Config { + pub trait Config: frame_system::Config + pallet_amm_support::Config { /// The overarching event type. type RuntimeEvent: From> + IsType<::RuntimeEvent>; @@ -306,9 +306,6 @@ pub mod pallet { #[pallet::constant] type NamedReserveId: Get; - /// Support for depositing unified events - type AmmUnifiedEventSupport: IncrementalIdProvider + ExecutionTypeStack; - /// Convert a weight value into a deductible fee type WeightToFee: WeightToFee; @@ -701,8 +698,7 @@ impl Pallet { schedule_id: ScheduleId, schedule: &Schedule>, ) -> Result, DispatchError> { - let next_event_id = T::AmmUnifiedEventSupport::next_id().map_err(|_| ArithmeticError::Overflow)?; - T::AmmUnifiedEventSupport::push(ExecutionType::DCA(next_event_id))?; + pallet_amm_support::Pallet::::add_to_context(ExecutionType::DCA)?; let origin: OriginFor = Origin::::Signed(schedule.owner.clone()).into(); let trade_result = match &schedule.order { @@ -790,7 +786,7 @@ impl Pallet { } }; - T::AmmUnifiedEventSupport::pop()?; + pallet_amm_support::Pallet::::remove_from_context()?; trade_result } diff --git a/pallets/dca/src/tests/mock.rs b/pallets/dca/src/tests/mock.rs index f2503d12c..a61870bd8 100644 --- a/pallets/dca/src/tests/mock.rs +++ b/pallets/dca/src/tests/mock.rs @@ -265,7 +265,6 @@ impl pallet_omnipool::Config for Test { type MinWithdrawalFee = (); type ExternalPriceOracle = WithdrawFeePriceOracle; type Fee = FeeProvider; - type AmmUnifiedEventSupport = AmmSupport; } pub struct WithdrawFeePriceOracle; @@ -378,7 +377,6 @@ impl pallet_route_executor::Config for Test { type EdToRefundCalculator = MockedEdCalculator; type OraclePriceProvider = PriceProviderMock; type OraclePeriod = RouteValidationOraclePeriod; - type AmmUnifiedEventSupport = AmmSupport; type WeightInfo = (); } @@ -708,7 +706,6 @@ impl Config for Test { type RetryOnError = (); type PolkadotNativeAssetId = PolkadotNativeCurrencyId; type SwappablePaymentAssetSupport = MockedInsufficientAssetSupport; - type AmmUnifiedEventSupport = AmmSupport; } pub struct MockedInsufficientAssetSupport; diff --git a/pallets/omnipool-liquidity-mining/src/tests/mock.rs b/pallets/omnipool-liquidity-mining/src/tests/mock.rs index 032bb4e7d..83fd6d167 100644 --- a/pallets/omnipool-liquidity-mining/src/tests/mock.rs +++ b/pallets/omnipool-liquidity-mining/src/tests/mock.rs @@ -306,7 +306,6 @@ impl pallet_omnipool::Config for Test { type MinWithdrawalFee = MinWithdrawFee; type ExternalPriceOracle = WithdrawFeePriceOracle; type Fee = FeeProvider; - type AmmUnifiedEventSupport = AmmSupport; } impl pallet_amm_support::Config for Test { diff --git a/pallets/omnipool/src/lib.rs b/pallets/omnipool/src/lib.rs index c82008d4b..f389b22aa 100644 --- a/pallets/omnipool/src/lib.rs +++ b/pallets/omnipool/src/lib.rs @@ -235,9 +235,6 @@ pub mod pallet { /// Oracle price provider. Provides price for given asset. Used in remove liquidity to support calculation of dynamic withdrawal fee. type ExternalPriceOracle: ExternalPriceProvider; - - /// Operation id provider for unified events - type AmmUnifiedEventSupport: IncrementalIdProvider + ExecutionTypeStack; } #[pallet::storage] @@ -1098,8 +1095,7 @@ pub mod pallet { protocol_fee_amount: state_changes.fee.protocol_fee, }); - let next_event_id = T::AmmUnifiedEventSupport::next_id().map_err(|_| ArithmeticError::Overflow)?; - T::AmmUnifiedEventSupport::push(ExecutionType::Omnipool(next_event_id))?; + pallet_amm_support::Pallet::::add_to_context(ExecutionType::Omnipool)?; //Swapped event for AssetA to HubAsset pallet_amm_support::Pallet::::deposit_trade_event( @@ -1140,7 +1136,7 @@ pub mod pallet { }], ); - T::AmmUnifiedEventSupport::pop()?; + pallet_amm_support::Pallet::::remove_from_context()?; #[cfg(feature = "try-runtime")] Self::ensure_trade_invariant( @@ -1347,8 +1343,7 @@ pub mod pallet { protocol_fee_amount: state_changes.fee.protocol_fee, }); - let next_event_id = T::AmmUnifiedEventSupport::next_id().map_err(|_| ArithmeticError::Overflow)?; - T::AmmUnifiedEventSupport::push(ExecutionType::Omnipool(next_event_id))?; + pallet_amm_support::Pallet::::add_to_context(ExecutionType::Omnipool)?; //Swapped even from AssetA to HubAsset pallet_amm_support::Pallet::::deposit_trade_event( @@ -1392,7 +1387,7 @@ pub mod pallet { }], ); - T::AmmUnifiedEventSupport::pop()?; + pallet_amm_support::Pallet::::remove_from_context()?; #[cfg(feature = "try-runtime")] Self::ensure_trade_invariant( diff --git a/pallets/omnipool/src/tests/mock.rs b/pallets/omnipool/src/tests/mock.rs index b4d4a645f..ebb712b20 100644 --- a/pallets/omnipool/src/tests/mock.rs +++ b/pallets/omnipool/src/tests/mock.rs @@ -211,7 +211,6 @@ impl Config for Test { type MinWithdrawalFee = MinWithdrawFee; type ExternalPriceOracle = WithdrawFeePriceOracle; type Fee = FeeProvider; - type AmmUnifiedEventSupport = AmmSupport; } pub struct ExtBuilder { diff --git a/pallets/otc-settlements/src/mock.rs b/pallets/otc-settlements/src/mock.rs index a95614e03..150016c27 100644 --- a/pallets/otc-settlements/src/mock.rs +++ b/pallets/otc-settlements/src/mock.rs @@ -157,7 +157,6 @@ impl pallet_route_executor::Config for Test { type OraclePeriod = RouteValidationOraclePeriod; type DefaultRoutePoolType = DefaultRoutePoolType; type TechnicalOrigin = EnsureRoot; - type AmmUnifiedEventSupport = AmmSupport; type WeightInfo = (); } @@ -352,7 +351,6 @@ impl pallet_omnipool::Config for Test { type MinWithdrawalFee = (); type ExternalPriceOracle = WithdrawFeePriceOracle; type Fee = FeeProvider; - type AmmUnifiedEventSupport = AmmSupport; } pub struct DummyNFT; diff --git a/pallets/route-executor/src/lib.rs b/pallets/route-executor/src/lib.rs index 8f179cd64..de1e60425 100644 --- a/pallets/route-executor/src/lib.rs +++ b/pallets/route-executor/src/lib.rs @@ -76,7 +76,7 @@ pub mod pallet { pub struct Pallet(_); #[pallet::config] - pub trait Config: frame_system::Config { + pub trait Config: frame_system::Config + pallet_amm_support::Config { type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Asset id type @@ -131,9 +131,6 @@ pub mod pallet { /// Origin able to set route without validation type TechnicalOrigin: EnsureOrigin; - /// AMM Unified event support - type AmmUnifiedEventSupport: IncrementalIdProvider + ExecutionTypeStack; - /// Weight information for the extrinsics. type WeightInfo: AmmTradeWeights>; } @@ -264,8 +261,7 @@ pub mod pallet { let route_length = route.len(); - let next_event_id = T::AmmUnifiedEventSupport::next_id().map_err(|_| ArithmeticError::Overflow)?; - T::AmmUnifiedEventSupport::push(ExecutionType::Router(next_event_id))?; + let next_event_id = pallet_amm_support::Pallet::::add_to_context(ExecutionType::Router)?; for (trade_index, (trade_amount, trade)) in trade_amounts.iter().rev().zip(route).enumerate() { Self::disable_ed_handling_for_insufficient_assets(route_length, trade_index, trade); @@ -309,7 +305,7 @@ pub mod pallet { event_id: next_event_id, }); - let _ = T::AmmUnifiedEventSupport::pop()?; + let _ = pallet_amm_support::Pallet::::remove_from_context()?; Ok(()) } @@ -502,8 +498,7 @@ impl Pallet { let route_length = route.len(); - let next_event_id = T::AmmUnifiedEventSupport::next_id().map_err(|_| ArithmeticError::Overflow)?; - T::AmmUnifiedEventSupport::push(ExecutionType::Router(next_event_id))?; + let next_event_id = pallet_amm_support::Pallet::::add_to_context(ExecutionType::Router)?; for (trade_index, (trade_amount, trade)) in trade_amounts.iter().zip(route.clone()).enumerate() { Self::disable_ed_handling_for_insufficient_assets(route_length, trade_index, trade); @@ -548,7 +543,7 @@ impl Pallet { event_id: next_event_id, }); - let _ = T::AmmUnifiedEventSupport::pop()?; + let _ = pallet_amm_support::Pallet::::remove_from_context()?; Ok(()) } diff --git a/pallets/route-executor/src/tests/mock.rs b/pallets/route-executor/src/tests/mock.rs index 968fb6bfd..c7e1aeee5 100644 --- a/pallets/route-executor/src/tests/mock.rs +++ b/pallets/route-executor/src/tests/mock.rs @@ -170,7 +170,6 @@ impl Config for Test { type OraclePeriod = RouteValidationOraclePeriod; type DefaultRoutePoolType = DefaultRoutePoolType; type TechnicalOrigin = EnsureRoot; - type AmmUnifiedEventSupport = AmmSupport; type WeightInfo = (); } diff --git a/runtime/adapters/src/tests/mock.rs b/runtime/adapters/src/tests/mock.rs index 07278a582..ddc320cdf 100644 --- a/runtime/adapters/src/tests/mock.rs +++ b/runtime/adapters/src/tests/mock.rs @@ -217,7 +217,6 @@ impl pallet_omnipool::Config for Test { ); type MinWithdrawalFee = MinWithdrawFee; type ExternalPriceOracle = WithdrawFeePriceOracle; - type AmmUnifiedEventSupport = AmmSupport; } pub struct FeeProvider; @@ -348,7 +347,6 @@ impl pallet_route_executor::Config for Test { type DefaultRoutePoolType = DefaultRoutePoolType; type TechnicalOrigin = EnsureRoot; type OraclePeriod = RouteValidationOraclePeriod; - type AmmUnifiedEventSupport = AmmSupport; type WeightInfo = (); } diff --git a/runtime/hydradx/src/assets.rs b/runtime/hydradx/src/assets.rs index c3adadda5..98f22e484 100644 --- a/runtime/hydradx/src/assets.rs +++ b/runtime/hydradx/src/assets.rs @@ -530,7 +530,6 @@ impl pallet_omnipool::Config for Runtime { ); type ExternalPriceOracle = EmaOraclePriceAdapter; type Fee = pallet_dynamic_fees::UpdateAndRetrieveFees; - type AmmUnifiedEventSupport = AmmSupport; } pub struct CircuitBreakerWhitelist; @@ -874,7 +873,6 @@ impl pallet_dca::Config for Runtime { type RetryOnError = RetryOnErrorForDca; type PolkadotNativeAssetId = DotAssetId; type SwappablePaymentAssetSupport = XykPaymentAssetSupport; - type AmmUnifiedEventSupport = AmmSupport; } // Provides weight info for the router. Router extrinsics can be executed with different AMMs, so we split the router weights into two parts: @@ -1216,7 +1214,6 @@ impl pallet_route_executor::Config for Runtime { type EdToRefundCalculator = RefundAndLockedEdCalculator; type OraclePriceProvider = hydradx_adapters::OraclePriceProvider; type OraclePeriod = RouteValidationOraclePeriod; - type AmmUnifiedEventSupport = AmmSupport; } parameter_types! { diff --git a/runtime/hydradx/src/system.rs b/runtime/hydradx/src/system.rs index 07f81a86b..d81cb8b4a 100644 --- a/runtime/hydradx/src/system.rs +++ b/runtime/hydradx/src/system.rs @@ -318,8 +318,7 @@ pub struct PushBatchExecutionTypeForUnifiedEvent; impl BatchPreHook for PushBatchExecutionTypeForUnifiedEvent { fn on_batch_start() -> DispatchResult { - let next_event_id = AmmSupport::next_id().map_err(|_| ArithmeticError::Overflow)?; - AmmSupport::push(ExecutionType::Batch(next_event_id))?; + AmmSupport::add_to_context(ExecutionType::Batch)?; Ok(()) } @@ -329,7 +328,7 @@ pub struct PopBatchExecutionTypeForUnifiedEvent; impl BatchPostHook for PopBatchExecutionTypeForUnifiedEvent { fn on_batch_end() -> DispatchResult { - AmmSupport::pop()?; + AmmSupport::remove_from_context()?; Ok(()) } From 5edd26e1fd54decfdff5eabdec8832c531b88221 Mon Sep 17 00:00:00 2001 From: dmoka Date: Wed, 18 Dec 2024 09:31:04 +0100 Subject: [PATCH 080/142] remove unused trait --- pallets/amm-support/src/lib.rs | 6 +--- pallets/amm-support/src/types.rs | 5 +-- pallets/dca/src/lib.rs | 60 +++++++++++++++---------------- pallets/omnipool/src/lib.rs | 1 - pallets/route-executor/src/lib.rs | 1 - runtime/hydradx/src/system.rs | 4 +-- 6 files changed, 31 insertions(+), 46 deletions(-) diff --git a/pallets/amm-support/src/lib.rs b/pallets/amm-support/src/lib.rs index 645092ccd..f7d5a5aba 100644 --- a/pallets/amm-support/src/lib.rs +++ b/pallets/amm-support/src/lib.rs @@ -205,8 +205,4 @@ impl ExecutionTypeStack for Pallet { IdStack::::kill(); } } -impl IncrementalIdProvider for Pallet { - fn next_id() -> Result { - Self::next_incremental_id() - } -} + diff --git a/pallets/amm-support/src/types.rs b/pallets/amm-support/src/types.rs index 0c0eaf864..c66811b75 100644 --- a/pallets/amm-support/src/types.rs +++ b/pallets/amm-support/src/types.rs @@ -9,10 +9,7 @@ use sp_arithmetic::FixedU128; use sp_std::vec; use sp_std::vec::Vec; -//TODO: we dont need this, delete -pub trait IncrementalIdProvider { - fn next_id() -> Result; -} + #[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] pub enum AssetType { diff --git a/pallets/dca/src/lib.rs b/pallets/dca/src/lib.rs index e288d1bff..a309df5ca 100644 --- a/pallets/dca/src/lib.rs +++ b/pallets/dca/src/lib.rs @@ -63,7 +63,6 @@ #![cfg_attr(not(feature = "std"), no_std)] -use frame_support::traits::DefensiveOption; use frame_support::{ ensure, pallet_prelude::*, @@ -71,32 +70,37 @@ use frame_support::{ transactional, weights::WeightToFee as FrameSupportWeight, }; +use frame_support::traits::DefensiveOption; use frame_system::{ ensure_signed, - pallet_prelude::{BlockNumberFor, OriginFor}, Origin, + pallet_prelude::{BlockNumberFor, OriginFor}, }; -use hydradx_adapters::RelayChainBlockHashProvider; -use hydradx_traits::fee::{InspectTransactionFeeCurrency, SwappablePaymentAssetTrader}; -use hydradx_traits::router::{inverse_route, RouteProvider}; -use hydradx_traits::router::{AmmTradeWeights, AmountInAndOut, RouterT, Trade}; -use hydradx_traits::NativePriceOracle; -use hydradx_traits::OraclePeriod; -use hydradx_traits::PriceOracle; use orml_traits::{arithmetic::CheckedAdd, MultiCurrency, NamedMultiReservableCurrency}; -use pallet_amm_support::types::{ExecutionType, ExecutionTypeStack, IncrementalIdProvider}; -use pallet_amm_support::IncrementalIdType; -use primitives::IncrementalId; -use rand::rngs::StdRng; use rand::{Rng, SeedableRng}; -use sp_runtime::helpers_128bit::multiply_by_rational_with_rounding; -use sp_runtime::traits::CheckedMul; +use rand::rngs::StdRng; use sp_runtime::{ - traits::{BlockNumberProvider, Saturating}, - ArithmeticError, BoundedVec, DispatchError, FixedPointNumber, FixedU128, Percent, Permill, Rounding, + ArithmeticError, + BoundedVec, DispatchError, FixedPointNumber, FixedU128, Percent, Permill, Rounding, traits::{BlockNumberProvider, Saturating}, }; +use sp_runtime::helpers_128bit::multiply_by_rational_with_rounding; +use sp_runtime::traits::CheckedMul; +use sp_std::cmp::min; use sp_std::vec::Vec; -use sp_std::{cmp::min, vec}; + +use hydradx_adapters::RelayChainBlockHashProvider; +use hydradx_traits::fee::{InspectTransactionFeeCurrency, SwappablePaymentAssetTrader}; +use hydradx_traits::NativePriceOracle; +use hydradx_traits::OraclePeriod; +use hydradx_traits::PriceOracle; +use hydradx_traits::router::{inverse_route, RouteProvider}; +use hydradx_traits::router::{AmmTradeWeights, AmountInAndOut, RouterT, Trade}; +pub use pallet::*; +use pallet_amm_support::types::{ExecutionType,}; +pub use weights::WeightInfo; + +// Re-export pallet items so that they can be accessed from the crate namespace. +use crate::types::*; #[cfg(test)] mod tests; @@ -104,32 +108,24 @@ mod tests; pub mod types; pub mod weights; -pub use weights::WeightInfo; - -// Re-export pallet items so that they can be accessed from the crate namespace. -use crate::types::*; -pub use pallet::*; - pub const SHORT_ORACLE_BLOCK_PERIOD: u32 = 10; pub const MAX_NUMBER_OF_RETRY_FOR_RESCHEDULING: u32 = 10; pub const FEE_MULTIPLIER_FOR_MIN_TRADE_LIMIT: Balance = 20; #[frame_support::pallet] pub mod pallet { - use super::*; use frame_support::traits::Contains; - use frame_support::weights::WeightToFee; - use frame_system::pallet_prelude::OriginFor; - use hydra_dx_math::ema::EmaPrice; - use hydradx_traits::fee::SwappablePaymentAssetTrader; - use hydradx_traits::{NativePriceOracle, PriceOracle}; use orml_traits::NamedMultiReservableCurrency; - use pallet_amm_support::types::ExecutionTypeStack; - use pallet_amm_support::types::IncrementalIdProvider; use sp_runtime::Percent; + use hydra_dx_math::ema::EmaPrice; + use hydradx_traits::{NativePriceOracle, PriceOracle}; + use hydradx_traits::fee::SwappablePaymentAssetTrader; + + use super::*; + #[pallet::pallet] pub struct Pallet(_); diff --git a/pallets/omnipool/src/lib.rs b/pallets/omnipool/src/lib.rs index f389b22aa..82c13c540 100644 --- a/pallets/omnipool/src/lib.rs +++ b/pallets/omnipool/src/lib.rs @@ -136,7 +136,6 @@ pub mod pallet { use hydra_dx_math::ema::EmaPrice; use hydra_dx_math::omnipool::types::{BalanceUpdate, I129}; use orml_traits::GetByKey; - use pallet_amm_support::types::IncrementalIdProvider; use pallet_amm_support::IncrementalIdType; use sp_runtime::ArithmeticError; diff --git a/pallets/route-executor/src/lib.rs b/pallets/route-executor/src/lib.rs index de1e60425..ee45302a8 100644 --- a/pallets/route-executor/src/lib.rs +++ b/pallets/route-executor/src/lib.rs @@ -39,7 +39,6 @@ pub use hydradx_traits::router::{ }; use orml_traits::arithmetic::{CheckedAdd, CheckedSub}; -use pallet_amm_support::types::IncrementalIdProvider; pub use pallet_amm_support::types::{AssetType, ExecutionType, ExecutionTypeStack, Fee}; use pallet_amm_support::IncrementalIdType; use primitives::IncrementalId; diff --git a/runtime/hydradx/src/system.rs b/runtime/hydradx/src/system.rs index d81cb8b4a..c091344cc 100644 --- a/runtime/hydradx/src/system.rs +++ b/runtime/hydradx/src/system.rs @@ -35,8 +35,6 @@ use frame_support::{ use frame_system::EnsureRoot; use hydradx_adapters::{OraclePriceProvider, RelayChainBlockNumberProvider}; use pallet_amm_support::types::ExecutionType; -use pallet_amm_support::types::ExecutionTypeStack; -use pallet_amm_support::types::IncrementalIdProvider; use pallet_transaction_multi_payment::{DepositAll, TransferFees, WeightInfo}; use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment}; use pallet_utility::{BatchPostHook, BatchPreHook}; @@ -46,7 +44,7 @@ use primitives::constants::{ time::{DAYS, HOURS, SLOT_DURATION}, }; use scale_info::TypeInfo; -use sp_runtime::{ArithmeticError, DispatchResult}; +use sp_runtime::{DispatchResult}; pub struct CallFilter; impl Contains for CallFilter { From fd38cf050515dd8615373ed92ea123a33579d9ff Mon Sep 17 00:00:00 2001 From: dmoka Date: Wed, 18 Dec 2024 10:35:57 +0100 Subject: [PATCH 081/142] remove unnecessary types --- pallets/amm-support/src/lib.rs | 50 ++++++---------------------- pallets/amm-support/src/tests/mod.rs | 2 +- pallets/amm-support/src/types.rs | 2 +- 3 files changed, 12 insertions(+), 42 deletions(-) diff --git a/pallets/amm-support/src/lib.rs b/pallets/amm-support/src/lib.rs index f7d5a5aba..0bdf44d43 100644 --- a/pallets/amm-support/src/lib.rs +++ b/pallets/amm-support/src/lib.rs @@ -41,22 +41,6 @@ pub use pallet::*; pub const MAX_STACK_SIZE: u32 = 10; -#[derive(RuntimeDebug, Encode, Decode, Default, Clone, PartialEq, Eq, TypeInfo, MaxEncodedLen)] -pub struct ExecutionIdStack(BoundedVec, ConstU32>); -impl ExecutionIdStack { - fn push(&mut self, execution_type: ExecutionType) -> Result<(), ()> { - self.0.try_push(execution_type).map_err(|_| ()) - } - - fn pop(&mut self) -> Result, ()> { - self.0.pop().ok_or(()) - } - - fn get(self) -> Vec> { - self.0.into_inner() - } -} - #[frame_support::pallet] pub mod pallet { use super::*; @@ -83,7 +67,7 @@ pub mod pallet { #[pallet::storage] /// Next available incremental ID #[pallet::getter(fn id_stack)] - pub(super) type IdStack = StorageValue<_, ExecutionIdStack, ValueQuery>; + pub(super) type IdStack = StorageValue<_, BoundedVec, ConstU32>, ValueQuery>; #[pallet::error] pub enum Error { @@ -114,7 +98,7 @@ pub mod pallet { let mut weight: Weight = Weight::zero(); weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 1)); - >::clear(); + IdStack::::get().clear(); Weight::from_parts(weight.ref_time(), 0) } @@ -143,6 +127,7 @@ impl Pallet { outputs: Vec<(AssetType, Balance)>, fees: Vec>, ) { + let operation_id = IdStack::::get().to_vec(); Self::deposit_event(Event::::Swapped { swapper, filler, @@ -151,7 +136,7 @@ impl Pallet { inputs, outputs, fees, - operation_id: >::get(), + operation_id, }); } @@ -166,8 +151,10 @@ impl Pallet { IdStack::::try_mutate(|stack| -> DispatchResult { stack - .push(execution_type(next_id)) - .map_err(|_| Error::::MaxStackSizeReached.into()) + .try_push(execution_type(next_id)) + .map_err(|_| Error::::MaxStackSizeReached)?; + + Ok(()) })?; Ok(next_id) @@ -177,32 +164,15 @@ impl Pallet { pub fn remove_from_context() -> Result, DispatchError> { //TODO: check what to do when it fails, we might dont want to bloc ktrades becase of it IdStack::::try_mutate(|stack| -> Result, DispatchError> { - stack.pop().map_err(|_| Error::::EmptyStack.into()) - }) - } -} - -impl ExecutionTypeStack for Pallet { - fn push(execution_type: ExecutionType) -> DispatchResult { - IdStack::::try_mutate(|stack| -> DispatchResult { - stack - .push(execution_type) - .map_err(|_| Error::::MaxStackSizeReached.into()) - }) - } - - fn pop() -> Result, DispatchError> { - IdStack::::try_mutate(|stack| -> Result, DispatchError> { - stack.pop().map_err(|_| Error::::EmptyStack.into()) + stack.pop().ok_or(Error::::EmptyStack.into()) }) } fn get() -> Vec> { - IdStack::::get().get() + IdStack::::get().to_vec() } fn clear() { IdStack::::kill(); } } - diff --git a/pallets/amm-support/src/tests/mod.rs b/pallets/amm-support/src/tests/mod.rs index 73687e527..209bf9a9a 100644 --- a/pallets/amm-support/src/tests/mod.rs +++ b/pallets/amm-support/src/tests/mod.rs @@ -1,2 +1,2 @@ -mod incremental_id; +//mod incremental_id; pub mod mock; diff --git a/pallets/amm-support/src/types.rs b/pallets/amm-support/src/types.rs index c66811b75..e30267e7e 100644 --- a/pallets/amm-support/src/types.rs +++ b/pallets/amm-support/src/types.rs @@ -58,7 +58,7 @@ impl Fee { #[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] pub enum ExecutionType { Router(IncrementalId), - DCA(IncrementalId), + DCA(IncrementalId), //We might need schedule id. How about otc? ICE(IncrementalId), Batch(IncrementalId), Omnipool(IncrementalId), From a8c33d0e7ee9a40d14d3487e759d0148eca52bb2 Mon Sep 17 00:00:00 2001 From: dmoka Date: Wed, 18 Dec 2024 10:41:32 +0100 Subject: [PATCH 082/142] use alias for executionIdStack --- pallets/amm-support/src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pallets/amm-support/src/lib.rs b/pallets/amm-support/src/lib.rs index 0bdf44d43..303fcebe3 100644 --- a/pallets/amm-support/src/lib.rs +++ b/pallets/amm-support/src/lib.rs @@ -41,6 +41,8 @@ pub use pallet::*; pub const MAX_STACK_SIZE: u32 = 10; +type ExecutionIdStack = BoundedVec, ConstU32>; + #[frame_support::pallet] pub mod pallet { use super::*; @@ -67,7 +69,7 @@ pub mod pallet { #[pallet::storage] /// Next available incremental ID #[pallet::getter(fn id_stack)] - pub(super) type IdStack = StorageValue<_, BoundedVec, ConstU32>, ValueQuery>; + pub(super) type IdStack = StorageValue<_, ExecutionIdStack, ValueQuery>; #[pallet::error] pub enum Error { From 66a0a25d5ceb13af4a0877bf26d6d588d5e2e56b Mon Sep 17 00:00:00 2001 From: dmoka Date: Wed, 18 Dec 2024 11:11:55 +0100 Subject: [PATCH 083/142] fix unit tests as we removed many traits from amm support pallet --- .../amm-support/src/tests/incremental_id.rs | 54 +++++++++---------- pallets/amm-support/src/tests/mod.rs | 2 +- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/pallets/amm-support/src/tests/incremental_id.rs b/pallets/amm-support/src/tests/incremental_id.rs index fe1d275e0..fe7ccbb23 100644 --- a/pallets/amm-support/src/tests/incremental_id.rs +++ b/pallets/amm-support/src/tests/incremental_id.rs @@ -35,35 +35,35 @@ fn event_id_should_be_incremented() { #[test] fn stack_should_be_populated_when_pushed() { ExtBuilder::default().build().execute_with(|| { - assert_ok!(AmmSupport::push(ExecutionType::Router(1))); - assert_eq!(AmmSupport::get(), vec![ExecutionType::Router(1)]); - assert_eq!(AmmSupport::id_stack().0.into_inner(), vec![ExecutionType::Router(1)]); + assert_ok!(AmmSupport::add_to_context(ExecutionType::Router)); + assert_eq!(AmmSupport::get(), vec![ExecutionType::Router(0)]); + assert_eq!(AmmSupport::id_stack().into_inner(), vec![ExecutionType::Router(0)]); - assert_ok!(AmmSupport::push(ExecutionType::Router(2))); + assert_ok!(AmmSupport::add_to_context(ExecutionType::Router)); assert_eq!( AmmSupport::get(), - vec![ExecutionType::Router(1), ExecutionType::Router(2)] + vec![ExecutionType::Router(0), ExecutionType::Router(1)] ); assert_eq!( - AmmSupport::id_stack().0.into_inner(), - vec![ExecutionType::Router(1), ExecutionType::Router(2)] + AmmSupport::id_stack().into_inner(), + vec![ExecutionType::Router(0), ExecutionType::Router(1)] ); - assert_ok!(AmmSupport::push(ExecutionType::ICE(3))); + assert_ok!(AmmSupport::add_to_context(ExecutionType::ICE)); assert_eq!( AmmSupport::get(), vec![ + ExecutionType::Router(0), ExecutionType::Router(1), - ExecutionType::Router(2), - ExecutionType::ICE(3) + ExecutionType::ICE(2) ] ); assert_eq!( - AmmSupport::id_stack().0.into_inner(), + AmmSupport::id_stack().into_inner(), vec![ + ExecutionType::Router(0), ExecutionType::Router(1), - ExecutionType::Router(2), - ExecutionType::ICE(3) + ExecutionType::ICE(2) ] ); }); @@ -73,11 +73,11 @@ fn stack_should_be_populated_when_pushed() { fn stack_should_not_panic_when_full() { ExtBuilder::default().build().execute_with(|| { for id in 0..MAX_STACK_SIZE { - assert_ok!(AmmSupport::push(ExecutionType::Router(id))); + assert_ok!(AmmSupport::add_to_context(ExecutionType::Router)); } assert_err!( - AmmSupport::push(ExecutionType::Router(MAX_STACK_SIZE)), + AmmSupport::add_to_context(ExecutionType::Router), Error::::MaxStackSizeReached ); }); @@ -86,34 +86,34 @@ fn stack_should_not_panic_when_full() { #[test] fn stack_should_be_reduced_when_poped() { ExtBuilder::default().build().execute_with(|| { - assert_ok!(AmmSupport::push(ExecutionType::Router(1))); - assert_ok!(AmmSupport::push(ExecutionType::Router(2))); - assert_ok!(AmmSupport::push(ExecutionType::ICE(3))); + assert_ok!(AmmSupport::add_to_context(ExecutionType::Router)); + assert_ok!(AmmSupport::add_to_context(ExecutionType::Router)); + assert_ok!(AmmSupport::add_to_context(ExecutionType::ICE)); - assert_ok!(AmmSupport::pop(), ExecutionType::ICE(3)); + assert_ok!(AmmSupport::remove_from_context(), ExecutionType::ICE(2)); assert_eq!( AmmSupport::get(), - vec![ExecutionType::Router(1), ExecutionType::Router(2)] + vec![ExecutionType::Router(0), ExecutionType::Router(1)] ); assert_eq!( - AmmSupport::id_stack().0.into_inner(), - vec![ExecutionType::Router(1), ExecutionType::Router(2)] + AmmSupport::id_stack().into_inner(), + vec![ExecutionType::Router(0), ExecutionType::Router(1)] ); - assert_ok!(AmmSupport::push(ExecutionType::ICE(3))); + assert_ok!(AmmSupport::add_to_context(ExecutionType::ICE)); assert_eq!( AmmSupport::get(), vec![ + ExecutionType::Router(0), ExecutionType::Router(1), - ExecutionType::Router(2), ExecutionType::ICE(3) ] ); assert_eq!( - AmmSupport::id_stack().0.into_inner(), + AmmSupport::id_stack().into_inner(), vec![ + ExecutionType::Router(0), ExecutionType::Router(1), - ExecutionType::Router(2), ExecutionType::ICE(3) ] ); @@ -123,7 +123,7 @@ fn stack_should_be_reduced_when_poped() { #[test] fn pop_from_empty_stack_should_not_panic() { ExtBuilder::default().build().execute_with(|| { - assert_err!(AmmSupport::pop(), Error::::EmptyStack); + assert_err!(AmmSupport::remove_from_context(), Error::::EmptyStack); }); } diff --git a/pallets/amm-support/src/tests/mod.rs b/pallets/amm-support/src/tests/mod.rs index 209bf9a9a..73687e527 100644 --- a/pallets/amm-support/src/tests/mod.rs +++ b/pallets/amm-support/src/tests/mod.rs @@ -1,2 +1,2 @@ -//mod incremental_id; +mod incremental_id; pub mod mock; From 1a00e1c444a687b219327597c83a573b258b2d8c Mon Sep 17 00:00:00 2001 From: dmoka Date: Wed, 18 Dec 2024 13:50:11 +0100 Subject: [PATCH 084/142] cleaning up --- pallets/amm-support/README.md | 13 ------------- pallets/amm-support/src/lib.rs | 5 +---- pallets/amm-support/src/tests/incremental_id.rs | 2 +- pallets/amm-support/src/types.rs | 12 ------------ pallets/omnipool/src/lib.rs | 1 - pallets/route-executor/src/lib.rs | 2 +- 6 files changed, 3 insertions(+), 32 deletions(-) diff --git a/pallets/amm-support/README.md b/pallets/amm-support/README.md index 0c72ac448..44eb41c86 100644 --- a/pallets/amm-support/README.md +++ b/pallets/amm-support/README.md @@ -4,30 +4,17 @@ Support pallet for AMMs. Includes the unified event that is emitted by all AMM p TODO -we should override the deposit event - replace amm specific types i the pallet make the types specific in amm pallet OtcOrderId in filler etc and use u32 -also for AssetFee, we need only account in as generic - -dont use associated type , use tighlty coopled it - -ExecutioonIdStack can be alias bounded vec - -and when we push pop, use increase_stack and decrase_decrase - -we ExecutionIdIdStack and ExecutionTypeStack does the same, we dont need the exetionTypeStack trait at all on_intialize should also directly. we can make storagw=e non-persistent, so we dont need on initialize -IncrementalIdProvuder is not needed - otc pallet we dont need into<32>. instead use atleastu32Unsuged diff --git a/pallets/amm-support/src/lib.rs b/pallets/amm-support/src/lib.rs index 303fcebe3..186cc5a28 100644 --- a/pallets/amm-support/src/lib.rs +++ b/pallets/amm-support/src/lib.rs @@ -22,7 +22,7 @@ type AssetId = u32; type Balance = u128; use crate::types::*; -use codec::{Decode, Encode, MaxEncodedLen}; +use codec::{Decode, Encode}; use frame_support::sp_runtime::app_crypto::sp_core; use frame_support::sp_runtime::{ArithmeticError, BoundedVec, DispatchError, DispatchResult}; use frame_system::pallet_prelude::BlockNumberFor; @@ -174,7 +174,4 @@ impl Pallet { IdStack::::get().to_vec() } - fn clear() { - IdStack::::kill(); - } } diff --git a/pallets/amm-support/src/tests/incremental_id.rs b/pallets/amm-support/src/tests/incremental_id.rs index fe7ccbb23..2ca8e07eb 100644 --- a/pallets/amm-support/src/tests/incremental_id.rs +++ b/pallets/amm-support/src/tests/incremental_id.rs @@ -72,7 +72,7 @@ fn stack_should_be_populated_when_pushed() { #[test] fn stack_should_not_panic_when_full() { ExtBuilder::default().build().execute_with(|| { - for id in 0..MAX_STACK_SIZE { + for _id in 0..MAX_STACK_SIZE { assert_ok!(AmmSupport::add_to_context(ExecutionType::Router)); } diff --git a/pallets/amm-support/src/types.rs b/pallets/amm-support/src/types.rs index e30267e7e..c84d83965 100644 --- a/pallets/amm-support/src/types.rs +++ b/pallets/amm-support/src/types.rs @@ -1,14 +1,8 @@ use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::dispatch::DispatchResultWithPostInfo; -use frame_support::sp_runtime::{DispatchError, DispatchResult}; -use frame_support::weights::Weight; use scale_info::TypeInfo; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; -use sp_arithmetic::FixedU128; -use sp_std::vec; -use sp_std::vec::Vec; - #[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] @@ -31,12 +25,6 @@ pub enum Filler { // ICE(solution_id/block id), swapper: alice, filler: solver } -pub trait ExecutionTypeStack { - fn push(execution_type: ExecutionType) -> DispatchResult; - fn pop() -> Result, DispatchError>; - fn get() -> Vec>; - fn clear(); -} #[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] pub struct Fee { diff --git a/pallets/omnipool/src/lib.rs b/pallets/omnipool/src/lib.rs index 82c13c540..59b47085f 100644 --- a/pallets/omnipool/src/lib.rs +++ b/pallets/omnipool/src/lib.rs @@ -95,7 +95,6 @@ use hydra_dx_math::ema::EmaPrice; use hydra_dx_math::omnipool::types::{AssetStateChange, BalanceUpdate, I129}; use hydradx_traits::registry::Inspect as RegistryInspect; use orml_traits::{GetByKey, MultiCurrency}; -use pallet_amm_support::types::ExecutionTypeStack; use pallet_amm_support::types::{AssetType, ExecutionType, Fee}; #[cfg(feature = "try-runtime")] use primitive_types::U256; diff --git a/pallets/route-executor/src/lib.rs b/pallets/route-executor/src/lib.rs index ee45302a8..1f14289a6 100644 --- a/pallets/route-executor/src/lib.rs +++ b/pallets/route-executor/src/lib.rs @@ -39,7 +39,7 @@ pub use hydradx_traits::router::{ }; use orml_traits::arithmetic::{CheckedAdd, CheckedSub}; -pub use pallet_amm_support::types::{AssetType, ExecutionType, ExecutionTypeStack, Fee}; +pub use pallet_amm_support::types::{AssetType, ExecutionType, Fee}; use pallet_amm_support::IncrementalIdType; use primitives::IncrementalId; use sp_core::U512; From 83104b3eedc7fa396b97f882c88f20faca6a9a6b Mon Sep 17 00:00:00 2001 From: dmoka Date: Wed, 18 Dec 2024 13:53:58 +0100 Subject: [PATCH 085/142] use overflowing to prevent future issues --- pallets/amm-support/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/amm-support/src/lib.rs b/pallets/amm-support/src/lib.rs index 186cc5a28..57f351265 100644 --- a/pallets/amm-support/src/lib.rs +++ b/pallets/amm-support/src/lib.rs @@ -147,7 +147,7 @@ impl Pallet { //TODO: double check what to do when these can fail, we dont really want failing due to this let next_id = IncrementalId::::try_mutate(|current_id| -> Result { let inc_id = *current_id; - *current_id = current_id.checked_add(1).ok_or(ArithmeticError::Overflow)?; + *current_id = current_id.overflowing_add(1).0.into(); Ok(inc_id) })?; From b887f62f2dc2e7029f35116fc7cf5b9e2f5fed67 Mon Sep 17 00:00:00 2001 From: dmoka Date: Wed, 18 Dec 2024 14:01:04 +0100 Subject: [PATCH 086/142] cleaning up --- pallets/amm-support/README.md | 4 ---- pallets/amm-support/src/lib.rs | 20 ++++++++----------- .../amm-support/src/tests/incremental_id.rs | 1 - pallets/amm-support/src/types.rs | 1 - 4 files changed, 8 insertions(+), 18 deletions(-) diff --git a/pallets/amm-support/README.md b/pallets/amm-support/README.md index 44eb41c86..7c1222481 100644 --- a/pallets/amm-support/README.md +++ b/pallets/amm-support/README.md @@ -24,7 +24,3 @@ remove nonfungibalbe asset type input and output should be tpye instead of tuple, because asset fee is also having same strucutre for inputs, outputs and fees - -next inceremetnal id use overflwoing add - -call it context instead of stack \ No newline at end of file diff --git a/pallets/amm-support/src/lib.rs b/pallets/amm-support/src/lib.rs index 57f351265..7be2f610f 100644 --- a/pallets/amm-support/src/lib.rs +++ b/pallets/amm-support/src/lib.rs @@ -22,14 +22,12 @@ type AssetId = u32; type Balance = u128; use crate::types::*; -use codec::{Decode, Encode}; use frame_support::sp_runtime::app_crypto::sp_core; use frame_support::sp_runtime::{ArithmeticError, BoundedVec, DispatchError, DispatchResult}; use frame_system::pallet_prelude::BlockNumberFor; pub use primitives::IncrementalId as IncrementalIdType; use primitives::ItemId as NftId; -use scale_info::TypeInfo; -use sp_core::{ConstU32, RuntimeDebug}; +use sp_core::{ConstU32}; use sp_std::vec::Vec; #[cfg(test)] mod tests; @@ -65,11 +63,10 @@ pub mod pallet { #[pallet::getter(fn incremental_id)] pub(super) type IncrementalId = StorageValue<_, IncrementalIdType, ValueQuery>; - //TODO: add better name #[pallet::storage] - /// Next available incremental ID + /// Execution context stack #[pallet::getter(fn id_stack)] - pub(super) type IdStack = StorageValue<_, ExecutionIdStack, ValueQuery>; + pub(super) type ExecutionContext = StorageValue<_, ExecutionIdStack, ValueQuery>; #[pallet::error] pub enum Error { @@ -96,11 +93,10 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { fn on_initialize(_n: BlockNumberFor) -> Weight { - //TODO: we might not need it if we can make sotrage not persistable let mut weight: Weight = Weight::zero(); weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 1)); - IdStack::::get().clear(); + ExecutionContext::::kill(); Weight::from_parts(weight.ref_time(), 0) } @@ -129,7 +125,7 @@ impl Pallet { outputs: Vec<(AssetType, Balance)>, fees: Vec>, ) { - let operation_id = IdStack::::get().to_vec(); + let operation_id = ExecutionContext::::get().to_vec(); Self::deposit_event(Event::::Swapped { swapper, filler, @@ -151,7 +147,7 @@ impl Pallet { Ok(inc_id) })?; - IdStack::::try_mutate(|stack| -> DispatchResult { + ExecutionContext::::try_mutate(|stack| -> DispatchResult { stack .try_push(execution_type(next_id)) .map_err(|_| Error::::MaxStackSizeReached)?; @@ -165,13 +161,13 @@ impl Pallet { //TODO: rename to pop context pub fn remove_from_context() -> Result, DispatchError> { //TODO: check what to do when it fails, we might dont want to bloc ktrades becase of it - IdStack::::try_mutate(|stack| -> Result, DispatchError> { + ExecutionContext::::try_mutate(|stack| -> Result, DispatchError> { stack.pop().ok_or(Error::::EmptyStack.into()) }) } fn get() -> Vec> { - IdStack::::get().to_vec() + ExecutionContext::::get().to_vec() } } diff --git a/pallets/amm-support/src/tests/incremental_id.rs b/pallets/amm-support/src/tests/incremental_id.rs index 2ca8e07eb..a038374f9 100644 --- a/pallets/amm-support/src/tests/incremental_id.rs +++ b/pallets/amm-support/src/tests/incremental_id.rs @@ -16,7 +16,6 @@ // limitations under the License. use crate::tests::mock::*; -use crate::types::*; use crate::Event; #[test] fn event_id_should_be_incremented() { diff --git a/pallets/amm-support/src/types.rs b/pallets/amm-support/src/types.rs index c84d83965..95f68fefc 100644 --- a/pallets/amm-support/src/types.rs +++ b/pallets/amm-support/src/types.rs @@ -1,5 +1,4 @@ use codec::{Decode, Encode, MaxEncodedLen}; -use frame_support::dispatch::DispatchResultWithPostInfo; use scale_info::TypeInfo; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; From 0233d43f47e199d85457a92966d8372b8d391c68 Mon Sep 17 00:00:00 2001 From: dmoka Date: Wed, 18 Dec 2024 14:02:02 +0100 Subject: [PATCH 087/142] cleaning up --- pallets/amm-support/src/lib.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/pallets/amm-support/src/lib.rs b/pallets/amm-support/src/lib.rs index 7be2f610f..539ea4bd1 100644 --- a/pallets/amm-support/src/lib.rs +++ b/pallets/amm-support/src/lib.rs @@ -138,7 +138,6 @@ impl Pallet { }); } - //TODO: rename pub fn add_to_context(execution_type: fn(u32) -> ExecutionType) -> Result { //TODO: double check what to do when these can fail, we dont really want failing due to this let next_id = IncrementalId::::try_mutate(|current_id| -> Result { @@ -158,7 +157,6 @@ impl Pallet { Ok(next_id) } - //TODO: rename to pop context pub fn remove_from_context() -> Result, DispatchError> { //TODO: check what to do when it fails, we might dont want to bloc ktrades becase of it ExecutionContext::::try_mutate(|stack| -> Result, DispatchError> { From feb24dce96cb2830e221435f3c5a82bf93da135b Mon Sep 17 00:00:00 2001 From: dmoka Date: Wed, 18 Dec 2024 16:25:33 +0100 Subject: [PATCH 088/142] remove unnecessary generic types --- integration-tests/src/referrals.rs | 4 +++- integration-tests/src/router.rs | 3 ++- pallets/amm-support/src/lib.rs | 18 ++++++++---------- .../amm-support/src/tests/incremental_id.rs | 2 +- pallets/amm-support/src/types.rs | 10 ++++++---- pallets/omnipool/src/lib.rs | 1 - pallets/stableswap/src/tests/add_liquidity.rs | 2 +- 7 files changed, 21 insertions(+), 19 deletions(-) diff --git a/integration-tests/src/referrals.rs b/integration-tests/src/referrals.rs index 967f42e68..31985e0f3 100644 --- a/integration-tests/src/referrals.rs +++ b/integration-tests/src/referrals.rs @@ -5,14 +5,16 @@ use frame_support::assert_ok; use frame_system::RawOrigin; use hydradx_runtime::{Currencies, Omnipool, Referrals, Runtime, RuntimeOrigin, Staking, Tokens}; use orml_traits::MultiCurrency; -use pallet_amm_support::types::*; +use pallet_amm_support::types::{AssetType, TradeOperation}; use pallet_referrals::{FeeDistribution, ReferralCode}; +use pallet_amm_support::types::Fee; use primitives::AccountId; use sp_core::crypto::Ss58AddressFormat; use sp_runtime::FixedU128; use sp_runtime::Permill; use std::vec; use xcm_emulator::TestExt; +use pallet_amm_support::types::Filler; #[test] fn registering_a_code_should_charge_registration_fee() { Hydra::execute_with(|| { diff --git a/integration-tests/src/router.rs b/integration-tests/src/router.rs index 41e45007a..054995cc5 100644 --- a/integration-tests/src/router.rs +++ b/integration-tests/src/router.rs @@ -17,7 +17,8 @@ use hydradx_traits::{ use pallet_amm_support::types::AssetType; use pallet_amm_support::types::ExecutionType; use pallet_amm_support::types::Fee; -use pallet_amm_support::types::*; +use pallet_amm_support::types::TradeOperation; +use pallet_amm_support::types::Filler; use pallet_lbp::weights::WeightInfo as LbpWeights; use pallet_lbp::WeightCurveType; use pallet_omnipool::traits::OmnipoolHooks; diff --git a/pallets/amm-support/src/lib.rs b/pallets/amm-support/src/lib.rs index 539ea4bd1..a75b72973 100644 --- a/pallets/amm-support/src/lib.rs +++ b/pallets/amm-support/src/lib.rs @@ -18,8 +18,6 @@ #![cfg_attr(not(feature = "std"), no_std)] #![allow(clippy::too_many_arguments)] -type AssetId = u32; -type Balance = u128; use crate::types::*; use frame_support::sp_runtime::app_crypto::sp_core; @@ -81,11 +79,11 @@ pub mod pallet { Swapped { swapper: T::AccountId, filler: T::AccountId, - filler_type: Filler, + filler_type: Filler, operation: TradeOperation, - inputs: Vec<(AssetType, Balance)>, - outputs: Vec<(AssetType, Balance)>, - fees: Vec>, + inputs: Vec<(AssetType, Balance)>, + outputs: Vec<(AssetType, Balance)>, + fees: Vec>, operation_id: Vec>, }, } @@ -119,11 +117,11 @@ impl Pallet { pub fn deposit_trade_event( swapper: T::AccountId, filler: T::AccountId, - filler_type: Filler, + filler_type: Filler, operation: TradeOperation, - inputs: Vec<(AssetType, Balance)>, - outputs: Vec<(AssetType, Balance)>, - fees: Vec>, + inputs: Vec<(AssetType, Balance)>, + outputs: Vec<(AssetType, Balance)>, + fees: Vec>, ) { let operation_id = ExecutionContext::::get().to_vec(); Self::deposit_event(Event::::Swapped { diff --git a/pallets/amm-support/src/tests/incremental_id.rs b/pallets/amm-support/src/tests/incremental_id.rs index a038374f9..50da63b7a 100644 --- a/pallets/amm-support/src/tests/incremental_id.rs +++ b/pallets/amm-support/src/tests/incremental_id.rs @@ -136,7 +136,7 @@ fn event_should_be_deposited() { TradeOperation::ExactIn, vec![(AssetType::Fungible(HDX), 1_000_000)], vec![(AssetType::Fungible(DOT), 2_000_000)], - vec![Fee::new(HDX, 1_000, ALICE), Fee::new(DOT, 2_000, BOB)], + vec![Fee::new(HDX, 1_000, ALICE.into()), Fee::new(DOT, 2_000, BOB.into())], ); expect_events(vec![Event::Swapped { diff --git a/pallets/amm-support/src/types.rs b/pallets/amm-support/src/types.rs index 95f68fefc..46c583a18 100644 --- a/pallets/amm-support/src/types.rs +++ b/pallets/amm-support/src/types.rs @@ -3,9 +3,11 @@ use scale_info::TypeInfo; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; +pub type AssetId = u32; +pub type Balance = u128; #[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] -pub enum AssetType { +pub enum AssetType { Fungible(AssetId), NFT(NFTId), } @@ -13,7 +15,7 @@ pub enum AssetType { pub type OtcOrderId = u32; #[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] -pub enum Filler { +pub enum Filler { Omnipool, Stableswap(AssetId), // pool id XYK(AssetId), // share token @@ -26,12 +28,12 @@ pub enum Filler { #[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] -pub struct Fee { +pub struct Fee { pub asset: AssetId, pub amount: Balance, pub recipient: AccountId, } -impl Fee { +impl Fee { pub fn new(asset: AssetId, amount: Balance, recipient: AccountId) -> Self { Self { asset, diff --git a/pallets/omnipool/src/lib.rs b/pallets/omnipool/src/lib.rs index 59b47085f..02d4d171e 100644 --- a/pallets/omnipool/src/lib.rs +++ b/pallets/omnipool/src/lib.rs @@ -135,7 +135,6 @@ pub mod pallet { use hydra_dx_math::ema::EmaPrice; use hydra_dx_math::omnipool::types::{BalanceUpdate, I129}; use orml_traits::GetByKey; - use pallet_amm_support::IncrementalIdType; use sp_runtime::ArithmeticError; #[pallet::pallet] diff --git a/pallets/stableswap/src/tests/add_liquidity.rs b/pallets/stableswap/src/tests/add_liquidity.rs index 857e7a5fa..71e3475f9 100644 --- a/pallets/stableswap/src/tests/add_liquidity.rs +++ b/pallets/stableswap/src/tests/add_liquidity.rs @@ -2,7 +2,7 @@ use crate::tests::mock::*; use crate::types::{AssetAmount, PoolInfo}; use crate::{assert_balance, to_precision, Error}; use frame_support::{assert_noop, assert_ok}; -use pallet_amm_support::types::*; +use pallet_amm_support::types::{Fee, AssetType}; use sp_runtime::Permill; use std::num::NonZeroU16; From 6ea27c7dc8039f0309fd31caa2796d9524aacb12 Mon Sep 17 00:00:00 2001 From: dmoka Date: Thu, 19 Dec 2024 08:20:17 +0100 Subject: [PATCH 089/142] added asset type and using it in swapped event --- integration-tests/src/dca.rs | 32 +++--- integration-tests/src/referrals.rs | 28 ++--- integration-tests/src/router.rs | 102 +++++++++--------- integration-tests/src/utility.rs | 30 +++--- pallets/amm-support/README.md | 16 --- pallets/amm-support/src/lib.rs | 9 +- .../amm-support/src/tests/incremental_id.rs | 8 +- pallets/amm-support/src/types.rs | 20 ++-- pallets/lbp/src/lib.rs | 10 +- pallets/lbp/src/tests.rs | 24 ++--- pallets/omnipool/src/lib.rs | 86 +++++++-------- pallets/omnipool/src/tests/buy.rs | 24 ++--- pallets/omnipool/src/tests/sell.rs | 8 +- pallets/otc-settlements/src/tests.rs | 8 +- pallets/otc/src/lib.rs | 12 +-- pallets/otc/src/tests/fill_order.rs | 14 +-- pallets/otc/src/tests/partial_fill_order.rs | 6 +- pallets/route-executor/src/lib.rs | 3 +- pallets/stableswap/src/lib.rs | 28 ++--- pallets/stableswap/src/tests/add_liquidity.rs | 10 +- .../stableswap/src/tests/remove_liquidity.rs | 10 +- pallets/stableswap/src/tests/trades.rs | 10 +- pallets/xyk/src/lib.rs | 10 +- pallets/xyk/src/tests/fees.rs | 26 ++--- pallets/xyk/src/tests/trades.rs | 18 ++-- 25 files changed, 270 insertions(+), 282 deletions(-) diff --git a/integration-tests/src/dca.rs b/integration-tests/src/dca.rs index e89b46861..7e340f86d 100644 --- a/integration-tests/src/dca.rs +++ b/integration-tests/src/dca.rs @@ -228,8 +228,8 @@ mod omnipool { filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::types::Filler::Omnipool, operation: pallet_amm_support::types::TradeOperation::ExactOut, - inputs: vec![(AssetType::Fungible(HDX), 140421094367051)], - outputs: vec![(AssetType::Fungible(LRNA), 70210545436437)], + inputs: vec![Asset::new(HDX, 140421094367051)], + outputs: vec![Asset::new(LRNA, 70210545436437)], fees: vec![Fee::new(LRNA, 35105272718, Omnipool::protocol_account()),], operation_id: vec![ ExecutionType::DCA(0), @@ -242,8 +242,8 @@ mod omnipool { filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::types::Filler::Omnipool, operation: pallet_amm_support::types::TradeOperation::ExactOut, - inputs: vec![(AssetType::Fungible(LRNA), 70175440163719)], - outputs: vec![(AssetType::Fungible(DAI), amount_out)], + inputs: vec![Asset::new(LRNA, 70175440163719)], + outputs: vec![Asset::new(DAI, amount_out)], fees: vec![Fee::new(DAI, 250626566417, Omnipool::protocol_account()),], operation_id: vec![ ExecutionType::DCA(0), @@ -266,8 +266,8 @@ mod omnipool { filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::types::Filler::Omnipool, operation: pallet_amm_support::types::TradeOperation::ExactOut, - inputs: vec![(AssetType::Fungible(HDX), 140421107716515)], - outputs: vec![(AssetType::Fungible(LRNA), 70210548448729)], + inputs: vec![Asset::new(HDX, 140421107716515)], + outputs: vec![Asset::new(LRNA, 70210548448729)], fees: vec![Fee::new(LRNA, 35105274224, Omnipool::protocol_account()),], operation_id: vec![ ExecutionType::DCA(3), @@ -280,8 +280,8 @@ mod omnipool { filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::types::Filler::Omnipool, operation: pallet_amm_support::types::TradeOperation::ExactOut, - inputs: vec![(AssetType::Fungible(LRNA), 70175443174505)], - outputs: vec![(AssetType::Fungible(DAI), amount_out)], + inputs: vec![Asset::new(LRNA, 70175443174505)], + outputs: vec![Asset::new(DAI, amount_out)], fees: vec![Fee::new(DAI, 250626566417, Omnipool::protocol_account()),], operation_id: vec![ ExecutionType::DCA(3), @@ -714,8 +714,8 @@ mod omnipool { filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::types::Filler::Omnipool, operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(HDX), amount_to_sell)], - outputs: vec![(AssetType::Fungible(LRNA), 49999999159957)], + inputs: vec![Asset::new(HDX, amount_to_sell)], + outputs: vec![Asset::new(LRNA, 49999999159957)], fees: vec![Fee::new(LRNA, 24999999579, Omnipool::protocol_account()),], operation_id: vec![ ExecutionType::DCA(0), @@ -728,8 +728,8 @@ mod omnipool { filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::types::Filler::Omnipool, operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(LRNA), 49974999160378)], - outputs: vec![(AssetType::Fungible(DAI), 71214372624126)], + inputs: vec![Asset::new(LRNA, 49974999160378)], + outputs: vec![Asset::new(DAI, 71214372624126)], fees: vec![Fee::new(DAI, 178482136903, Omnipool::protocol_account()),], operation_id: vec![ ExecutionType::DCA(0), @@ -752,8 +752,8 @@ mod omnipool { filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::types::Filler::Omnipool, operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(HDX), amount_to_sell)], - outputs: vec![(AssetType::Fungible(LRNA), 49999997360044)], + inputs: vec![Asset::new(HDX, amount_to_sell)], + outputs: vec![Asset::new(LRNA, 49999997360044)], fees: vec![Fee::new(LRNA, 24999998680, Omnipool::protocol_account()),], operation_id: vec![ ExecutionType::DCA(3), @@ -766,8 +766,8 @@ mod omnipool { filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::types::Filler::Omnipool, operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(LRNA), 49974997361364)], - outputs: vec![(AssetType::Fungible(DAI), 71214367826179)], + inputs: vec![Asset::new(LRNA, 49974997361364)], + outputs: vec![Asset::new(DAI, 71214367826179)], fees: vec![Fee::new(DAI, 178482124878, Omnipool::protocol_account()),], operation_id: vec![ ExecutionType::DCA(3), diff --git a/integration-tests/src/referrals.rs b/integration-tests/src/referrals.rs index 31985e0f3..641868c11 100644 --- a/integration-tests/src/referrals.rs +++ b/integration-tests/src/referrals.rs @@ -5,7 +5,7 @@ use frame_support::assert_ok; use frame_system::RawOrigin; use hydradx_runtime::{Currencies, Omnipool, Referrals, Runtime, RuntimeOrigin, Staking, Tokens}; use orml_traits::MultiCurrency; -use pallet_amm_support::types::{AssetType, TradeOperation}; +use pallet_amm_support::types::{TradeOperation}; use pallet_referrals::{FeeDistribution, ReferralCode}; use pallet_amm_support::types::Fee; use primitives::AccountId; @@ -15,6 +15,8 @@ use sp_runtime::Permill; use std::vec; use xcm_emulator::TestExt; use pallet_amm_support::types::Filler; +use pallet_amm_support::types::Asset; + #[test] fn registering_a_code_should_charge_registration_fee() { Hydra::execute_with(|| { @@ -334,8 +336,8 @@ fn trading_in_omnipool_should_use_asset_rewards_when_set() { filler: Omnipool::protocol_account(), filler_type: Filler::Omnipool, operation: TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(HDX), 1000000000000)], - outputs: vec![(AssetType::Fungible(LRNA), 1205768843)], + inputs: vec![Asset::new(HDX, 1000000000000)], + outputs: vec![Asset::new(LRNA, 1205768843)], fees: vec![Fee::new(LRNA, 602884, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Omnipool(0)], } @@ -345,8 +347,8 @@ fn trading_in_omnipool_should_use_asset_rewards_when_set() { filler: Omnipool::protocol_account(), filler_type: Filler::Omnipool, operation: TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(LRNA), 1205165959)], - outputs: vec![(AssetType::Fungible(DAI), 26663424573622008)], + inputs: vec![Asset::new(LRNA, 1205165959)], + outputs: vec![Asset::new(DAI, 26663424573622008)], fees: vec![Fee::new(DAI, 70524156750724, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Omnipool(0)], } @@ -391,8 +393,8 @@ fn buying_hdx_in_omnipool_should_transfer_correct_fee() { filler: Omnipool::protocol_account(), filler_type: Filler::Omnipool, operation: TradeOperation::ExactOut, - inputs: vec![(AssetType::Fungible(DAI), 26_835_579_541_620_354)], - outputs: vec![(AssetType::Fungible(LRNA), 1_209_746_177)], + inputs: vec![Asset::new(DAI, 26_835_579_541_620_354)], + outputs: vec![Asset::new(LRNA, 1_209_746_177)], fees: vec![Fee::new(LRNA, 604_873, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Omnipool(0)], } @@ -402,8 +404,8 @@ fn buying_hdx_in_omnipool_should_transfer_correct_fee() { filler: Omnipool::protocol_account(), filler_type: Filler::Omnipool, operation: TradeOperation::ExactOut, - inputs: vec![(AssetType::Fungible(LRNA), 1_209_141_304)], - outputs: vec![(AssetType::Fungible(HDX), 1_000_000_000_000)], + inputs: vec![Asset::new(LRNA, 1_209_141_304)], + outputs: vec![Asset::new(HDX, 1_000_000_000_000)], fees: vec![Fee::new(HDX, 2_794_789_078, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Omnipool(0)], } @@ -452,8 +454,8 @@ fn buying_with_hdx_in_omnipool_should_transfer_correct_fee() { filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::types::Filler::Omnipool, operation: pallet_amm_support::types::TradeOperation::ExactOut, - inputs: vec![(AssetType::Fungible(HDX), 37_506_757_329_085)], - outputs: vec![(AssetType::Fungible(LRNA), 45_222_713_080)], + inputs: vec![Asset::new(HDX, 37_506_757_329_085)], + outputs: vec![Asset::new(LRNA, 45_222_713_080)], fees: vec![Fee::new(LRNA, 22_611_356, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Omnipool(0)], } @@ -463,8 +465,8 @@ fn buying_with_hdx_in_omnipool_should_transfer_correct_fee() { filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::types::Filler::Omnipool, operation: pallet_amm_support::types::TradeOperation::ExactOut, - inputs: vec![(AssetType::Fungible(LRNA), 45_200_101_724)], - outputs: vec![(AssetType::Fungible(DAI), 1_000_000_000_000_000_000)], + inputs: vec![Asset::new(LRNA, 45_200_101_724)], + outputs: vec![Asset::new(DAI, 1_000_000_000_000_000_000)], fees: vec![Fee::new(DAI, 2_644_977_450_514_458, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Omnipool(0)], } diff --git a/integration-tests/src/router.rs b/integration-tests/src/router.rs index 054995cc5..648cea99d 100644 --- a/integration-tests/src/router.rs +++ b/integration-tests/src/router.rs @@ -7,6 +7,7 @@ use hydradx_runtime::{ AssetRegistry, BlockNumber, Currencies, Omnipool, Router, RouterWeightInfo, Runtime, RuntimeOrigin, Stableswap, LBP, XYK, }; +use pallet_amm_support::types::Asset; use hydradx_traits::router::AssetPair as Pair; use hydradx_traits::router::RouteSpotPriceProvider; use hydradx_traits::{ @@ -14,7 +15,6 @@ use hydradx_traits::{ router::{PoolType, Trade}, AssetKind, AMM, }; -use pallet_amm_support::types::AssetType; use pallet_amm_support::types::ExecutionType; use pallet_amm_support::types::Fee; use pallet_amm_support::types::TradeOperation; @@ -163,8 +163,8 @@ mod router_different_pools_tests { filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA)), filler_type: pallet_amm_support::types::Filler::LBP, operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(DAI), 9980000000)], - outputs: vec![(AssetType::Fungible(LRNA), 5640664064)], + inputs: vec![Asset::new(DAI, 9980000000)], + outputs: vec![Asset::new(LRNA, 5640664064)], fees: vec![Fee::new( DAI, 20000000, @@ -180,8 +180,8 @@ mod router_different_pools_tests { filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::types::Filler::Omnipool, operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(LRNA), 5640664064)], - outputs: vec![(AssetType::Fungible(HDX), 4682924837974)], + inputs: vec![Asset::new(LRNA, 5640664064)], + outputs: vec![Asset::new(HDX, 4682924837974)], fees: vec![Fee::new(HDX, 11736653730, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Router(0)], } @@ -199,8 +199,8 @@ mod router_different_pools_tests { }, ))), operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(HDX), 4682924837974)], - outputs: vec![(AssetType::Fungible(DOT), 2230008413831)], + inputs: vec![Asset::new(HDX, 4682924837974)], + outputs: vec![Asset::new(DOT, 2230008413831)], fees: vec![Fee::new( DOT, 6710155707, @@ -286,8 +286,8 @@ mod router_different_pools_tests { filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX)), filler_type: Filler::LBP, operation: TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(DAI), 9980000000)], - outputs: vec![(AssetType::Fungible(HDX), 5640664064)], + inputs: vec![Asset::new(DAI, 9980000000)], + outputs: vec![Asset::new(HDX, 5640664064)], fees: vec![Fee::new( DAI, 20000000, @@ -311,8 +311,8 @@ mod router_different_pools_tests { }, ))), operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(HDX), 5640664064)], - outputs: vec![(AssetType::Fungible(stable_asset_1), 2811712439)], + inputs: vec![Asset::new(HDX, 5640664064)], + outputs: vec![Asset::new(stable_asset_1, 2811712439)], fees: vec![Fee::new( stable_asset_1, 8460516, @@ -332,8 +332,8 @@ mod router_different_pools_tests { ), filler_type: pallet_amm_support::types::Filler::Stableswap(stable_pool_id), operation: TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(stable_asset_1), 2811712439)], - outputs: vec![(AssetType::Fungible(stable_asset_2), 2783595233)], + inputs: vec![Asset::new(stable_asset_1, 2811712439)], + outputs: vec![Asset::new(stable_asset_2, 2783595233)], fees: vec![Fee::new( stable_asset_2, 28117123, @@ -416,8 +416,8 @@ mod router_different_pools_tests { filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA)), filler_type: pallet_amm_support::types::Filler::LBP, operation: pallet_amm_support::types::TradeOperation::ExactOut, - inputs: vec![(AssetType::Fungible(DAI), 4362157193)], - outputs: vec![(AssetType::Fungible(LRNA), 2465566245)], + inputs: vec![Asset::new(DAI, 4362157193)], + outputs: vec![Asset::new(LRNA, 2465566245)], fees: vec![Fee::new( DAI, 8741796, @@ -433,8 +433,8 @@ mod router_different_pools_tests { filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::types::Filler::Omnipool, operation: pallet_amm_support::types::TradeOperation::ExactOut, - inputs: vec![(AssetType::Fungible(LRNA), 2465566245)], - outputs: vec![(AssetType::Fungible(HDX), 2046938775509)], + inputs: vec![Asset::new(LRNA, 2465566245)], + outputs: vec![Asset::new(HDX, 2046938775509)], fees: vec![Fee::new(HDX, 5130172370, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Router(0)], } @@ -452,8 +452,8 @@ mod router_different_pools_tests { }, ))), operation: pallet_amm_support::types::TradeOperation::ExactOut, - inputs: vec![(AssetType::Fungible(HDX), 1000000000000)], - outputs: vec![(AssetType::Fungible(DOT), 2040816326531)], + inputs: vec![Asset::new(HDX, 1000000000000)], + outputs: vec![Asset::new(DOT, 2040816326531)], fees: vec![Fee::new( HDX, 6122448978, @@ -539,8 +539,8 @@ mod router_different_pools_tests { filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX)), filler_type: pallet_amm_support::types::Filler::LBP, operation: pallet_amm_support::types::TradeOperation::ExactOut, - inputs: vec![(AssetType::Fungible(DAI), 3746042043754)], - outputs: vec![(AssetType::Fungible(HDX), 2067851065323)], + inputs: vec![Asset::new(DAI, 3746042043754)], + outputs: vec![Asset::new(HDX, 2067851065323)], fees: vec![Fee::new( DAI, 7507098284, @@ -564,8 +564,8 @@ mod router_different_pools_tests { }, ))), operation: pallet_amm_support::types::TradeOperation::ExactOut, - inputs: vec![(AssetType::Fungible(HDX), 1010010000114)], - outputs: vec![(AssetType::Fungible(stable_asset_1), 2061666067122)], + inputs: vec![Asset::new(HDX, 1010010000114)], + outputs: vec![Asset::new(stable_asset_1, 2061666067122)], fees: vec![Fee::new( HDX, 6184998201, @@ -585,8 +585,8 @@ mod router_different_pools_tests { ), filler_type: pallet_amm_support::types::Filler::Stableswap(stable_pool_id), operation: pallet_amm_support::types::TradeOperation::ExactOut, - inputs: vec![(AssetType::Fungible(stable_asset_1), 1010010000114)], - outputs: vec![(AssetType::Fungible(stable_asset_2), 1000000000000)], + inputs: vec![Asset::new(stable_asset_1, 1010010000114)], + outputs: vec![Asset::new(stable_asset_2, 1000000000000)], fees: vec![Fee::new( stable_asset_1, 10000099012, @@ -672,8 +672,8 @@ mod router_different_pools_tests { }, ))), operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(HDX), 10000000000)], - outputs: vec![(AssetType::Fungible(DOT), 4984501549)], + inputs: vec![Asset::new(HDX, 10000000000)], + outputs: vec![Asset::new(DOT, 4984501549)], fees: vec![Fee::new( DOT, 14998500, @@ -698,8 +698,8 @@ mod router_different_pools_tests { }, ))), operation: pallet_amm_support::types::TradeOperation::ExactOut, - inputs: vec![(AssetType::Fungible(HDX), 10000000000)], - outputs: vec![(AssetType::Fungible(DOT), 20007996198)], + inputs: vec![Asset::new(HDX, 10000000000)], + outputs: vec![Asset::new(DOT, 20007996198)], fees: vec![Fee::new( HDX, 60023988, @@ -724,8 +724,8 @@ mod router_different_pools_tests { }, ))), operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(HDX), 10000000000)], - outputs: vec![(AssetType::Fungible(DOT), 4981510054)], + inputs: vec![Asset::new(HDX, 10000000000)], + outputs: vec![Asset::new(DOT, 4981510054)], fees: vec![Fee::new( DOT, 14989497, @@ -2405,8 +2405,8 @@ mod omnipool_router_tests { filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::types::Filler::Omnipool, operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(HDX), amount_to_sell)], - outputs: vec![(AssetType::Fungible(LRNA), 12014871681)], + inputs: vec![Asset::new(HDX, amount_to_sell)], + outputs: vec![Asset::new(LRNA, 12014871681)], fees: vec![Fee::new(LRNA, 6007435, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Router(0), ExecutionType::Omnipool(1)], } @@ -2416,8 +2416,8 @@ mod omnipool_router_tests { filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::types::Filler::Omnipool, operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(LRNA), 12008864246)], - outputs: vec![(AssetType::Fungible(DAI), amount_out)], + inputs: vec![Asset::new(LRNA, 12008864246)], + outputs: vec![Asset::new(DAI, amount_out)], fees: vec![Fee::new(DAI, 667155563986401, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Router(0), ExecutionType::Omnipool(1)], } @@ -2467,8 +2467,8 @@ mod omnipool_router_tests { filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::types::Filler::Omnipool, operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(HDX), amount_to_sell)], - outputs: vec![(AssetType::Fungible(LRNA), 12014871681)], + inputs: vec![Asset::new(HDX, amount_to_sell)], + outputs: vec![Asset::new(LRNA, 12014871681)], fees: vec![Fee::new(LRNA, 6007435, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Omnipool(0)], } @@ -2478,8 +2478,8 @@ mod omnipool_router_tests { filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::types::Filler::Omnipool, operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(LRNA), 12008864246)], - outputs: vec![(AssetType::Fungible(DAI), amount_out)], + inputs: vec![Asset::new(LRNA, 12008864246)], + outputs: vec![Asset::new(DAI, amount_out)], fees: vec![Fee::new(DAI, 667155563986401, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Omnipool(0)], } @@ -2635,8 +2635,8 @@ mod omnipool_router_tests { filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::types::Filler::Omnipool, operation: pallet_amm_support::types::TradeOperation::ExactOut, - inputs: vec![(AssetType::Fungible(HDX), amount_in)], - outputs: vec![(AssetType::Fungible(LRNA), 45135)], + inputs: vec![Asset::new(HDX, amount_in)], + outputs: vec![Asset::new(LRNA, 45135)], fees: vec![Fee::new(LRNA, 22, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Router(0), ExecutionType::Omnipool(1)], } @@ -2646,8 +2646,8 @@ mod omnipool_router_tests { filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::types::Filler::Omnipool, operation: pallet_amm_support::types::TradeOperation::ExactOut, - inputs: vec![(AssetType::Fungible(LRNA), 45113)], - outputs: vec![(AssetType::Fungible(DAI), amount_to_buy)], + inputs: vec![Asset::new(LRNA, 45113)], + outputs: vec![Asset::new(DAI, amount_to_buy)], fees: vec![Fee::new(DAI, 2506265665, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Router(0), ExecutionType::Omnipool(1)], } @@ -2697,8 +2697,8 @@ mod omnipool_router_tests { filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::types::Filler::Omnipool, operation: pallet_amm_support::types::TradeOperation::ExactOut, - inputs: vec![(AssetType::Fungible(HDX), amount_in)], - outputs: vec![(AssetType::Fungible(LRNA), 45135)], + inputs: vec![Asset::new(HDX, amount_in)], + outputs: vec![Asset::new(LRNA, 45135)], fees: vec![Fee::new(LRNA, 22, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Omnipool(0)], } @@ -2708,8 +2708,8 @@ mod omnipool_router_tests { filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::types::Filler::Omnipool, operation: pallet_amm_support::types::TradeOperation::ExactOut, - inputs: vec![(AssetType::Fungible(LRNA), 45113)], - outputs: vec![(AssetType::Fungible(DAI), amount_to_buy)], + inputs: vec![Asset::new(LRNA, 45113)], + outputs: vec![Asset::new(DAI, amount_to_buy)], fees: vec![Fee::new(DAI, 2506265665, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Omnipool(0)], } @@ -2992,8 +2992,8 @@ mod lbp_router_tests { filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX)), filler_type: pallet_amm_support::types::Filler::LBP, operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(HDX), amount_to_sell - fee)], - outputs: vec![(AssetType::Fungible(DAI), received_amount_out)], + inputs: vec![Asset::new(HDX, amount_to_sell - fee)], + outputs: vec![Asset::new(DAI, received_amount_out)], fees: vec![Fee::new( HDX, fee, @@ -3048,8 +3048,8 @@ mod lbp_router_tests { filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX)), filler_type: pallet_amm_support::types::Filler::LBP, operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(HDX), 9_980_000_000_000)], - outputs: vec![(AssetType::Fungible(DAI), received_amount_out)], + inputs: vec![Asset::new(HDX, 9_980_000_000_000)], + outputs: vec![Asset::new(DAI, received_amount_out)], fees: vec![Fee::new( HDX, 20_000_000_000, diff --git a/integration-tests/src/utility.rs b/integration-tests/src/utility.rs index 69910ccf7..dd6d9f662 100644 --- a/integration-tests/src/utility.rs +++ b/integration-tests/src/utility.rs @@ -10,11 +10,11 @@ use hydradx_runtime::{Currencies, Omnipool, Runtime, RuntimeEvent}; use hydradx_runtime::{RuntimeCall, Utility}; use hydradx_traits::router::PoolType; use xcm_emulator::TestExt; +use pallet_amm_support::types::Asset; use hydradx_traits::router::Trade; use hydradx_traits::AMM; use orml_traits::MultiCurrency; -use pallet_amm_support::types::AssetType; use pallet_amm_support::types::ExecutionType; use pallet_amm_support::types::Fee; #[test] @@ -75,8 +75,8 @@ fn batch_execution_type_should_be_included_in_batch() { filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA)), filler_type: pallet_amm_support::types::Filler::LBP, operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(DAI), 9980000000)], - outputs: vec![(AssetType::Fungible(LRNA), 5640664064)], + inputs: vec![Asset::new(DAI, 9980000000)], + outputs: vec![Asset::new(LRNA, 5640664064)], fees: vec![Fee::new( DAI, 20000000, @@ -91,8 +91,8 @@ fn batch_execution_type_should_be_included_in_batch() { filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::types::Filler::Omnipool, operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(LRNA), 5640664064)], - outputs: vec![(AssetType::Fungible(HDX), 4682924837974)], + inputs: vec![Asset::new(LRNA, 5640664064)], + outputs: vec![Asset::new(HDX, 4682924837974)], fees: vec![Fee::new(HDX, 11736653730, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Batch(0), ExecutionType::Router(1)], }), @@ -109,8 +109,8 @@ fn batch_execution_type_should_be_included_in_batch() { }, ))), operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(HDX), 4682924837974)], - outputs: vec![(AssetType::Fungible(DOT), 2230008413831)], + inputs: vec![Asset::new(HDX, 4682924837974)], + outputs: vec![Asset::new(DOT, 2230008413831)], fees: vec![Fee::new( DOT, 6710155707, @@ -204,8 +204,8 @@ fn batch_execution_type_should_be_popped_when_multiple_batch_calls_happen() { }, ))), operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(HDX), amount_to_sell)], - outputs: vec![(AssetType::Fungible(DOT), 4549178628)], + inputs: vec![Asset::new(HDX, amount_to_sell)], + outputs: vec![Asset::new(DOT, 4549178628)], fees: vec![Fee::new( DOT, 13688601, @@ -282,8 +282,8 @@ fn nested_batch_should_represent_embeddedness() { filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA)), filler_type: pallet_amm_support::types::Filler::LBP, operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(DAI), 9980000000)], - outputs: vec![(AssetType::Fungible(LRNA), 5640664064)], + inputs: vec![Asset::new(DAI, 9980000000)], + outputs: vec![Asset::new(LRNA, 5640664064)], fees: vec![Fee::new( DAI, 20000000, @@ -298,8 +298,8 @@ fn nested_batch_should_represent_embeddedness() { filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::types::Filler::Omnipool, operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(LRNA), 5640664064)], - outputs: vec![(AssetType::Fungible(HDX), 4682924837974)], + inputs: vec![Asset::new(LRNA, 5640664064)], + outputs: vec![Asset::new(HDX, 4682924837974)], fees: vec![Fee::new(HDX, 11736653730, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Batch(0), ExecutionType::Batch(1), ExecutionType::Router(2)], }), @@ -316,8 +316,8 @@ fn nested_batch_should_represent_embeddedness() { }, ))), operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(HDX), 4682924837974)], - outputs: vec![(AssetType::Fungible(DOT), 2230008413831)], + inputs: vec![Asset::new(HDX, 4682924837974)], + outputs: vec![Asset::new(DOT, 2230008413831)], fees: vec![Fee::new( DOT, 6710155707, diff --git a/pallets/amm-support/README.md b/pallets/amm-support/README.md index 7c1222481..20f239b78 100644 --- a/pallets/amm-support/README.md +++ b/pallets/amm-support/README.md @@ -4,23 +4,7 @@ Support pallet for AMMs. Includes the unified event that is emitted by all AMM p TODO -replace amm specific types i the pallet - -make the types specific in amm pallet - OtcOrderId in filler etc and use u32 -on_intialize should also directly. - -we can make storagw=e non-persistent, so we dont need on initialize - otc pallet we dont need into<32>. instead use atleastu32Unsuged - - -remove nonfungibalbe asset type - - -input and output should be tpye instead of tuple, because asset fee is also - -having same strucutre for inputs, outputs and fees diff --git a/pallets/amm-support/src/lib.rs b/pallets/amm-support/src/lib.rs index a75b72973..8ca0ccae4 100644 --- a/pallets/amm-support/src/lib.rs +++ b/pallets/amm-support/src/lib.rs @@ -24,7 +24,6 @@ use frame_support::sp_runtime::app_crypto::sp_core; use frame_support::sp_runtime::{ArithmeticError, BoundedVec, DispatchError, DispatchResult}; use frame_system::pallet_prelude::BlockNumberFor; pub use primitives::IncrementalId as IncrementalIdType; -use primitives::ItemId as NftId; use sp_core::{ConstU32}; use sp_std::vec::Vec; #[cfg(test)] @@ -81,8 +80,8 @@ pub mod pallet { filler: T::AccountId, filler_type: Filler, operation: TradeOperation, - inputs: Vec<(AssetType, Balance)>, - outputs: Vec<(AssetType, Balance)>, + inputs: Vec, + outputs: Vec, fees: Vec>, operation_id: Vec>, }, @@ -119,8 +118,8 @@ impl Pallet { filler: T::AccountId, filler_type: Filler, operation: TradeOperation, - inputs: Vec<(AssetType, Balance)>, - outputs: Vec<(AssetType, Balance)>, + inputs: Vec, + outputs: Vec, fees: Vec>, ) { let operation_id = ExecutionContext::::get().to_vec(); diff --git a/pallets/amm-support/src/tests/incremental_id.rs b/pallets/amm-support/src/tests/incremental_id.rs index 50da63b7a..6c18401ce 100644 --- a/pallets/amm-support/src/tests/incremental_id.rs +++ b/pallets/amm-support/src/tests/incremental_id.rs @@ -134,8 +134,8 @@ fn event_should_be_deposited() { BOB, Filler::Omnipool, TradeOperation::ExactIn, - vec![(AssetType::Fungible(HDX), 1_000_000)], - vec![(AssetType::Fungible(DOT), 2_000_000)], + vec![Asset::new(HDX, 1_000_000)], + vec![Asset::new(DOT, 2_000_000)], vec![Fee::new(HDX, 1_000, ALICE.into()), Fee::new(DOT, 2_000, BOB.into())], ); @@ -144,8 +144,8 @@ fn event_should_be_deposited() { filler: BOB, filler_type: Filler::Omnipool, operation: TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(HDX), 1_000_000)], - outputs: vec![(AssetType::Fungible(DOT), 2_000_000)], + inputs: vec![Asset::new(HDX, 1_000_000)], + outputs: vec![Asset::new(DOT, 2_000_000)], fees: vec![Fee::new(HDX, 1_000, ALICE), Fee::new(DOT, 2_000, BOB)], operation_id: vec![], } diff --git a/pallets/amm-support/src/types.rs b/pallets/amm-support/src/types.rs index 46c583a18..1da56c87c 100644 --- a/pallets/amm-support/src/types.rs +++ b/pallets/amm-support/src/types.rs @@ -6,12 +6,6 @@ use serde::{Deserialize, Serialize}; pub type AssetId = u32; pub type Balance = u128; -#[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] -pub enum AssetType { - Fungible(AssetId), - NFT(NFTId), -} - pub type OtcOrderId = u32; #[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] @@ -43,6 +37,20 @@ impl Fee { } } +#[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] +pub struct Asset { + pub asset: AssetId, + pub amount: Balance, +} +impl Asset { + pub fn new(asset: AssetId, amount: Balance) -> Self { + Self { + asset, + amount, + } + } +} + #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] #[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] pub enum ExecutionType { diff --git a/pallets/lbp/src/lib.rs b/pallets/lbp/src/lib.rs index bbd9b1b6d..42b9d292d 100644 --- a/pallets/lbp/src/lib.rs +++ b/pallets/lbp/src/lib.rs @@ -37,7 +37,7 @@ use frame_system::ensure_signed; use frame_system::pallet_prelude::BlockNumberFor; use hydra_dx_math::types::LBPWeight; use hydradx_traits::{AMMTransfer, AssetPairAccountIdFor, CanCreatePool, LockedBalance, AMM}; -use pallet_amm_support::types::{AssetType, Fee}; +use pallet_amm_support::types::{Asset, Fee}; use orml_traits::{MultiCurrency, MultiCurrencyExtended, MultiLockableCurrency}; @@ -1126,8 +1126,8 @@ impl AMM> for Pallet AMM> for Pallet Pallet { Self::protocol_account(), pallet_amm_support::types::Filler::Omnipool, pallet_amm_support::types::TradeOperation::ExactIn, - vec![( - AssetType::Fungible(T::HubAssetId::get().into()), - *state_changes.asset.delta_hub_reserve, - )], - vec![( - AssetType::Fungible(asset_out.into()), - *state_changes.asset.delta_reserve, - )], + vec![ + Asset::new(T::HubAssetId::get().into(), + *state_changes.asset.delta_hub_reserve), + ], + vec![ + Asset::new(asset_out.into(), + *state_changes.asset.delta_reserve), + ], vec![Fee { asset: asset_out.into(), amount: state_changes.fee.asset_fee, @@ -2040,14 +2034,14 @@ impl Pallet { Self::protocol_account(), pallet_amm_support::types::Filler::Omnipool, pallet_amm_support::types::TradeOperation::ExactOut, - vec![( - AssetType::Fungible(T::HubAssetId::get().into()), - *state_changes.asset.delta_hub_reserve, - )], - vec![( - AssetType::Fungible(asset_out.into()), - *state_changes.asset.delta_reserve, - )], + vec![ + Asset::new(T::HubAssetId::get().into(), + *state_changes.asset.delta_hub_reserve), + ], + vec![ + Asset::new(asset_out.into(), + *state_changes.asset.delta_reserve), + ], vec![Fee { asset: asset_out.into(), amount: state_changes.fee.asset_fee, diff --git a/pallets/omnipool/src/tests/buy.rs b/pallets/omnipool/src/tests/buy.rs index f325fe087..7ed256ef9 100644 --- a/pallets/omnipool/src/tests/buy.rs +++ b/pallets/omnipool/src/tests/buy.rs @@ -442,8 +442,8 @@ fn buy_should_emit_event_with_correct_asset_fee_amount() { filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::types::Filler::Omnipool, operation: pallet_amm_support::types::TradeOperation::ExactOut, - inputs: vec![(AssetType::Fungible(100), expected_sold_amount)], - outputs: vec![(AssetType::Fungible(1), 57142857142858)], + inputs: vec![Asset::new(100, expected_sold_amount)], + outputs: vec![Asset::new(1, 57142857142858)], fees: vec![Fee::new(LRNA, 0, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Omnipool(0)], } @@ -453,8 +453,8 @@ fn buy_should_emit_event_with_correct_asset_fee_amount() { filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::types::Filler::Omnipool, operation: pallet_amm_support::types::TradeOperation::ExactOut, - inputs: vec![(AssetType::Fungible(1), 57142857142858)], - outputs: vec![(AssetType::Fungible(200), buy_amount)], + inputs: vec![Asset::new(1, 57142857142858)], + outputs: vec![Asset::new(200, buy_amount)], fees: vec![Fee::new(200, 5555555555556, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Omnipool(0)], } @@ -489,8 +489,8 @@ fn buy_should_emit_event_with_correct_asset_fee_amount() { filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::types::Filler::Omnipool, operation: pallet_amm_support::types::TradeOperation::ExactOut, - inputs: vec![(AssetType::Fungible(100), 65976185738813)], - outputs: vec![(AssetType::Fungible(1), 60326770004314)], + inputs: vec![Asset::new(100, 65976185738813)], + outputs: vec![Asset::new(1, 60326770004314)], fees: vec![Fee::new(LRNA, 0, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Omnipool(1)], } @@ -500,8 +500,8 @@ fn buy_should_emit_event_with_correct_asset_fee_amount() { filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::types::Filler::Omnipool, operation: pallet_amm_support::types::TradeOperation::ExactOut, - inputs: vec![(AssetType::Fungible(1), 60326770004314)], - outputs: vec![(AssetType::Fungible(200), other_buy_amount)], + inputs: vec![Asset::new(1, 60326770004314)], + outputs: vec![Asset::new(200, other_buy_amount)], fees: vec![Fee::new(200, 5555555555567, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Omnipool(1)], } @@ -558,8 +558,8 @@ fn buy_should_emit_event_with_correct_protocol_fee_amount() { filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::types::Filler::Omnipool, operation: pallet_amm_support::types::TradeOperation::ExactOut, - inputs: vec![(AssetType::Fungible(100), expected_sold_amount)], - outputs: vec![(AssetType::Fungible(1), 56980056980057)], + inputs: vec![Asset::new(100, expected_sold_amount)], + outputs: vec![Asset::new(1, 56980056980057)], fees: vec![Fee::new(LRNA, 5698005698005, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Omnipool(0)], } @@ -569,8 +569,8 @@ fn buy_should_emit_event_with_correct_protocol_fee_amount() { filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::types::Filler::Omnipool, operation: pallet_amm_support::types::TradeOperation::ExactOut, - inputs: vec![(AssetType::Fungible(1), 51282051282052)], - outputs: vec![(AssetType::Fungible(200), buy_amount)], + inputs: vec![Asset::new(1, 51282051282052)], + outputs: vec![Asset::new(200, buy_amount)], fees: vec![Fee::new(200, 0, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Omnipool(0)], } diff --git a/pallets/omnipool/src/tests/sell.rs b/pallets/omnipool/src/tests/sell.rs index 14be1d713..58781a7c0 100644 --- a/pallets/omnipool/src/tests/sell.rs +++ b/pallets/omnipool/src/tests/sell.rs @@ -749,8 +749,8 @@ fn sell_should_get_same_amount() { filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::types::Filler::Omnipool, operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(100), expected_sold_amount)], - outputs: vec![(AssetType::Fungible(LRNA), 57142857142858)], + inputs: vec![Asset::new(100, expected_sold_amount)], + outputs: vec![Asset::new(LRNA, 57142857142858)], fees: vec![Fee::new(LRNA, 0, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Omnipool(0)], } @@ -760,8 +760,8 @@ fn sell_should_get_same_amount() { filler: Omnipool::protocol_account(), filler_type: pallet_amm_support::types::Filler::Omnipool, operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(LRNA), 57142857142858)], - outputs: vec![(AssetType::Fungible(200), buy_amount)], + inputs: vec![Asset::new(LRNA, 57142857142858)], + outputs: vec![Asset::new(200, buy_amount)], fees: vec![Fee::new(200, 5555555555556, Omnipool::protocol_account())], operation_id: vec![ExecutionType::Omnipool(0)], } diff --git a/pallets/otc-settlements/src/tests.rs b/pallets/otc-settlements/src/tests.rs index 849f458f7..0c89b3451 100644 --- a/pallets/otc-settlements/src/tests.rs +++ b/pallets/otc-settlements/src/tests.rs @@ -24,7 +24,9 @@ pub use crate::mock::*; use frame_support::{assert_ok, assert_storage_noop}; use hydradx_traits::Inspect; use orml_traits::MultiCurrency; -use pallet_amm_support::types::{AssetType, Fee}; +use pallet_amm_support::types::{Fee}; +use pallet_amm_support::types::Asset; + pub fn expect_events(e: Vec) { e.into_iter().for_each(frame_system::Pallet::::assert_has_event); } @@ -303,8 +305,8 @@ fn existing_arb_opportunity_should_trigger_trade_when_correct_amount_can_be_foun filler: otc.owner, filler_type: pallet_amm_support::types::Filler::OTC(otc_id), operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(HDX), 2413749694825193)], - outputs: vec![(AssetType::Fungible(DAI), 4948186874391645)], + inputs: vec![Asset::new(HDX, 2413749694825193)], + outputs: vec![Asset::new(DAI, 4948186874391645)], fees: vec![Fee::new( DAI, 49481868743917, diff --git a/pallets/otc/src/lib.rs b/pallets/otc/src/lib.rs index 97b70826e..1ab2bc557 100644 --- a/pallets/otc/src/lib.rs +++ b/pallets/otc/src/lib.rs @@ -39,7 +39,7 @@ use frame_support::{pallet_prelude::*, require_transactional}; use frame_system::{ensure_signed, pallet_prelude::OriginFor}; use hydradx_traits::Inspect; use orml_traits::{GetByKey, MultiCurrency, NamedMultiReservableCurrency}; -use pallet_amm_support::types::{AssetType, Fee}; +use pallet_amm_support::types::Fee; use sp_core::U256; use sp_runtime::traits::{One, Zero}; use sp_runtime::Permill; @@ -57,7 +57,7 @@ pub use weights::WeightInfo; // Re-export pallet items so that they can be accessed from the crate namespace. pub use pallet::*; - +use pallet_amm_support::types::Asset; pub type Balance = u128; pub type OrderId = pallet_amm_support::types::OtcOrderId; //TODO: just use exacty type pub type NamedReserveIdentifier = [u8; 8]; @@ -315,8 +315,8 @@ pub mod pallet { order.owner.clone(), pallet_amm_support::types::Filler::OTC(order_id), pallet_amm_support::types::TradeOperation::ExactIn, - vec![(AssetType::Fungible(order.asset_in.into()), amount_in)], - vec![(AssetType::Fungible(order.asset_out.into()), amount_out)], + vec![Asset::new(order.asset_in.into(), amount_in)], + vec![Asset::new(order.asset_out.into(), amount_out)], vec![Fee { asset: order.asset_out.into(), amount: fee, @@ -361,8 +361,8 @@ pub mod pallet { order.owner, pallet_amm_support::types::Filler::OTC(order_id), pallet_amm_support::types::TradeOperation::ExactIn, - vec![(AssetType::Fungible(order.asset_in.into()), order.amount_in)], - vec![(AssetType::Fungible(order.asset_out.into()), order.amount_out)], + vec![Asset::new(order.asset_in.into(), order.amount_in)], + vec![Asset::new(order.asset_out.into(), order.amount_out)], vec![Fee { asset: order.asset_out.into(), amount: fee, diff --git a/pallets/otc/src/tests/fill_order.rs b/pallets/otc/src/tests/fill_order.rs index fc9ca93e8..92c480275 100644 --- a/pallets/otc/src/tests/fill_order.rs +++ b/pallets/otc/src/tests/fill_order.rs @@ -18,7 +18,7 @@ use crate::Event; use frame_support::{assert_noop, assert_ok}; use orml_tokens::Error::BalanceTooLow; use orml_traits::{MultiCurrency, NamedMultiReservableCurrency}; -use pallet_amm_support::types::{AssetType, Fee}; +use pallet_amm_support::types::{Asset, Fee}; use pretty_assertions::assert_eq; #[test] @@ -85,8 +85,8 @@ fn complete_fill_order_should_work() { filler: ALICE, filler_type: pallet_amm_support::types::Filler::OTC(0), operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(DAI), 20 * ONE)], - outputs: vec![(AssetType::Fungible(HDX), 100 * ONE)], + inputs: vec![Asset::new(DAI, 20 * ONE)], + outputs: vec![Asset::new(HDX, 100 * ONE)], fees: vec![Fee::new(HDX, ONE, ::FeeReceiver::get())], operation_id: vec![], } @@ -161,8 +161,8 @@ fn complete_fill_order_should_work_when_order_is_not_partially_fillable() { filler: ALICE, filler_type: pallet_amm_support::types::Filler::OTC(order_id), operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(DAI), 20 * ONE)], - outputs: vec![(AssetType::Fungible(HDX), 100 * ONE)], + inputs: vec![Asset::new(DAI, 20 * ONE)], + outputs: vec![Asset::new(HDX, 100 * ONE)], fees: vec![Fee::new(HDX, ONE, ::FeeReceiver::get())], operation_id: vec![], } @@ -249,8 +249,8 @@ fn complete_fill_order_should_work_when_there_are_multiple_orders() { filler: ALICE, filler_type: pallet_amm_support::types::Filler::OTC(order_id), operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(DAI), 20 * ONE)], - outputs: vec![(AssetType::Fungible(HDX), 100 * ONE)], + inputs: vec![Asset::new(DAI, 20 * ONE)], + outputs: vec![Asset::new(HDX, 100 * ONE)], fees: vec![Fee::new(HDX, ONE, ::FeeReceiver::get())], operation_id: vec![], } diff --git a/pallets/otc/src/tests/partial_fill_order.rs b/pallets/otc/src/tests/partial_fill_order.rs index aabf6bc08..c57ff5b6a 100644 --- a/pallets/otc/src/tests/partial_fill_order.rs +++ b/pallets/otc/src/tests/partial_fill_order.rs @@ -18,7 +18,7 @@ use crate::{Error, Event}; use frame_support::{assert_noop, assert_ok}; use orml_tokens::Error::BalanceTooLow; use orml_traits::{MultiCurrency, NamedMultiReservableCurrency}; -use pallet_amm_support::types::{AssetType, Fee}; +use pallet_amm_support::types::{Asset, Fee}; use pretty_assertions::assert_eq; #[test] @@ -99,8 +99,8 @@ fn partial_fill_order_should_work_when_order_is_partially_fillable() { filler: order.owner, filler_type: pallet_amm_support::types::Filler::OTC(order_id), operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(order.asset_in), 5 * ONE)], - outputs: vec![(AssetType::Fungible(order.asset_out), expected_amount_out)], + inputs: vec![Asset::new(order.asset_in, 5 * ONE)], + outputs: vec![Asset::new(order.asset_out, expected_amount_out)], fees: vec![Fee::new( order.asset_out, fee, diff --git a/pallets/route-executor/src/lib.rs b/pallets/route-executor/src/lib.rs index 1f14289a6..fba87de0a 100644 --- a/pallets/route-executor/src/lib.rs +++ b/pallets/route-executor/src/lib.rs @@ -39,9 +39,8 @@ pub use hydradx_traits::router::{ }; use orml_traits::arithmetic::{CheckedAdd, CheckedSub}; -pub use pallet_amm_support::types::{AssetType, ExecutionType, Fee}; +pub use pallet_amm_support::types::{ExecutionType, Fee}; use pallet_amm_support::IncrementalIdType; -use primitives::IncrementalId; use sp_core::U512; use sp_runtime::traits::{AccountIdConversion, CheckedDiv}; use sp_runtime::{ArithmeticError, DispatchError, FixedPointNumber, FixedU128, Saturating, TransactionOutcome}; diff --git a/pallets/stableswap/src/lib.rs b/pallets/stableswap/src/lib.rs index 9baa47e9e..5bd1f846a 100644 --- a/pallets/stableswap/src/lib.rs +++ b/pallets/stableswap/src/lib.rs @@ -75,7 +75,7 @@ use crate::types::{AssetAmount, Balance, PoolInfo, PoolState, StableswapHooks, T use hydra_dx_math::stableswap::types::AssetReserve; use hydradx_traits::pools::DustRemovalAccountWhitelist; use orml_traits::MultiCurrency; -use pallet_amm_support::types::{AssetType, Fee}; +use pallet_amm_support::types::{Asset, Fee}; use sp_std::collections::btree_map::BTreeMap; pub use weights::WeightInfo; @@ -104,7 +104,7 @@ pub mod pallet { use core::ops::RangeInclusive; use frame_support::pallet_prelude::*; use hydradx_traits::pools::DustRemovalAccountWhitelist; - use pallet_amm_support::types::{AssetType, Fee}; + use pallet_amm_support::types::{Fee}; use sp_runtime::traits::{BlockNumberProvider, Zero}; use sp_runtime::ArithmeticError; use sp_runtime::Permill; @@ -633,8 +633,8 @@ pub mod pallet { pool_account.clone(), pallet_amm_support::types::Filler::Stableswap(pool_id.into()), pallet_amm_support::types::TradeOperation::LiquidityRemove, - vec![(AssetType::Fungible(pool_id.into()), share_amount)], - vec![(AssetType::Fungible(asset_id.into()), amount)], + vec![Asset::new(pool_id.into(), share_amount)], + vec![Asset::new(asset_id.into(), amount)], vec![Fee { asset: pool_id.into(), amount: fee, @@ -736,8 +736,8 @@ pub mod pallet { pool_account.clone(), pallet_amm_support::types::Filler::Stableswap(pool_id.into()), pallet_amm_support::types::TradeOperation::LiquidityRemove, - vec![(AssetType::Fungible(pool_id.into()), shares)], - vec![(AssetType::Fungible(asset_id.into()), amount)], + vec![Asset::new(pool_id.into(), shares)], + vec![Asset::new(asset_id.into(), amount)], fees, ); @@ -819,8 +819,8 @@ pub mod pallet { pool_account.clone(), pallet_amm_support::types::Filler::Stableswap(pool_id.into()), pallet_amm_support::types::TradeOperation::ExactIn, - vec![(AssetType::Fungible(asset_in.into()), amount_in)], - vec![(AssetType::Fungible(asset_out.into()), amount_out)], + vec![Asset::new(asset_in.into(), amount_in)], + vec![Asset::new(asset_out.into(), amount_out)], vec![Fee { asset: asset_out.into(), amount: fee_amount, @@ -912,8 +912,8 @@ pub mod pallet { pool_account.clone(), pallet_amm_support::types::Filler::Stableswap(pool_id.into()), pallet_amm_support::types::TradeOperation::ExactOut, - vec![(AssetType::Fungible(asset_in.into()), amount_in)], - vec![(AssetType::Fungible(asset_out.into()), amount_out)], + vec![Asset::new(asset_in.into(), amount_in)], + vec![Asset::new(asset_out.into(), amount_out)], vec![Fee { asset: asset_in.into(), amount: fee_amount, @@ -1263,7 +1263,7 @@ impl Pallet { let inputs = assets .iter() - .map(|asset| (AssetType::Fungible(asset.asset_id.into()), asset.amount)) + .map(|asset| Asset::new(asset.asset_id.into(), asset.amount)) .collect(); let fees = fees .iter() @@ -1276,7 +1276,7 @@ impl Pallet { pallet_amm_support::types::Filler::Stableswap(pool_id.into()), pallet_amm_support::types::TradeOperation::LiquidityAdd, inputs, - vec![(AssetType::Fungible(pool_id.into()), share_amount)], + vec![Asset::new(pool_id.into(), share_amount)], fees, ); @@ -1340,8 +1340,8 @@ impl Pallet { pool_account.clone(), pallet_amm_support::types::Filler::Stableswap(pool_id.into()), pallet_amm_support::types::TradeOperation::LiquidityAdd, - vec![(AssetType::Fungible(asset_id.into()), amount_in)], - vec![(AssetType::Fungible(pool_id.into()), shares)], + vec![Asset::new(asset_id.into(), amount_in)], + vec![Asset::new(pool_id.into(), shares)], vec![Fee { asset: pool_id.into(), amount: fee, diff --git a/pallets/stableswap/src/tests/add_liquidity.rs b/pallets/stableswap/src/tests/add_liquidity.rs index 71e3475f9..2521a7ec2 100644 --- a/pallets/stableswap/src/tests/add_liquidity.rs +++ b/pallets/stableswap/src/tests/add_liquidity.rs @@ -2,7 +2,7 @@ use crate::tests::mock::*; use crate::types::{AssetAmount, PoolInfo}; use crate::{assert_balance, to_precision, Error}; use frame_support::{assert_noop, assert_ok}; -use pallet_amm_support::types::{Fee, AssetType}; +use pallet_amm_support::types::{Fee, Asset}; use sp_runtime::Permill; use std::num::NonZeroU16; @@ -112,8 +112,8 @@ fn add_liquidity_should_emit_swapped_events() { filler: pool_account, filler_type: pallet_amm_support::types::Filler::Stableswap(pool_id), operation: pallet_amm_support::types::TradeOperation::LiquidityAdd, - inputs: vec![(AssetType::Fungible(asset_a), 2000000000000000000),], - outputs: vec![(AssetType::Fungible(pool_id), 1947487201901031408)], + inputs: vec![Asset::new(asset_a, 2000000000000000000),], + outputs: vec![Asset::new(pool_id, 1947487201901031408)], fees: vec![ Fee::new(asset_a, 57410103828678, pool_account), Fee::new(asset_b, 17, pool_account), @@ -715,8 +715,8 @@ fn add_liquidity_should_work_correctly_when_providing_exact_amount_of_shares() { filler: pool_account, filler_type: pallet_amm_support::types::Filler::Stableswap(pool_id), operation: pallet_amm_support::types::TradeOperation::LiquidityAdd, - inputs: vec![(AssetType::Fungible(asset_a), 2000000000000000003),], - outputs: vec![(AssetType::Fungible(pool_id), 1947597621401945851)], + inputs: vec![Asset::new(asset_a, 2000000000000000003),], + outputs: vec![Asset::new(pool_id, 1947597621401945851)], fees: vec![Fee::new(pool_id, 0, pool_account)], operation_id: vec![], }) diff --git a/pallets/stableswap/src/tests/remove_liquidity.rs b/pallets/stableswap/src/tests/remove_liquidity.rs index a6061525d..07df8dc1a 100644 --- a/pallets/stableswap/src/tests/remove_liquidity.rs +++ b/pallets/stableswap/src/tests/remove_liquidity.rs @@ -3,7 +3,7 @@ use crate::types::{AssetAmount, PoolInfo}; use crate::{assert_balance, Error, Event, Pools}; use frame_support::traits::Contains; use frame_support::{assert_noop, assert_ok, BoundedVec}; -use pallet_amm_support::types::{AssetType, Fee}; +use pallet_amm_support::types::{Asset, Fee}; use sp_runtime::Permill; use std::num::NonZeroU16; @@ -80,8 +80,8 @@ fn remove_liquidity_should_work_when_withdrawing_all_shares() { filler: pool_account, filler_type: pallet_amm_support::types::Filler::Stableswap(pool_id), operation: pallet_amm_support::types::TradeOperation::LiquidityRemove, - inputs: vec![(AssetType::Fungible(pool_id), 200516043533380244763),], - outputs: vec![(AssetType::Fungible(asset_c), 199999999999999)], + inputs: vec![Asset::new(pool_id, 200516043533380244763),], + outputs: vec![Asset::new(asset_c, 199999999999999)], fees: vec![Fee::new(pool_id, 0, pool_account)], operation_id: vec![], }) @@ -1086,8 +1086,8 @@ fn removing_liquidity_with_exact_amount_should_emit_swapped_event() { filler: pool_account, filler_type: pallet_amm_support::types::Filler::Stableswap(4), operation: pallet_amm_support::types::TradeOperation::LiquidityRemove, - inputs: vec![(AssetType::Fungible(pool_id), 979387928052053203)], - outputs: vec![(AssetType::Fungible(asset_a), 1000000000000000000),], + inputs: vec![Asset::new(pool_id, 979387928052053203)], + outputs: vec![Asset::new(asset_a, 1000000000000000000),], fees: vec![ Fee::new(asset_a, 2870505165609705, pool_account), Fee::new(asset_b, 872, pool_account), diff --git a/pallets/stableswap/src/tests/trades.rs b/pallets/stableswap/src/tests/trades.rs index 070160bc3..4bb47c3c4 100644 --- a/pallets/stableswap/src/tests/trades.rs +++ b/pallets/stableswap/src/tests/trades.rs @@ -4,7 +4,7 @@ use crate::{assert_balance, to_precision, Error, Event}; use std::num::NonZeroU16; use frame_support::{assert_noop, assert_ok}; -use pallet_amm_support::types::{AssetType, Fee}; +use pallet_amm_support::types::{Asset, Fee}; use sp_runtime::Permill; #[test] @@ -71,8 +71,8 @@ fn sell_should_work_when_correct_input_provided() { filler: pool_account, filler_type: pallet_amm_support::types::Filler::Stableswap(pool_id), operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(asset_a), 30000000000000)], - outputs: vec![(AssetType::Fungible(asset_b), 29902625420922)], + inputs: vec![Asset::new(asset_a, 30000000000000)], + outputs: vec![Asset::new(asset_b, 29902625420922)], fees: vec![Fee::new(asset_b, 0, pool_account)], operation_id: vec![], } @@ -145,8 +145,8 @@ fn buy_should_work_when_correct_input_provided() { filler: pool_account, filler_type: pallet_amm_support::types::Filler::Stableswap(pool_id), operation: pallet_amm_support::types::TradeOperation::ExactOut, - inputs: vec![(AssetType::Fungible(asset_a), 30098072706882)], - outputs: vec![(AssetType::Fungible(asset_b), 30000000000000)], + inputs: vec![Asset::new(asset_a, 30098072706882)], + outputs: vec![Asset::new(asset_b, 30000000000000)], fees: vec![Fee::new(asset_a, 0, pool_account)], operation_id: vec![], } diff --git a/pallets/xyk/src/lib.rs b/pallets/xyk/src/lib.rs index eb9930741..eec5a83c2 100644 --- a/pallets/xyk/src/lib.rs +++ b/pallets/xyk/src/lib.rs @@ -36,7 +36,7 @@ use hydradx_traits::{ AMMPosition, AMMTransfer, AssetPairAccountIdFor, CanCreatePool, OnCreatePoolHandler, OnLiquidityChangedHandler, OnTradeHandler, AMM, }; -use pallet_amm_support::types::{AssetType, Fee}; +use pallet_amm_support::types::{Asset, Fee}; use sp_std::{vec, vec::Vec}; @@ -923,8 +923,8 @@ impl AMM for Pallet { pair_account.clone(), pallet_amm_support::types::Filler::XYK(Self::share_token(&pair_account)), pallet_amm_support::types::TradeOperation::ExactIn, - vec![(AssetType::Fungible(transfer.assets.asset_in), transfer.amount)], - vec![(AssetType::Fungible(transfer.assets.asset_out), transfer.amount_b)], + vec![Asset::new(transfer.assets.asset_in, transfer.amount)], + vec![Asset::new(transfer.assets.asset_out, transfer.amount_b)], vec![Fee { asset: transfer.fee.0, amount: transfer.fee.1, @@ -1103,8 +1103,8 @@ impl AMM for Pallet { pair_account.clone(), pallet_amm_support::types::Filler::XYK(Self::share_token(&pair_account)), pallet_amm_support::types::TradeOperation::ExactOut, - vec![(AssetType::Fungible(transfer.assets.asset_in), transfer.amount)], - vec![(AssetType::Fungible(transfer.assets.asset_out), transfer.amount_b)], + vec![Asset::new(transfer.assets.asset_in, transfer.amount)], + vec![Asset::new(transfer.assets.asset_out, transfer.amount_b)], vec![Fee { asset: transfer.fee.0, amount: transfer.fee.1, diff --git a/pallets/xyk/src/tests/fees.rs b/pallets/xyk/src/tests/fees.rs index 00c78c862..289d393b4 100644 --- a/pallets/xyk/src/tests/fees.rs +++ b/pallets/xyk/src/tests/fees.rs @@ -3,7 +3,7 @@ use crate::{Error, Event}; use frame_support::{assert_noop, assert_ok}; use hydradx_traits::AMM as AmmPool; use orml_traits::MultiCurrency; -use pallet_amm_support::types::{AssetType, Fee}; +use pallet_amm_support::types::{Asset, Fee}; use crate::types::AssetPair; @@ -151,8 +151,8 @@ fn discount_sell_fees_should_work() { filler: pair_account, filler_type: pallet_amm_support::types::Filler::XYK(share_token), operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(asset_a), 10_000_000)], - outputs: vec![(AssetType::Fungible(asset_b), 19_986_006)], + inputs: vec![Asset::new(asset_a, 10_000_000)], + outputs: vec![Asset::new(asset_b, 19_986_006)], fees: vec![Fee::new(asset_b, 13_993, pair_account)], operation_id: vec![], } @@ -239,8 +239,8 @@ fn discount_sell_fees_should_work() { filler: pair_account, filler_type: pallet_amm_support::types::Filler::XYK(share_token), operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(asset_a), 10_000_000)], - outputs: vec![(AssetType::Fungible(asset_b), 19_980_009)], + inputs: vec![Asset::new(asset_a, 10_000_000)], + outputs: vec![Asset::new(asset_b, 19_980_009)], fees: vec![Fee::new(asset_b, 19_990, pair_account)], operation_id: vec![], } @@ -322,8 +322,8 @@ fn discount_sell_fees_should_work() { filler: pair_account, filler_type: pallet_amm_support::types::Filler::XYK(share_token), operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(asset_a), 10_000_000)], - outputs: vec![(AssetType::Fungible(asset_b), 19_999_999)], + inputs: vec![Asset::new(asset_a, 10_000_000)], + outputs: vec![Asset::new(asset_b, 19_999_999)], fees: vec![Fee::new(asset_b, 0, pair_account)], operation_id: vec![], } @@ -422,8 +422,8 @@ fn discount_buy_fees_should_work() { filler: pair_account, filler_type: pallet_amm_support::types::Filler::XYK(share_token), operation: pallet_amm_support::types::TradeOperation::ExactOut, - inputs: vec![(AssetType::Fungible(asset_b), 10_000_000)], - outputs: vec![(AssetType::Fungible(asset_a), 20_000_002)], + inputs: vec![Asset::new(asset_b, 10_000_000)], + outputs: vec![Asset::new(asset_a, 20_000_002)], fees: vec![Fee::new(asset_b, 14_000, pair_account)], operation_id: vec![], } @@ -514,8 +514,8 @@ fn discount_buy_fees_should_work() { filler: pair_account, filler_type: pallet_amm_support::types::Filler::XYK(share_token), operation: pallet_amm_support::types::TradeOperation::ExactOut, - inputs: vec![(AssetType::Fungible(asset_b), 10_000_000)], - outputs: vec![(AssetType::Fungible(asset_a), 20_000_002)], + inputs: vec![Asset::new(asset_b, 10_000_000)], + outputs: vec![Asset::new(asset_a, 20_000_002)], fees: vec![Fee::new(asset_b, 20_000, pair_account)], operation_id: vec![], } @@ -595,8 +595,8 @@ fn discount_buy_fees_should_work() { filler: pair_account, filler_type: pallet_amm_support::types::Filler::XYK(share_token), operation: pallet_amm_support::types::TradeOperation::ExactOut, - inputs: vec![(AssetType::Fungible(asset_b), 10_000_000)], - outputs: vec![(AssetType::Fungible(asset_a), 20_000_002)], + inputs: vec![Asset::new(asset_b, 10_000_000)], + outputs: vec![Asset::new(asset_a, 20_000_002)], fees: vec![Fee::new(asset_b, 0, pair_account)], operation_id: vec![], } diff --git a/pallets/xyk/src/tests/trades.rs b/pallets/xyk/src/tests/trades.rs index 34d88c43f..75a98fddd 100644 --- a/pallets/xyk/src/tests/trades.rs +++ b/pallets/xyk/src/tests/trades.rs @@ -3,7 +3,7 @@ use crate::{AMMTransfer, Error, Event}; use frame_support::{assert_noop, assert_ok}; use hydradx_traits::AMM as AmmPool; use orml_traits::MultiCurrency; -use pallet_amm_support::types::{AssetType, Fee}; +use pallet_amm_support::types::{Asset, Fee}; use crate::types::AssetPair; @@ -76,8 +76,8 @@ fn sell_test() { filler: pair_account, filler_type: pallet_amm_support::types::Filler::XYK(share_token), operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(asset_a), 456444678)], - outputs: vec![(AssetType::Fungible(asset_b), 1363483591788)], + inputs: vec![Asset::new(asset_a, 456444678)], + outputs: vec![Asset::new(asset_b, 1363483591788)], fees: vec![Fee::new(asset_b, 2732432046, pair_account)], operation_id: vec![], } @@ -140,8 +140,8 @@ fn execute_sell_should_use_event_id() { filler: pair_account, filler_type: pallet_amm_support::types::Filler::XYK(share_token), operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(asset_a), 456444678)], - outputs: vec![(AssetType::Fungible(asset_b), 1363483591788)], + inputs: vec![Asset::new(asset_a, 456444678)], + outputs: vec![Asset::new(asset_b, 1363483591788)], fees: vec![Fee::new(asset_b, 2732432046, pair_account)], operation_id: vec![], } @@ -447,8 +447,8 @@ fn sell_with_correct_fees_should_work() { filler: pair_account, filler_type: pallet_amm_support::types::Filler::XYK(share_token), operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![(AssetType::Fungible(asset_a), 100_000)], - outputs: vec![(AssetType::Fungible(asset_b), 19_762_378)], + inputs: vec![Asset::new(asset_a, 100_000)], + outputs: vec![Asset::new(asset_b, 19_762_378)], fees: vec![Fee::new(asset_b, 39_602, pair_account)], operation_id: vec![], } @@ -665,8 +665,8 @@ fn single_buy_should_work() { filler: pair_account, filler_type: pallet_amm_support::types::Filler::XYK(share_token), operation: pallet_amm_support::types::TradeOperation::ExactOut, - inputs: vec![(AssetType::Fungible(asset_b), 6_666_666)], - outputs: vec![(AssetType::Fungible(asset_a), 22_068_963_235)], + inputs: vec![Asset::new(asset_b, 6_666_666)], + outputs: vec![Asset::new(asset_a, 22_068_963_235)], fees: vec![Fee::new(asset_b, 44_137_926, pair_account)], operation_id: vec![], } From c7fbb355c658206f2676fa5c433a48acb202a1ac Mon Sep 17 00:00:00 2001 From: dmoka Date: Thu, 19 Dec 2024 08:24:02 +0100 Subject: [PATCH 090/142] remove unnecessary getter --- pallets/amm-support/src/lib.rs | 6 +----- .../amm-support/src/tests/incremental_id.rs | 20 +++++++++---------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/pallets/amm-support/src/lib.rs b/pallets/amm-support/src/lib.rs index 8ca0ccae4..73adada61 100644 --- a/pallets/amm-support/src/lib.rs +++ b/pallets/amm-support/src/lib.rs @@ -62,7 +62,7 @@ pub mod pallet { #[pallet::storage] /// Execution context stack - #[pallet::getter(fn id_stack)] + #[pallet::getter(fn execution_context)] pub(super) type ExecutionContext = StorageValue<_, ExecutionIdStack, ValueQuery>; #[pallet::error] @@ -161,8 +161,4 @@ impl Pallet { }) } - fn get() -> Vec> { - ExecutionContext::::get().to_vec() - } - } diff --git a/pallets/amm-support/src/tests/incremental_id.rs b/pallets/amm-support/src/tests/incremental_id.rs index 6c18401ce..538d6e494 100644 --- a/pallets/amm-support/src/tests/incremental_id.rs +++ b/pallets/amm-support/src/tests/incremental_id.rs @@ -35,22 +35,22 @@ fn event_id_should_be_incremented() { fn stack_should_be_populated_when_pushed() { ExtBuilder::default().build().execute_with(|| { assert_ok!(AmmSupport::add_to_context(ExecutionType::Router)); - assert_eq!(AmmSupport::get(), vec![ExecutionType::Router(0)]); - assert_eq!(AmmSupport::id_stack().into_inner(), vec![ExecutionType::Router(0)]); + assert_eq!(AmmSupport::execution_context(), vec![ExecutionType::Router(0)]); + assert_eq!(AmmSupport::execution_context().into_inner(), vec![ExecutionType::Router(0)]); assert_ok!(AmmSupport::add_to_context(ExecutionType::Router)); assert_eq!( - AmmSupport::get(), + AmmSupport::execution_context(), vec![ExecutionType::Router(0), ExecutionType::Router(1)] ); assert_eq!( - AmmSupport::id_stack().into_inner(), + AmmSupport::execution_context().into_inner(), vec![ExecutionType::Router(0), ExecutionType::Router(1)] ); assert_ok!(AmmSupport::add_to_context(ExecutionType::ICE)); assert_eq!( - AmmSupport::get(), + AmmSupport::execution_context(), vec![ ExecutionType::Router(0), ExecutionType::Router(1), @@ -58,7 +58,7 @@ fn stack_should_be_populated_when_pushed() { ] ); assert_eq!( - AmmSupport::id_stack().into_inner(), + AmmSupport::execution_context().into_inner(), vec![ ExecutionType::Router(0), ExecutionType::Router(1), @@ -91,17 +91,17 @@ fn stack_should_be_reduced_when_poped() { assert_ok!(AmmSupport::remove_from_context(), ExecutionType::ICE(2)); assert_eq!( - AmmSupport::get(), + AmmSupport::execution_context(), vec![ExecutionType::Router(0), ExecutionType::Router(1)] ); assert_eq!( - AmmSupport::id_stack().into_inner(), + AmmSupport::execution_context().into_inner(), vec![ExecutionType::Router(0), ExecutionType::Router(1)] ); assert_ok!(AmmSupport::add_to_context(ExecutionType::ICE)); assert_eq!( - AmmSupport::get(), + AmmSupport::execution_context(), vec![ ExecutionType::Router(0), ExecutionType::Router(1), @@ -109,7 +109,7 @@ fn stack_should_be_reduced_when_poped() { ] ); assert_eq!( - AmmSupport::id_stack().into_inner(), + AmmSupport::execution_context().into_inner(), vec![ ExecutionType::Router(0), ExecutionType::Router(1), From 27f6b3fc0e7f3136c8178bba6ef1072b56f6a107 Mon Sep 17 00:00:00 2001 From: dmoka Date: Thu, 19 Dec 2024 08:26:08 +0100 Subject: [PATCH 091/142] remove unnecessary incremental id getter --- pallets/amm-support/src/lib.rs | 9 --------- pallets/amm-support/src/tests/incremental_id.rs | 13 ------------- 2 files changed, 22 deletions(-) diff --git a/pallets/amm-support/src/lib.rs b/pallets/amm-support/src/lib.rs index 73adada61..04a89212d 100644 --- a/pallets/amm-support/src/lib.rs +++ b/pallets/amm-support/src/lib.rs @@ -104,15 +104,6 @@ pub mod pallet { } impl Pallet { - /// Returns next incremental ID and updates the storage. - pub fn next_incremental_id() -> Result { - IncrementalId::::try_mutate(|current_id| -> Result { - let inc_id = *current_id; - *current_id = current_id.checked_add(1).ok_or(ArithmeticError::Overflow)?; - Ok(inc_id) - }) - } - pub fn deposit_trade_event( swapper: T::AccountId, filler: T::AccountId, diff --git a/pallets/amm-support/src/tests/incremental_id.rs b/pallets/amm-support/src/tests/incremental_id.rs index 538d6e494..93db3a2ba 100644 --- a/pallets/amm-support/src/tests/incremental_id.rs +++ b/pallets/amm-support/src/tests/incremental_id.rs @@ -17,19 +17,6 @@ use crate::tests::mock::*; use crate::Event; -#[test] -fn event_id_should_be_incremented() { - ExtBuilder::default().build().execute_with(|| { - assert_eq!(AmmSupport::incremental_id(), 0); - assert_eq!(AmmSupport::next_incremental_id().unwrap(), 0); - - assert_eq!(AmmSupport::incremental_id(), 1); - assert_eq!(AmmSupport::next_incremental_id().unwrap(), 1); - - assert_eq!(AmmSupport::incremental_id(), 2); - assert_eq!(AmmSupport::next_incremental_id().unwrap(), 2); - }); -} #[test] fn stack_should_be_populated_when_pushed() { From 34a0c73b8597a1913851f1f04b7f25e1b9241714 Mon Sep 17 00:00:00 2001 From: dmoka Date: Thu, 19 Dec 2024 19:15:31 +0100 Subject: [PATCH 092/142] add xcm echange event stack population --- integration-tests/src/exchange_asset.rs | 90 ++++++++++++++++++++++++- integration-tests/src/referrals.rs | 8 +-- integration-tests/src/router.rs | 4 +- integration-tests/src/utility.rs | 20 ++++-- runtime/adapters/Cargo.toml | 1 + runtime/adapters/src/xcm_exchange.rs | 18 +++-- 6 files changed, 125 insertions(+), 16 deletions(-) diff --git a/integration-tests/src/exchange_asset.rs b/integration-tests/src/exchange_asset.rs index 1bc3106e9..2c77df9ef 100644 --- a/integration-tests/src/exchange_asset.rs +++ b/integration-tests/src/exchange_asset.rs @@ -7,7 +7,9 @@ use frame_support::traits::fungible::Balanced; use frame_support::traits::tokens::Precision; use frame_support::weights::Weight; use frame_support::{assert_ok, pallet_prelude::*}; -use hydradx_runtime::AssetRegistry; +use hydradx_runtime::Omnipool; +use hydradx_runtime::RuntimeEvent; +use hydradx_runtime::{AssetRegistry, LRNA}; use hydradx_traits::AssetKind; use hydradx_traits::Create; use orml_traits::currency::MultiCurrency; @@ -21,7 +23,9 @@ use sp_runtime::DispatchResult; use sp_runtime::{FixedU128, Permill, TransactionOutcome}; use sp_std::sync::Arc; use xcm_emulator::TestExt; - +use hydradx_runtime::TempAccountForXcmAssetExchange; +use hydradx_runtime::RuntimeOrigin; +use hydradx_runtime::Router; pub const SELL: bool = true; pub const BUY: bool = false; @@ -120,6 +124,87 @@ fn hydra_should_swap_assets_when_receiving_from_acala_with_sell() { // We receive about 39_101 HDX (HDX is super cheap in our test) let received = 39_101 * UNITS + BOB_INITIAL_NATIVE_BALANCE + 207_131_554_396; assert_eq!(hydradx_runtime::Balances::free_balance(AccountId::from(BOB)), received); + + let last_swapped_events = get_last_swapped_events(); + let last_two_swapped_events = &last_swapped_events[last_swapped_events.len() - 2..]; + pretty_assertions::assert_eq!( + last_two_swapped_events, + vec![ + RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + swapper: TempAccountForXcmAssetExchange::get(), + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::types::Filler::Omnipool, + operation: pallet_amm_support::types::TradeOperation::ExactIn, + inputs: vec![pallet_amm_support::types::Asset::new(ACA, 50000000000000),], + outputs: vec![pallet_amm_support::types::Asset::new(LRNA::get(), 49180327868852)], + fees: vec![Fee::new(LRNA::get(), 24590163934, Omnipool::protocol_account()),], + operation_id: vec![ + ExecutionType::XcmExchange(0), + ExecutionType::Router(1), + ExecutionType::Omnipool(2) + ], + }), + RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + swapper: TempAccountForXcmAssetExchange::get(), + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::types::Filler::Omnipool, + operation: pallet_amm_support::types::TradeOperation::ExactIn, + inputs: vec![pallet_amm_support::types::Asset::new(LRNA::get(), 49155737704918),], + outputs: vec![pallet_amm_support::types::Asset::new(HDX, 39101207131554396)], + fees: vec![Fee::new(HDX, 97998012861039, Omnipool::protocol_account()),], + operation_id: vec![ + ExecutionType::XcmExchange(0), + ExecutionType::Router(1), + ExecutionType::Omnipool(2) + ], + }) + ] + ); + + //We assert that another trade doesnt have the xcm exchange type on stack + assert_ok!(Router::sell( + RuntimeOrigin::signed(ALICE.into()), + HDX, + ACA, + 1 * UNITS, + 0, + vec![], + )); + + let last_swapped_events = get_last_swapped_events(); + let last_two_swapped_events = &last_swapped_events[last_swapped_events.len() - 2..]; + pretty_assertions::assert_eq!( + last_two_swapped_events, + vec![ + RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + swapper: ALICE.into(), + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::types::Filler::Omnipool, + operation: pallet_amm_support::types::TradeOperation::ExactIn, + inputs: vec![pallet_amm_support::types::Asset::new(HDX, 1 * UNITS),], + outputs: vec![pallet_amm_support::types::Asset::new(LRNA::get(), 1308673515)], + fees: vec![Fee::new(LRNA::get(), 654336, Omnipool::protocol_account()),], + operation_id: vec![ + ExecutionType::Router(3), + ExecutionType::Omnipool(4) + ], + }), + RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + swapper: ALICE.into(), + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::types::Filler::Omnipool, + operation: pallet_amm_support::types::TradeOperation::ExactIn, + inputs: vec![pallet_amm_support::types::Asset::new(LRNA::get(), 1308019179),], + outputs: vec![pallet_amm_support::types::Asset::new(ACA, 1348602600)], + fees: vec![Fee::new(ACA, 3379957, Omnipool::protocol_account()),], + operation_id: vec![ + ExecutionType::Router(3), + ExecutionType::Omnipool(4) + ], + }) + ] + ); + }); } @@ -1143,6 +1228,7 @@ fn half(asset: &Asset) -> Asset { id: asset.clone().id, } } +use pallet_amm_support::types::{ExecutionType, Fee}; use rococo_runtime::xcm_config::BaseXcmWeight; use xcm_builder::FixedWeightBounds; use xcm_executor::traits::WeightBounds; diff --git a/integration-tests/src/referrals.rs b/integration-tests/src/referrals.rs index 641868c11..dab16a6be 100644 --- a/integration-tests/src/referrals.rs +++ b/integration-tests/src/referrals.rs @@ -5,17 +5,17 @@ use frame_support::assert_ok; use frame_system::RawOrigin; use hydradx_runtime::{Currencies, Omnipool, Referrals, Runtime, RuntimeOrigin, Staking, Tokens}; use orml_traits::MultiCurrency; -use pallet_amm_support::types::{TradeOperation}; -use pallet_referrals::{FeeDistribution, ReferralCode}; +use pallet_amm_support::types::Asset; use pallet_amm_support::types::Fee; +use pallet_amm_support::types::Filler; +use pallet_amm_support::types::TradeOperation; +use pallet_referrals::{FeeDistribution, ReferralCode}; use primitives::AccountId; use sp_core::crypto::Ss58AddressFormat; use sp_runtime::FixedU128; use sp_runtime::Permill; use std::vec; use xcm_emulator::TestExt; -use pallet_amm_support::types::Filler; -use pallet_amm_support::types::Asset; #[test] fn registering_a_code_should_charge_registration_fee() { diff --git a/integration-tests/src/router.rs b/integration-tests/src/router.rs index 648cea99d..10e9bde47 100644 --- a/integration-tests/src/router.rs +++ b/integration-tests/src/router.rs @@ -7,7 +7,6 @@ use hydradx_runtime::{ AssetRegistry, BlockNumber, Currencies, Omnipool, Router, RouterWeightInfo, Runtime, RuntimeOrigin, Stableswap, LBP, XYK, }; -use pallet_amm_support::types::Asset; use hydradx_traits::router::AssetPair as Pair; use hydradx_traits::router::RouteSpotPriceProvider; use hydradx_traits::{ @@ -15,10 +14,11 @@ use hydradx_traits::{ router::{PoolType, Trade}, AssetKind, AMM, }; +use pallet_amm_support::types::Asset; use pallet_amm_support::types::ExecutionType; use pallet_amm_support::types::Fee; -use pallet_amm_support::types::TradeOperation; use pallet_amm_support::types::Filler; +use pallet_amm_support::types::TradeOperation; use pallet_lbp::weights::WeightInfo as LbpWeights; use pallet_lbp::WeightCurveType; use pallet_omnipool::traits::OmnipoolHooks; diff --git a/integration-tests/src/utility.rs b/integration-tests/src/utility.rs index dd6d9f662..38105013b 100644 --- a/integration-tests/src/utility.rs +++ b/integration-tests/src/utility.rs @@ -9,8 +9,8 @@ use hydradx_runtime::XYK; use hydradx_runtime::{Currencies, Omnipool, Runtime, RuntimeEvent}; use hydradx_runtime::{RuntimeCall, Utility}; use hydradx_traits::router::PoolType; -use xcm_emulator::TestExt; use pallet_amm_support::types::Asset; +use xcm_emulator::TestExt; use hydradx_traits::router::Trade; use hydradx_traits::AMM; @@ -291,7 +291,11 @@ fn nested_batch_should_represent_embeddedness() { .unwrap() .fee_collector, )], - operation_id: vec![ExecutionType::Batch(0), ExecutionType::Batch(1), ExecutionType::Router(2)], + operation_id: vec![ + ExecutionType::Batch(0), + ExecutionType::Batch(1), + ExecutionType::Router(2) + ], }), RuntimeEvent::AmmSupport(pallet_amm_support::Event::::Swapped { swapper: BOB.into(), @@ -301,7 +305,11 @@ fn nested_batch_should_represent_embeddedness() { inputs: vec![Asset::new(LRNA, 5640664064)], outputs: vec![Asset::new(HDX, 4682924837974)], fees: vec![Fee::new(HDX, 11736653730, Omnipool::protocol_account())], - operation_id: vec![ExecutionType::Batch(0), ExecutionType::Batch(1), ExecutionType::Router(2)], + operation_id: vec![ + ExecutionType::Batch(0), + ExecutionType::Batch(1), + ExecutionType::Router(2) + ], }), RuntimeEvent::AmmSupport(pallet_amm_support::Event::::Swapped { swapper: BOB.into(), @@ -326,7 +334,11 @@ fn nested_batch_should_represent_embeddedness() { asset_out: DOT, }), )], - operation_id: vec![ExecutionType::Batch(0), ExecutionType::Batch(1), ExecutionType::Router(2)], + operation_id: vec![ + ExecutionType::Batch(0), + ExecutionType::Batch(1), + ExecutionType::Router(2) + ], }) ] ); diff --git a/runtime/adapters/Cargo.toml b/runtime/adapters/Cargo.toml index 0fc8221ea..c145b7503 100644 --- a/runtime/adapters/Cargo.toml +++ b/runtime/adapters/Cargo.toml @@ -32,6 +32,7 @@ pallet-referrals = { workspace = true } pallet-lbp = { workspace = true } pallet-asset-registry = { workspace = true } pallet-bonds = { workspace = true } +pallet-amm-support = { workspace = true } # Substrate dependencies frame-support = { workspace = true } diff --git a/runtime/adapters/src/xcm_exchange.rs b/runtime/adapters/src/xcm_exchange.rs index b4704724c..deaf9da5f 100644 --- a/runtime/adapters/src/xcm_exchange.rs +++ b/runtime/adapters/src/xcm_exchange.rs @@ -1,3 +1,4 @@ +use frame_system::ensure_signed; use orml_traits::MultiCurrency; use polkadot_xcm::v4::prelude::*; use sp_core::Get; @@ -6,6 +7,7 @@ use sp_std::marker::PhantomData; use sp_std::vec; use xcm_executor::traits::AssetExchange; use xcm_executor::AssetsInHolding; +use pallet_amm_support::types::{ExecutionType, Fee}; /// Implements `AssetExchange` to support the `ExchangeAsset` XCM instruction. /// @@ -27,6 +29,7 @@ where CurrencyIdConvert: Convert>, Currency: MultiCurrency, Runtime::Balance: From + Zero + Into, + Runtime::AssetId: Into, { fn exchange_asset( _origin: Option<&Location>, @@ -62,7 +65,9 @@ where }; let use_onchain_route = vec![]; - if maximal { + pallet_amm_support::Pallet::::add_to_context(ExecutionType::XcmExchange).map_err(|_| give.clone())?; + + let trade_result = if maximal { // sell let Fungible(amount) = given.fun else { return Err(give) }; let Fungible(min_buy_amount) = wanted.fun else { @@ -90,9 +95,10 @@ where ); Currency::withdraw(asset_out, &account, amount_received)?; // burn the received tokens let holding: Asset = (wanted.id.clone(), amount_received.into()).into(); + Ok(holding.into()) }) - .map_err(|_| give) + .map_err(|_| give.clone()) } else { // buy let Fungible(amount) = wanted.fun else { return Err(give) }; @@ -127,7 +133,11 @@ where assets.push(holding); Ok(assets.into()) }) - .map_err(|_| give) - } + .map_err(|_| give.clone()) + }; + + pallet_amm_support::Pallet::::remove_from_context().map_err(|_| give)?; + + trade_result } } From 2ff4aee53364bedfb96780b33ce214c47ee34380 Mon Sep 17 00:00:00 2001 From: dmoka Date: Thu, 19 Dec 2024 19:20:26 +0100 Subject: [PATCH 093/142] add better doc --- pallets/amm-support/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/amm-support/src/lib.rs b/pallets/amm-support/src/lib.rs index 04a89212d..097daba75 100644 --- a/pallets/amm-support/src/lib.rs +++ b/pallets/amm-support/src/lib.rs @@ -61,7 +61,7 @@ pub mod pallet { pub(super) type IncrementalId = StorageValue<_, IncrementalIdType, ValueQuery>; #[pallet::storage] - /// Execution context stack + /// Execution context to figure out where the trade is originated from #[pallet::getter(fn execution_context)] pub(super) type ExecutionContext = StorageValue<_, ExecutionIdStack, ValueQuery>; From c7be65b954d42a1e62951acb3ff601ac2b7abaf5 Mon Sep 17 00:00:00 2001 From: dmoka Date: Thu, 19 Dec 2024 19:28:42 +0100 Subject: [PATCH 094/142] replace incremental id type from primites as primites tpyes only used in runtime --- pallets/amm-support/src/lib.rs | 4 ++-- pallets/amm-support/src/types.rs | 2 +- pallets/route-executor/src/lib.rs | 2 +- primitives/src/lib.rs | 3 --- runtime/adapters/src/xcm_exchange.rs | 3 +-- 5 files changed, 5 insertions(+), 9 deletions(-) diff --git a/pallets/amm-support/src/lib.rs b/pallets/amm-support/src/lib.rs index 097daba75..3fcd2f5b3 100644 --- a/pallets/amm-support/src/lib.rs +++ b/pallets/amm-support/src/lib.rs @@ -21,11 +21,11 @@ use crate::types::*; use frame_support::sp_runtime::app_crypto::sp_core; -use frame_support::sp_runtime::{ArithmeticError, BoundedVec, DispatchError, DispatchResult}; +use frame_support::sp_runtime::{BoundedVec, DispatchError, DispatchResult}; use frame_system::pallet_prelude::BlockNumberFor; -pub use primitives::IncrementalId as IncrementalIdType; use sp_core::{ConstU32}; use sp_std::vec::Vec; + #[cfg(test)] mod tests; diff --git a/pallets/amm-support/src/types.rs b/pallets/amm-support/src/types.rs index 1da56c87c..8a4149b18 100644 --- a/pallets/amm-support/src/types.rs +++ b/pallets/amm-support/src/types.rs @@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize}; pub type AssetId = u32; pub type Balance = u128; - +pub type IncrementalIdType = u32; pub type OtcOrderId = u32; #[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] diff --git a/pallets/route-executor/src/lib.rs b/pallets/route-executor/src/lib.rs index fba87de0a..ade1e3eea 100644 --- a/pallets/route-executor/src/lib.rs +++ b/pallets/route-executor/src/lib.rs @@ -40,7 +40,7 @@ pub use hydradx_traits::router::{ use orml_traits::arithmetic::{CheckedAdd, CheckedSub}; pub use pallet_amm_support::types::{ExecutionType, Fee}; -use pallet_amm_support::IncrementalIdType; +use pallet_amm_support::types::IncrementalIdType; use sp_core::U512; use sp_runtime::traits::{AccountIdConversion, CheckedDiv}; use sp_runtime::{ArithmeticError, DispatchError, FixedPointNumber, FixedU128, Saturating, TransactionOutcome}; diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index 04bd29d7c..524bc8d27 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -78,6 +78,3 @@ pub type Header = generic::Header; /// Block type. pub type Block = generic::Block; - -/// Incremental ID type -pub type IncrementalId = u32; diff --git a/runtime/adapters/src/xcm_exchange.rs b/runtime/adapters/src/xcm_exchange.rs index deaf9da5f..a857c90b5 100644 --- a/runtime/adapters/src/xcm_exchange.rs +++ b/runtime/adapters/src/xcm_exchange.rs @@ -1,4 +1,3 @@ -use frame_system::ensure_signed; use orml_traits::MultiCurrency; use polkadot_xcm::v4::prelude::*; use sp_core::Get; @@ -7,7 +6,7 @@ use sp_std::marker::PhantomData; use sp_std::vec; use xcm_executor::traits::AssetExchange; use xcm_executor::AssetsInHolding; -use pallet_amm_support::types::{ExecutionType, Fee}; +use pallet_amm_support::types::{ExecutionType}; /// Implements `AssetExchange` to support the `ExchangeAsset` XCM instruction. /// From c36165d7c2392d1af7a8b494c52f2f9c49039ddd Mon Sep 17 00:00:00 2001 From: dmoka Date: Fri, 20 Dec 2024 07:31:22 +0100 Subject: [PATCH 095/142] remove xcm exchange from filler type --- pallets/amm-support/src/types.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/pallets/amm-support/src/types.rs b/pallets/amm-support/src/types.rs index 8a4149b18..34f3d96d5 100644 --- a/pallets/amm-support/src/types.rs +++ b/pallets/amm-support/src/types.rs @@ -15,7 +15,6 @@ pub enum Filler { XYK(AssetId), // share token LBP, OTC(OtcOrderId), - XcmExchange, //TODO: do we need some info? Xcm(Option<[u8; 32]>), //TODO: VERIFY // ICE(solution_id/block id), swapper: alice, filler: solver } From b5d94bca40db91c8b1c36257f39bd1e77d369cf9 Mon Sep 17 00:00:00 2001 From: dmoka Date: Fri, 20 Dec 2024 07:49:41 +0100 Subject: [PATCH 096/142] remove generic type --- pallets/amm-support/src/lib.rs | 10 +++++----- pallets/amm-support/src/types.rs | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pallets/amm-support/src/lib.rs b/pallets/amm-support/src/lib.rs index 3fcd2f5b3..e40e8dbc3 100644 --- a/pallets/amm-support/src/lib.rs +++ b/pallets/amm-support/src/lib.rs @@ -36,7 +36,7 @@ pub use pallet::*; pub const MAX_STACK_SIZE: u32 = 10; -type ExecutionIdStack = BoundedVec, ConstU32>; +type ExecutionIdStack = BoundedVec>; #[frame_support::pallet] pub mod pallet { @@ -83,7 +83,7 @@ pub mod pallet { inputs: Vec, outputs: Vec, fees: Vec>, - operation_id: Vec>, + operation_id: Vec, }, } @@ -126,7 +126,7 @@ impl Pallet { }); } - pub fn add_to_context(execution_type: fn(u32) -> ExecutionType) -> Result { + pub fn add_to_context(execution_type: fn(u32) -> ExecutionType) -> Result { //TODO: double check what to do when these can fail, we dont really want failing due to this let next_id = IncrementalId::::try_mutate(|current_id| -> Result { let inc_id = *current_id; @@ -145,9 +145,9 @@ impl Pallet { Ok(next_id) } - pub fn remove_from_context() -> Result, DispatchError> { + pub fn remove_from_context() -> Result { //TODO: check what to do when it fails, we might dont want to bloc ktrades becase of it - ExecutionContext::::try_mutate(|stack| -> Result, DispatchError> { + ExecutionContext::::try_mutate(|stack| -> Result { stack.pop().ok_or(Error::::EmptyStack.into()) }) } diff --git a/pallets/amm-support/src/types.rs b/pallets/amm-support/src/types.rs index 34f3d96d5..ad1b0881b 100644 --- a/pallets/amm-support/src/types.rs +++ b/pallets/amm-support/src/types.rs @@ -52,13 +52,13 @@ impl Asset { #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] #[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] -pub enum ExecutionType { - Router(IncrementalId), - DCA(IncrementalId), //We might need schedule id. How about otc? - ICE(IncrementalId), - Batch(IncrementalId), - Omnipool(IncrementalId), - XcmExchange(IncrementalId), +pub enum ExecutionType{ + Router(IncrementalIdType), + DCA(IncrementalIdType), //We might need schedule id. How about otc? + ICE(IncrementalIdType), + Batch(IncrementalIdType), + Omnipool(IncrementalIdType), + XcmExchange(IncrementalIdType), } #[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] From 58c2c8016636109e29bce3a997b6306501a2e77a Mon Sep 17 00:00:00 2001 From: dmoka Date: Fri, 20 Dec 2024 08:06:55 +0100 Subject: [PATCH 097/142] add schedule id to dca execution type so indexer can relate DCA used for split trades --- integration-tests/src/dca.rs | 18 ++++++++++-------- pallets/amm-support/src/lib.rs | 3 ++- pallets/amm-support/src/types.rs | 3 ++- pallets/dca/src/lib.rs | 2 +- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/integration-tests/src/dca.rs b/integration-tests/src/dca.rs index 7e340f86d..55b6e23cc 100644 --- a/integration-tests/src/dca.rs +++ b/integration-tests/src/dca.rs @@ -211,6 +211,7 @@ mod omnipool { let dca_budget = 1000 * UNITS; let amount_out = 100 * UNITS; + let schedule_id = 0; let schedule1 = schedule_fake_with_buy_order(PoolType::Omnipool, HDX, DAI, amount_out, dca_budget); create_schedule(ALICE, schedule1); @@ -232,7 +233,7 @@ mod omnipool { outputs: vec![Asset::new(LRNA, 70210545436437)], fees: vec![Fee::new(LRNA, 35105272718, Omnipool::protocol_account()),], operation_id: vec![ - ExecutionType::DCA(0), + ExecutionType::DCA(schedule_id, 0), ExecutionType::Router(1), ExecutionType::Omnipool(2) ] @@ -246,7 +247,7 @@ mod omnipool { outputs: vec![Asset::new(DAI, amount_out)], fees: vec![Fee::new(DAI, 250626566417, Omnipool::protocol_account()),], operation_id: vec![ - ExecutionType::DCA(0), + ExecutionType::DCA(schedule_id, 0), ExecutionType::Router(1), ExecutionType::Omnipool(2) ], @@ -270,7 +271,7 @@ mod omnipool { outputs: vec![Asset::new(LRNA, 70210548448729)], fees: vec![Fee::new(LRNA, 35105274224, Omnipool::protocol_account()),], operation_id: vec![ - ExecutionType::DCA(3), + ExecutionType::DCA(schedule_id, 3), ExecutionType::Router(4), ExecutionType::Omnipool(5) ], @@ -284,7 +285,7 @@ mod omnipool { outputs: vec![Asset::new(DAI, amount_out)], fees: vec![Fee::new(DAI, 250626566417, Omnipool::protocol_account()),], operation_id: vec![ - ExecutionType::DCA(3), + ExecutionType::DCA(schedule_id, 3), ExecutionType::Router(4), ExecutionType::Omnipool(5) ], @@ -696,6 +697,7 @@ mod omnipool { let dca_budget = 1100 * UNITS; let amount_to_sell = 100 * UNITS; + let schedule_id = 0; let schedule1 = schedule_fake_with_sell_order(ALICE, PoolType::Omnipool, dca_budget, HDX, DAI, amount_to_sell); create_schedule(ALICE, schedule1); @@ -718,7 +720,7 @@ mod omnipool { outputs: vec![Asset::new(LRNA, 49999999159957)], fees: vec![Fee::new(LRNA, 24999999579, Omnipool::protocol_account()),], operation_id: vec![ - ExecutionType::DCA(0), + ExecutionType::DCA(schedule_id, 0), ExecutionType::Router(1), ExecutionType::Omnipool(2) ], @@ -732,7 +734,7 @@ mod omnipool { outputs: vec![Asset::new(DAI, 71214372624126)], fees: vec![Fee::new(DAI, 178482136903, Omnipool::protocol_account()),], operation_id: vec![ - ExecutionType::DCA(0), + ExecutionType::DCA(schedule_id, 0), ExecutionType::Router(1), ExecutionType::Omnipool(2) ], @@ -756,7 +758,7 @@ mod omnipool { outputs: vec![Asset::new(LRNA, 49999997360044)], fees: vec![Fee::new(LRNA, 24999998680, Omnipool::protocol_account()),], operation_id: vec![ - ExecutionType::DCA(3), + ExecutionType::DCA(schedule_id, 3), ExecutionType::Router(4), ExecutionType::Omnipool(5) ], @@ -770,7 +772,7 @@ mod omnipool { outputs: vec![Asset::new(DAI, 71214367826179)], fees: vec![Fee::new(DAI, 178482124878, Omnipool::protocol_account()),], operation_id: vec![ - ExecutionType::DCA(3), + ExecutionType::DCA(schedule_id, 3), ExecutionType::Router(4), ExecutionType::Omnipool(5) ], diff --git a/pallets/amm-support/src/lib.rs b/pallets/amm-support/src/lib.rs index e40e8dbc3..fa094e767 100644 --- a/pallets/amm-support/src/lib.rs +++ b/pallets/amm-support/src/lib.rs @@ -126,7 +126,8 @@ impl Pallet { }); } - pub fn add_to_context(execution_type: fn(u32) -> ExecutionType) -> Result { + pub fn add_to_context(execution_type: F) -> Result + where F: FnOnce(u32) -> ExecutionType { //TODO: double check what to do when these can fail, we dont really want failing due to this let next_id = IncrementalId::::try_mutate(|current_id| -> Result { let inc_id = *current_id; diff --git a/pallets/amm-support/src/types.rs b/pallets/amm-support/src/types.rs index ad1b0881b..ea910e632 100644 --- a/pallets/amm-support/src/types.rs +++ b/pallets/amm-support/src/types.rs @@ -7,6 +7,7 @@ pub type AssetId = u32; pub type Balance = u128; pub type IncrementalIdType = u32; pub type OtcOrderId = u32; +pub type ScheduleId = u32; #[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] pub enum Filler { @@ -54,7 +55,7 @@ impl Asset { #[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] pub enum ExecutionType{ Router(IncrementalIdType), - DCA(IncrementalIdType), //We might need schedule id. How about otc? + DCA(ScheduleId, IncrementalIdType), ICE(IncrementalIdType), Batch(IncrementalIdType), Omnipool(IncrementalIdType), diff --git a/pallets/dca/src/lib.rs b/pallets/dca/src/lib.rs index a309df5ca..d90f96593 100644 --- a/pallets/dca/src/lib.rs +++ b/pallets/dca/src/lib.rs @@ -694,7 +694,7 @@ impl Pallet { schedule_id: ScheduleId, schedule: &Schedule>, ) -> Result, DispatchError> { - pallet_amm_support::Pallet::::add_to_context(ExecutionType::DCA)?; + pallet_amm_support::Pallet::::add_to_context(|id| ExecutionType::DCA(schedule_id, id))?; let origin: OriginFor = Origin::::Signed(schedule.owner.clone()).into(); let trade_result = match &schedule.order { From ce767c28fc7e78b9ddf35594139158aa77a7f4e3 Mon Sep 17 00:00:00 2001 From: dmoka Date: Fri, 20 Dec 2024 10:43:53 +0100 Subject: [PATCH 098/142] formatting --- integration-tests/src/exchange_asset.rs | 33 ++++----- pallets/amm-support/src/lib.rs | 8 +-- .../amm-support/src/tests/incremental_id.rs | 5 +- pallets/amm-support/src/types.rs | 10 +-- pallets/dca/src/lib.rs | 22 +++--- pallets/omnipool/src/lib.rs | 67 ++++++++----------- pallets/otc-settlements/src/tests.rs | 2 +- pallets/route-executor/src/lib.rs | 2 +- pallets/stableswap/src/lib.rs | 2 +- pallets/stableswap/src/tests/add_liquidity.rs | 2 +- runtime/adapters/src/xcm_exchange.rs | 2 +- runtime/hydradx/src/system.rs | 2 +- 12 files changed, 70 insertions(+), 87 deletions(-) diff --git a/integration-tests/src/exchange_asset.rs b/integration-tests/src/exchange_asset.rs index 2c77df9ef..712bc20f6 100644 --- a/integration-tests/src/exchange_asset.rs +++ b/integration-tests/src/exchange_asset.rs @@ -8,7 +8,10 @@ use frame_support::traits::tokens::Precision; use frame_support::weights::Weight; use frame_support::{assert_ok, pallet_prelude::*}; use hydradx_runtime::Omnipool; +use hydradx_runtime::Router; use hydradx_runtime::RuntimeEvent; +use hydradx_runtime::RuntimeOrigin; +use hydradx_runtime::TempAccountForXcmAssetExchange; use hydradx_runtime::{AssetRegistry, LRNA}; use hydradx_traits::AssetKind; use hydradx_traits::Create; @@ -23,9 +26,6 @@ use sp_runtime::DispatchResult; use sp_runtime::{FixedU128, Permill, TransactionOutcome}; use sp_std::sync::Arc; use xcm_emulator::TestExt; -use hydradx_runtime::TempAccountForXcmAssetExchange; -use hydradx_runtime::RuntimeOrigin; -use hydradx_runtime::Router; pub const SELL: bool = true; pub const BUY: bool = false; @@ -163,13 +163,13 @@ fn hydra_should_swap_assets_when_receiving_from_acala_with_sell() { //We assert that another trade doesnt have the xcm exchange type on stack assert_ok!(Router::sell( - RuntimeOrigin::signed(ALICE.into()), - HDX, - ACA, - 1 * UNITS, - 0, - vec![], - )); + RuntimeOrigin::signed(ALICE.into()), + HDX, + ACA, + 1 * UNITS, + 0, + vec![], + )); let last_swapped_events = get_last_swapped_events(); let last_two_swapped_events = &last_swapped_events[last_swapped_events.len() - 2..]; @@ -183,11 +183,8 @@ fn hydra_should_swap_assets_when_receiving_from_acala_with_sell() { operation: pallet_amm_support::types::TradeOperation::ExactIn, inputs: vec![pallet_amm_support::types::Asset::new(HDX, 1 * UNITS),], outputs: vec![pallet_amm_support::types::Asset::new(LRNA::get(), 1308673515)], - fees: vec![Fee::new(LRNA::get(), 654336, Omnipool::protocol_account()),], - operation_id: vec![ - ExecutionType::Router(3), - ExecutionType::Omnipool(4) - ], + fees: vec![Fee::new(LRNA::get(), 654336, Omnipool::protocol_account()),], + operation_id: vec![ExecutionType::Router(3), ExecutionType::Omnipool(4)], }), RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { swapper: ALICE.into(), @@ -197,14 +194,10 @@ fn hydra_should_swap_assets_when_receiving_from_acala_with_sell() { inputs: vec![pallet_amm_support::types::Asset::new(LRNA::get(), 1308019179),], outputs: vec![pallet_amm_support::types::Asset::new(ACA, 1348602600)], fees: vec![Fee::new(ACA, 3379957, Omnipool::protocol_account()),], - operation_id: vec![ - ExecutionType::Router(3), - ExecutionType::Omnipool(4) - ], + operation_id: vec![ExecutionType::Router(3), ExecutionType::Omnipool(4)], }) ] ); - }); } diff --git a/pallets/amm-support/src/lib.rs b/pallets/amm-support/src/lib.rs index fa094e767..387b382ef 100644 --- a/pallets/amm-support/src/lib.rs +++ b/pallets/amm-support/src/lib.rs @@ -18,12 +18,11 @@ #![cfg_attr(not(feature = "std"), no_std)] #![allow(clippy::too_many_arguments)] - use crate::types::*; use frame_support::sp_runtime::app_crypto::sp_core; use frame_support::sp_runtime::{BoundedVec, DispatchError, DispatchResult}; use frame_system::pallet_prelude::BlockNumberFor; -use sp_core::{ConstU32}; +use sp_core::ConstU32; use sp_std::vec::Vec; #[cfg(test)] @@ -127,7 +126,9 @@ impl Pallet { } pub fn add_to_context(execution_type: F) -> Result - where F: FnOnce(u32) -> ExecutionType { + where + F: FnOnce(u32) -> ExecutionType, + { //TODO: double check what to do when these can fail, we dont really want failing due to this let next_id = IncrementalId::::try_mutate(|current_id| -> Result { let inc_id = *current_id; @@ -152,5 +153,4 @@ impl Pallet { stack.pop().ok_or(Error::::EmptyStack.into()) }) } - } diff --git a/pallets/amm-support/src/tests/incremental_id.rs b/pallets/amm-support/src/tests/incremental_id.rs index 93db3a2ba..8391880b7 100644 --- a/pallets/amm-support/src/tests/incremental_id.rs +++ b/pallets/amm-support/src/tests/incremental_id.rs @@ -23,7 +23,10 @@ fn stack_should_be_populated_when_pushed() { ExtBuilder::default().build().execute_with(|| { assert_ok!(AmmSupport::add_to_context(ExecutionType::Router)); assert_eq!(AmmSupport::execution_context(), vec![ExecutionType::Router(0)]); - assert_eq!(AmmSupport::execution_context().into_inner(), vec![ExecutionType::Router(0)]); + assert_eq!( + AmmSupport::execution_context().into_inner(), + vec![ExecutionType::Router(0)] + ); assert_ok!(AmmSupport::add_to_context(ExecutionType::Router)); assert_eq!( diff --git a/pallets/amm-support/src/types.rs b/pallets/amm-support/src/types.rs index ea910e632..46166eae5 100644 --- a/pallets/amm-support/src/types.rs +++ b/pallets/amm-support/src/types.rs @@ -17,10 +17,9 @@ pub enum Filler { LBP, OTC(OtcOrderId), Xcm(Option<[u8; 32]>), //TODO: VERIFY - // ICE(solution_id/block id), swapper: alice, filler: solver + // ICE(solution_id/block id), swapper: alice, filler: solver } - #[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] pub struct Fee { pub asset: AssetId, @@ -44,16 +43,13 @@ pub struct Asset { } impl Asset { pub fn new(asset: AssetId, amount: Balance) -> Self { - Self { - asset, - amount, - } + Self { asset, amount } } } #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] #[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] -pub enum ExecutionType{ +pub enum ExecutionType { Router(IncrementalIdType), DCA(ScheduleId, IncrementalIdType), ICE(IncrementalIdType), diff --git a/pallets/dca/src/lib.rs b/pallets/dca/src/lib.rs index d90f96593..402fba329 100644 --- a/pallets/dca/src/lib.rs +++ b/pallets/dca/src/lib.rs @@ -63,6 +63,7 @@ #![cfg_attr(not(feature = "std"), no_std)] +use frame_support::traits::DefensiveOption; use frame_support::{ ensure, pallet_prelude::*, @@ -70,33 +71,32 @@ use frame_support::{ transactional, weights::WeightToFee as FrameSupportWeight, }; -use frame_support::traits::DefensiveOption; use frame_system::{ ensure_signed, - Origin, pallet_prelude::{BlockNumberFor, OriginFor}, + Origin, }; use orml_traits::{arithmetic::CheckedAdd, MultiCurrency, NamedMultiReservableCurrency}; -use rand::{Rng, SeedableRng}; use rand::rngs::StdRng; -use sp_runtime::{ - ArithmeticError, - BoundedVec, DispatchError, FixedPointNumber, FixedU128, Percent, Permill, Rounding, traits::{BlockNumberProvider, Saturating}, -}; +use rand::{Rng, SeedableRng}; use sp_runtime::helpers_128bit::multiply_by_rational_with_rounding; use sp_runtime::traits::CheckedMul; +use sp_runtime::{ + traits::{BlockNumberProvider, Saturating}, + ArithmeticError, BoundedVec, DispatchError, FixedPointNumber, FixedU128, Percent, Permill, Rounding, +}; use sp_std::cmp::min; use sp_std::vec::Vec; use hydradx_adapters::RelayChainBlockHashProvider; use hydradx_traits::fee::{InspectTransactionFeeCurrency, SwappablePaymentAssetTrader}; +use hydradx_traits::router::{inverse_route, RouteProvider}; +use hydradx_traits::router::{AmmTradeWeights, AmountInAndOut, RouterT, Trade}; use hydradx_traits::NativePriceOracle; use hydradx_traits::OraclePeriod; use hydradx_traits::PriceOracle; -use hydradx_traits::router::{inverse_route, RouteProvider}; -use hydradx_traits::router::{AmmTradeWeights, AmountInAndOut, RouterT, Trade}; pub use pallet::*; -use pallet_amm_support::types::{ExecutionType,}; +use pallet_amm_support::types::ExecutionType; pub use weights::WeightInfo; // Re-export pallet items so that they can be accessed from the crate namespace. @@ -121,8 +121,8 @@ pub mod pallet { use sp_runtime::Percent; use hydra_dx_math::ema::EmaPrice; - use hydradx_traits::{NativePriceOracle, PriceOracle}; use hydradx_traits::fee::SwappablePaymentAssetTrader; + use hydradx_traits::{NativePriceOracle, PriceOracle}; use super::*; diff --git a/pallets/omnipool/src/lib.rs b/pallets/omnipool/src/lib.rs index 683fe19e4..eef6e9ea2 100644 --- a/pallets/omnipool/src/lib.rs +++ b/pallets/omnipool/src/lib.rs @@ -1101,9 +1101,10 @@ pub mod pallet { pallet_amm_support::types::Filler::Omnipool, pallet_amm_support::types::TradeOperation::ExactIn, vec![Asset::new(asset_in.into(), amount)], - vec![Asset::new(T::HubAssetId::get().into(), - *state_changes.asset_in.delta_hub_reserve) - ], + vec![Asset::new( + T::HubAssetId::get().into(), + *state_changes.asset_in.delta_hub_reserve, + )], vec![Fee::new( T::HubAssetId::get().into(), state_changes.fee.protocol_fee, @@ -1117,12 +1118,11 @@ pub mod pallet { Self::protocol_account(), pallet_amm_support::types::Filler::Omnipool, pallet_amm_support::types::TradeOperation::ExactIn, - vec![Asset::new(T::HubAssetId::get().into(), - *state_changes.asset_out.delta_hub_reserve) - ], - vec![Asset::new(asset_out.into(), - *state_changes.asset_out.delta_reserve) - ], + vec![Asset::new( + T::HubAssetId::get().into(), + *state_changes.asset_out.delta_hub_reserve, + )], + vec![Asset::new(asset_out.into(), *state_changes.asset_out.delta_reserve)], vec![Fee { asset: asset_out.into(), amount: state_changes.fee.asset_fee, @@ -1345,13 +1345,11 @@ pub mod pallet { Self::protocol_account(), pallet_amm_support::types::Filler::Omnipool, pallet_amm_support::types::TradeOperation::ExactOut, - vec![ - Asset::new(asset_in.into(), - *state_changes.asset_in.delta_reserve), - ], - vec![Asset::new(T::HubAssetId::get().into(), - *state_changes.asset_in.delta_hub_reserve) - ], + vec![Asset::new(asset_in.into(), *state_changes.asset_in.delta_reserve)], + vec![Asset::new( + T::HubAssetId::get().into(), + *state_changes.asset_in.delta_hub_reserve, + )], vec![Fee::new( T::HubAssetId::get().into(), state_changes.fee.protocol_fee, @@ -1365,12 +1363,11 @@ pub mod pallet { Self::protocol_account(), pallet_amm_support::types::Filler::Omnipool, pallet_amm_support::types::TradeOperation::ExactOut, - vec![Asset::new(T::HubAssetId::get().into(), - *state_changes.asset_out.delta_hub_reserve), - ], - vec![Asset::new(asset_out.into(), - *state_changes.asset_out.delta_reserve) - ], + vec![Asset::new( + T::HubAssetId::get().into(), + *state_changes.asset_out.delta_hub_reserve, + )], + vec![Asset::new(asset_out.into(), *state_changes.asset_out.delta_reserve)], vec![Fee { asset: asset_out.into(), amount: state_changes.fee.asset_fee, @@ -1905,14 +1902,11 @@ impl Pallet { Self::protocol_account(), pallet_amm_support::types::Filler::Omnipool, pallet_amm_support::types::TradeOperation::ExactIn, - vec![ - Asset::new(T::HubAssetId::get().into(), - *state_changes.asset.delta_hub_reserve), - ], - vec![ - Asset::new(asset_out.into(), - *state_changes.asset.delta_reserve), - ], + vec![Asset::new( + T::HubAssetId::get().into(), + *state_changes.asset.delta_hub_reserve, + )], + vec![Asset::new(asset_out.into(), *state_changes.asset.delta_reserve)], vec![Fee { asset: asset_out.into(), amount: state_changes.fee.asset_fee, @@ -2034,14 +2028,11 @@ impl Pallet { Self::protocol_account(), pallet_amm_support::types::Filler::Omnipool, pallet_amm_support::types::TradeOperation::ExactOut, - vec![ - Asset::new(T::HubAssetId::get().into(), - *state_changes.asset.delta_hub_reserve), - ], - vec![ - Asset::new(asset_out.into(), - *state_changes.asset.delta_reserve), - ], + vec![Asset::new( + T::HubAssetId::get().into(), + *state_changes.asset.delta_hub_reserve, + )], + vec![Asset::new(asset_out.into(), *state_changes.asset.delta_reserve)], vec![Fee { asset: asset_out.into(), amount: state_changes.fee.asset_fee, diff --git a/pallets/otc-settlements/src/tests.rs b/pallets/otc-settlements/src/tests.rs index 0c89b3451..92e893a81 100644 --- a/pallets/otc-settlements/src/tests.rs +++ b/pallets/otc-settlements/src/tests.rs @@ -24,8 +24,8 @@ pub use crate::mock::*; use frame_support::{assert_ok, assert_storage_noop}; use hydradx_traits::Inspect; use orml_traits::MultiCurrency; -use pallet_amm_support::types::{Fee}; use pallet_amm_support::types::Asset; +use pallet_amm_support::types::Fee; pub fn expect_events(e: Vec) { e.into_iter().for_each(frame_system::Pallet::::assert_has_event); diff --git a/pallets/route-executor/src/lib.rs b/pallets/route-executor/src/lib.rs index ade1e3eea..c1556fbe9 100644 --- a/pallets/route-executor/src/lib.rs +++ b/pallets/route-executor/src/lib.rs @@ -39,8 +39,8 @@ pub use hydradx_traits::router::{ }; use orml_traits::arithmetic::{CheckedAdd, CheckedSub}; -pub use pallet_amm_support::types::{ExecutionType, Fee}; use pallet_amm_support::types::IncrementalIdType; +pub use pallet_amm_support::types::{ExecutionType, Fee}; use sp_core::U512; use sp_runtime::traits::{AccountIdConversion, CheckedDiv}; use sp_runtime::{ArithmeticError, DispatchError, FixedPointNumber, FixedU128, Saturating, TransactionOutcome}; diff --git a/pallets/stableswap/src/lib.rs b/pallets/stableswap/src/lib.rs index 5bd1f846a..e215b66c7 100644 --- a/pallets/stableswap/src/lib.rs +++ b/pallets/stableswap/src/lib.rs @@ -104,7 +104,7 @@ pub mod pallet { use core::ops::RangeInclusive; use frame_support::pallet_prelude::*; use hydradx_traits::pools::DustRemovalAccountWhitelist; - use pallet_amm_support::types::{Fee}; + use pallet_amm_support::types::Fee; use sp_runtime::traits::{BlockNumberProvider, Zero}; use sp_runtime::ArithmeticError; use sp_runtime::Permill; diff --git a/pallets/stableswap/src/tests/add_liquidity.rs b/pallets/stableswap/src/tests/add_liquidity.rs index 2521a7ec2..04eb299f5 100644 --- a/pallets/stableswap/src/tests/add_liquidity.rs +++ b/pallets/stableswap/src/tests/add_liquidity.rs @@ -2,7 +2,7 @@ use crate::tests::mock::*; use crate::types::{AssetAmount, PoolInfo}; use crate::{assert_balance, to_precision, Error}; use frame_support::{assert_noop, assert_ok}; -use pallet_amm_support::types::{Fee, Asset}; +use pallet_amm_support::types::{Asset, Fee}; use sp_runtime::Permill; use std::num::NonZeroU16; diff --git a/runtime/adapters/src/xcm_exchange.rs b/runtime/adapters/src/xcm_exchange.rs index a857c90b5..2348b34ee 100644 --- a/runtime/adapters/src/xcm_exchange.rs +++ b/runtime/adapters/src/xcm_exchange.rs @@ -1,4 +1,5 @@ use orml_traits::MultiCurrency; +use pallet_amm_support::types::ExecutionType; use polkadot_xcm::v4::prelude::*; use sp_core::Get; use sp_runtime::traits::{Convert, Zero}; @@ -6,7 +7,6 @@ use sp_std::marker::PhantomData; use sp_std::vec; use xcm_executor::traits::AssetExchange; use xcm_executor::AssetsInHolding; -use pallet_amm_support::types::{ExecutionType}; /// Implements `AssetExchange` to support the `ExchangeAsset` XCM instruction. /// diff --git a/runtime/hydradx/src/system.rs b/runtime/hydradx/src/system.rs index c091344cc..a30f0797c 100644 --- a/runtime/hydradx/src/system.rs +++ b/runtime/hydradx/src/system.rs @@ -44,7 +44,7 @@ use primitives::constants::{ time::{DAYS, HOURS, SLOT_DURATION}, }; use scale_info::TypeInfo; -use sp_runtime::{DispatchResult}; +use sp_runtime::DispatchResult; pub struct CallFilter; impl Contains for CallFilter { From 96f2c5cc3b9ff6e91b815eb7a713daf4d1167d93 Mon Sep 17 00:00:00 2001 From: dmoka Date: Fri, 20 Dec 2024 15:02:47 +0100 Subject: [PATCH 099/142] add todo --- pallets/amm-support/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/pallets/amm-support/src/lib.rs b/pallets/amm-support/src/lib.rs index 387b382ef..2ae722142 100644 --- a/pallets/amm-support/src/lib.rs +++ b/pallets/amm-support/src/lib.rs @@ -129,6 +129,7 @@ impl Pallet { where F: FnOnce(u32) -> ExecutionType, { + //TODO: create patch 4 //TODO: double check what to do when these can fail, we dont really want failing due to this let next_id = IncrementalId::::try_mutate(|current_id| -> Result { let inc_id = *current_id; From 8e2ba94309d3fb72538ae261ae64673d0f7781c0 Mon Sep 17 00:00:00 2001 From: dmoka Date: Mon, 23 Dec 2024 14:40:28 +0100 Subject: [PATCH 100/142] add custom send xcm --- pallets/amm-support/src/types.rs | 2 +- runtime/hydradx/src/xcm.rs | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/pallets/amm-support/src/types.rs b/pallets/amm-support/src/types.rs index 46166eae5..df49b49a7 100644 --- a/pallets/amm-support/src/types.rs +++ b/pallets/amm-support/src/types.rs @@ -16,7 +16,6 @@ pub enum Filler { XYK(AssetId), // share token LBP, OTC(OtcOrderId), - Xcm(Option<[u8; 32]>), //TODO: VERIFY // ICE(solution_id/block id), swapper: alice, filler: solver } @@ -56,6 +55,7 @@ pub enum ExecutionType { Batch(IncrementalIdType), Omnipool(IncrementalIdType), XcmExchange(IncrementalIdType), + Xcm([u8; 32], IncrementalIdType), } #[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] diff --git a/runtime/hydradx/src/xcm.rs b/runtime/hydradx/src/xcm.rs index 271daa1d8..759718d9b 100644 --- a/runtime/hydradx/src/xcm.rs +++ b/runtime/hydradx/src/xcm.rs @@ -13,6 +13,7 @@ use frame_support::{ traits::{ConstU32, Contains, ContainsPair, Everything, Get, Nothing, TransformOrigin}, PalletId, }; +use frame_system::unique; use hydradx_adapters::{xcm_exchange::XcmAssetExchanger, xcm_execute_filter::AllowTransferAndSwap}; use orml_traits::{location::AbsoluteReserveProvider, parameter_type_with_key}; use orml_xcm_support::{DepositToAlternative, IsNativeConcrete, MultiNativeAsset}; @@ -421,6 +422,7 @@ pub type LocationToAccountId = ( EvmAddressConversion, ); use xcm_executor::traits::ConvertLocation; +use pallet_amm_support::types::ExecutionType; /// Converts Account20 (ethereum) addresses to AccountId32 (substrate) addresses. pub struct EvmAddressConversion(PhantomData); @@ -468,3 +470,33 @@ pub type LocalAssetTransactor = ReroutingMultiCurrencyAdapter< OmnipoolProtocolAccount, TreasuryAccount, >; + + +pub struct HydrationSendXcm(PhantomData); +impl SendXcm for HydrationSendXcm { + type Ticket = (Inner::Ticket, [u8; 32]); + + fn validate( + destination: &mut Option, + message: &mut Option>, + ) -> SendResult { + let mut message = message.take().ok_or(SendError::MissingArgument)?; + let unique_id = if let Some(SetTopic(id)) = message.last() { + *id + } else { + let unique_id = unique(&message); + message.0.push(SetTopic(unique_id)); + unique_id + }; + let (ticket, assets) = Inner::validate(destination, &mut Some(message))?; + Ok(((ticket, unique_id), assets)) + } + + fn deliver(ticket: Self::Ticket) -> Result { + let (ticket, unique_id) = ticket; + pallet_amm_support::Pallet::::add_to_context(|id| ExecutionType::Xcm(unique_id, id)).map_err(|_| SendError::Transport("Unexpected error at modifying unified events stack"))?; + Inner::deliver(ticket)?; + pallet_amm_support::Pallet::::remove_from_context().map_err(|_| SendError::Transport("Unexpected error at modifying unified events stack"))?; + Ok(unique_id) + } +} From e5bd8634d5a7671580306495367499ad11a25272 Mon Sep 17 00:00:00 2001 From: dmoka Date: Thu, 26 Dec 2024 09:16:01 +0100 Subject: [PATCH 101/142] add unified even support for xcm with xcm hash --- .../src/global_account_derivation.rs | 131 ------- integration-tests/src/lib.rs | 2 +- integration-tests/src/xcm.rs | 342 ++++++++++++++++++ pallets/amm-support/src/types.rs | 2 +- runtime/hydradx/src/xcm.rs | 86 +++-- 5 files changed, 394 insertions(+), 169 deletions(-) delete mode 100644 integration-tests/src/global_account_derivation.rs create mode 100644 integration-tests/src/xcm.rs diff --git a/integration-tests/src/global_account_derivation.rs b/integration-tests/src/global_account_derivation.rs deleted file mode 100644 index 94c28931b..000000000 --- a/integration-tests/src/global_account_derivation.rs +++ /dev/null @@ -1,131 +0,0 @@ -#![cfg(test)] -use crate::polkadot_test_net::*; - -use frame_support::assert_ok; -use sp_runtime::codec::Encode; - -use frame_support::dispatch::GetDispatchInfo; -use orml_traits::MultiCurrency; -use polkadot_xcm::v4::prelude::*; -use sp_std::sync::Arc; -use xcm_builder::DescribeAllTerminal; -use xcm_builder::DescribeFamily; -use xcm_builder::HashedDescription; -use xcm_emulator::ConvertLocation; -use xcm_emulator::TestExt; - -#[test] -fn other_chain_remote_account_should_work_on_hydra() { - // Arrange - TestNet::reset(); - - let xcm_interior_at_acala = - cumulus_primitives_core::Junctions::X1(Arc::new([cumulus_primitives_core::Junction::AccountId32 { - network: None, - id: evm_account().into(), - }])); - - let xcm_origin_at_hydra = Location { - parents: 1, - interior: cumulus_primitives_core::Junctions::X2(Arc::new([ - cumulus_primitives_core::Junction::Parachain(ACALA_PARA_ID), - cumulus_primitives_core::Junction::AccountId32 { - network: None, - id: evm_account().into(), - }, - ])), - }; - - let acala_account_id_at_hydra: AccountId = - HashedDescription::>::convert_location(&xcm_origin_at_hydra) - .unwrap(); - - Hydra::execute_with(|| { - init_omnipool(); - - assert_ok!(hydradx_runtime::Balances::transfer_allow_death( - hydradx_runtime::RuntimeOrigin::signed(ALICE.into()), - acala_account_id_at_hydra.clone(), - 1_000 * UNITS, - )); - - assert_eq!( - hydradx_runtime::Currencies::free_balance(DAI, &AccountId::from(acala_account_id_at_hydra.clone())), - 0 - ); - }); - - // Act - Acala::execute_with(|| { - let omni_sell = - hydradx_runtime::RuntimeCall::Omnipool(pallet_omnipool::Call::::sell { - asset_in: HDX, - asset_out: DAI, - amount: UNITS, - min_buy_amount: 0, - }); - - let hdx_loc = Location::new( - 1, - cumulus_primitives_core::Junctions::X2(Arc::new([ - cumulus_primitives_core::Junction::Parachain(HYDRA_PARA_ID), - cumulus_primitives_core::Junction::GeneralIndex(0), - ])), - ); - let asset_to_withdraw: Asset = Asset { - id: cumulus_primitives_core::AssetId(hdx_loc.clone()), - fun: Fungible(900 * UNITS), - }; - let asset_for_buy_execution: Asset = Asset { - id: cumulus_primitives_core::AssetId(hdx_loc), - fun: Fungible(800 * UNITS), - }; - - let message = Xcm(vec![ - WithdrawAsset(asset_to_withdraw.into()), - BuyExecution { - fees: asset_for_buy_execution, - weight_limit: Unlimited, - }, - Transact { - require_weight_at_most: omni_sell.get_dispatch_info().weight, - origin_kind: OriginKind::SovereignAccount, - call: omni_sell.encode().into(), - }, - ExpectTransactStatus(MaybeErrorCode::Success), - RefundSurplus, - DepositAsset { - assets: All.into(), - beneficiary: cumulus_primitives_core::Junction::AccountId32 { - id: acala_account_id_at_hydra.clone().into(), - network: None, - } - .into(), - }, - ]); - - let dest_hydradx = Location::new( - 1, - cumulus_primitives_core::Junctions::X1(Arc::new([cumulus_primitives_core::Junction::Parachain( - HYDRA_PARA_ID, - )])), - ); - - assert_ok!(hydradx_runtime::PolkadotXcm::send_xcm( - xcm_interior_at_acala, - dest_hydradx, - message - )); - }); - - // Assert - Hydra::execute_with(|| { - assert_xcm_message_processing_passed(); - - let dai_balance = hydradx_runtime::Currencies::free_balance(DAI, &AccountId::from(acala_account_id_at_hydra)); - assert!( - dai_balance > 0, - "Omnipool sell swap failed as the user did not receive any DAI" - ); - }); -} diff --git a/integration-tests/src/lib.rs b/integration-tests/src/lib.rs index 0d71637e9..e02ef2ce2 100644 --- a/integration-tests/src/lib.rs +++ b/integration-tests/src/lib.rs @@ -16,7 +16,7 @@ mod evm; mod evm_permit; mod exchange_asset; mod fee_calculation; -mod global_account_derivation; +mod xcm; mod insufficient_assets_ed; mod multi_payment; mod non_native_fee; diff --git a/integration-tests/src/xcm.rs b/integration-tests/src/xcm.rs new file mode 100644 index 000000000..f6f897296 --- /dev/null +++ b/integration-tests/src/xcm.rs @@ -0,0 +1,342 @@ +#![cfg(test)] +use crate::polkadot_test_net::*; + +use frame_support::assert_ok; +use sp_runtime::codec::Encode; + +use frame_support::dispatch::GetDispatchInfo; +use hydradx_runtime::Omnipool; +use hydradx_runtime::RuntimeEvent; +use orml_traits::MultiCurrency; +use pallet_amm_support::types::Asset as UnifiedEventAsset; +use pallet_amm_support::types::ExecutionType; +use pallet_amm_support::types::Fee; +use polkadot_xcm::v4::prelude::*; +use sp_std::sync::Arc; +use xcm_builder::DescribeAllTerminal; +use xcm_builder::DescribeFamily; +use xcm_builder::HashedDescription; +use xcm_emulator::ConvertLocation; +use xcm_emulator::TestExt; + +#[test] +fn global_account_derivation_should_work_when_with_other_chain_remote_account() { + // Arrange + TestNet::reset(); + + let xcm_interior_at_acala = + cumulus_primitives_core::Junctions::X1(Arc::new([cumulus_primitives_core::Junction::AccountId32 { + network: None, + id: evm_account().into(), + }])); + + let xcm_origin_at_hydra = Location { + parents: 1, + interior: cumulus_primitives_core::Junctions::X2(Arc::new([ + cumulus_primitives_core::Junction::Parachain(ACALA_PARA_ID), + cumulus_primitives_core::Junction::AccountId32 { + network: None, + id: evm_account().into(), + }, + ])), + }; + + let acala_account_id_at_hydra: AccountId = + HashedDescription::>::convert_location(&xcm_origin_at_hydra) + .unwrap(); + + Hydra::execute_with(|| { + init_omnipool(); + + assert_ok!(hydradx_runtime::Balances::transfer_allow_death( + hydradx_runtime::RuntimeOrigin::signed(ALICE.into()), + acala_account_id_at_hydra.clone(), + 1_000 * UNITS, + )); + + assert_eq!( + hydradx_runtime::Currencies::free_balance(DAI, &AccountId::from(acala_account_id_at_hydra.clone())), + 0 + ); + }); + + // Act + Acala::execute_with(|| { + let omni_sell = + hydradx_runtime::RuntimeCall::Omnipool(pallet_omnipool::Call::::sell { + asset_in: HDX, + asset_out: DAI, + amount: UNITS, + min_buy_amount: 0, + }); + + let hdx_loc = Location::new( + 1, + cumulus_primitives_core::Junctions::X2(Arc::new([ + cumulus_primitives_core::Junction::Parachain(HYDRA_PARA_ID), + cumulus_primitives_core::Junction::GeneralIndex(0), + ])), + ); + let asset_to_withdraw: Asset = Asset { + id: cumulus_primitives_core::AssetId(hdx_loc.clone()), + fun: Fungible(900 * UNITS), + }; + let asset_for_buy_execution: Asset = Asset { + id: cumulus_primitives_core::AssetId(hdx_loc), + fun: Fungible(800 * UNITS), + }; + + let message = Xcm(vec![ + WithdrawAsset(asset_to_withdraw.into()), + BuyExecution { + fees: asset_for_buy_execution, + weight_limit: Unlimited, + }, + Transact { + require_weight_at_most: omni_sell.get_dispatch_info().weight, + origin_kind: OriginKind::SovereignAccount, + call: omni_sell.encode().into(), + }, + ExpectTransactStatus(MaybeErrorCode::Success), + RefundSurplus, + DepositAsset { + assets: All.into(), + beneficiary: cumulus_primitives_core::Junction::AccountId32 { + id: acala_account_id_at_hydra.clone().into(), + network: None, + } + .into(), + }, + ]); + + let dest_hydradx = Location::new( + 1, + cumulus_primitives_core::Junctions::X1(Arc::new([cumulus_primitives_core::Junction::Parachain( + HYDRA_PARA_ID, + )])), + ); + + assert_ok!(hydradx_runtime::PolkadotXcm::send_xcm( + xcm_interior_at_acala, + dest_hydradx, + message + )); + }); + + // Assert + Hydra::execute_with(|| { + assert_xcm_message_processing_passed(); + let account = AccountId::from(acala_account_id_at_hydra); + + let dai_balance = hydradx_runtime::Currencies::free_balance(DAI, &account); + assert!( + dai_balance > 0, + "Omnipool sell swap failed as the user did not receive any DAI" + ); + + let swapped_events = get_last_swapped_events(); + let last_two_swapped_events = &get_last_swapped_events()[swapped_events.len() - 2..]; + pretty_assertions::assert_eq!( + last_two_swapped_events, + vec![ + RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + swapper: account.clone().into(), + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::types::Filler::Omnipool, + operation: pallet_amm_support::types::TradeOperation::ExactIn, + inputs: vec![UnifiedEventAsset::new(HDX, 1000000000000)], + outputs: vec![UnifiedEventAsset::new(LRNA, 1201498716)], + fees: vec![Fee::new(LRNA, 600749, Omnipool::protocol_account()),], + operation_id: vec![ + ExecutionType::Xcm( + [ + 105, 235, 204, 213, 153, 222, 42, 199, 108, 12, 60, 148, 48, 156, 46, 18, 60, 221, 150, + 116, 143, 103, 206, 40, 127, 183, 175, 193, 168, 255, 190, 82, + ], + 0 + ), + ExecutionType::Omnipool(1) + ] + }), + RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + swapper: account.into(), + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::types::Filler::Omnipool, + operation: pallet_amm_support::types::TradeOperation::ExactIn, + inputs: vec![UnifiedEventAsset::new(LRNA, 1200897967)], + outputs: vec![UnifiedEventAsset::new(DAI, 26619890727267708)], + fees: vec![Fee::new(DAI, 66716518113453, Omnipool::protocol_account()),], + operation_id: vec![ + ExecutionType::Xcm( + [ + 105, 235, 204, 213, 153, 222, 42, 199, 108, 12, 60, 148, 48, 156, 46, 18, 60, 221, 150, + 116, 143, 103, 206, 40, 127, 183, 175, 193, 168, 255, 190, 82, + ], + 0 + ), + ExecutionType::Omnipool(1) + ], + }) + ] + ); + }); +} + + +#[test] +fn xcm_call_should_populate_unified_event_call_context() { + // Arrange + TestNet::reset(); + + let xcm_interior_at_acala = + cumulus_primitives_core::Junctions::X1(Arc::new([cumulus_primitives_core::Junction::AccountId32 { + network: None, + id: evm_account().into(), + }])); + + let xcm_origin_at_hydra = Location { + parents: 1, + interior: cumulus_primitives_core::Junctions::X2(Arc::new([ + cumulus_primitives_core::Junction::Parachain(ACALA_PARA_ID), + cumulus_primitives_core::Junction::AccountId32 { + network: None, + id: evm_account().into(), + }, + ])), + }; + + let acala_account_id_at_hydra: AccountId = + HashedDescription::>::convert_location(&xcm_origin_at_hydra) + .unwrap(); + + Hydra::execute_with(|| { + init_omnipool(); + + assert_ok!(hydradx_runtime::Balances::transfer_allow_death( + hydradx_runtime::RuntimeOrigin::signed(ALICE.into()), + acala_account_id_at_hydra.clone(), + 1_000 * UNITS, + )); + + assert_eq!( + hydradx_runtime::Currencies::free_balance(DAI, &AccountId::from(acala_account_id_at_hydra.clone())), + 0 + ); + }); + + // Act + Acala::execute_with(|| { + let omni_sell = + hydradx_runtime::RuntimeCall::Omnipool(pallet_omnipool::Call::::sell { + asset_in: HDX, + asset_out: DAI, + amount: UNITS, + min_buy_amount: 0, + }); + + let hdx_loc = Location::new( + 1, + cumulus_primitives_core::Junctions::X2(Arc::new([ + cumulus_primitives_core::Junction::Parachain(HYDRA_PARA_ID), + cumulus_primitives_core::Junction::GeneralIndex(0), + ])), + ); + let asset_to_withdraw: Asset = Asset { + id: cumulus_primitives_core::AssetId(hdx_loc.clone()), + fun: Fungible(900 * UNITS), + }; + let asset_for_buy_execution: Asset = Asset { + id: cumulus_primitives_core::AssetId(hdx_loc), + fun: Fungible(800 * UNITS), + }; + + let message = Xcm(vec![ + WithdrawAsset(asset_to_withdraw.into()), + BuyExecution { + fees: asset_for_buy_execution, + weight_limit: Unlimited, + }, + Transact { + require_weight_at_most: omni_sell.get_dispatch_info().weight, + origin_kind: OriginKind::SovereignAccount, + call: omni_sell.encode().into(), + }, + ExpectTransactStatus(MaybeErrorCode::Success), + RefundSurplus, + DepositAsset { + assets: All.into(), + beneficiary: cumulus_primitives_core::Junction::AccountId32 { + id: acala_account_id_at_hydra.clone().into(), + network: None, + } + .into(), + }, + ]); + + let dest_hydradx = Location::new( + 1, + cumulus_primitives_core::Junctions::X1(Arc::new([cumulus_primitives_core::Junction::Parachain( + HYDRA_PARA_ID, + )])), + ); + + assert_ok!(hydradx_runtime::PolkadotXcm::send_xcm( + xcm_interior_at_acala, + dest_hydradx, + message + )); + }); + + // Assert + Hydra::execute_with(|| { + let account = AccountId::from(acala_account_id_at_hydra); + + assert_xcm_message_processing_passed(); + + let swapped_events = get_last_swapped_events(); + let last_two_swapped_events = &get_last_swapped_events()[swapped_events.len() - 2..]; + pretty_assertions::assert_eq!( + last_two_swapped_events, + vec![ + RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + swapper: account.clone().into(), + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::types::Filler::Omnipool, + operation: pallet_amm_support::types::TradeOperation::ExactIn, + inputs: vec![UnifiedEventAsset::new(HDX, 1000000000000)], + outputs: vec![UnifiedEventAsset::new(LRNA, 1201498716)], + fees: vec![Fee::new(LRNA, 600749, Omnipool::protocol_account()),], + operation_id: vec![ + ExecutionType::Xcm( + [ + 105, 235, 204, 213, 153, 222, 42, 199, 108, 12, 60, 148, 48, 156, 46, 18, 60, 221, 150, + 116, 143, 103, 206, 40, 127, 183, 175, 193, 168, 255, 190, 82, + ], + 0 + ), + ExecutionType::Omnipool(1) + ] + }), + RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + swapper: account.into(), + filler: Omnipool::protocol_account(), + filler_type: pallet_amm_support::types::Filler::Omnipool, + operation: pallet_amm_support::types::TradeOperation::ExactIn, + inputs: vec![UnifiedEventAsset::new(LRNA, 1200897967)], + outputs: vec![UnifiedEventAsset::new(DAI, 26619890727267708)], + fees: vec![Fee::new(DAI, 66716518113453, Omnipool::protocol_account()),], + operation_id: vec![ + ExecutionType::Xcm( + [ + 105, 235, 204, 213, 153, 222, 42, 199, 108, 12, 60, 148, 48, 156, 46, 18, 60, 221, 150, + 116, 143, 103, 206, 40, 127, 183, 175, 193, 168, 255, 190, 82, + ], + 0 + ), + ExecutionType::Omnipool(1) + ], + }) + ] + ); + }); +} diff --git a/pallets/amm-support/src/types.rs b/pallets/amm-support/src/types.rs index df49b49a7..e65a5b9da 100644 --- a/pallets/amm-support/src/types.rs +++ b/pallets/amm-support/src/types.rs @@ -16,7 +16,7 @@ pub enum Filler { XYK(AssetId), // share token LBP, OTC(OtcOrderId), - // ICE(solution_id/block id), swapper: alice, filler: solver + // ICE(solution_id/block id), swapper: alice, filler: solver } #[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)] diff --git a/runtime/hydradx/src/xcm.rs b/runtime/hydradx/src/xcm.rs index 759718d9b..1fae489cb 100644 --- a/runtime/hydradx/src/xcm.rs +++ b/runtime/hydradx/src/xcm.rs @@ -13,7 +13,6 @@ use frame_support::{ traits::{ConstU32, Contains, ContainsPair, Everything, Get, Nothing, TransformOrigin}, PalletId, }; -use frame_system::unique; use hydradx_adapters::{xcm_exchange::XcmAssetExchanger, xcm_execute_filter::AllowTransferAndSwap}; use orml_traits::{location::AbsoluteReserveProvider, parameter_type_with_key}; use orml_xcm_support::{DepositToAlternative, IsNativeConcrete, MultiNativeAsset}; @@ -224,9 +223,54 @@ impl Config for XcmConfig { impl cumulus_pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type XcmExecutor = XcmExecutor; + type XcmExecutor = WithUnifiedEventSupport>; } +pub struct WithUnifiedEventSupport(PhantomData); + +impl::RuntimeCall>> ExecuteXcm<::RuntimeCall> for WithUnifiedEventSupport { + type Prepared = >::Prepared; + + fn prepare(message: Xcm<::RuntimeCall>) -> Result::RuntimeCall>> { + Inner::prepare(message) + } + + fn execute( + origin: impl Into, + pre: Self::Prepared, + id: &mut XcmHash, + weight_credit: XcmWeight, + ) -> Outcome { + let Ok(_) = pallet_amm_support::Pallet::::add_to_context(|event_id| ExecutionType::Xcm(*id, event_id)) + else { + return Outcome::Error { + error: XcmError::FailedToTransactAsset("Unexpected error at modifying unified events stack"), + }; + }; + + let outcome = Inner::execute(origin, pre, id, weight_credit); + + let Ok(_) = pallet_amm_support::Pallet::::remove_from_context() else { + return Outcome::Error { + error: XcmError::FailedToTransactAsset("Unexpected error at modifying unified events stack"), + }; + }; + + outcome + } + + fn charge_fees(location: impl Into, fees: Assets) -> XcmResult { + Inner::charge_fees(location, fees) + } +} + +impl::RuntimeCall>> XcmAssetTransfers for WithUnifiedEventSupport { + type IsReserve = ::IsReserve; + type IsTeleporter = ::IsTeleporter; + type AssetTransactor = ::AssetTransactor; +} + + parameter_types! { pub const MaxInboundSuspended: u32 = 1_000; } @@ -262,7 +306,7 @@ impl orml_xtokens::Config for Runtime { type CurrencyIdConvert = CurrencyIdConvert; type AccountIdToLocation = AccountIdToMultiLocation; type SelfLocation = SelfLocation; - type XcmExecutor = XcmExecutor; + type XcmExecutor = WithUnifiedEventSupport>; type Weigher = FixedWeightBounds; type BaseXcmWeight = BaseXcmWeight; type MaxAssetsForTransfer = MaxAssetsForTransfer; @@ -291,7 +335,7 @@ impl pallet_xcm::Config for Runtime { type XcmRouter = XcmRouter; type ExecuteXcmOrigin = EnsureXcmOrigin; type XcmExecuteFilter = AllowTransferAndSwap; - type XcmExecutor = XcmExecutor; + type XcmExecutor = WithUnifiedEventSupport>; type XcmTeleportFilter = Nothing; type XcmReserveTransferFilter = Everything; type Weigher = FixedWeightBounds; @@ -322,7 +366,7 @@ impl pallet_message_queue::Config for Runtime { type MessageProcessor = pallet_message_queue::mock_helpers::NoopMessageProcessor; #[cfg(not(feature = "runtime-benchmarks"))] - type MessageProcessor = xcm_builder::ProcessXcmMessage, RuntimeCall>; + type MessageProcessor = xcm_builder::ProcessXcmMessage>, RuntimeCall>; type Size = u32; type QueueChangeHandler = NarrowOriginToSibling; type QueuePausedQuery = NarrowOriginToSibling; @@ -421,8 +465,8 @@ pub type LocationToAccountId = ( // Convert ETH to local substrate account EvmAddressConversion, ); -use xcm_executor::traits::ConvertLocation; use pallet_amm_support::types::ExecutionType; +use xcm_executor::traits::{ConvertLocation, XcmAssetTransfers}; /// Converts Account20 (ethereum) addresses to AccountId32 (substrate) addresses. pub struct EvmAddressConversion(PhantomData); @@ -470,33 +514,3 @@ pub type LocalAssetTransactor = ReroutingMultiCurrencyAdapter< OmnipoolProtocolAccount, TreasuryAccount, >; - - -pub struct HydrationSendXcm(PhantomData); -impl SendXcm for HydrationSendXcm { - type Ticket = (Inner::Ticket, [u8; 32]); - - fn validate( - destination: &mut Option, - message: &mut Option>, - ) -> SendResult { - let mut message = message.take().ok_or(SendError::MissingArgument)?; - let unique_id = if let Some(SetTopic(id)) = message.last() { - *id - } else { - let unique_id = unique(&message); - message.0.push(SetTopic(unique_id)); - unique_id - }; - let (ticket, assets) = Inner::validate(destination, &mut Some(message))?; - Ok(((ticket, unique_id), assets)) - } - - fn deliver(ticket: Self::Ticket) -> Result { - let (ticket, unique_id) = ticket; - pallet_amm_support::Pallet::::add_to_context(|id| ExecutionType::Xcm(unique_id, id)).map_err(|_| SendError::Transport("Unexpected error at modifying unified events stack"))?; - Inner::deliver(ticket)?; - pallet_amm_support::Pallet::::remove_from_context().map_err(|_| SendError::Transport("Unexpected error at modifying unified events stack"))?; - Ok(unique_id) - } -} From 1acc07f0d3b5dd9147b7afe2b6c37bc15ba62326 Mon Sep 17 00:00:00 2001 From: dmoka Date: Fri, 27 Dec 2024 10:33:10 +0100 Subject: [PATCH 102/142] populate unified event stack with xcm and topic id --- integration-tests/src/cross_chain_transfer.rs | 2 +- integration-tests/src/exchange_asset.rs | 22 ++-- integration-tests/src/lib.rs | 2 +- integration-tests/src/xcm.rs | 105 +++++++++++++++--- pallets/amm-support/src/lib.rs | 6 + runtime/hydradx/src/xcm.rs | 36 +++--- 6 files changed, 129 insertions(+), 44 deletions(-) diff --git a/integration-tests/src/cross_chain_transfer.rs b/integration-tests/src/cross_chain_transfer.rs index 4a168f696..4bc0012d2 100644 --- a/integration-tests/src/cross_chain_transfer.rs +++ b/integration-tests/src/cross_chain_transfer.rs @@ -110,7 +110,7 @@ fn rococo_should_receive_asset_when_sent_from_hydra() { Rococo::execute_with(|| { assert_eq!( hydradx_runtime::Balances::free_balance(AccountId::from(BOB)), - 2_999_989_698_923 // 3 * HDX - fee + 2_999_989_606_492 // 3 * HDX - fee ); }); } diff --git a/integration-tests/src/exchange_asset.rs b/integration-tests/src/exchange_asset.rs index 712bc20f6..87defcbaa 100644 --- a/integration-tests/src/exchange_asset.rs +++ b/integration-tests/src/exchange_asset.rs @@ -127,6 +127,10 @@ fn hydra_should_swap_assets_when_receiving_from_acala_with_sell() { let last_swapped_events = get_last_swapped_events(); let last_two_swapped_events = &last_swapped_events[last_swapped_events.len() - 2..]; + let topic_id = [ + 218, 12, 174, 219, 122, 191, 122, 133, 121, 249, 25, 38, 23, 16, 236, 2, 4, 232, + 184, 111, 154, 26, 180, 68, 160, 59, 227, 99, 52, 246, 247, 115, + ]; pretty_assertions::assert_eq!( last_two_swapped_events, vec![ @@ -139,9 +143,10 @@ fn hydra_should_swap_assets_when_receiving_from_acala_with_sell() { outputs: vec![pallet_amm_support::types::Asset::new(LRNA::get(), 49180327868852)], fees: vec![Fee::new(LRNA::get(), 24590163934, Omnipool::protocol_account()),], operation_id: vec![ - ExecutionType::XcmExchange(0), - ExecutionType::Router(1), - ExecutionType::Omnipool(2) + ExecutionType::Xcm(topic_id, 0), + ExecutionType::XcmExchange(1), + ExecutionType::Router(2), + ExecutionType::Omnipool(3) ], }), RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { @@ -153,9 +158,10 @@ fn hydra_should_swap_assets_when_receiving_from_acala_with_sell() { outputs: vec![pallet_amm_support::types::Asset::new(HDX, 39101207131554396)], fees: vec![Fee::new(HDX, 97998012861039, Omnipool::protocol_account()),], operation_id: vec![ - ExecutionType::XcmExchange(0), - ExecutionType::Router(1), - ExecutionType::Omnipool(2) + ExecutionType::Xcm(topic_id, 0), + ExecutionType::XcmExchange(1), + ExecutionType::Router(2), + ExecutionType::Omnipool(3) ], }) ] @@ -184,7 +190,7 @@ fn hydra_should_swap_assets_when_receiving_from_acala_with_sell() { inputs: vec![pallet_amm_support::types::Asset::new(HDX, 1 * UNITS),], outputs: vec![pallet_amm_support::types::Asset::new(LRNA::get(), 1308673515)], fees: vec![Fee::new(LRNA::get(), 654336, Omnipool::protocol_account()),], - operation_id: vec![ExecutionType::Router(3), ExecutionType::Omnipool(4)], + operation_id: vec![ExecutionType::Router(4), ExecutionType::Omnipool(5)], }), RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { swapper: ALICE.into(), @@ -194,7 +200,7 @@ fn hydra_should_swap_assets_when_receiving_from_acala_with_sell() { inputs: vec![pallet_amm_support::types::Asset::new(LRNA::get(), 1308019179),], outputs: vec![pallet_amm_support::types::Asset::new(ACA, 1348602600)], fees: vec![Fee::new(ACA, 3379957, Omnipool::protocol_account()),], - operation_id: vec![ExecutionType::Router(3), ExecutionType::Omnipool(4)], + operation_id: vec![ExecutionType::Router(4), ExecutionType::Omnipool(5)], }) ] ); diff --git a/integration-tests/src/lib.rs b/integration-tests/src/lib.rs index e02ef2ce2..6752a9387 100644 --- a/integration-tests/src/lib.rs +++ b/integration-tests/src/lib.rs @@ -16,7 +16,6 @@ mod evm; mod evm_permit; mod exchange_asset; mod fee_calculation; -mod xcm; mod insufficient_assets_ed; mod multi_payment; mod non_native_fee; @@ -32,6 +31,7 @@ mod transact_call_filter; mod utility; pub mod utils; mod vesting; +mod xcm; mod xyk; mod xyk_liquidity_mining; diff --git a/integration-tests/src/xcm.rs b/integration-tests/src/xcm.rs index f6f897296..0531ffaba 100644 --- a/integration-tests/src/xcm.rs +++ b/integration-tests/src/xcm.rs @@ -136,6 +136,10 @@ fn global_account_derivation_should_work_when_with_other_chain_remote_account() let swapped_events = get_last_swapped_events(); let last_two_swapped_events = &get_last_swapped_events()[swapped_events.len() - 2..]; + let topic_id = [ + 237, 209, 186, 1, 116, 50, 158, 190, 169, 150, 18, 38, 37, 51, 136, 30, 219, 60, 5, + 253, 212, 209, 227, 230, 38, 183, 105, 62, 69, 234, 5, 249, + ]; pretty_assertions::assert_eq!( last_two_swapped_events, vec![ @@ -149,10 +153,7 @@ fn global_account_derivation_should_work_when_with_other_chain_remote_account() fees: vec![Fee::new(LRNA, 600749, Omnipool::protocol_account()),], operation_id: vec![ ExecutionType::Xcm( - [ - 105, 235, 204, 213, 153, 222, 42, 199, 108, 12, 60, 148, 48, 156, 46, 18, 60, 221, 150, - 116, 143, 103, 206, 40, 127, 183, 175, 193, 168, 255, 190, 82, - ], + topic_id, 0 ), ExecutionType::Omnipool(1) @@ -164,14 +165,11 @@ fn global_account_derivation_should_work_when_with_other_chain_remote_account() filler_type: pallet_amm_support::types::Filler::Omnipool, operation: pallet_amm_support::types::TradeOperation::ExactIn, inputs: vec![UnifiedEventAsset::new(LRNA, 1200897967)], - outputs: vec![UnifiedEventAsset::new(DAI, 26619890727267708)], - fees: vec![Fee::new(DAI, 66716518113453, Omnipool::protocol_account()),], + outputs: vec![UnifiedEventAsset::new(DAI, 26619890727267708)], + fees: vec![Fee::new(DAI, 66716518113453, Omnipool::protocol_account()),], operation_id: vec![ ExecutionType::Xcm( - [ - 105, 235, 204, 213, 153, 222, 42, 199, 108, 12, 60, 148, 48, 156, 46, 18, 60, 221, 150, - 116, 143, 103, 206, 40, 127, 183, 175, 193, 168, 255, 190, 82, - ], + topic_id, 0 ), ExecutionType::Omnipool(1) @@ -182,7 +180,6 @@ fn global_account_derivation_should_work_when_with_other_chain_remote_account() }); } - #[test] fn xcm_call_should_populate_unified_event_call_context() { // Arrange @@ -269,7 +266,7 @@ fn xcm_call_should_populate_unified_event_call_context() { id: acala_account_id_at_hydra.clone().into(), network: None, } - .into(), + .into(), }, ]); @@ -309,8 +306,8 @@ fn xcm_call_should_populate_unified_event_call_context() { operation_id: vec![ ExecutionType::Xcm( [ - 105, 235, 204, 213, 153, 222, 42, 199, 108, 12, 60, 148, 48, 156, 46, 18, 60, 221, 150, - 116, 143, 103, 206, 40, 127, 183, 175, 193, 168, 255, 190, 82, + 237, 209, 186, 1, 116, 50, 158, 190, 169, 150, 18, 38, 37, 51, 136, 30, 219, 60, 5, + 253, 212, 209, 227, 230, 38, 183, 105, 62, 69, 234, 5, 249, ], 0 ), @@ -323,13 +320,13 @@ fn xcm_call_should_populate_unified_event_call_context() { filler_type: pallet_amm_support::types::Filler::Omnipool, operation: pallet_amm_support::types::TradeOperation::ExactIn, inputs: vec![UnifiedEventAsset::new(LRNA, 1200897967)], - outputs: vec![UnifiedEventAsset::new(DAI, 26619890727267708)], - fees: vec![Fee::new(DAI, 66716518113453, Omnipool::protocol_account()),], + outputs: vec![UnifiedEventAsset::new(DAI, 26619890727267708)], + fees: vec![Fee::new(DAI, 66716518113453, Omnipool::protocol_account()),], operation_id: vec![ ExecutionType::Xcm( [ - 105, 235, 204, 213, 153, 222, 42, 199, 108, 12, 60, 148, 48, 156, 46, 18, 60, 221, 150, - 116, 143, 103, 206, 40, 127, 183, 175, 193, 168, 255, 190, 82, + 237, 209, 186, 1, 116, 50, 158, 190, 169, 150, 18, 38, 37, 51, 136, 30, 219, 60, 5, + 253, 212, 209, 227, 230, 38, 183, 105, 62, 69, 234, 5, 249, ], 0 ), @@ -338,5 +335,77 @@ fn xcm_call_should_populate_unified_event_call_context() { }) ] ); + + let unified_event_context = pallet_amm_support::Pallet::::get_context().unwrap(); + assert!(unified_event_context.is_empty()); }); } + +#[test] +fn unified_event_context_should_be_cleared_when_error_happens_in_xcm_prepare() { + // Arrange + TestNet::reset(); + + let xcm_interior_at_acala = + cumulus_primitives_core::Junctions::X1(Arc::new([cumulus_primitives_core::Junction::AccountId32 { + network: None, + id: evm_account().into(), + }])); + + let xcm_origin_at_hydra = Location { + parents: 1, + interior: cumulus_primitives_core::Junctions::X2(Arc::new([ + cumulus_primitives_core::Junction::Parachain(ACALA_PARA_ID), + cumulus_primitives_core::Junction::AccountId32 { + network: None, + id: evm_account().into(), + }, + ])), + }; + + let acala_account_id_at_hydra: AccountId = + HashedDescription::>::convert_location(&xcm_origin_at_hydra) + .unwrap(); + + Hydra::execute_with(|| { + init_omnipool(); + + assert_ok!(hydradx_runtime::Balances::transfer_allow_death( + hydradx_runtime::RuntimeOrigin::signed(ALICE.into()), + acala_account_id_at_hydra.clone(), + 1_000 * UNITS, + )); + + assert_eq!( + hydradx_runtime::Currencies::free_balance(DAI, &AccountId::from(acala_account_id_at_hydra.clone())), + 0 + ); + }); + + // Act + Acala::execute_with(|| { + + //We make a big xcm so it results in error + const ARRAY_REPEAT_VALUE: cumulus_primitives_core::Instruction<()> = RefundSurplus; + let message : cumulus_primitives_core::Xcm<()> = Xcm([ARRAY_REPEAT_VALUE;10000].to_vec()); + + let dest_hydradx = Location::new( + 1, + cumulus_primitives_core::Junctions::X1(Arc::new([cumulus_primitives_core::Junction::Parachain( + HYDRA_PARA_ID, + )])), + ); + + assert_ok!(hydradx_runtime::PolkadotXcm::send_xcm( + xcm_interior_at_acala, + dest_hydradx, + message + )); + }); + + // Assert + Hydra::execute_with(|| { + let context = pallet_amm_support::Pallet::::get_context().unwrap(); + assert!(context.is_empty()) + }); +} \ No newline at end of file diff --git a/pallets/amm-support/src/lib.rs b/pallets/amm-support/src/lib.rs index 2ae722142..07e65d416 100644 --- a/pallets/amm-support/src/lib.rs +++ b/pallets/amm-support/src/lib.rs @@ -154,4 +154,10 @@ impl Pallet { stack.pop().ok_or(Error::::EmptyStack.into()) }) } + + pub fn get_context() -> Result, DispatchError> { + //TODO: check what to do when it fails, we might dont want to bloc ktrades becase of it + let stack = ExecutionContext::::get().to_vec(); + Ok(stack) + } } diff --git a/runtime/hydradx/src/xcm.rs b/runtime/hydradx/src/xcm.rs index 1fae489cb..9d1768424 100644 --- a/runtime/hydradx/src/xcm.rs +++ b/runtime/hydradx/src/xcm.rs @@ -13,6 +13,7 @@ use frame_support::{ traits::{ConstU32, Contains, ContainsPair, Everything, Get, Nothing, TransformOrigin}, PalletId, }; +use frame_system::unique; use hydradx_adapters::{xcm_exchange::XcmAssetExchanger, xcm_execute_filter::AllowTransferAndSwap}; use orml_traits::{location::AbsoluteReserveProvider, parameter_type_with_key}; use orml_xcm_support::{DepositToAlternative, IsNativeConcrete, MultiNativeAsset}; @@ -25,12 +26,7 @@ use polkadot_xcm::v3::MultiLocation; use polkadot_xcm::v4::{prelude::*, Asset, InteriorLocation, Weight as XcmWeight}; use scale_info::TypeInfo; use sp_runtime::{traits::MaybeEquivalence, Perbill}; -use xcm_builder::{ - AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, - DescribeAllTerminal, DescribeFamily, EnsureXcmOrigin, FixedWeightBounds, HashedDescription, ParentIsPreset, - RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, - SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, WithComputedOrigin, -}; +use xcm_builder::{AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DescribeAllTerminal, DescribeFamily, EnsureXcmOrigin, FixedWeightBounds, HashedDescription, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, WithComputedOrigin, WithUniqueTopic}; use xcm_executor::{Config, XcmExecutor}; #[derive(Debug, Default, Encode, Decode, Clone, PartialEq, Eq, TypeInfo, MaxEncodedLen)] @@ -232,7 +228,22 @@ impl::RuntimeCall>> ExecuteXcm<>::Prepared; fn prepare(message: Xcm<::RuntimeCall>) -> Result::RuntimeCall>> { - Inner::prepare(message) + //We populate the context in `prepare` as we have the xcm message at this point so we can get the unique topic id + let unique_id = if let Some(SetTopic(id)) = message.last() { + *id + } else { + unique(&message) + }; + pallet_amm_support::Pallet::::add_to_context(|event_id| ExecutionType::Xcm(unique_id, event_id)).map_err(|_| message.clone())?; + + let prepare_result = Inner::prepare(message); + + //In case of error we need to clean context as xcm execution won't happen + if let Err(_) = prepare_result { + let _ = pallet_amm_support::Pallet::::remove_from_context(); + } + + prepare_result } fn execute( @@ -241,13 +252,6 @@ impl::RuntimeCall>> ExecuteXcm< Outcome { - let Ok(_) = pallet_amm_support::Pallet::::add_to_context(|event_id| ExecutionType::Xcm(*id, event_id)) - else { - return Outcome::Error { - error: XcmError::FailedToTransactAsset("Unexpected error at modifying unified events stack"), - }; - }; - let outcome = Inner::execute(origin, pre, id, weight_credit); let Ok(_) = pallet_amm_support::Pallet::::remove_from_context() else { @@ -443,12 +447,12 @@ impl Convert for AccountIdToMultiLocation { /// The means for routing XCM messages which are not for local execution into the right message /// queues. -pub type XcmRouter = ( +pub type XcmRouter = WithUniqueTopic<( // Two routers - use UMP to communicate with the relay chain: cumulus_primitives_utility::ParentAsUmp, // ..and XCMP to communicate with the sibling chains. XcmpQueue, -); +)>; /// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used /// when determining ownership of accounts for asset transacting and when attempting to use XCM From f19c09172a7285fac5163d4ab3d8f3c7a221f032 Mon Sep 17 00:00:00 2001 From: dmoka Date: Fri, 27 Dec 2024 11:30:39 +0100 Subject: [PATCH 103/142] make unified events storage operations more bullet proof as we dont want to block any operations when wrongly implemented --- Cargo.lock | 1 + pallets/amm-support/Cargo.toml | 2 ++ pallets/amm-support/src/lib.rs | 33 ++++++++++++------- .../amm-support/src/tests/incremental_id.rs | 23 +------------ pallets/amm-support/src/tests/mock.rs | 2 +- 5 files changed, 26 insertions(+), 35 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 34966c962..45edc107f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7504,6 +7504,7 @@ dependencies = [ "frame-support", "frame-system", "hydradx-traits", + "log", "parity-scale-codec", "primitives", "scale-info", diff --git a/pallets/amm-support/Cargo.toml b/pallets/amm-support/Cargo.toml index 95d412be9..91b88e29a 100644 --- a/pallets/amm-support/Cargo.toml +++ b/pallets/amm-support/Cargo.toml @@ -18,6 +18,8 @@ sp-arithmetic = { workspace = true } hydradx-traits = { workspace = true } primitives = { workspace = true } +log = { workspace = true } + # Substrate dependencies sp-std = { workspace = true } sp-api = { workspace = true } diff --git a/pallets/amm-support/src/lib.rs b/pallets/amm-support/src/lib.rs index 07e65d416..0f8b0efb9 100644 --- a/pallets/amm-support/src/lib.rs +++ b/pallets/amm-support/src/lib.rs @@ -33,6 +33,8 @@ pub mod types; // Re-export pallet items so that they can be accessed from the crate namespace. pub use pallet::*; +const LOG_TARGET: &str = "runtime::amm-support"; + pub const MAX_STACK_SIZE: u32 = 10; type ExecutionIdStack = BoundedVec>; @@ -66,8 +68,6 @@ pub mod pallet { #[pallet::error] pub enum Error { - MaxStackSizeReached, - EmptyStack, } #[pallet::event] @@ -130,7 +130,6 @@ impl Pallet { F: FnOnce(u32) -> ExecutionType, { //TODO: create patch 4 - //TODO: double check what to do when these can fail, we dont really want failing due to this let next_id = IncrementalId::::try_mutate(|current_id| -> Result { let inc_id = *current_id; *current_id = current_id.overflowing_add(1).0.into(); @@ -138,9 +137,11 @@ impl Pallet { })?; ExecutionContext::::try_mutate(|stack| -> DispatchResult { - stack - .try_push(execution_type(next_id)) - .map_err(|_| Error::::MaxStackSizeReached)?; + //We make it fire and forget, and it should fail only in test and when if wrongly used + debug_assert_ne!(stack.len(), MAX_STACK_SIZE as usize, "Stack should not be full"); + if let Err(err) = stack.try_push(execution_type(next_id)) { + log::warn!(target: LOG_TARGET, "The max stack size of execution stack has been reached: {:?}", err); + } Ok(()) })?; @@ -148,16 +149,24 @@ impl Pallet { Ok(next_id) } - pub fn remove_from_context() -> Result { - //TODO: check what to do when it fails, we might dont want to bloc ktrades becase of it - ExecutionContext::::try_mutate(|stack| -> Result { - stack.pop().ok_or(Error::::EmptyStack.into()) - }) + pub fn remove_from_context() -> DispatchResult { + ExecutionContext::::try_mutate(|stack| -> DispatchResult { + //We make it fire and forget, and it should fail only in test and when if wrongly used + debug_assert_ne!(stack.len(), 0, "The stack should not be empty when decreased"); + + if let None = stack.pop() { + log::warn!(target: LOG_TARGET,"The execution stack should not be empty when decreased. The stack should be populated first, or should not be decreased more than its size"); + } + + Ok(()) + })?; + + Ok(()) } pub fn get_context() -> Result, DispatchError> { - //TODO: check what to do when it fails, we might dont want to bloc ktrades becase of it let stack = ExecutionContext::::get().to_vec(); + Ok(stack) } } diff --git a/pallets/amm-support/src/tests/incremental_id.rs b/pallets/amm-support/src/tests/incremental_id.rs index 8391880b7..3fa78a670 100644 --- a/pallets/amm-support/src/tests/incremental_id.rs +++ b/pallets/amm-support/src/tests/incremental_id.rs @@ -58,20 +58,6 @@ fn stack_should_be_populated_when_pushed() { }); } -#[test] -fn stack_should_not_panic_when_full() { - ExtBuilder::default().build().execute_with(|| { - for _id in 0..MAX_STACK_SIZE { - assert_ok!(AmmSupport::add_to_context(ExecutionType::Router)); - } - - assert_err!( - AmmSupport::add_to_context(ExecutionType::Router), - Error::::MaxStackSizeReached - ); - }); -} - #[test] fn stack_should_be_reduced_when_poped() { ExtBuilder::default().build().execute_with(|| { @@ -79,7 +65,7 @@ fn stack_should_be_reduced_when_poped() { assert_ok!(AmmSupport::add_to_context(ExecutionType::Router)); assert_ok!(AmmSupport::add_to_context(ExecutionType::ICE)); - assert_ok!(AmmSupport::remove_from_context(), ExecutionType::ICE(2)); + AmmSupport::remove_from_context().unwrap(); assert_eq!( AmmSupport::execution_context(), vec![ExecutionType::Router(0), ExecutionType::Router(1)] @@ -109,13 +95,6 @@ fn stack_should_be_reduced_when_poped() { }); } -#[test] -fn pop_from_empty_stack_should_not_panic() { - ExtBuilder::default().build().execute_with(|| { - assert_err!(AmmSupport::remove_from_context(), Error::::EmptyStack); - }); -} - #[test] fn event_should_be_deposited() { ExtBuilder::default().build().execute_with(|| { diff --git a/pallets/amm-support/src/tests/mock.rs b/pallets/amm-support/src/tests/mock.rs index b0c12b300..a3d0683af 100644 --- a/pallets/amm-support/src/tests/mock.rs +++ b/pallets/amm-support/src/tests/mock.rs @@ -19,7 +19,7 @@ use crate as pallet_amm_support; pub use crate::*; pub use frame_support::{ - assert_err, assert_ok, construct_runtime, + assert_ok, construct_runtime, sp_runtime::{ traits::{BlakeTwo256, IdentityLookup}, BuildStorage, From 4f56dd88bc8c25182493d4f22eee80ce2c35e788 Mon Sep 17 00:00:00 2001 From: dmoka Date: Fri, 27 Dec 2024 13:13:42 +0100 Subject: [PATCH 104/142] formatting --- integration-tests/src/exchange_asset.rs | 5 +++- integration-tests/src/xcm.rs | 27 +++++-------------- pallets/amm-support/src/lib.rs | 3 +-- pallets/stableswap/src/tests/add_liquidity.rs | 2 +- runtime/hydradx/src/system.rs | 4 +-- runtime/hydradx/src/xcm.rs | 27 ++++++++++++++----- 6 files changed, 34 insertions(+), 34 deletions(-) diff --git a/integration-tests/src/exchange_asset.rs b/integration-tests/src/exchange_asset.rs index 0bf134d4b..37ee62825 100644 --- a/integration-tests/src/exchange_asset.rs +++ b/integration-tests/src/exchange_asset.rs @@ -127,7 +127,10 @@ fn hydra_should_swap_assets_when_receiving_from_acala_with_sell() { let last_swapped_events = get_last_swapped_events(); let last_two_swapped_events = &last_swapped_events[last_swapped_events.len() - 2..]; - let topic_id = [88, 96, 17, 161, 1, 110, 221, 66, 135, 183, 36, 117, 203, 64, 121, 121, 144, 130, 127, 130, 11, 90, 144, 184, 162, 244, 249, 80, 95, 193, 189, 200]; + let topic_id = [ + 88, 96, 17, 161, 1, 110, 221, 66, 135, 183, 36, 117, 203, 64, 121, 121, 144, 130, 127, 130, 11, 90, 144, + 184, 162, 244, 249, 80, 95, 193, 189, 200, + ]; pretty_assertions::assert_eq!( last_two_swapped_events, vec![ diff --git a/integration-tests/src/xcm.rs b/integration-tests/src/xcm.rs index 0531ffaba..3e6887bcd 100644 --- a/integration-tests/src/xcm.rs +++ b/integration-tests/src/xcm.rs @@ -136,9 +136,9 @@ fn global_account_derivation_should_work_when_with_other_chain_remote_account() let swapped_events = get_last_swapped_events(); let last_two_swapped_events = &get_last_swapped_events()[swapped_events.len() - 2..]; - let topic_id = [ - 237, 209, 186, 1, 116, 50, 158, 190, 169, 150, 18, 38, 37, 51, 136, 30, 219, 60, 5, - 253, 212, 209, 227, 230, 38, 183, 105, 62, 69, 234, 5, 249, + let topic_id = [ + 237, 209, 186, 1, 116, 50, 158, 190, 169, 150, 18, 38, 37, 51, 136, 30, 219, 60, 5, 253, 212, 209, 227, + 230, 38, 183, 105, 62, 69, 234, 5, 249, ]; pretty_assertions::assert_eq!( last_two_swapped_events, @@ -151,13 +151,7 @@ fn global_account_derivation_should_work_when_with_other_chain_remote_account() inputs: vec![UnifiedEventAsset::new(HDX, 1000000000000)], outputs: vec![UnifiedEventAsset::new(LRNA, 1201498716)], fees: vec![Fee::new(LRNA, 600749, Omnipool::protocol_account()),], - operation_id: vec![ - ExecutionType::Xcm( - topic_id, - 0 - ), - ExecutionType::Omnipool(1) - ] + operation_id: vec![ExecutionType::Xcm(topic_id, 0), ExecutionType::Omnipool(1)] }), RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { swapper: account.into(), @@ -167,13 +161,7 @@ fn global_account_derivation_should_work_when_with_other_chain_remote_account() inputs: vec![UnifiedEventAsset::new(LRNA, 1200897967)], outputs: vec![UnifiedEventAsset::new(DAI, 26619890727267708)], fees: vec![Fee::new(DAI, 66716518113453, Omnipool::protocol_account()),], - operation_id: vec![ - ExecutionType::Xcm( - topic_id, - 0 - ), - ExecutionType::Omnipool(1) - ], + operation_id: vec![ExecutionType::Xcm(topic_id, 0), ExecutionType::Omnipool(1)], }) ] ); @@ -384,10 +372,9 @@ fn unified_event_context_should_be_cleared_when_error_happens_in_xcm_prepare() { // Act Acala::execute_with(|| { - //We make a big xcm so it results in error const ARRAY_REPEAT_VALUE: cumulus_primitives_core::Instruction<()> = RefundSurplus; - let message : cumulus_primitives_core::Xcm<()> = Xcm([ARRAY_REPEAT_VALUE;10000].to_vec()); + let message: cumulus_primitives_core::Xcm<()> = Xcm([ARRAY_REPEAT_VALUE; 10000].to_vec()); let dest_hydradx = Location::new( 1, @@ -408,4 +395,4 @@ fn unified_event_context_should_be_cleared_when_error_happens_in_xcm_prepare() { let context = pallet_amm_support::Pallet::::get_context().unwrap(); assert!(context.is_empty()) }); -} \ No newline at end of file +} diff --git a/pallets/amm-support/src/lib.rs b/pallets/amm-support/src/lib.rs index 0f8b0efb9..e19ac6260 100644 --- a/pallets/amm-support/src/lib.rs +++ b/pallets/amm-support/src/lib.rs @@ -67,8 +67,7 @@ pub mod pallet { pub(super) type ExecutionContext = StorageValue<_, ExecutionIdStack, ValueQuery>; #[pallet::error] - pub enum Error { - } + pub enum Error {} #[pallet::event] #[pallet::generate_deposit(pub(crate) fn deposit_event)] diff --git a/pallets/stableswap/src/tests/add_liquidity.rs b/pallets/stableswap/src/tests/add_liquidity.rs index c9456032e..911bdcc86 100644 --- a/pallets/stableswap/src/tests/add_liquidity.rs +++ b/pallets/stableswap/src/tests/add_liquidity.rs @@ -1,8 +1,8 @@ use crate::tests::mock::*; use crate::types::{AssetAmount, PoolInfo}; use crate::{assert_balance, to_precision, Error}; -use pallet_amm_support::types::{Asset, Fee}; use frame_support::{assert_noop, assert_ok, BoundedVec}; +use pallet_amm_support::types::{Asset, Fee}; use sp_runtime::Permill; use std::num::NonZeroU16; diff --git a/runtime/hydradx/src/system.rs b/runtime/hydradx/src/system.rs index 33a5acf3e..b1dd4aad6 100644 --- a/runtime/hydradx/src/system.rs +++ b/runtime/hydradx/src/system.rs @@ -45,10 +45,10 @@ use frame_support::{ }, PalletId, }; -use pallet_utility::BatchHook; use frame_system::EnsureRoot; use hydradx_adapters::{OraclePriceProvider, RelayChainBlockNumberProvider}; use pallet_amm_support::types::ExecutionType; +use pallet_utility::BatchHook; use scale_info::TypeInfo; use sp_runtime::DispatchResult; @@ -399,8 +399,6 @@ impl BatchHook for ManageExecutionTypeForUnifiedEvent { } } - - parameter_types! { pub const BasicDeposit: Balance = 5 * DOLLARS; pub const ByteDeposit: Balance = DOLLARS / 10; diff --git a/runtime/hydradx/src/xcm.rs b/runtime/hydradx/src/xcm.rs index 391950015..3a2925073 100644 --- a/runtime/hydradx/src/xcm.rs +++ b/runtime/hydradx/src/xcm.rs @@ -15,8 +15,8 @@ use frame_support::{ traits::{ConstU32, Contains, ContainsPair, EitherOf, Everything, Get, Nothing, TransformOrigin}, PalletId, }; -use frame_system::EnsureRoot; use frame_system::unique; +use frame_system::EnsureRoot; use hydradx_adapters::{xcm_exchange::XcmAssetExchanger, xcm_execute_filter::AllowTransferAndSwap}; use orml_traits::{location::AbsoluteReserveProvider, parameter_type_with_key}; use orml_xcm_support::{DepositToAlternative, IsNativeConcrete, MultiNativeAsset}; @@ -29,7 +29,12 @@ use polkadot_xcm::v3::MultiLocation; use polkadot_xcm::v4::{prelude::*, Asset, InteriorLocation, Weight as XcmWeight}; use scale_info::TypeInfo; use sp_runtime::{traits::MaybeEquivalence, Perbill}; -use xcm_builder::{AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DescribeAllTerminal, DescribeFamily, EnsureXcmOrigin, FixedWeightBounds, HashedDescription, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, WithComputedOrigin, WithUniqueTopic}; +use xcm_builder::{ + AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, + DescribeAllTerminal, DescribeFamily, EnsureXcmOrigin, FixedWeightBounds, HashedDescription, ParentIsPreset, + RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, + SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, WithComputedOrigin, WithUniqueTopic, +}; use xcm_executor::{Config, XcmExecutor}; #[derive(Debug, Default, Encode, Decode, Clone, PartialEq, Eq, TypeInfo, MaxEncodedLen)] @@ -227,17 +232,22 @@ impl cumulus_pallet_xcm::Config for Runtime { pub struct WithUnifiedEventSupport(PhantomData); -impl::RuntimeCall>> ExecuteXcm<::RuntimeCall> for WithUnifiedEventSupport { +impl::RuntimeCall>> ExecuteXcm<::RuntimeCall> + for WithUnifiedEventSupport +{ type Prepared = >::Prepared; - fn prepare(message: Xcm<::RuntimeCall>) -> Result::RuntimeCall>> { + fn prepare( + message: Xcm<::RuntimeCall>, + ) -> Result::RuntimeCall>> { //We populate the context in `prepare` as we have the xcm message at this point so we can get the unique topic id let unique_id = if let Some(SetTopic(id)) = message.last() { *id } else { unique(&message) }; - pallet_amm_support::Pallet::::add_to_context(|event_id| ExecutionType::Xcm(unique_id, event_id)).map_err(|_| message.clone())?; + pallet_amm_support::Pallet::::add_to_context(|event_id| ExecutionType::Xcm(unique_id, event_id)) + .map_err(|_| message.clone())?; let prepare_result = Inner::prepare(message); @@ -277,7 +287,6 @@ impl::RuntimeCall>> XcmAssetTransfers fo type AssetTransactor = ::AssetTransactor; } - parameter_types! { pub const MaxInboundSuspended: u32 = 1_000; } @@ -373,7 +382,11 @@ impl pallet_message_queue::Config for Runtime { type MessageProcessor = pallet_message_queue::mock_helpers::NoopMessageProcessor; #[cfg(not(feature = "runtime-benchmarks"))] - type MessageProcessor = xcm_builder::ProcessXcmMessage>, RuntimeCall>; + type MessageProcessor = xcm_builder::ProcessXcmMessage< + AggregateMessageOrigin, + WithUnifiedEventSupport>, + RuntimeCall, + >; type Size = u32; type QueueChangeHandler = NarrowOriginToSibling; type QueuePausedQuery = NarrowOriginToSibling; From d59b9d510321a66bef130b6871c9153df07dd12d Mon Sep 17 00:00:00 2001 From: dmoka Date: Fri, 27 Dec 2024 13:20:21 +0100 Subject: [PATCH 105/142] bump versions --- Cargo.lock | 10 +++++----- pallets/circuit-breaker/Cargo.toml | 2 +- pallets/liquidation/Cargo.toml | 2 +- pallets/liquidity-mining/Cargo.toml | 2 +- runtime/adapters/Cargo.toml | 2 +- runtime/hydradx/Cargo.toml | 2 +- runtime/hydradx/src/lib.rs | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cc4bff1fa..3ef36608f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4868,7 +4868,7 @@ dependencies = [ [[package]] name = "hydradx-adapters" -version = "1.3.9" +version = "1.3.10" dependencies = [ "cumulus-pallet-parachain-system", "cumulus-primitives-core", @@ -4919,7 +4919,7 @@ dependencies = [ [[package]] name = "hydradx-runtime" -version = "276.0.0" +version = "277.0.0" dependencies = [ "cumulus-pallet-aura-ext", "cumulus-pallet-parachain-system", @@ -7853,7 +7853,7 @@ dependencies = [ [[package]] name = "pallet-circuit-breaker" -version = "1.1.27" +version = "1.1.28" dependencies = [ "frame-benchmarking", "frame-support", @@ -8542,7 +8542,7 @@ dependencies = [ [[package]] name = "pallet-liquidation" -version = "1.0.1" +version = "1.0.2" dependencies = [ "ethabi", "evm", @@ -8580,7 +8580,7 @@ dependencies = [ [[package]] name = "pallet-liquidity-mining" -version = "4.4.4" +version = "4.4.5" dependencies = [ "fixed", "frame-support", diff --git a/pallets/circuit-breaker/Cargo.toml b/pallets/circuit-breaker/Cargo.toml index b81f27db5..1e7a550d7 100644 --- a/pallets/circuit-breaker/Cargo.toml +++ b/pallets/circuit-breaker/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-circuit-breaker" -version = "1.1.27" +version = "1.1.28" authors = ["GalacticCouncil "] edition = "2021" license = "Apache-2.0" diff --git a/pallets/liquidation/Cargo.toml b/pallets/liquidation/Cargo.toml index 8f4cdb00a..53ddab951 100644 --- a/pallets/liquidation/Cargo.toml +++ b/pallets/liquidation/Cargo.toml @@ -1,6 +1,6 @@ [package] name = 'pallet-liquidation' -version = '1.0.1' +version = '1.0.2' description = 'A pallet for money market liquidations' authors = ['GalacticCouncil'] edition = '2021' diff --git a/pallets/liquidity-mining/Cargo.toml b/pallets/liquidity-mining/Cargo.toml index e37f2471a..a94f4b733 100644 --- a/pallets/liquidity-mining/Cargo.toml +++ b/pallets/liquidity-mining/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-liquidity-mining" -version = "4.4.4" +version = "4.4.5" description = "Liquidity mining" authors = ["GalacticCouncil"] edition = "2021" diff --git a/runtime/adapters/Cargo.toml b/runtime/adapters/Cargo.toml index c145b7503..b09f40c3a 100644 --- a/runtime/adapters/Cargo.toml +++ b/runtime/adapters/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hydradx-adapters" -version = "1.3.9" +version = "1.3.10" description = "Structs and other generic types for building runtimes." authors = ["GalacticCouncil"] edition = "2021" diff --git a/runtime/hydradx/Cargo.toml b/runtime/hydradx/Cargo.toml index 8cc1b6748..10c912ae3 100644 --- a/runtime/hydradx/Cargo.toml +++ b/runtime/hydradx/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hydradx-runtime" -version = "276.0.0" +version = "277.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 6f9cc2295..ecff9da0d 100644 --- a/runtime/hydradx/src/lib.rs +++ b/runtime/hydradx/src/lib.rs @@ -113,7 +113,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("hydradx"), impl_name: create_runtime_str!("hydradx"), authoring_version: 1, - spec_version: 276, + spec_version: 277, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, From d71deca7eb1b9c78bea699eb99176174737f2d5b Mon Sep 17 00:00:00 2001 From: dmoka Date: Fri, 27 Dec 2024 13:23:10 +0100 Subject: [PATCH 106/142] bump versions --- Cargo.lock | 2 +- traits/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3ef36608f..9024cd1bb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5064,7 +5064,7 @@ dependencies = [ [[package]] name = "hydradx-traits" -version = "3.10.0" +version = "3.11.0" dependencies = [ "frame-support", "impl-trait-for-tuples", diff --git a/traits/Cargo.toml b/traits/Cargo.toml index e1cd13374..0654d2730 100644 --- a/traits/Cargo.toml +++ b/traits/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hydradx-traits" -version = "3.10.0" +version = "3.11.0" description = "Shared traits" authors = ["GalacticCouncil"] edition = "2021" From 239b22f24a83cfe7e82ca3c65b09256d09e842f6 Mon Sep 17 00:00:00 2001 From: dmoka Date: Fri, 27 Dec 2024 14:01:01 +0100 Subject: [PATCH 107/142] make clippy happy --- pallets/amm-support/src/lib.rs | 5 ++--- pallets/amm-support/src/tests/incremental_id.rs | 2 +- pallets/route-executor/src/lib.rs | 4 ++-- runtime/hydradx/src/xcm.rs | 2 +- traits/src/router.rs | 2 -- 5 files changed, 6 insertions(+), 9 deletions(-) diff --git a/pallets/amm-support/src/lib.rs b/pallets/amm-support/src/lib.rs index e19ac6260..4e98214db 100644 --- a/pallets/amm-support/src/lib.rs +++ b/pallets/amm-support/src/lib.rs @@ -128,10 +128,9 @@ impl Pallet { where F: FnOnce(u32) -> ExecutionType, { - //TODO: create patch 4 let next_id = IncrementalId::::try_mutate(|current_id| -> Result { let inc_id = *current_id; - *current_id = current_id.overflowing_add(1).0.into(); + *current_id = current_id.overflowing_add(1).0; Ok(inc_id) })?; @@ -153,7 +152,7 @@ impl Pallet { //We make it fire and forget, and it should fail only in test and when if wrongly used debug_assert_ne!(stack.len(), 0, "The stack should not be empty when decreased"); - if let None = stack.pop() { + if stack.pop().is_none() { log::warn!(target: LOG_TARGET,"The execution stack should not be empty when decreased. The stack should be populated first, or should not be decreased more than its size"); } diff --git a/pallets/amm-support/src/tests/incremental_id.rs b/pallets/amm-support/src/tests/incremental_id.rs index 3fa78a670..5531f937b 100644 --- a/pallets/amm-support/src/tests/incremental_id.rs +++ b/pallets/amm-support/src/tests/incremental_id.rs @@ -105,7 +105,7 @@ fn event_should_be_deposited() { TradeOperation::ExactIn, vec![Asset::new(HDX, 1_000_000)], vec![Asset::new(DOT, 2_000_000)], - vec![Fee::new(HDX, 1_000, ALICE.into()), Fee::new(DOT, 2_000, BOB.into())], + vec![Fee::new(HDX, 1_000, ALICE), Fee::new(DOT, 2_000, BOB)], ); expect_events(vec![Event::Swapped { diff --git a/pallets/route-executor/src/lib.rs b/pallets/route-executor/src/lib.rs index adea01a98..026fa2727 100644 --- a/pallets/route-executor/src/lib.rs +++ b/pallets/route-executor/src/lib.rs @@ -303,7 +303,7 @@ pub mod pallet { event_id: next_event_id, }); - let _ = pallet_amm_support::Pallet::::remove_from_context()?; + pallet_amm_support::Pallet::::remove_from_context()?; Ok(()) } @@ -541,7 +541,7 @@ impl Pallet { event_id: next_event_id, }); - let _ = pallet_amm_support::Pallet::::remove_from_context()?; + pallet_amm_support::Pallet::::remove_from_context()?; Ok(()) } diff --git a/runtime/hydradx/src/xcm.rs b/runtime/hydradx/src/xcm.rs index 3a2925073..fa3711f35 100644 --- a/runtime/hydradx/src/xcm.rs +++ b/runtime/hydradx/src/xcm.rs @@ -252,7 +252,7 @@ impl::RuntimeCall>> ExecuteXcm<::remove_from_context(); } diff --git a/traits/src/router.rs b/traits/src/router.rs index aeaf738f6..e8d6d615b 100644 --- a/traits/src/router.rs +++ b/traits/src/router.rs @@ -3,8 +3,6 @@ use frame_support::dispatch::DispatchResultWithPostInfo; use frame_support::sp_runtime::{DispatchError, DispatchResult}; use frame_support::weights::Weight; use scale_info::TypeInfo; -#[cfg(feature = "std")] -use serde::{Deserialize, Serialize}; use sp_arithmetic::FixedU128; use sp_std::vec; use sp_std::vec::Vec; From 53e9b581d557e54352551af3bf9809212f5ea7d6 Mon Sep 17 00:00:00 2001 From: dmoka Date: Fri, 27 Dec 2024 14:37:30 +0100 Subject: [PATCH 108/142] fix test --- integration-tests/src/xcm.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/integration-tests/src/xcm.rs b/integration-tests/src/xcm.rs index 3e6887bcd..ad8fb9c6e 100644 --- a/integration-tests/src/xcm.rs +++ b/integration-tests/src/xcm.rs @@ -137,8 +137,11 @@ fn global_account_derivation_should_work_when_with_other_chain_remote_account() let swapped_events = get_last_swapped_events(); let last_two_swapped_events = &get_last_swapped_events()[swapped_events.len() - 2..]; let topic_id = [ - 237, 209, 186, 1, 116, 50, 158, 190, 169, 150, 18, 38, 37, 51, 136, 30, 219, 60, 5, 253, 212, 209, 227, - 230, 38, 183, 105, 62, 69, 234, 5, 249, + 162, 58, 237, 167, 26, 250, 26, 161, + 116, 182, 7, 12, 84, 48, 100, 53, + 175, 60, 179, 213, 59, 7, 83, 150, + 136, 112, 126, 15, 199,223,71,230 + ]; pretty_assertions::assert_eq!( last_two_swapped_events, From 2ca6939811e1445205284bba50a9f7377fc5ee33 Mon Sep 17 00:00:00 2001 From: dmoka Date: Fri, 27 Dec 2024 14:54:31 +0100 Subject: [PATCH 109/142] formatting --- integration-tests/src/xcm.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/integration-tests/src/xcm.rs b/integration-tests/src/xcm.rs index ad8fb9c6e..2a4a2f98c 100644 --- a/integration-tests/src/xcm.rs +++ b/integration-tests/src/xcm.rs @@ -137,11 +137,8 @@ fn global_account_derivation_should_work_when_with_other_chain_remote_account() let swapped_events = get_last_swapped_events(); let last_two_swapped_events = &get_last_swapped_events()[swapped_events.len() - 2..]; let topic_id = [ - 162, 58, 237, 167, 26, 250, 26, 161, - 116, 182, 7, 12, 84, 48, 100, 53, - 175, 60, 179, 213, 59, 7, 83, 150, - 136, 112, 126, 15, 199,223,71,230 - + 162, 58, 237, 167, 26, 250, 26, 161, 116, 182, 7, 12, 84, 48, 100, 53, 175, 60, 179, 213, 59, 7, 83, 150, + 136, 112, 126, 15, 199, 223, 71, 230, ]; pretty_assertions::assert_eq!( last_two_swapped_events, From 92151cb223124104cac5f6315b32067e57033d88 Mon Sep 17 00:00:00 2001 From: dmoka Date: Mon, 30 Dec 2024 08:24:06 +0100 Subject: [PATCH 110/142] renaming to express intent better --- integration-tests/src/dca.rs | 16 +++--- integration-tests/src/exchange_asset.rs | 8 +-- integration-tests/src/referrals.rs | 12 ++--- integration-tests/src/router.rs | 50 +++++++++---------- integration-tests/src/utility.rs | 14 +++--- integration-tests/src/xcm.rs | 8 +-- pallets/amm-support/src/lib.rs | 6 +-- .../amm-support/src/tests/incremental_id.rs | 2 +- pallets/lbp/src/tests.rs | 12 ++--- pallets/omnipool/src/tests/buy.rs | 12 ++--- pallets/omnipool/src/tests/sell.rs | 4 +- pallets/otc-settlements/src/tests.rs | 2 +- pallets/otc/src/tests/fill_order.rs | 6 +-- pallets/otc/src/tests/partial_fill_order.rs | 2 +- pallets/stableswap/src/tests/add_liquidity.rs | 4 +- .../stableswap/src/tests/remove_liquidity.rs | 4 +- pallets/stableswap/src/tests/trades.rs | 4 +- pallets/xyk/src/tests/fees.rs | 12 ++--- pallets/xyk/src/tests/trades.rs | 8 +-- 19 files changed, 93 insertions(+), 93 deletions(-) diff --git a/integration-tests/src/dca.rs b/integration-tests/src/dca.rs index 7da2f562a..6ac5a5961 100644 --- a/integration-tests/src/dca.rs +++ b/integration-tests/src/dca.rs @@ -232,7 +232,7 @@ mod omnipool { inputs: vec![Asset::new(HDX, 140421094367051)], outputs: vec![Asset::new(LRNA, 70210545436437)], fees: vec![Fee::new(LRNA, 35105272718, Omnipool::protocol_account()),], - operation_id: vec![ + operation_stack: vec![ ExecutionType::DCA(schedule_id, 0), ExecutionType::Router(1), ExecutionType::Omnipool(2) @@ -246,7 +246,7 @@ mod omnipool { inputs: vec![Asset::new(LRNA, 70175440163719)], outputs: vec![Asset::new(DAI, amount_out)], fees: vec![Fee::new(DAI, 250626566417, Omnipool::protocol_account()),], - operation_id: vec![ + operation_stack: vec![ ExecutionType::DCA(schedule_id, 0), ExecutionType::Router(1), ExecutionType::Omnipool(2) @@ -270,7 +270,7 @@ mod omnipool { inputs: vec![Asset::new(HDX, 140421107716515)], outputs: vec![Asset::new(LRNA, 70210548448729)], fees: vec![Fee::new(LRNA, 35105274224, Omnipool::protocol_account()),], - operation_id: vec![ + operation_stack: vec![ ExecutionType::DCA(schedule_id, 3), ExecutionType::Router(4), ExecutionType::Omnipool(5) @@ -284,7 +284,7 @@ mod omnipool { inputs: vec![Asset::new(LRNA, 70175443174505)], outputs: vec![Asset::new(DAI, amount_out)], fees: vec![Fee::new(DAI, 250626566417, Omnipool::protocol_account()),], - operation_id: vec![ + operation_stack: vec![ ExecutionType::DCA(schedule_id, 3), ExecutionType::Router(4), ExecutionType::Omnipool(5) @@ -719,7 +719,7 @@ mod omnipool { inputs: vec![Asset::new(HDX, amount_to_sell)], outputs: vec![Asset::new(LRNA, 49999999159957)], fees: vec![Fee::new(LRNA, 24999999579, Omnipool::protocol_account()),], - operation_id: vec![ + operation_stack: vec![ ExecutionType::DCA(schedule_id, 0), ExecutionType::Router(1), ExecutionType::Omnipool(2) @@ -733,7 +733,7 @@ mod omnipool { inputs: vec![Asset::new(LRNA, 49974999160378)], outputs: vec![Asset::new(DAI, 71214372624126)], fees: vec![Fee::new(DAI, 178482136903, Omnipool::protocol_account()),], - operation_id: vec![ + operation_stack: vec![ ExecutionType::DCA(schedule_id, 0), ExecutionType::Router(1), ExecutionType::Omnipool(2) @@ -757,7 +757,7 @@ mod omnipool { inputs: vec![Asset::new(HDX, amount_to_sell)], outputs: vec![Asset::new(LRNA, 49999997360044)], fees: vec![Fee::new(LRNA, 24999998680, Omnipool::protocol_account()),], - operation_id: vec![ + operation_stack: vec![ ExecutionType::DCA(schedule_id, 3), ExecutionType::Router(4), ExecutionType::Omnipool(5) @@ -771,7 +771,7 @@ mod omnipool { inputs: vec![Asset::new(LRNA, 49974997361364)], outputs: vec![Asset::new(DAI, 71214367826179)], fees: vec![Fee::new(DAI, 178482124878, Omnipool::protocol_account()),], - operation_id: vec![ + operation_stack: vec![ ExecutionType::DCA(schedule_id, 3), ExecutionType::Router(4), ExecutionType::Omnipool(5) diff --git a/integration-tests/src/exchange_asset.rs b/integration-tests/src/exchange_asset.rs index 37ee62825..147d5a0a8 100644 --- a/integration-tests/src/exchange_asset.rs +++ b/integration-tests/src/exchange_asset.rs @@ -142,7 +142,7 @@ fn hydra_should_swap_assets_when_receiving_from_acala_with_sell() { inputs: vec![pallet_amm_support::types::Asset::new(ACA, 50000000000000),], outputs: vec![pallet_amm_support::types::Asset::new(LRNA::get(), 49180327868852)], fees: vec![Fee::new(LRNA::get(), 24590163934, Omnipool::protocol_account()),], - operation_id: vec![ + operation_stack: vec![ ExecutionType::Xcm(topic_id, 0), ExecutionType::XcmExchange(1), ExecutionType::Router(2), @@ -157,7 +157,7 @@ fn hydra_should_swap_assets_when_receiving_from_acala_with_sell() { inputs: vec![pallet_amm_support::types::Asset::new(LRNA::get(), 49155737704918),], outputs: vec![pallet_amm_support::types::Asset::new(HDX, 39101207131554396)], fees: vec![Fee::new(HDX, 97998012861039, Omnipool::protocol_account()),], - operation_id: vec![ + operation_stack: vec![ ExecutionType::Xcm(topic_id, 0), ExecutionType::XcmExchange(1), ExecutionType::Router(2), @@ -190,7 +190,7 @@ fn hydra_should_swap_assets_when_receiving_from_acala_with_sell() { inputs: vec![pallet_amm_support::types::Asset::new(HDX, 1 * UNITS),], outputs: vec![pallet_amm_support::types::Asset::new(LRNA::get(), 1308673515)], fees: vec![Fee::new(LRNA::get(), 654336, Omnipool::protocol_account()),], - operation_id: vec![ExecutionType::Router(4), ExecutionType::Omnipool(5)], + operation_stack: vec![ExecutionType::Router(4), ExecutionType::Omnipool(5)], }), RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { swapper: ALICE.into(), @@ -200,7 +200,7 @@ fn hydra_should_swap_assets_when_receiving_from_acala_with_sell() { inputs: vec![pallet_amm_support::types::Asset::new(LRNA::get(), 1308019179),], outputs: vec![pallet_amm_support::types::Asset::new(ACA, 1348602600)], fees: vec![Fee::new(ACA, 3379957, Omnipool::protocol_account()),], - operation_id: vec![ExecutionType::Router(4), ExecutionType::Omnipool(5)], + operation_stack: vec![ExecutionType::Router(4), ExecutionType::Omnipool(5)], }) ] ); diff --git a/integration-tests/src/referrals.rs b/integration-tests/src/referrals.rs index dab16a6be..7c20d01c1 100644 --- a/integration-tests/src/referrals.rs +++ b/integration-tests/src/referrals.rs @@ -339,7 +339,7 @@ fn trading_in_omnipool_should_use_asset_rewards_when_set() { inputs: vec![Asset::new(HDX, 1000000000000)], outputs: vec![Asset::new(LRNA, 1205768843)], fees: vec![Fee::new(LRNA, 602884, Omnipool::protocol_account())], - operation_id: vec![ExecutionType::Omnipool(0)], + operation_stack: vec![ExecutionType::Omnipool(0)], } .into(), pallet_amm_support::Event::Swapped { @@ -350,7 +350,7 @@ fn trading_in_omnipool_should_use_asset_rewards_when_set() { inputs: vec![Asset::new(LRNA, 1205165959)], outputs: vec![Asset::new(DAI, 26663424573622008)], fees: vec![Fee::new(DAI, 70524156750724, Omnipool::protocol_account())], - operation_id: vec![ExecutionType::Omnipool(0)], + operation_stack: vec![ExecutionType::Omnipool(0)], } .into(), ] @@ -396,7 +396,7 @@ fn buying_hdx_in_omnipool_should_transfer_correct_fee() { inputs: vec![Asset::new(DAI, 26_835_579_541_620_354)], outputs: vec![Asset::new(LRNA, 1_209_746_177)], fees: vec![Fee::new(LRNA, 604_873, Omnipool::protocol_account())], - operation_id: vec![ExecutionType::Omnipool(0)], + operation_stack: vec![ExecutionType::Omnipool(0)], } .into(), pallet_amm_support::Event::Swapped { @@ -407,7 +407,7 @@ fn buying_hdx_in_omnipool_should_transfer_correct_fee() { inputs: vec![Asset::new(LRNA, 1_209_141_304)], outputs: vec![Asset::new(HDX, 1_000_000_000_000)], fees: vec![Fee::new(HDX, 2_794_789_078, Omnipool::protocol_account())], - operation_id: vec![ExecutionType::Omnipool(0)], + operation_stack: vec![ExecutionType::Omnipool(0)], } .into(), ]); @@ -457,7 +457,7 @@ fn buying_with_hdx_in_omnipool_should_transfer_correct_fee() { inputs: vec![Asset::new(HDX, 37_506_757_329_085)], outputs: vec![Asset::new(LRNA, 45_222_713_080)], fees: vec![Fee::new(LRNA, 22_611_356, Omnipool::protocol_account())], - operation_id: vec![ExecutionType::Omnipool(0)], + operation_stack: vec![ExecutionType::Omnipool(0)], } .into(), pallet_amm_support::Event::Swapped { @@ -468,7 +468,7 @@ fn buying_with_hdx_in_omnipool_should_transfer_correct_fee() { inputs: vec![Asset::new(LRNA, 45_200_101_724)], outputs: vec![Asset::new(DAI, 1_000_000_000_000_000_000)], fees: vec![Fee::new(DAI, 2_644_977_450_514_458, Omnipool::protocol_account())], - operation_id: vec![ExecutionType::Omnipool(0)], + operation_stack: vec![ExecutionType::Omnipool(0)], } .into(), ]); diff --git a/integration-tests/src/router.rs b/integration-tests/src/router.rs index 92b3875c0..96244f83c 100644 --- a/integration-tests/src/router.rs +++ b/integration-tests/src/router.rs @@ -172,7 +172,7 @@ mod router_different_pools_tests { .unwrap() .fee_collector, )], - operation_id: vec![ExecutionType::Router(0)], + operation_stack: vec![ExecutionType::Router(0)], } .into(), pallet_amm_support::Event::Swapped { @@ -183,7 +183,7 @@ mod router_different_pools_tests { inputs: vec![Asset::new(LRNA, 5640664064)], outputs: vec![Asset::new(HDX, 4682924837974)], fees: vec![Fee::new(HDX, 11736653730, Omnipool::protocol_account())], - operation_id: vec![ExecutionType::Router(0)], + operation_stack: vec![ExecutionType::Router(0)], } .into(), pallet_amm_support::Event::Swapped { @@ -209,7 +209,7 @@ mod router_different_pools_tests { asset_out: DOT, }), )], - operation_id: vec![ExecutionType::Router(0)], + operation_stack: vec![ExecutionType::Router(0)], } .into(), pallet_route_executor::Event::Executed { @@ -295,7 +295,7 @@ mod router_different_pools_tests { .unwrap() .fee_collector, )], - operation_id: vec![ExecutionType::Router(0)], + operation_stack: vec![ExecutionType::Router(0)], } .into(), pallet_amm_support::Event::Swapped { @@ -321,7 +321,7 @@ mod router_different_pools_tests { asset_out: stable_asset_1, }), )], - operation_id: vec![ExecutionType::Router(0)], + operation_stack: vec![ExecutionType::Router(0)], } .into(), pallet_amm_support::Event::Swapped { @@ -342,7 +342,7 @@ mod router_different_pools_tests { Some(pallet_stableswap::POOL_IDENTIFIER), ), )], - operation_id: vec![ExecutionType::Router(0)], + operation_stack: vec![ExecutionType::Router(0)], } .into(), pallet_route_executor::Event::Executed { @@ -425,7 +425,7 @@ mod router_different_pools_tests { .unwrap() .fee_collector, )], - operation_id: vec![ExecutionType::Router(0)], + operation_stack: vec![ExecutionType::Router(0)], } .into(), pallet_amm_support::Event::Swapped { @@ -436,7 +436,7 @@ mod router_different_pools_tests { inputs: vec![Asset::new(LRNA, 2465566245)], outputs: vec![Asset::new(HDX, 2046938775509)], fees: vec![Fee::new(HDX, 5130172370, Omnipool::protocol_account())], - operation_id: vec![ExecutionType::Router(0)], + operation_stack: vec![ExecutionType::Router(0)], } .into(), pallet_amm_support::Event::Swapped { @@ -462,7 +462,7 @@ mod router_different_pools_tests { asset_out: DOT, }), )], - operation_id: vec![ExecutionType::Router(0)], + operation_stack: vec![ExecutionType::Router(0)], } .into(), pallet_route_executor::Event::Executed { @@ -548,7 +548,7 @@ mod router_different_pools_tests { .unwrap() .fee_collector, )], - operation_id: vec![ExecutionType::Router(0)], + operation_stack: vec![ExecutionType::Router(0)], } .into(), pallet_amm_support::Event::Swapped { @@ -574,7 +574,7 @@ mod router_different_pools_tests { asset_out: stable_asset_1, }), )], - operation_id: vec![ExecutionType::Router(0)], + operation_stack: vec![ExecutionType::Router(0)], } .into(), pallet_amm_support::Event::Swapped { @@ -595,7 +595,7 @@ mod router_different_pools_tests { Some(pallet_stableswap::POOL_IDENTIFIER), ), )], - operation_id: vec![ExecutionType::Router(0)], + operation_stack: vec![ExecutionType::Router(0)], } .into(), pallet_route_executor::Event::Executed { @@ -682,7 +682,7 @@ mod router_different_pools_tests { asset_out: DOT, }), )], - operation_id: vec![ExecutionType::Router(0)], + operation_stack: vec![ExecutionType::Router(0)], } .into(), pallet_amm_support::Event::Swapped { @@ -708,7 +708,7 @@ mod router_different_pools_tests { asset_out: DOT, }), )], - operation_id: vec![ExecutionType::Router(1)], + operation_stack: vec![ExecutionType::Router(1)], } .into(), pallet_amm_support::Event::Swapped { @@ -734,7 +734,7 @@ mod router_different_pools_tests { asset_out: DOT, }), )], - operation_id: vec![ExecutionType::Router(2)], + operation_stack: vec![ExecutionType::Router(2)], } .into(), ]); @@ -2408,7 +2408,7 @@ mod omnipool_router_tests { inputs: vec![Asset::new(HDX, amount_to_sell)], outputs: vec![Asset::new(LRNA, 12014871681)], fees: vec![Fee::new(LRNA, 6007435, Omnipool::protocol_account())], - operation_id: vec![ExecutionType::Router(0), ExecutionType::Omnipool(1)], + operation_stack: vec![ExecutionType::Router(0), ExecutionType::Omnipool(1)], } .into(), pallet_amm_support::Event::Swapped { @@ -2419,7 +2419,7 @@ mod omnipool_router_tests { inputs: vec![Asset::new(LRNA, 12008864246)], outputs: vec![Asset::new(DAI, amount_out)], fees: vec![Fee::new(DAI, 667155563986401, Omnipool::protocol_account())], - operation_id: vec![ExecutionType::Router(0), ExecutionType::Omnipool(1)], + operation_stack: vec![ExecutionType::Router(0), ExecutionType::Omnipool(1)], } .into(), pallet_route_executor::Event::Executed { @@ -2470,7 +2470,7 @@ mod omnipool_router_tests { inputs: vec![Asset::new(HDX, amount_to_sell)], outputs: vec![Asset::new(LRNA, 12014871681)], fees: vec![Fee::new(LRNA, 6007435, Omnipool::protocol_account())], - operation_id: vec![ExecutionType::Omnipool(0)], + operation_stack: vec![ExecutionType::Omnipool(0)], } .into(), pallet_amm_support::Event::Swapped { @@ -2481,7 +2481,7 @@ mod omnipool_router_tests { inputs: vec![Asset::new(LRNA, 12008864246)], outputs: vec![Asset::new(DAI, amount_out)], fees: vec![Fee::new(DAI, 667155563986401, Omnipool::protocol_account())], - operation_id: vec![ExecutionType::Omnipool(0)], + operation_stack: vec![ExecutionType::Omnipool(0)], } .into(), ]); @@ -2638,7 +2638,7 @@ mod omnipool_router_tests { inputs: vec![Asset::new(HDX, amount_in)], outputs: vec![Asset::new(LRNA, 45135)], fees: vec![Fee::new(LRNA, 22, Omnipool::protocol_account())], - operation_id: vec![ExecutionType::Router(0), ExecutionType::Omnipool(1)], + operation_stack: vec![ExecutionType::Router(0), ExecutionType::Omnipool(1)], } .into(), pallet_amm_support::Event::Swapped { @@ -2649,7 +2649,7 @@ mod omnipool_router_tests { inputs: vec![Asset::new(LRNA, 45113)], outputs: vec![Asset::new(DAI, amount_to_buy)], fees: vec![Fee::new(DAI, 2506265665, Omnipool::protocol_account())], - operation_id: vec![ExecutionType::Router(0), ExecutionType::Omnipool(1)], + operation_stack: vec![ExecutionType::Router(0), ExecutionType::Omnipool(1)], } .into(), pallet_route_executor::Event::Executed { @@ -2700,7 +2700,7 @@ mod omnipool_router_tests { inputs: vec![Asset::new(HDX, amount_in)], outputs: vec![Asset::new(LRNA, 45135)], fees: vec![Fee::new(LRNA, 22, Omnipool::protocol_account())], - operation_id: vec![ExecutionType::Omnipool(0)], + operation_stack: vec![ExecutionType::Omnipool(0)], } .into(), pallet_amm_support::Event::Swapped { @@ -2711,7 +2711,7 @@ mod omnipool_router_tests { inputs: vec![Asset::new(LRNA, 45113)], outputs: vec![Asset::new(DAI, amount_to_buy)], fees: vec![Fee::new(DAI, 2506265665, Omnipool::protocol_account())], - operation_id: vec![ExecutionType::Omnipool(0)], + operation_stack: vec![ExecutionType::Omnipool(0)], } .into(), ]); @@ -3001,7 +3001,7 @@ mod lbp_router_tests { .unwrap() .fee_collector, )], - operation_id: vec![ExecutionType::Router(0)], + operation_stack: vec![ExecutionType::Router(0)], } .into(), pallet_route_executor::Event::Executed { @@ -3057,7 +3057,7 @@ mod lbp_router_tests { .unwrap() .fee_collector, )], - operation_id: vec![], + operation_stack: vec![], } .into(), ]); diff --git a/integration-tests/src/utility.rs b/integration-tests/src/utility.rs index 38105013b..88efbb6a4 100644 --- a/integration-tests/src/utility.rs +++ b/integration-tests/src/utility.rs @@ -84,7 +84,7 @@ fn batch_execution_type_should_be_included_in_batch() { .unwrap() .fee_collector, )], - operation_id: vec![ExecutionType::Batch(0), ExecutionType::Router(1)], + operation_stack: vec![ExecutionType::Batch(0), ExecutionType::Router(1)], }), RuntimeEvent::AmmSupport(pallet_amm_support::Event::::Swapped { swapper: BOB.into(), @@ -94,7 +94,7 @@ fn batch_execution_type_should_be_included_in_batch() { inputs: vec![Asset::new(LRNA, 5640664064)], outputs: vec![Asset::new(HDX, 4682924837974)], fees: vec![Fee::new(HDX, 11736653730, Omnipool::protocol_account())], - operation_id: vec![ExecutionType::Batch(0), ExecutionType::Router(1)], + operation_stack: vec![ExecutionType::Batch(0), ExecutionType::Router(1)], }), RuntimeEvent::AmmSupport(pallet_amm_support::Event::::Swapped { swapper: BOB.into(), @@ -119,7 +119,7 @@ fn batch_execution_type_should_be_included_in_batch() { asset_out: DOT, }), )], - operation_id: vec![ExecutionType::Batch(0), ExecutionType::Router(1)], + operation_stack: vec![ExecutionType::Batch(0), ExecutionType::Router(1)], }) ] ); @@ -214,7 +214,7 @@ fn batch_execution_type_should_be_popped_when_multiple_batch_calls_happen() { asset_out: DOT, }), )], - operation_id: vec![ExecutionType::Batch(2), ExecutionType::Router(3)], + operation_stack: vec![ExecutionType::Batch(2), ExecutionType::Router(3)], }) ); }); @@ -291,7 +291,7 @@ fn nested_batch_should_represent_embeddedness() { .unwrap() .fee_collector, )], - operation_id: vec![ + operation_stack: vec![ ExecutionType::Batch(0), ExecutionType::Batch(1), ExecutionType::Router(2) @@ -305,7 +305,7 @@ fn nested_batch_should_represent_embeddedness() { inputs: vec![Asset::new(LRNA, 5640664064)], outputs: vec![Asset::new(HDX, 4682924837974)], fees: vec![Fee::new(HDX, 11736653730, Omnipool::protocol_account())], - operation_id: vec![ + operation_stack: vec![ ExecutionType::Batch(0), ExecutionType::Batch(1), ExecutionType::Router(2) @@ -334,7 +334,7 @@ fn nested_batch_should_represent_embeddedness() { asset_out: DOT, }), )], - operation_id: vec![ + operation_stack: vec![ ExecutionType::Batch(0), ExecutionType::Batch(1), ExecutionType::Router(2) diff --git a/integration-tests/src/xcm.rs b/integration-tests/src/xcm.rs index 2a4a2f98c..f792ab055 100644 --- a/integration-tests/src/xcm.rs +++ b/integration-tests/src/xcm.rs @@ -151,7 +151,7 @@ fn global_account_derivation_should_work_when_with_other_chain_remote_account() inputs: vec![UnifiedEventAsset::new(HDX, 1000000000000)], outputs: vec![UnifiedEventAsset::new(LRNA, 1201498716)], fees: vec![Fee::new(LRNA, 600749, Omnipool::protocol_account()),], - operation_id: vec![ExecutionType::Xcm(topic_id, 0), ExecutionType::Omnipool(1)] + operation_stack: vec![ExecutionType::Xcm(topic_id, 0), ExecutionType::Omnipool(1)] }), RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { swapper: account.into(), @@ -161,7 +161,7 @@ fn global_account_derivation_should_work_when_with_other_chain_remote_account() inputs: vec![UnifiedEventAsset::new(LRNA, 1200897967)], outputs: vec![UnifiedEventAsset::new(DAI, 26619890727267708)], fees: vec![Fee::new(DAI, 66716518113453, Omnipool::protocol_account()),], - operation_id: vec![ExecutionType::Xcm(topic_id, 0), ExecutionType::Omnipool(1)], + operation_stack: vec![ExecutionType::Xcm(topic_id, 0), ExecutionType::Omnipool(1)], }) ] ); @@ -291,7 +291,7 @@ fn xcm_call_should_populate_unified_event_call_context() { inputs: vec![UnifiedEventAsset::new(HDX, 1000000000000)], outputs: vec![UnifiedEventAsset::new(LRNA, 1201498716)], fees: vec![Fee::new(LRNA, 600749, Omnipool::protocol_account()),], - operation_id: vec![ + operation_stack: vec![ ExecutionType::Xcm( [ 237, 209, 186, 1, 116, 50, 158, 190, 169, 150, 18, 38, 37, 51, 136, 30, 219, 60, 5, @@ -310,7 +310,7 @@ fn xcm_call_should_populate_unified_event_call_context() { inputs: vec![UnifiedEventAsset::new(LRNA, 1200897967)], outputs: vec![UnifiedEventAsset::new(DAI, 26619890727267708)], fees: vec![Fee::new(DAI, 66716518113453, Omnipool::protocol_account()),], - operation_id: vec![ + operation_stack: vec![ ExecutionType::Xcm( [ 237, 209, 186, 1, 116, 50, 158, 190, 169, 150, 18, 38, 37, 51, 136, 30, 219, 60, 5, diff --git a/pallets/amm-support/src/lib.rs b/pallets/amm-support/src/lib.rs index 4e98214db..aaaed6f9d 100644 --- a/pallets/amm-support/src/lib.rs +++ b/pallets/amm-support/src/lib.rs @@ -81,7 +81,7 @@ pub mod pallet { inputs: Vec, outputs: Vec, fees: Vec>, - operation_id: Vec, + operation_stack: Vec, }, } @@ -111,7 +111,7 @@ impl Pallet { outputs: Vec, fees: Vec>, ) { - let operation_id = ExecutionContext::::get().to_vec(); + let operation_stack = ExecutionContext::::get().to_vec(); Self::deposit_event(Event::::Swapped { swapper, filler, @@ -120,7 +120,7 @@ impl Pallet { inputs, outputs, fees, - operation_id, + operation_stack, }); } diff --git a/pallets/amm-support/src/tests/incremental_id.rs b/pallets/amm-support/src/tests/incremental_id.rs index 5531f937b..b394a35d9 100644 --- a/pallets/amm-support/src/tests/incremental_id.rs +++ b/pallets/amm-support/src/tests/incremental_id.rs @@ -116,7 +116,7 @@ fn event_should_be_deposited() { inputs: vec![Asset::new(HDX, 1_000_000)], outputs: vec![Asset::new(DOT, 2_000_000)], fees: vec![Fee::new(HDX, 1_000, ALICE), Fee::new(DOT, 2_000, BOB)], - operation_id: vec![], + operation_stack: vec![], } .into()]); }); diff --git a/pallets/lbp/src/tests.rs b/pallets/lbp/src/tests.rs index 086b31558..9e1ae8808 100644 --- a/pallets/lbp/src/tests.rs +++ b/pallets/lbp/src/tests.rs @@ -1851,7 +1851,7 @@ fn execute_sell_should_work() { inputs: vec![Asset::new(asset_in, amount_in)], outputs: vec![Asset::new(asset_out, amount_b)], fees: vec![Fee::new(asset_in, 1_000, pool_data.fee_collector)], - operation_id: vec![], + operation_stack: vec![], } .into(), ]); @@ -1994,7 +1994,7 @@ fn execute_buy_should_work() { inputs: vec![Asset::new(asset_in, amount_in)], outputs: vec![Asset::new(asset_out, amount_b)], fees: vec![Fee::new(asset_in, 1_000, pool_data.fee_collector)], - operation_id: vec![], + operation_stack: vec![], } .into(), ]); @@ -2323,7 +2323,7 @@ fn buy_should_work() { inputs: vec![Asset::new(asset_in, 17_894_738)], outputs: vec![Asset::new(asset_out, 10_000_000)], fees: vec![Fee::new(asset_in, 35860, pool_data.fee_collector)], - operation_id: vec![], // calling buy directly from the pallet doesn't set event_id + operation_stack: vec![], // calling buy directly from the pallet doesn't set event_id } .into(), ]); @@ -2468,7 +2468,7 @@ fn buy_should_work_when_limit_is_set_above_account_balance() { inputs: vec![Asset::new(asset_in, 17_894_738)], outputs: vec![Asset::new(asset_out, 10_000_000)], fees: vec![Fee::new(asset_in, 35860, pool_data.fee_collector)], - operation_id: vec![], + operation_stack: vec![], } .into(), ]); @@ -2503,7 +2503,7 @@ fn buy_should_work_when_limit_is_set_above_account_balance() { outputs: vec![Asset::new(KUSD, 10_000_000)], fees: vec![Fee::new(KUSD, 20_000, pool_data.fee_collector)], - operation_id: vec![], + operation_stack: vec![], } .into(), ]); @@ -2593,7 +2593,7 @@ fn sell_should_work() { inputs: vec![Asset::new(asset_in, 9_980_000)], outputs: vec![Asset::new(asset_out, 5_605_138)], fees: vec![Fee::new(asset_in, 20_000, pool_data.fee_collector)], - operation_id: vec![], + operation_stack: vec![], } .into(), ]); diff --git a/pallets/omnipool/src/tests/buy.rs b/pallets/omnipool/src/tests/buy.rs index 7ed256ef9..42a80f367 100644 --- a/pallets/omnipool/src/tests/buy.rs +++ b/pallets/omnipool/src/tests/buy.rs @@ -445,7 +445,7 @@ fn buy_should_emit_event_with_correct_asset_fee_amount() { inputs: vec![Asset::new(100, expected_sold_amount)], outputs: vec![Asset::new(1, 57142857142858)], fees: vec![Fee::new(LRNA, 0, Omnipool::protocol_account())], - operation_id: vec![ExecutionType::Omnipool(0)], + operation_stack: vec![ExecutionType::Omnipool(0)], } .into(), pallet_amm_support::Event::Swapped { @@ -456,7 +456,7 @@ fn buy_should_emit_event_with_correct_asset_fee_amount() { inputs: vec![Asset::new(1, 57142857142858)], outputs: vec![Asset::new(200, buy_amount)], fees: vec![Fee::new(200, 5555555555556, Omnipool::protocol_account())], - operation_id: vec![ExecutionType::Omnipool(0)], + operation_stack: vec![ExecutionType::Omnipool(0)], } .into(), ]); @@ -492,7 +492,7 @@ fn buy_should_emit_event_with_correct_asset_fee_amount() { inputs: vec![Asset::new(100, 65976185738813)], outputs: vec![Asset::new(1, 60326770004314)], fees: vec![Fee::new(LRNA, 0, Omnipool::protocol_account())], - operation_id: vec![ExecutionType::Omnipool(1)], + operation_stack: vec![ExecutionType::Omnipool(1)], } .into(), pallet_amm_support::Event::Swapped { @@ -503,7 +503,7 @@ fn buy_should_emit_event_with_correct_asset_fee_amount() { inputs: vec![Asset::new(1, 60326770004314)], outputs: vec![Asset::new(200, other_buy_amount)], fees: vec![Fee::new(200, 5555555555567, Omnipool::protocol_account())], - operation_id: vec![ExecutionType::Omnipool(1)], + operation_stack: vec![ExecutionType::Omnipool(1)], } .into(), ]); @@ -561,7 +561,7 @@ fn buy_should_emit_event_with_correct_protocol_fee_amount() { inputs: vec![Asset::new(100, expected_sold_amount)], outputs: vec![Asset::new(1, 56980056980057)], fees: vec![Fee::new(LRNA, 5698005698005, Omnipool::protocol_account())], - operation_id: vec![ExecutionType::Omnipool(0)], + operation_stack: vec![ExecutionType::Omnipool(0)], } .into(), pallet_amm_support::Event::Swapped { @@ -572,7 +572,7 @@ fn buy_should_emit_event_with_correct_protocol_fee_amount() { inputs: vec![Asset::new(1, 51282051282052)], outputs: vec![Asset::new(200, buy_amount)], fees: vec![Fee::new(200, 0, Omnipool::protocol_account())], - operation_id: vec![ExecutionType::Omnipool(0)], + operation_stack: vec![ExecutionType::Omnipool(0)], } .into(), ]); diff --git a/pallets/omnipool/src/tests/sell.rs b/pallets/omnipool/src/tests/sell.rs index 58781a7c0..270a66f6c 100644 --- a/pallets/omnipool/src/tests/sell.rs +++ b/pallets/omnipool/src/tests/sell.rs @@ -752,7 +752,7 @@ fn sell_should_get_same_amount() { inputs: vec![Asset::new(100, expected_sold_amount)], outputs: vec![Asset::new(LRNA, 57142857142858)], fees: vec![Fee::new(LRNA, 0, Omnipool::protocol_account())], - operation_id: vec![ExecutionType::Omnipool(0)], + operation_stack: vec![ExecutionType::Omnipool(0)], } .into(), pallet_amm_support::Event::Swapped { @@ -763,7 +763,7 @@ fn sell_should_get_same_amount() { inputs: vec![Asset::new(LRNA, 57142857142858)], outputs: vec![Asset::new(200, buy_amount)], fees: vec![Fee::new(200, 5555555555556, Omnipool::protocol_account())], - operation_id: vec![ExecutionType::Omnipool(0)], + operation_stack: vec![ExecutionType::Omnipool(0)], } .into(), ]); diff --git a/pallets/otc-settlements/src/tests.rs b/pallets/otc-settlements/src/tests.rs index 92e893a81..f784c44ab 100644 --- a/pallets/otc-settlements/src/tests.rs +++ b/pallets/otc-settlements/src/tests.rs @@ -312,7 +312,7 @@ fn existing_arb_opportunity_should_trigger_trade_when_correct_amount_can_be_foun 49481868743917, ::FeeReceiver::get(), )], - operation_id: vec![], + operation_stack: vec![], } .into(), ]); diff --git a/pallets/otc/src/tests/fill_order.rs b/pallets/otc/src/tests/fill_order.rs index 92c480275..f4c903dc6 100644 --- a/pallets/otc/src/tests/fill_order.rs +++ b/pallets/otc/src/tests/fill_order.rs @@ -88,7 +88,7 @@ fn complete_fill_order_should_work() { inputs: vec![Asset::new(DAI, 20 * ONE)], outputs: vec![Asset::new(HDX, 100 * ONE)], fees: vec![Fee::new(HDX, ONE, ::FeeReceiver::get())], - operation_id: vec![], + operation_stack: vec![], } .into(), ]); @@ -164,7 +164,7 @@ fn complete_fill_order_should_work_when_order_is_not_partially_fillable() { inputs: vec![Asset::new(DAI, 20 * ONE)], outputs: vec![Asset::new(HDX, 100 * ONE)], fees: vec![Fee::new(HDX, ONE, ::FeeReceiver::get())], - operation_id: vec![], + operation_stack: vec![], } .into(), ]); @@ -252,7 +252,7 @@ fn complete_fill_order_should_work_when_there_are_multiple_orders() { inputs: vec![Asset::new(DAI, 20 * ONE)], outputs: vec![Asset::new(HDX, 100 * ONE)], fees: vec![Fee::new(HDX, ONE, ::FeeReceiver::get())], - operation_id: vec![], + operation_stack: vec![], } .into(), ]); diff --git a/pallets/otc/src/tests/partial_fill_order.rs b/pallets/otc/src/tests/partial_fill_order.rs index c57ff5b6a..dbfdcfd74 100644 --- a/pallets/otc/src/tests/partial_fill_order.rs +++ b/pallets/otc/src/tests/partial_fill_order.rs @@ -106,7 +106,7 @@ fn partial_fill_order_should_work_when_order_is_partially_fillable() { fee, ::FeeReceiver::get(), )], - operation_id: vec![], + operation_stack: vec![], } .into(), ]); diff --git a/pallets/stableswap/src/tests/add_liquidity.rs b/pallets/stableswap/src/tests/add_liquidity.rs index 911bdcc86..7c8241d42 100644 --- a/pallets/stableswap/src/tests/add_liquidity.rs +++ b/pallets/stableswap/src/tests/add_liquidity.rs @@ -119,7 +119,7 @@ fn add_liquidity_should_emit_swapped_events() { Fee::new(asset_b, 17, pool_account), Fee::new(asset_c, 39, pool_account) ], - operation_id: vec![], + operation_stack: vec![], }) ) }); @@ -718,7 +718,7 @@ fn add_liquidity_should_work_correctly_when_providing_exact_amount_of_shares() { inputs: vec![Asset::new(asset_a, 2000000000000000003),], outputs: vec![Asset::new(pool_id, 1947597621401945851)], fees: vec![Fee::new(pool_id, 0, pool_account)], - operation_id: vec![], + operation_stack: vec![], }) ) }); diff --git a/pallets/stableswap/src/tests/remove_liquidity.rs b/pallets/stableswap/src/tests/remove_liquidity.rs index 1538efb0f..fb09e2b3b 100644 --- a/pallets/stableswap/src/tests/remove_liquidity.rs +++ b/pallets/stableswap/src/tests/remove_liquidity.rs @@ -83,7 +83,7 @@ fn remove_liquidity_should_work_when_withdrawing_all_shares() { inputs: vec![Asset::new(pool_id, 200516043533380244763),], outputs: vec![Asset::new(asset_c, 199999999999999)], fees: vec![Fee::new(pool_id, 0, pool_account)], - operation_id: vec![], + operation_stack: vec![], }) ); }); @@ -1093,7 +1093,7 @@ fn removing_liquidity_with_exact_amount_should_emit_swapped_event() { Fee::new(asset_b, 872, pool_account), Fee::new(asset_c, 1998, pool_account) ], - operation_id: vec![], + operation_stack: vec![], }) ); }); diff --git a/pallets/stableswap/src/tests/trades.rs b/pallets/stableswap/src/tests/trades.rs index 4bb47c3c4..61be3159f 100644 --- a/pallets/stableswap/src/tests/trades.rs +++ b/pallets/stableswap/src/tests/trades.rs @@ -74,7 +74,7 @@ fn sell_should_work_when_correct_input_provided() { inputs: vec![Asset::new(asset_a, 30000000000000)], outputs: vec![Asset::new(asset_b, 29902625420922)], fees: vec![Fee::new(asset_b, 0, pool_account)], - operation_id: vec![], + operation_stack: vec![], } .into(), ]); @@ -148,7 +148,7 @@ fn buy_should_work_when_correct_input_provided() { inputs: vec![Asset::new(asset_a, 30098072706882)], outputs: vec![Asset::new(asset_b, 30000000000000)], fees: vec![Fee::new(asset_a, 0, pool_account)], - operation_id: vec![], + operation_stack: vec![], } .into(), ]); diff --git a/pallets/xyk/src/tests/fees.rs b/pallets/xyk/src/tests/fees.rs index 289d393b4..baf2ec30d 100644 --- a/pallets/xyk/src/tests/fees.rs +++ b/pallets/xyk/src/tests/fees.rs @@ -154,7 +154,7 @@ fn discount_sell_fees_should_work() { inputs: vec![Asset::new(asset_a, 10_000_000)], outputs: vec![Asset::new(asset_b, 19_986_006)], fees: vec![Fee::new(asset_b, 13_993, pair_account)], - operation_id: vec![], + operation_stack: vec![], } .into(), ]); @@ -242,7 +242,7 @@ fn discount_sell_fees_should_work() { inputs: vec![Asset::new(asset_a, 10_000_000)], outputs: vec![Asset::new(asset_b, 19_980_009)], fees: vec![Fee::new(asset_b, 19_990, pair_account)], - operation_id: vec![], + operation_stack: vec![], } .into(), ]); @@ -325,7 +325,7 @@ fn discount_sell_fees_should_work() { inputs: vec![Asset::new(asset_a, 10_000_000)], outputs: vec![Asset::new(asset_b, 19_999_999)], fees: vec![Fee::new(asset_b, 0, pair_account)], - operation_id: vec![], + operation_stack: vec![], } .into(), ]); @@ -425,7 +425,7 @@ fn discount_buy_fees_should_work() { inputs: vec![Asset::new(asset_b, 10_000_000)], outputs: vec![Asset::new(asset_a, 20_000_002)], fees: vec![Fee::new(asset_b, 14_000, pair_account)], - operation_id: vec![], + operation_stack: vec![], } .into(), ]); @@ -517,7 +517,7 @@ fn discount_buy_fees_should_work() { inputs: vec![Asset::new(asset_b, 10_000_000)], outputs: vec![Asset::new(asset_a, 20_000_002)], fees: vec![Fee::new(asset_b, 20_000, pair_account)], - operation_id: vec![], + operation_stack: vec![], } .into(), ]); @@ -598,7 +598,7 @@ fn discount_buy_fees_should_work() { inputs: vec![Asset::new(asset_b, 10_000_000)], outputs: vec![Asset::new(asset_a, 20_000_002)], fees: vec![Fee::new(asset_b, 0, pair_account)], - operation_id: vec![], + operation_stack: vec![], } .into(), ]); diff --git a/pallets/xyk/src/tests/trades.rs b/pallets/xyk/src/tests/trades.rs index 75a98fddd..62880b55c 100644 --- a/pallets/xyk/src/tests/trades.rs +++ b/pallets/xyk/src/tests/trades.rs @@ -79,7 +79,7 @@ fn sell_test() { inputs: vec![Asset::new(asset_a, 456444678)], outputs: vec![Asset::new(asset_b, 1363483591788)], fees: vec![Fee::new(asset_b, 2732432046, pair_account)], - operation_id: vec![], + operation_stack: vec![], } .into(), ]); @@ -143,7 +143,7 @@ fn execute_sell_should_use_event_id() { inputs: vec![Asset::new(asset_a, 456444678)], outputs: vec![Asset::new(asset_b, 1363483591788)], fees: vec![Fee::new(asset_b, 2732432046, pair_account)], - operation_id: vec![], + operation_stack: vec![], } .into(), ]); @@ -450,7 +450,7 @@ fn sell_with_correct_fees_should_work() { inputs: vec![Asset::new(asset_a, 100_000)], outputs: vec![Asset::new(asset_b, 19_762_378)], fees: vec![Fee::new(asset_b, 39_602, pair_account)], - operation_id: vec![], + operation_stack: vec![], } .into(), ]); @@ -668,7 +668,7 @@ fn single_buy_should_work() { inputs: vec![Asset::new(asset_b, 6_666_666)], outputs: vec![Asset::new(asset_a, 22_068_963_235)], fees: vec![Fee::new(asset_b, 44_137_926, pair_account)], - operation_id: vec![], + operation_stack: vec![], } .into(), ]); From 8ff8309d0bf2bcaac941ee058dca003709e1f2ba Mon Sep 17 00:00:00 2001 From: dmoka Date: Mon, 30 Dec 2024 10:10:24 +0100 Subject: [PATCH 111/142] increase stack size to 16 to have more room for events --- pallets/amm-support/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/amm-support/src/lib.rs b/pallets/amm-support/src/lib.rs index aaaed6f9d..3390ddb63 100644 --- a/pallets/amm-support/src/lib.rs +++ b/pallets/amm-support/src/lib.rs @@ -35,7 +35,7 @@ pub use pallet::*; const LOG_TARGET: &str = "runtime::amm-support"; -pub const MAX_STACK_SIZE: u32 = 10; +pub const MAX_STACK_SIZE: u32 = 16; type ExecutionIdStack = BoundedVec>; From 708a5eaa3f597d9f807aaaca7ef0518e865516fd Mon Sep 17 00:00:00 2001 From: dmoka Date: Mon, 30 Dec 2024 10:14:11 +0100 Subject: [PATCH 112/142] removed ICE as not used yet --- pallets/amm-support/src/tests/incremental_id.rs | 14 +++++++------- pallets/amm-support/src/types.rs | 1 - 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/pallets/amm-support/src/tests/incremental_id.rs b/pallets/amm-support/src/tests/incremental_id.rs index b394a35d9..7baadaeef 100644 --- a/pallets/amm-support/src/tests/incremental_id.rs +++ b/pallets/amm-support/src/tests/incremental_id.rs @@ -38,13 +38,13 @@ fn stack_should_be_populated_when_pushed() { vec![ExecutionType::Router(0), ExecutionType::Router(1)] ); - assert_ok!(AmmSupport::add_to_context(ExecutionType::ICE)); + assert_ok!(AmmSupport::add_to_context(ExecutionType::Omnipool)); assert_eq!( AmmSupport::execution_context(), vec![ ExecutionType::Router(0), ExecutionType::Router(1), - ExecutionType::ICE(2) + ExecutionType::Omnipool(2) ] ); assert_eq!( @@ -52,7 +52,7 @@ fn stack_should_be_populated_when_pushed() { vec![ ExecutionType::Router(0), ExecutionType::Router(1), - ExecutionType::ICE(2) + ExecutionType::Omnipool(2) ] ); }); @@ -63,7 +63,7 @@ fn stack_should_be_reduced_when_poped() { ExtBuilder::default().build().execute_with(|| { assert_ok!(AmmSupport::add_to_context(ExecutionType::Router)); assert_ok!(AmmSupport::add_to_context(ExecutionType::Router)); - assert_ok!(AmmSupport::add_to_context(ExecutionType::ICE)); + assert_ok!(AmmSupport::add_to_context(ExecutionType::Omnipool)); AmmSupport::remove_from_context().unwrap(); assert_eq!( @@ -75,13 +75,13 @@ fn stack_should_be_reduced_when_poped() { vec![ExecutionType::Router(0), ExecutionType::Router(1)] ); - assert_ok!(AmmSupport::add_to_context(ExecutionType::ICE)); + assert_ok!(AmmSupport::add_to_context(ExecutionType::Omnipool)); assert_eq!( AmmSupport::execution_context(), vec![ ExecutionType::Router(0), ExecutionType::Router(1), - ExecutionType::ICE(3) + ExecutionType::Omnipool(3) ] ); assert_eq!( @@ -89,7 +89,7 @@ fn stack_should_be_reduced_when_poped() { vec![ ExecutionType::Router(0), ExecutionType::Router(1), - ExecutionType::ICE(3) + ExecutionType::Omnipool(3) ] ); }); diff --git a/pallets/amm-support/src/types.rs b/pallets/amm-support/src/types.rs index e65a5b9da..5aab6e313 100644 --- a/pallets/amm-support/src/types.rs +++ b/pallets/amm-support/src/types.rs @@ -51,7 +51,6 @@ impl Asset { pub enum ExecutionType { Router(IncrementalIdType), DCA(ScheduleId, IncrementalIdType), - ICE(IncrementalIdType), Batch(IncrementalIdType), Omnipool(IncrementalIdType), XcmExchange(IncrementalIdType), From fd60605d2e7a75b109c2528f9be82287d371076c Mon Sep 17 00:00:00 2001 From: dmoka Date: Mon, 30 Dec 2024 10:59:57 +0100 Subject: [PATCH 113/142] rename to support pallet --- Cargo.lock | 66 ++++---- Cargo.toml | 4 +- integration-tests/Cargo.toml | 4 +- integration-tests/src/dca.rs | 50 +++--- integration-tests/src/exchange_asset.rs | 42 ++--- integration-tests/src/polkadot_test_net.rs | 2 +- integration-tests/src/referrals.rs | 30 ++-- integration-tests/src/router.rs | 158 +++++++++--------- integration-tests/src/utility.rs | 48 +++--- integration-tests/src/xcm.rs | 34 ++-- pallets/circuit-breaker/Cargo.toml | 2 +- pallets/circuit-breaker/src/tests/mock.rs | 4 +- pallets/dca/Cargo.toml | 4 +- pallets/dca/src/lib.rs | 8 +- pallets/dca/src/tests/mock.rs | 4 +- pallets/lbp/Cargo.toml | 4 +- pallets/lbp/src/lib.rs | 24 +-- pallets/lbp/src/mock.rs | 4 +- pallets/lbp/src/tests.rs | 36 ++-- pallets/liquidation/Cargo.toml | 2 +- pallets/liquidation/src/tests/mock.rs | 4 +- pallets/omnipool-liquidity-mining/Cargo.toml | 2 +- .../src/tests/mock.rs | 4 +- pallets/omnipool/Cargo.toml | 4 +- pallets/omnipool/src/lib.rs | 56 +++---- pallets/omnipool/src/tests/buy.rs | 36 ++-- pallets/omnipool/src/tests/mock.rs | 4 +- pallets/omnipool/src/tests/sell.rs | 12 +- pallets/otc-settlements/Cargo.toml | 2 +- pallets/otc-settlements/src/mock.rs | 4 +- pallets/otc-settlements/src/tests.rs | 10 +- pallets/otc/Cargo.toml | 4 +- pallets/otc/src/lib.rs | 28 ++-- pallets/otc/src/tests/fill_order.rs | 20 +-- pallets/otc/src/tests/mock.rs | 4 +- pallets/otc/src/tests/partial_fill_order.rs | 8 +- pallets/route-executor/Cargo.toml | 4 +- pallets/route-executor/src/lib.rs | 14 +- pallets/route-executor/src/tests/mock.rs | 4 +- pallets/stableswap/Cargo.toml | 4 +- pallets/stableswap/src/lib.rs | 58 +++---- pallets/stableswap/src/tests/add_liquidity.rs | 14 +- pallets/stableswap/src/tests/mock.rs | 6 +- .../stableswap/src/tests/remove_liquidity.rs | 14 +- pallets/stableswap/src/tests/trades.rs | 14 +- pallets/{amm-support => support}/Cargo.toml | 2 +- pallets/{amm-support => support}/README.md | 7 - pallets/{amm-support => support}/src/lib.rs | 0 .../src/tests/incremental_id.rs | 0 .../src/tests/mock.rs | 4 +- .../{amm-support => support}/src/tests/mod.rs | 0 pallets/{amm-support => support}/src/types.rs | 0 pallets/xyk/Cargo.toml | 4 +- pallets/xyk/src/lib.rs | 24 +-- pallets/xyk/src/tests/fees.rs | 38 ++--- pallets/xyk/src/tests/mock.rs | 4 +- pallets/xyk/src/tests/trades.rs | 26 +-- runtime/adapters/Cargo.toml | 4 +- runtime/adapters/src/tests/mock.rs | 4 +- runtime/adapters/src/xcm_exchange.rs | 6 +- runtime/hydradx/Cargo.toml | 6 +- runtime/hydradx/src/assets.rs | 2 +- runtime/hydradx/src/lib.rs | 2 +- runtime/hydradx/src/system.rs | 2 +- runtime/hydradx/src/xcm.rs | 8 +- 65 files changed, 500 insertions(+), 507 deletions(-) rename pallets/{amm-support => support}/Cargo.toml (97%) rename pallets/{amm-support => support}/README.md (50%) rename pallets/{amm-support => support}/src/lib.rs (100%) rename pallets/{amm-support => support}/src/tests/incremental_id.rs (100%) rename pallets/{amm-support => support}/src/tests/mock.rs (97%) rename pallets/{amm-support => support}/src/tests/mod.rs (100%) rename pallets/{amm-support => support}/src/types.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 9024cd1bb..811b638dc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4883,7 +4883,6 @@ dependencies = [ "orml-utilities", "orml-vesting", "orml-xcm-support", - "pallet-amm-support", "pallet-asset-registry", "pallet-balances", "pallet-bonds", @@ -4899,6 +4898,7 @@ dependencies = [ "pallet-route-executor", "pallet-stableswap", "pallet-staking 4.0.1", + "pallet-support", "pallet-transaction-multi-payment", "pallet-uniques", "pallet-xyk", @@ -4958,7 +4958,6 @@ dependencies = [ "orml-xcm", "orml-xcm-support", "orml-xtokens", - "pallet-amm-support", "pallet-asset-registry", "pallet-aura", "pallet-authorship", @@ -5013,6 +5012,7 @@ dependencies = [ "pallet-stableswap", "pallet-staking 4.0.1", "pallet-state-trie-migration", + "pallet-support", "pallet-timestamp", "pallet-tips", "pallet-transaction-multi-payment", @@ -7502,25 +7502,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" -[[package]] -name = "pallet-amm-support" -version = "1.0.0" -dependencies = [ - "frame-support", - "frame-system", - "hydradx-traits", - "log", - "parity-scale-codec", - "primitives", - "scale-info", - "serde", - "sp-api", - "sp-arithmetic", - "sp-core", - "sp-io", - "sp-std", -] - [[package]] name = "pallet-asset-conversion" version = "10.0.0" @@ -7862,9 +7843,9 @@ dependencies = [ "hydradx-traits", "orml-tokens", "orml-traits", - "pallet-amm-support", "pallet-balances", "pallet-omnipool", + "pallet-support", "parity-scale-codec", "pretty_assertions", "scale-info", @@ -8024,12 +8005,12 @@ dependencies = [ "log", "orml-tokens", "orml-traits", - "pallet-amm-support", "pallet-balances", "pallet-currencies", "pallet-ema-oracle", "pallet-omnipool", "pallet-route-executor", + "pallet-support", "pallet-xyk", "parity-scale-codec", "pretty_assertions", @@ -8525,7 +8506,7 @@ dependencies = [ "hydradx-traits", "orml-tokens", "orml-traits", - "pallet-amm-support", + "pallet-support", "parity-scale-codec", "primitive-types", "proptest", @@ -8557,7 +8538,6 @@ dependencies = [ "num_enum", "orml-tokens", "orml-traits", - "pallet-amm-support", "pallet-asset-registry", "pallet-balances", "pallet-currencies", @@ -8565,6 +8545,7 @@ dependencies = [ "pallet-evm-accounts", "pallet-omnipool", "pallet-route-executor", + "pallet-support", "parity-scale-codec", "parking_lot 0.12.3", "pretty_assertions", @@ -8816,8 +8797,8 @@ dependencies = [ "log", "orml-tokens", "orml-traits", - "pallet-amm-support", "pallet-balances", + "pallet-support", "parity-scale-codec", "pretty_assertions", "primitive-types", @@ -8843,11 +8824,11 @@ dependencies = [ "log", "orml-tokens", "orml-traits", - "pallet-amm-support", "pallet-balances", "pallet-ema-oracle", "pallet-liquidity-mining", "pallet-omnipool", + "pallet-support", "parity-scale-codec", "pretty_assertions", "primitive-types", @@ -8870,7 +8851,7 @@ dependencies = [ "hydradx-traits", "orml-tokens", "orml-traits", - "pallet-amm-support", + "pallet-support", "parity-scale-codec", "pretty_assertions", "proptest", @@ -8895,13 +8876,13 @@ dependencies = [ "log", "orml-tokens", "orml-traits", - "pallet-amm-support", "pallet-asset-registry", "pallet-balances", "pallet-currencies", "pallet-omnipool", "pallet-otc", "pallet-route-executor", + "pallet-support", "parity-scale-codec", "parking_lot 0.12.3", "pretty_assertions", @@ -9082,9 +9063,9 @@ dependencies = [ "hydradx-traits", "orml-tokens", "orml-traits", - "pallet-amm-support", "pallet-balances", "pallet-currencies", + "pallet-support", "parity-scale-codec", "pretty_assertions", "primitives", @@ -9184,7 +9165,7 @@ dependencies = [ "hydradx-traits", "orml-tokens", "orml-traits", - "pallet-amm-support", + "pallet-support", "parity-scale-codec", "pretty_assertions", "proptest", @@ -9311,6 +9292,25 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-support" +version = "1.0.0" +dependencies = [ + "frame-support", + "frame-system", + "hydradx-traits", + "log", + "parity-scale-codec", + "primitives", + "scale-info", + "serde", + "sp-api", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-std", +] + [[package]] name = "pallet-timestamp" version = "27.0.0" @@ -9579,8 +9579,8 @@ dependencies = [ "log", "orml-tokens", "orml-traits", - "pallet-amm-support", "pallet-asset-registry", + "pallet-support", "parity-scale-codec", "primitive-types", "proptest", @@ -12317,7 +12317,6 @@ dependencies = [ "orml-xcm", "orml-xcm-support", "orml-xtokens", - "pallet-amm-support", "pallet-asset-registry", "pallet-aura", "pallet-authorship", @@ -12354,6 +12353,7 @@ dependencies = [ "pallet-session", "pallet-stableswap", "pallet-staking 4.0.1", + "pallet-support", "pallet-timestamp", "pallet-tips", "pallet-transaction-multi-payment", diff --git a/Cargo.toml b/Cargo.toml index b13fa68eb..267a44499 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,7 +45,7 @@ members = [ 'pallets/liquidation', 'precompiles/call-permit', 'runtime-mock', - 'pallets/amm-support', + 'pallets/support', ] resolver = "2" @@ -146,7 +146,7 @@ pallet-referrals = { path = "pallets/referrals", default-features = false } pallet-evm-accounts = { path = "pallets/evm-accounts", default-features = false } pallet-evm-accounts-rpc-runtime-api = { path = "pallets/evm-accounts/rpc/runtime-api", default-features = false } pallet-liquidation = { path = "pallets/liquidation", default-features = false } -pallet-amm-support = { path = "pallets/amm-support", default-features = false } +pallet-support = { path = "pallets/support", default-features = false } hydra-dx-build-script-utils = { path = "utils/build-script-utils", default-features = false } scraper = { path = "scraper", default-features = false } diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index 73125d921..10e9f140b 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -44,7 +44,7 @@ pallet-evm-accounts = { workspace = true } pallet-xyk-liquidity-mining = { workspace = true } pallet-transaction-pause = { workspace = true } pallet-liquidation = { workspace = true } -pallet-amm-support = { workspace = true } +pallet-support = { workspace = true } pallet-treasury = { workspace = true } pallet-democracy = { workspace = true } @@ -222,7 +222,7 @@ std = [ "precompile-utils/std", "pallet-transaction-pause/std", "pallet-liquidation/std", - "pallet-amm-support/std", + "pallet-support/std", ] # we don't include integration tests when benchmarking feature is enabled diff --git a/integration-tests/src/dca.rs b/integration-tests/src/dca.rs index 6ac5a5961..e5be29a41 100644 --- a/integration-tests/src/dca.rs +++ b/integration-tests/src/dca.rs @@ -20,7 +20,7 @@ use hydradx_traits::router::PoolType; use hydradx_traits::router::Trade; use orml_traits::MultiCurrency; use orml_traits::MultiReservableCurrency; -use pallet_amm_support::types::*; +use pallet_support::types::*; use pallet_dca::types::{Order, Schedule}; use pallet_omnipool::types::Tradability; use pallet_stableswap::types::AssetAmount; @@ -224,11 +224,11 @@ mod omnipool { pretty_assertions::assert_eq!( last_two_swapped_events, vec![ - RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { swapper: ALICE.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::types::Filler::Omnipool, - operation: pallet_amm_support::types::TradeOperation::ExactOut, + filler_type:pallet_support::types::Filler::Omnipool, + operation:pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(HDX, 140421094367051)], outputs: vec![Asset::new(LRNA, 70210545436437)], fees: vec![Fee::new(LRNA, 35105272718, Omnipool::protocol_account()),], @@ -238,11 +238,11 @@ mod omnipool { ExecutionType::Omnipool(2) ] }), - RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { swapper: ALICE.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::types::Filler::Omnipool, - operation: pallet_amm_support::types::TradeOperation::ExactOut, + filler_type:pallet_support::types::Filler::Omnipool, + operation:pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(LRNA, 70175440163719)], outputs: vec![Asset::new(DAI, amount_out)], fees: vec![Fee::new(DAI, 250626566417, Omnipool::protocol_account()),], @@ -262,11 +262,11 @@ mod omnipool { pretty_assertions::assert_eq!( last_two_swapped_events, vec![ - RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { swapper: ALICE.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::types::Filler::Omnipool, - operation: pallet_amm_support::types::TradeOperation::ExactOut, + filler_type:pallet_support::types::Filler::Omnipool, + operation:pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(HDX, 140421107716515)], outputs: vec![Asset::new(LRNA, 70210548448729)], fees: vec![Fee::new(LRNA, 35105274224, Omnipool::protocol_account()),], @@ -276,11 +276,11 @@ mod omnipool { ExecutionType::Omnipool(5) ], }), - RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { swapper: ALICE.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::types::Filler::Omnipool, - operation: pallet_amm_support::types::TradeOperation::ExactOut, + filler_type:pallet_support::types::Filler::Omnipool, + operation:pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(LRNA, 70175443174505)], outputs: vec![Asset::new(DAI, amount_out)], fees: vec![Fee::new(DAI, 250626566417, Omnipool::protocol_account()),], @@ -711,11 +711,11 @@ mod omnipool { pretty_assertions::assert_eq!( last_two_swapped_events, vec![ - RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { swapper: ALICE.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::types::Filler::Omnipool, - operation: pallet_amm_support::types::TradeOperation::ExactIn, + filler_type:pallet_support::types::Filler::Omnipool, + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(HDX, amount_to_sell)], outputs: vec![Asset::new(LRNA, 49999999159957)], fees: vec![Fee::new(LRNA, 24999999579, Omnipool::protocol_account()),], @@ -725,11 +725,11 @@ mod omnipool { ExecutionType::Omnipool(2) ], }), - RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { swapper: ALICE.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::types::Filler::Omnipool, - operation: pallet_amm_support::types::TradeOperation::ExactIn, + filler_type:pallet_support::types::Filler::Omnipool, + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(LRNA, 49974999160378)], outputs: vec![Asset::new(DAI, 71214372624126)], fees: vec![Fee::new(DAI, 178482136903, Omnipool::protocol_account()),], @@ -749,11 +749,11 @@ mod omnipool { pretty_assertions::assert_eq!( last_two_swapped_events, vec![ - RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { swapper: ALICE.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::types::Filler::Omnipool, - operation: pallet_amm_support::types::TradeOperation::ExactIn, + filler_type:pallet_support::types::Filler::Omnipool, + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(HDX, amount_to_sell)], outputs: vec![Asset::new(LRNA, 49999997360044)], fees: vec![Fee::new(LRNA, 24999998680, Omnipool::protocol_account()),], @@ -763,11 +763,11 @@ mod omnipool { ExecutionType::Omnipool(5) ], }), - RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { swapper: ALICE.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::types::Filler::Omnipool, - operation: pallet_amm_support::types::TradeOperation::ExactIn, + filler_type:pallet_support::types::Filler::Omnipool, + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(LRNA, 49974997361364)], outputs: vec![Asset::new(DAI, 71214367826179)], fees: vec![Fee::new(DAI, 178482124878, Omnipool::protocol_account()),], diff --git a/integration-tests/src/exchange_asset.rs b/integration-tests/src/exchange_asset.rs index 147d5a0a8..27291eb95 100644 --- a/integration-tests/src/exchange_asset.rs +++ b/integration-tests/src/exchange_asset.rs @@ -134,13 +134,13 @@ fn hydra_should_swap_assets_when_receiving_from_acala_with_sell() { pretty_assertions::assert_eq!( last_two_swapped_events, vec![ - RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { swapper: TempAccountForXcmAssetExchange::get(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::types::Filler::Omnipool, - operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![pallet_amm_support::types::Asset::new(ACA, 50000000000000),], - outputs: vec![pallet_amm_support::types::Asset::new(LRNA::get(), 49180327868852)], + filler_type:pallet_support::types::Filler::Omnipool, + operation:pallet_support::types::TradeOperation::ExactIn, + inputs: vec![pallet_support::types::Asset::new(ACA, 50000000000000),], + outputs: vec![pallet_support::types::Asset::new(LRNA::get(), 49180327868852)], fees: vec![Fee::new(LRNA::get(), 24590163934, Omnipool::protocol_account()),], operation_stack: vec![ ExecutionType::Xcm(topic_id, 0), @@ -149,13 +149,13 @@ fn hydra_should_swap_assets_when_receiving_from_acala_with_sell() { ExecutionType::Omnipool(3) ], }), - RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { swapper: TempAccountForXcmAssetExchange::get(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::types::Filler::Omnipool, - operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![pallet_amm_support::types::Asset::new(LRNA::get(), 49155737704918),], - outputs: vec![pallet_amm_support::types::Asset::new(HDX, 39101207131554396)], + filler_type:pallet_support::types::Filler::Omnipool, + operation:pallet_support::types::TradeOperation::ExactIn, + inputs: vec![pallet_support::types::Asset::new(LRNA::get(), 49155737704918),], + outputs: vec![pallet_support::types::Asset::new(HDX, 39101207131554396)], fees: vec![Fee::new(HDX, 97998012861039, Omnipool::protocol_account()),], operation_stack: vec![ ExecutionType::Xcm(topic_id, 0), @@ -182,23 +182,23 @@ fn hydra_should_swap_assets_when_receiving_from_acala_with_sell() { pretty_assertions::assert_eq!( last_two_swapped_events, vec![ - RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { swapper: ALICE.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::types::Filler::Omnipool, - operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![pallet_amm_support::types::Asset::new(HDX, 1 * UNITS),], - outputs: vec![pallet_amm_support::types::Asset::new(LRNA::get(), 1308673515)], + filler_type:pallet_support::types::Filler::Omnipool, + operation:pallet_support::types::TradeOperation::ExactIn, + inputs: vec![pallet_support::types::Asset::new(HDX, 1 * UNITS),], + outputs: vec![pallet_support::types::Asset::new(LRNA::get(), 1308673515)], fees: vec![Fee::new(LRNA::get(), 654336, Omnipool::protocol_account()),], operation_stack: vec![ExecutionType::Router(4), ExecutionType::Omnipool(5)], }), - RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { swapper: ALICE.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::types::Filler::Omnipool, - operation: pallet_amm_support::types::TradeOperation::ExactIn, - inputs: vec![pallet_amm_support::types::Asset::new(LRNA::get(), 1308019179),], - outputs: vec![pallet_amm_support::types::Asset::new(ACA, 1348602600)], + filler_type:pallet_support::types::Filler::Omnipool, + operation:pallet_support::types::TradeOperation::ExactIn, + inputs: vec![pallet_support::types::Asset::new(LRNA::get(), 1308019179),], + outputs: vec![pallet_support::types::Asset::new(ACA, 1348602600)], fees: vec![Fee::new(ACA, 3379957, Omnipool::protocol_account()),], operation_stack: vec![ExecutionType::Router(4), ExecutionType::Omnipool(5)], }) @@ -1227,7 +1227,7 @@ fn half(asset: &Asset) -> Asset { id: asset.clone().id, } } -use pallet_amm_support::types::{ExecutionType, Fee}; +use pallet_support::types::{ExecutionType, Fee}; use rococo_runtime::xcm_config::BaseXcmWeight; use xcm_builder::FixedWeightBounds; use xcm_executor::traits::WeightBounds; diff --git a/integration-tests/src/polkadot_test_net.rs b/integration-tests/src/polkadot_test_net.rs index 3e1d4f06a..8ebad28be 100644 --- a/integration-tests/src/polkadot_test_net.rs +++ b/integration-tests/src/polkadot_test_net.rs @@ -900,7 +900,7 @@ pub fn get_last_swapped_events() -> Vec { for event in last_events { let e = event.clone(); - if let RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { .. }) = e { + if let RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { .. }) = e { swapped_events.push(e); } } diff --git a/integration-tests/src/referrals.rs b/integration-tests/src/referrals.rs index 7c20d01c1..815e06ae2 100644 --- a/integration-tests/src/referrals.rs +++ b/integration-tests/src/referrals.rs @@ -5,10 +5,10 @@ use frame_support::assert_ok; use frame_system::RawOrigin; use hydradx_runtime::{Currencies, Omnipool, Referrals, Runtime, RuntimeOrigin, Staking, Tokens}; use orml_traits::MultiCurrency; -use pallet_amm_support::types::Asset; -use pallet_amm_support::types::Fee; -use pallet_amm_support::types::Filler; -use pallet_amm_support::types::TradeOperation; +use pallet_support::types::Asset; +use pallet_support::types::Fee; +use pallet_support::types::Filler; +use pallet_support::types::TradeOperation; use pallet_referrals::{FeeDistribution, ReferralCode}; use primitives::AccountId; use sp_core::crypto::Ss58AddressFormat; @@ -331,7 +331,7 @@ fn trading_in_omnipool_should_use_asset_rewards_when_set() { pretty_assertions::assert_eq!( *last_two_swapped_events, vec![ - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), filler_type: Filler::Omnipool, @@ -342,7 +342,7 @@ fn trading_in_omnipool_should_use_asset_rewards_when_set() { operation_stack: vec![ExecutionType::Omnipool(0)], } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), filler_type: Filler::Omnipool, @@ -388,7 +388,7 @@ fn buying_hdx_in_omnipool_should_transfer_correct_fee() { protocol_fee_amount: 604_873, } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), filler_type: Filler::Omnipool, @@ -399,7 +399,7 @@ fn buying_hdx_in_omnipool_should_transfer_correct_fee() { operation_stack: vec![ExecutionType::Omnipool(0)], } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), filler_type: Filler::Omnipool, @@ -449,22 +449,22 @@ fn buying_with_hdx_in_omnipool_should_transfer_correct_fee() { protocol_fee_amount: 22_611_356, } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::types::Filler::Omnipool, - operation: pallet_amm_support::types::TradeOperation::ExactOut, + filler_type:pallet_support::types::Filler::Omnipool, + operation:pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(HDX, 37_506_757_329_085)], outputs: vec![Asset::new(LRNA, 45_222_713_080)], fees: vec![Fee::new(LRNA, 22_611_356, Omnipool::protocol_account())], operation_stack: vec![ExecutionType::Omnipool(0)], } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::types::Filler::Omnipool, - operation: pallet_amm_support::types::TradeOperation::ExactOut, + filler_type:pallet_support::types::Filler::Omnipool, + operation:pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(LRNA, 45_200_101_724)], outputs: vec![Asset::new(DAI, 1_000_000_000_000_000_000)], fees: vec![Fee::new(DAI, 2_644_977_450_514_458, Omnipool::protocol_account())], @@ -605,7 +605,7 @@ fn seed_pot_account() { )); } -use pallet_amm_support::types::ExecutionType; +use pallet_support::types::ExecutionType; use scraper::ALICE; use sp_core::crypto::Ss58Codec; diff --git a/integration-tests/src/router.rs b/integration-tests/src/router.rs index 96244f83c..a75359238 100644 --- a/integration-tests/src/router.rs +++ b/integration-tests/src/router.rs @@ -14,11 +14,11 @@ use hydradx_traits::{ router::{PoolType, Trade}, AssetKind, AMM, }; -use pallet_amm_support::types::Asset; -use pallet_amm_support::types::ExecutionType; -use pallet_amm_support::types::Fee; -use pallet_amm_support::types::Filler; -use pallet_amm_support::types::TradeOperation; +use pallet_support::types::Asset; +use pallet_support::types::ExecutionType; +use pallet_support::types::Fee; +use pallet_support::types::Filler; +use pallet_support::types::TradeOperation; use pallet_lbp::weights::WeightInfo as LbpWeights; use pallet_lbp::WeightCurveType; use pallet_omnipool::traits::OmnipoolHooks; @@ -58,7 +58,7 @@ fn router_weights_should_be_non_zero() { mod router_different_pools_tests { use super::*; use hydradx_traits::router::PoolType; - use pallet_amm_support::types::ExecutionType; + use pallet_support::types::ExecutionType; #[test] fn route_should_fail_when_route_is_not_consistent() { @@ -158,11 +158,11 @@ mod router_different_pools_tests { assert_balance!(BOB.into(), DOT, amount_out); expect_hydra_events(vec![ - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: BOB.into(), filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA)), - filler_type: pallet_amm_support::types::Filler::LBP, - operation: pallet_amm_support::types::TradeOperation::ExactIn, + filler_type:pallet_support::types::Filler::LBP, + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(DAI, 9980000000)], outputs: vec![Asset::new(LRNA, 5640664064)], fees: vec![Fee::new( @@ -175,30 +175,30 @@ mod router_different_pools_tests { operation_stack: vec![ExecutionType::Router(0)], } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::types::Filler::Omnipool, - operation: pallet_amm_support::types::TradeOperation::ExactIn, + filler_type:pallet_support::types::Filler::Omnipool, + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(LRNA, 5640664064)], outputs: vec![Asset::new(HDX, 4682924837974)], fees: vec![Fee::new(HDX, 11736653730, Omnipool::protocol_account())], operation_stack: vec![ExecutionType::Router(0)], } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: BOB.into(), filler: XYK::get_pair_id(pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: DOT, }), - filler_type: pallet_amm_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( + filler_type:pallet_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: DOT, }, ))), - operation: pallet_amm_support::types::TradeOperation::ExactIn, + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(HDX, 4682924837974)], outputs: vec![Asset::new(DOT, 2230008413831)], fees: vec![Fee::new( @@ -281,7 +281,7 @@ mod router_different_pools_tests { assert_balance!(BOB.into(), stable_asset_2, amount_out); expect_hydra_events(vec![ - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: BOB.into(), filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX)), filler_type: Filler::LBP, @@ -298,19 +298,19 @@ mod router_different_pools_tests { operation_stack: vec![ExecutionType::Router(0)], } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: BOB.into(), filler: XYK::get_pair_id(pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: stable_asset_1, }), - filler_type: pallet_amm_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( + filler_type:pallet_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: stable_asset_1, }, ))), - operation: pallet_amm_support::types::TradeOperation::ExactIn, + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(HDX, 5640664064)], outputs: vec![Asset::new(stable_asset_1, 2811712439)], fees: vec![Fee::new( @@ -324,13 +324,13 @@ mod router_different_pools_tests { operation_stack: vec![ExecutionType::Router(0)], } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: BOB.into(), filler: ::ShareAccountId::from_assets( &stable_pool_id, Some(pallet_stableswap::POOL_IDENTIFIER), ), - filler_type: pallet_amm_support::types::Filler::Stableswap(stable_pool_id), + filler_type:pallet_support::types::Filler::Stableswap(stable_pool_id), operation: TradeOperation::ExactIn, inputs: vec![Asset::new(stable_asset_1, 2811712439)], outputs: vec![Asset::new(stable_asset_2, 2783595233)], @@ -411,11 +411,11 @@ mod router_different_pools_tests { assert_balance!(BOB.into(), DOT, amount_to_buy); expect_hydra_events(vec![ - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: BOB.into(), filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA)), - filler_type: pallet_amm_support::types::Filler::LBP, - operation: pallet_amm_support::types::TradeOperation::ExactOut, + filler_type:pallet_support::types::Filler::LBP, + operation:pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(DAI, 4362157193)], outputs: vec![Asset::new(LRNA, 2465566245)], fees: vec![Fee::new( @@ -428,30 +428,30 @@ mod router_different_pools_tests { operation_stack: vec![ExecutionType::Router(0)], } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::types::Filler::Omnipool, - operation: pallet_amm_support::types::TradeOperation::ExactOut, + filler_type:pallet_support::types::Filler::Omnipool, + operation:pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(LRNA, 2465566245)], outputs: vec![Asset::new(HDX, 2046938775509)], fees: vec![Fee::new(HDX, 5130172370, Omnipool::protocol_account())], operation_stack: vec![ExecutionType::Router(0)], } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: BOB.into(), filler: XYK::get_pair_id(pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: DOT, }), - filler_type: pallet_amm_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( + filler_type:pallet_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: DOT, }, ))), - operation: pallet_amm_support::types::TradeOperation::ExactOut, + operation:pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(HDX, 1000000000000)], outputs: vec![Asset::new(DOT, 2040816326531)], fees: vec![Fee::new( @@ -534,11 +534,11 @@ mod router_different_pools_tests { assert_balance!(BOB.into(), stable_asset_2, amount_to_buy); expect_hydra_events(vec![ - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: BOB.into(), filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX)), - filler_type: pallet_amm_support::types::Filler::LBP, - operation: pallet_amm_support::types::TradeOperation::ExactOut, + filler_type:pallet_support::types::Filler::LBP, + operation:pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(DAI, 3746042043754)], outputs: vec![Asset::new(HDX, 2067851065323)], fees: vec![Fee::new( @@ -551,19 +551,19 @@ mod router_different_pools_tests { operation_stack: vec![ExecutionType::Router(0)], } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: BOB.into(), filler: XYK::get_pair_id(pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: stable_asset_1, }), - filler_type: pallet_amm_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( + filler_type:pallet_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: stable_asset_1, }, ))), - operation: pallet_amm_support::types::TradeOperation::ExactOut, + operation:pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(HDX, 1010010000114)], outputs: vec![Asset::new(stable_asset_1, 2061666067122)], fees: vec![Fee::new( @@ -577,14 +577,14 @@ mod router_different_pools_tests { operation_stack: vec![ExecutionType::Router(0)], } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: BOB.into(), filler: ::ShareAccountId::from_assets( &stable_pool_id, Some(pallet_stableswap::POOL_IDENTIFIER), ), - filler_type: pallet_amm_support::types::Filler::Stableswap(stable_pool_id), - operation: pallet_amm_support::types::TradeOperation::ExactOut, + filler_type:pallet_support::types::Filler::Stableswap(stable_pool_id), + operation:pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(stable_asset_1, 1010010000114)], outputs: vec![Asset::new(stable_asset_2, 1000000000000)], fees: vec![Fee::new( @@ -659,19 +659,19 @@ mod router_different_pools_tests { //Assert expect_hydra_events(vec![ - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: BOB.into(), filler: XYK::get_pair_id(pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: DOT, }), - filler_type: pallet_amm_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( + filler_type:pallet_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: DOT, }, ))), - operation: pallet_amm_support::types::TradeOperation::ExactIn, + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(HDX, 10000000000)], outputs: vec![Asset::new(DOT, 4984501549)], fees: vec![Fee::new( @@ -685,19 +685,19 @@ mod router_different_pools_tests { operation_stack: vec![ExecutionType::Router(0)], } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: BOB.into(), filler: XYK::get_pair_id(pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: DOT, }), - filler_type: pallet_amm_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( + filler_type:pallet_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: DOT, }, ))), - operation: pallet_amm_support::types::TradeOperation::ExactOut, + operation:pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(HDX, 10000000000)], outputs: vec![Asset::new(DOT, 20007996198)], fees: vec![Fee::new( @@ -711,19 +711,19 @@ mod router_different_pools_tests { operation_stack: vec![ExecutionType::Router(1)], } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: BOB.into(), filler: XYK::get_pair_id(pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: DOT, }), - filler_type: pallet_amm_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( + filler_type:pallet_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: DOT, }, ))), - operation: pallet_amm_support::types::TradeOperation::ExactIn, + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(HDX, 10000000000)], outputs: vec![Asset::new(DOT, 4981510054)], fees: vec![Fee::new( @@ -1146,7 +1146,7 @@ mod omnipool_router_tests { use hydradx_runtime::{Balances, XYK}; use hydradx_traits::router::PoolType; use hydradx_traits::AssetKind; - use pallet_amm_support::types::ExecutionType; + use pallet_support::types::ExecutionType; #[test] fn sell_should_work_when_route_contains_single_trade() { @@ -2400,22 +2400,22 @@ mod omnipool_router_tests { assert_balance!(BOB.into(), DAI, BOB_INITIAL_DAI_BALANCE + amount_out); expect_hydra_last_events(vec![ - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::types::Filler::Omnipool, - operation: pallet_amm_support::types::TradeOperation::ExactIn, + filler_type:pallet_support::types::Filler::Omnipool, + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(HDX, amount_to_sell)], outputs: vec![Asset::new(LRNA, 12014871681)], fees: vec![Fee::new(LRNA, 6007435, Omnipool::protocol_account())], operation_stack: vec![ExecutionType::Router(0), ExecutionType::Omnipool(1)], } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::types::Filler::Omnipool, - operation: pallet_amm_support::types::TradeOperation::ExactIn, + filler_type:pallet_support::types::Filler::Omnipool, + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(LRNA, 12008864246)], outputs: vec![Asset::new(DAI, amount_out)], fees: vec![Fee::new(DAI, 667155563986401, Omnipool::protocol_account())], @@ -2462,22 +2462,22 @@ mod omnipool_router_tests { protocol_fee_amount: 6_007_435, } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::types::Filler::Omnipool, - operation: pallet_amm_support::types::TradeOperation::ExactIn, + filler_type:pallet_support::types::Filler::Omnipool, + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(HDX, amount_to_sell)], outputs: vec![Asset::new(LRNA, 12014871681)], fees: vec![Fee::new(LRNA, 6007435, Omnipool::protocol_account())], operation_stack: vec![ExecutionType::Omnipool(0)], } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::types::Filler::Omnipool, - operation: pallet_amm_support::types::TradeOperation::ExactIn, + filler_type:pallet_support::types::Filler::Omnipool, + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(LRNA, 12008864246)], outputs: vec![Asset::new(DAI, amount_out)], fees: vec![Fee::new(DAI, 667155563986401, Omnipool::protocol_account())], @@ -2630,22 +2630,22 @@ mod omnipool_router_tests { assert_balance!(BOB.into(), DAI, BOB_INITIAL_DAI_BALANCE + amount_to_buy); expect_hydra_last_events(vec![ - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::types::Filler::Omnipool, - operation: pallet_amm_support::types::TradeOperation::ExactOut, + filler_type:pallet_support::types::Filler::Omnipool, + operation:pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(HDX, amount_in)], outputs: vec![Asset::new(LRNA, 45135)], fees: vec![Fee::new(LRNA, 22, Omnipool::protocol_account())], operation_stack: vec![ExecutionType::Router(0), ExecutionType::Omnipool(1)], } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::types::Filler::Omnipool, - operation: pallet_amm_support::types::TradeOperation::ExactOut, + filler_type:pallet_support::types::Filler::Omnipool, + operation:pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(LRNA, 45113)], outputs: vec![Asset::new(DAI, amount_to_buy)], fees: vec![Fee::new(DAI, 2506265665, Omnipool::protocol_account())], @@ -2692,22 +2692,22 @@ mod omnipool_router_tests { protocol_fee_amount: 22, } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::types::Filler::Omnipool, - operation: pallet_amm_support::types::TradeOperation::ExactOut, + filler_type:pallet_support::types::Filler::Omnipool, + operation:pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(HDX, amount_in)], outputs: vec![Asset::new(LRNA, 45135)], fees: vec![Fee::new(LRNA, 22, Omnipool::protocol_account())], operation_stack: vec![ExecutionType::Omnipool(0)], } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::types::Filler::Omnipool, - operation: pallet_amm_support::types::TradeOperation::ExactOut, + filler_type:pallet_support::types::Filler::Omnipool, + operation:pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(LRNA, 45113)], outputs: vec![Asset::new(DAI, amount_to_buy)], fees: vec![Fee::new(DAI, 2506265665, Omnipool::protocol_account())], @@ -2987,11 +2987,11 @@ mod lbp_router_tests { let fee = 20000000000; expect_hydra_last_events(vec![ - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: BOB.into(), filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX)), - filler_type: pallet_amm_support::types::Filler::LBP, - operation: pallet_amm_support::types::TradeOperation::ExactIn, + filler_type:pallet_support::types::Filler::LBP, + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(HDX, amount_to_sell - fee)], outputs: vec![Asset::new(DAI, received_amount_out)], fees: vec![Fee::new( @@ -3043,11 +3043,11 @@ mod lbp_router_tests { fee_amount: 20_000_000_000, } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: BOB.into(), filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX)), - filler_type: pallet_amm_support::types::Filler::LBP, - operation: pallet_amm_support::types::TradeOperation::ExactIn, + filler_type:pallet_support::types::Filler::LBP, + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(HDX, 9_980_000_000_000)], outputs: vec![Asset::new(DAI, received_amount_out)], fees: vec![Fee::new( diff --git a/integration-tests/src/utility.rs b/integration-tests/src/utility.rs index 88efbb6a4..d0cb04d6b 100644 --- a/integration-tests/src/utility.rs +++ b/integration-tests/src/utility.rs @@ -9,14 +9,14 @@ use hydradx_runtime::XYK; use hydradx_runtime::{Currencies, Omnipool, Runtime, RuntimeEvent}; use hydradx_runtime::{RuntimeCall, Utility}; use hydradx_traits::router::PoolType; -use pallet_amm_support::types::Asset; +use pallet_support::types::Asset; use xcm_emulator::TestExt; use hydradx_traits::router::Trade; use hydradx_traits::AMM; use orml_traits::MultiCurrency; -use pallet_amm_support::types::ExecutionType; -use pallet_amm_support::types::Fee; +use pallet_support::types::ExecutionType; +use pallet_support::types::Fee; #[test] fn batch_execution_type_should_be_included_in_batch() { TestNet::reset(); @@ -70,11 +70,11 @@ fn batch_execution_type_should_be_included_in_batch() { pretty_assertions::assert_eq!( swapped_events, vec![ - RuntimeEvent::AmmSupport(pallet_amm_support::Event::::Swapped { + RuntimeEvent::AmmSupport(pallet_support::Event::::Swapped { swapper: BOB.into(), filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA)), - filler_type: pallet_amm_support::types::Filler::LBP, - operation: pallet_amm_support::types::TradeOperation::ExactIn, + filler_type:pallet_support::types::Filler::LBP, + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(DAI, 9980000000)], outputs: vec![Asset::new(LRNA, 5640664064)], fees: vec![Fee::new( @@ -86,29 +86,29 @@ fn batch_execution_type_should_be_included_in_batch() { )], operation_stack: vec![ExecutionType::Batch(0), ExecutionType::Router(1)], }), - RuntimeEvent::AmmSupport(pallet_amm_support::Event::::Swapped { + RuntimeEvent::AmmSupport(pallet_support::Event::::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::types::Filler::Omnipool, - operation: pallet_amm_support::types::TradeOperation::ExactIn, + filler_type:pallet_support::types::Filler::Omnipool, + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(LRNA, 5640664064)], outputs: vec![Asset::new(HDX, 4682924837974)], fees: vec![Fee::new(HDX, 11736653730, Omnipool::protocol_account())], operation_stack: vec![ExecutionType::Batch(0), ExecutionType::Router(1)], }), - RuntimeEvent::AmmSupport(pallet_amm_support::Event::::Swapped { + RuntimeEvent::AmmSupport(pallet_support::Event::::Swapped { swapper: BOB.into(), filler: XYK::get_pair_id(pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: DOT, }), - filler_type: pallet_amm_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( + filler_type:pallet_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: DOT, }, ))), - operation: pallet_amm_support::types::TradeOperation::ExactIn, + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(HDX, 4682924837974)], outputs: vec![Asset::new(DOT, 2230008413831)], fees: vec![Fee::new( @@ -191,19 +191,19 @@ fn batch_execution_type_should_be_popped_when_multiple_batch_calls_happen() { //Assert pretty_assertions::assert_eq!( *get_last_swapped_events().last().unwrap(), - RuntimeEvent::AmmSupport(pallet_amm_support::Event::::Swapped { + RuntimeEvent::AmmSupport(pallet_support::Event::::Swapped { swapper: BOB.into(), filler: XYK::get_pair_id(pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: DOT, }), - filler_type: pallet_amm_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( + filler_type:pallet_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: DOT, }, ))), - operation: pallet_amm_support::types::TradeOperation::ExactIn, + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(HDX, amount_to_sell)], outputs: vec![Asset::new(DOT, 4549178628)], fees: vec![Fee::new( @@ -277,11 +277,11 @@ fn nested_batch_should_represent_embeddedness() { pretty_assertions::assert_eq!( swapped_events, vec![ - RuntimeEvent::AmmSupport(pallet_amm_support::Event::::Swapped { + RuntimeEvent::AmmSupport(pallet_support::Event::::Swapped { swapper: BOB.into(), filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA)), - filler_type: pallet_amm_support::types::Filler::LBP, - operation: pallet_amm_support::types::TradeOperation::ExactIn, + filler_type:pallet_support::types::Filler::LBP, + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(DAI, 9980000000)], outputs: vec![Asset::new(LRNA, 5640664064)], fees: vec![Fee::new( @@ -297,11 +297,11 @@ fn nested_batch_should_represent_embeddedness() { ExecutionType::Router(2) ], }), - RuntimeEvent::AmmSupport(pallet_amm_support::Event::::Swapped { + RuntimeEvent::AmmSupport(pallet_support::Event::::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::types::Filler::Omnipool, - operation: pallet_amm_support::types::TradeOperation::ExactIn, + filler_type:pallet_support::types::Filler::Omnipool, + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(LRNA, 5640664064)], outputs: vec![Asset::new(HDX, 4682924837974)], fees: vec![Fee::new(HDX, 11736653730, Omnipool::protocol_account())], @@ -311,19 +311,19 @@ fn nested_batch_should_represent_embeddedness() { ExecutionType::Router(2) ], }), - RuntimeEvent::AmmSupport(pallet_amm_support::Event::::Swapped { + RuntimeEvent::AmmSupport(pallet_support::Event::::Swapped { swapper: BOB.into(), filler: XYK::get_pair_id(pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: DOT, }), - filler_type: pallet_amm_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( + filler_type:pallet_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: DOT, }, ))), - operation: pallet_amm_support::types::TradeOperation::ExactIn, + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(HDX, 4682924837974)], outputs: vec![Asset::new(DOT, 2230008413831)], fees: vec![Fee::new( diff --git a/integration-tests/src/xcm.rs b/integration-tests/src/xcm.rs index f792ab055..d3050e52c 100644 --- a/integration-tests/src/xcm.rs +++ b/integration-tests/src/xcm.rs @@ -8,9 +8,9 @@ use frame_support::dispatch::GetDispatchInfo; use hydradx_runtime::Omnipool; use hydradx_runtime::RuntimeEvent; use orml_traits::MultiCurrency; -use pallet_amm_support::types::Asset as UnifiedEventAsset; -use pallet_amm_support::types::ExecutionType; -use pallet_amm_support::types::Fee; +use pallet_support::types::Asset as UnifiedEventAsset; +use pallet_support::types::ExecutionType; +use pallet_support::types::Fee; use polkadot_xcm::v4::prelude::*; use sp_std::sync::Arc; use xcm_builder::DescribeAllTerminal; @@ -143,21 +143,21 @@ fn global_account_derivation_should_work_when_with_other_chain_remote_account() pretty_assertions::assert_eq!( last_two_swapped_events, vec![ - RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { swapper: account.clone().into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::types::Filler::Omnipool, - operation: pallet_amm_support::types::TradeOperation::ExactIn, + filler_type:pallet_support::types::Filler::Omnipool, + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![UnifiedEventAsset::new(HDX, 1000000000000)], outputs: vec![UnifiedEventAsset::new(LRNA, 1201498716)], fees: vec![Fee::new(LRNA, 600749, Omnipool::protocol_account()),], operation_stack: vec![ExecutionType::Xcm(topic_id, 0), ExecutionType::Omnipool(1)] }), - RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { swapper: account.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::types::Filler::Omnipool, - operation: pallet_amm_support::types::TradeOperation::ExactIn, + filler_type:pallet_support::types::Filler::Omnipool, + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![UnifiedEventAsset::new(LRNA, 1200897967)], outputs: vec![UnifiedEventAsset::new(DAI, 26619890727267708)], fees: vec![Fee::new(DAI, 66716518113453, Omnipool::protocol_account()),], @@ -283,11 +283,11 @@ fn xcm_call_should_populate_unified_event_call_context() { pretty_assertions::assert_eq!( last_two_swapped_events, vec![ - RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { swapper: account.clone().into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::types::Filler::Omnipool, - operation: pallet_amm_support::types::TradeOperation::ExactIn, + filler_type:pallet_support::types::Filler::Omnipool, + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![UnifiedEventAsset::new(HDX, 1000000000000)], outputs: vec![UnifiedEventAsset::new(LRNA, 1201498716)], fees: vec![Fee::new(LRNA, 600749, Omnipool::protocol_account()),], @@ -302,11 +302,11 @@ fn xcm_call_should_populate_unified_event_call_context() { ExecutionType::Omnipool(1) ] }), - RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { swapper: account.into(), filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::types::Filler::Omnipool, - operation: pallet_amm_support::types::TradeOperation::ExactIn, + filler_type:pallet_support::types::Filler::Omnipool, + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![UnifiedEventAsset::new(LRNA, 1200897967)], outputs: vec![UnifiedEventAsset::new(DAI, 26619890727267708)], fees: vec![Fee::new(DAI, 66716518113453, Omnipool::protocol_account()),], @@ -324,7 +324,7 @@ fn xcm_call_should_populate_unified_event_call_context() { ] ); - let unified_event_context = pallet_amm_support::Pallet::::get_context().unwrap(); + let unified_event_context =pallet_support::Pallet::::get_context().unwrap(); assert!(unified_event_context.is_empty()); }); } @@ -392,7 +392,7 @@ fn unified_event_context_should_be_cleared_when_error_happens_in_xcm_prepare() { // Assert Hydra::execute_with(|| { - let context = pallet_amm_support::Pallet::::get_context().unwrap(); + let context =pallet_support::Pallet::::get_context().unwrap(); assert!(context.is_empty()) }); } diff --git a/pallets/circuit-breaker/Cargo.toml b/pallets/circuit-breaker/Cargo.toml index 1e7a550d7..8fdd79b35 100644 --- a/pallets/circuit-breaker/Cargo.toml +++ b/pallets/circuit-breaker/Cargo.toml @@ -31,7 +31,7 @@ hydradx-traits = { workspace = true } [dev-dependencies] pallet-omnipool = { workspace = true } -pallet-amm-support = { workspace = true } +pallet-support = { workspace = true } pallet-balances = { workspace = true } orml-tokens = { workspace = true } orml-traits = { workspace = true } diff --git a/pallets/circuit-breaker/src/tests/mock.rs b/pallets/circuit-breaker/src/tests/mock.rs index 3b06a5fe8..5dd22fae0 100644 --- a/pallets/circuit-breaker/src/tests/mock.rs +++ b/pallets/circuit-breaker/src/tests/mock.rs @@ -86,7 +86,7 @@ frame_support::construct_runtime!( Omnipool: pallet_omnipool, Tokens: orml_tokens, CircuitBreaker: pallet_circuit_breaker, - AmmSupport: pallet_amm_support, + AmmSupport:pallet_support, } ); @@ -232,7 +232,7 @@ impl pallet_omnipool::Config for Test { type Fee = FeeProvider; } -impl pallet_amm_support::Config for Test { +impl pallet_support::Config for Test { type RuntimeEvent = RuntimeEvent; } diff --git a/pallets/dca/Cargo.toml b/pallets/dca/Cargo.toml index 7c92ebf3d..f1c375b66 100644 --- a/pallets/dca/Cargo.toml +++ b/pallets/dca/Cargo.toml @@ -34,7 +34,7 @@ pallet-omnipool = { workspace = true } hydradx-traits = { workspace = true } hydradx-adapters = { workspace = true } pallet-ema-oracle = { workspace = true } -pallet-amm-support = { workspace = true } +pallet-support = { workspace = true } hydra-dx-math = { workspace = true } @@ -53,7 +53,7 @@ primitives = { path = "../../primitives", default-features = false } pallet-route-executor = { workspace = true } smallvec = { workspace = true } pallet-balances = { workspace = true } -pallet-amm-support = { workspace = true } +pallet-support = { workspace = true } pallet-currencies = { workspace = true } lazy_static = { workspace = true } sp-api = { workspace = true } diff --git a/pallets/dca/src/lib.rs b/pallets/dca/src/lib.rs index 6659ea266..ae9092c92 100644 --- a/pallets/dca/src/lib.rs +++ b/pallets/dca/src/lib.rs @@ -96,7 +96,7 @@ use hydradx_traits::NativePriceOracle; use hydradx_traits::OraclePeriod; use hydradx_traits::PriceOracle; pub use pallet::*; -use pallet_amm_support::types::ExecutionType; +use pallet_support::types::ExecutionType; pub use weights::WeightInfo; // Re-export pallet items so that they can be accessed from the crate namespace. @@ -206,7 +206,7 @@ pub mod pallet { } #[pallet::config] - pub trait Config: frame_system::Config + pallet_amm_support::Config { + pub trait Config: frame_system::Config + pallet_support::Config { /// The overarching event type. type RuntimeEvent: From> + IsType<::RuntimeEvent>; @@ -694,7 +694,7 @@ impl Pallet { schedule_id: ScheduleId, schedule: &Schedule>, ) -> Result, DispatchError> { - pallet_amm_support::Pallet::::add_to_context(|id| ExecutionType::DCA(schedule_id, id))?; + pallet_support::Pallet::::add_to_context(|id| ExecutionType::DCA(schedule_id, id))?; let origin: OriginFor = Origin::::Signed(schedule.owner.clone()).into(); let trade_result = match &schedule.order { @@ -782,7 +782,7 @@ impl Pallet { } }; - pallet_amm_support::Pallet::::remove_from_context()?; + pallet_support::Pallet::::remove_from_context()?; trade_result } diff --git a/pallets/dca/src/tests/mock.rs b/pallets/dca/src/tests/mock.rs index 3a9b53c6f..a9143fecc 100644 --- a/pallets/dca/src/tests/mock.rs +++ b/pallets/dca/src/tests/mock.rs @@ -79,7 +79,7 @@ frame_support::construct_runtime!( Balances: pallet_balances, Currencies: pallet_currencies, EmaOracle: pallet_ema_oracle, - AmmSupport: pallet_amm_support, + AmmSupport:pallet_support, } ); @@ -358,7 +358,7 @@ parameter_types! { } -impl pallet_amm_support::Config for Test { +impl pallet_support::Config for Test { type RuntimeEvent = RuntimeEvent; } diff --git a/pallets/lbp/Cargo.toml b/pallets/lbp/Cargo.toml index 00f07321b..7b13597ab 100644 --- a/pallets/lbp/Cargo.toml +++ b/pallets/lbp/Cargo.toml @@ -23,7 +23,7 @@ serde = { workspace = true, optional = true } # HydraDX dependencies hydra-dx-math = { workspace = true } hydradx-traits = { workspace = true } -pallet-amm-support = { workspace = true } +pallet-support = { workspace = true } ## ORML dependencies orml-traits = { workspace = true } @@ -67,6 +67,6 @@ std = [ 'frame-benchmarking/std', "scale-info/std", "hydra-dx-math/std", - "pallet-amm-support/std", + "pallet-support/std", ] try-runtime = ["frame-support/try-runtime"] diff --git a/pallets/lbp/src/lib.rs b/pallets/lbp/src/lib.rs index 42b9d292d..a0f8e5c6e 100644 --- a/pallets/lbp/src/lib.rs +++ b/pallets/lbp/src/lib.rs @@ -37,7 +37,7 @@ use frame_system::ensure_signed; use frame_system::pallet_prelude::BlockNumberFor; use hydra_dx_math::types::LBPWeight; use hydradx_traits::{AMMTransfer, AssetPairAccountIdFor, CanCreatePool, LockedBalance, AMM}; -use pallet_amm_support::types::{Asset, Fee}; +use pallet_support::types::{Asset, Fee}; use orml_traits::{MultiCurrency, MultiCurrencyExtended, MultiLockableCurrency}; @@ -185,7 +185,7 @@ pub mod pallet { pub struct Pallet(_); #[pallet::config] - pub trait Config: frame_system::Config + pallet_amm_support::Config { + pub trait Config: frame_system::Config + pallet_support::Config { type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Multi currency for transfer of currencies @@ -343,7 +343,7 @@ pub mod pallet { }, /// Sale executed. - /// Deprecated. Replaced by pallet_amm_support::Swapped + /// Deprecated. Replaced bypallet_support::Swapped SellExecuted { who: T::AccountId, asset_in: AssetId, @@ -355,7 +355,7 @@ pub mod pallet { }, /// Purchase executed. - /// Deprecated. Replaced by pallet_amm_support::Swapped + /// Deprecated. Replaced bypallet_support::Swapped BuyExecuted { who: T::AccountId, asset_out: AssetId, @@ -722,7 +722,7 @@ pub mod pallet { /// - `max_limit`: minimum amount of `asset_out` / amount of asset_out to be obtained from the pool in exchange for `asset_in`. /// /// Emits `SellExecuted` when successful. Deprecated. - /// Emits `pallet_amm_support::Swapped` when successful. + /// Emits `pallet_support::Swapped` when successful. #[pallet::call_index(4)] #[pallet::weight(::WeightInfo::sell())] pub fn sell( @@ -753,7 +753,7 @@ pub mod pallet { /// - `max_limit`: maximum amount of `asset_in` to be sold in exchange for `asset_out`. /// /// Emits `BuyExecuted` when successful. Deprecated. - /// Emits `pallet_amm_support::Swapped` when successful. + /// Emits `pallet_support::Swapped` when successful. #[pallet::call_index(5)] #[pallet::weight(::WeightInfo::buy())] pub fn buy( @@ -1121,11 +1121,11 @@ impl AMM> for Pallet>::try_get(&pool_account).map_err(|_| Error::::PoolNotFound)?; - pallet_amm_support::Pallet::::deposit_trade_event( + pallet_support::Pallet::::deposit_trade_event( transfer.origin.clone(), pool_account, - pallet_amm_support::types::Filler::LBP, - pallet_amm_support::types::TradeOperation::ExactIn, + pallet_support::types::Filler::LBP, + pallet_support::types::TradeOperation::ExactIn, vec![Asset::new(transfer.assets.asset_in, transfer.amount)], vec![Asset::new(transfer.assets.asset_out, transfer.amount_b)], vec![Fee { @@ -1276,11 +1276,11 @@ impl AMM> for Pallet>::try_get(&pool_account).map_err(|_| Error::::PoolNotFound)?; - pallet_amm_support::Pallet::::deposit_trade_event( + pallet_support::Pallet::::deposit_trade_event( transfer.origin.clone(), pool_account, - pallet_amm_support::types::Filler::LBP, - pallet_amm_support::types::TradeOperation::ExactOut, + pallet_support::types::Filler::LBP, + pallet_support::types::TradeOperation::ExactOut, vec![Asset::new(transfer.assets.asset_in, transfer.amount)], vec![Asset::new(transfer.assets.asset_out, transfer.amount_b)], vec![Fee { diff --git a/pallets/lbp/src/mock.rs b/pallets/lbp/src/mock.rs index 933708aa7..e702abc6a 100644 --- a/pallets/lbp/src/mock.rs +++ b/pallets/lbp/src/mock.rs @@ -75,7 +75,7 @@ frame_support::construct_runtime!( System: frame_system, LBPPallet: lbp, Currency: orml_tokens, - AmmSupport: pallet_amm_support, + AmmSupport:pallet_support, } ); @@ -176,7 +176,7 @@ impl LockedBalance for MultiLockedBalance { } } -impl pallet_amm_support::Config for Test { +impl pallet_support::Config for Test { type RuntimeEvent = RuntimeEvent; } diff --git a/pallets/lbp/src/tests.rs b/pallets/lbp/src/tests.rs index 9e1ae8808..8ff23a654 100644 --- a/pallets/lbp/src/tests.rs +++ b/pallets/lbp/src/tests.rs @@ -1843,11 +1843,11 @@ fn execute_sell_should_work() { fee_amount: 1_000, } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: ALICE, filler: pool_id, - filler_type: pallet_amm_support::types::Filler::LBP, - operation: pallet_amm_support::types::TradeOperation::ExactIn, + filler_type:pallet_support::types::Filler::LBP, + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(asset_in, amount_in)], outputs: vec![Asset::new(asset_out, amount_b)], fees: vec![Fee::new(asset_in, 1_000, pool_data.fee_collector)], @@ -1986,11 +1986,11 @@ fn execute_buy_should_work() { fee_amount: 1_000, } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: ALICE, filler: pool_id, - filler_type: pallet_amm_support::types::Filler::LBP, - operation: pallet_amm_support::types::TradeOperation::ExactOut, + filler_type:pallet_support::types::Filler::LBP, + operation:pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(asset_in, amount_in)], outputs: vec![Asset::new(asset_out, amount_b)], fees: vec![Fee::new(asset_in, 1_000, pool_data.fee_collector)], @@ -2315,11 +2315,11 @@ fn buy_should_work() { fee_amount: 35860, } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: buyer, filler: pool_id, - filler_type: pallet_amm_support::types::Filler::LBP, - operation: pallet_amm_support::types::TradeOperation::ExactOut, + filler_type:pallet_support::types::Filler::LBP, + operation:pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(asset_in, 17_894_738)], outputs: vec![Asset::new(asset_out, 10_000_000)], fees: vec![Fee::new(asset_in, 35860, pool_data.fee_collector)], @@ -2460,11 +2460,11 @@ fn buy_should_work_when_limit_is_set_above_account_balance() { fee_amount: 35860, } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: buyer, filler: pool_id, - filler_type: pallet_amm_support::types::Filler::LBP, - operation: pallet_amm_support::types::TradeOperation::ExactOut, + filler_type:pallet_support::types::Filler::LBP, + operation:pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(asset_in, 17_894_738)], outputs: vec![Asset::new(asset_out, 10_000_000)], fees: vec![Fee::new(asset_in, 35860, pool_data.fee_collector)], @@ -2494,11 +2494,11 @@ fn buy_should_work_when_limit_is_set_above_account_balance() { fee_amount: 20_000, } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: buyer, filler: pool_id, - filler_type: pallet_amm_support::types::Filler::LBP, - operation: pallet_amm_support::types::TradeOperation::ExactOut, + filler_type:pallet_support::types::Filler::LBP, + operation:pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(BSX, 5_560_304)], outputs: vec![Asset::new(KUSD, 10_000_000)], @@ -2585,11 +2585,11 @@ fn sell_should_work() { fee_amount: 20_000, } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: buyer, filler: pool_id, - filler_type: pallet_amm_support::types::Filler::LBP, - operation: pallet_amm_support::types::TradeOperation::ExactIn, + filler_type:pallet_support::types::Filler::LBP, + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(asset_in, 9_980_000)], outputs: vec![Asset::new(asset_out, 5_605_138)], fees: vec![Fee::new(asset_in, 20_000, pool_data.fee_collector)], diff --git a/pallets/liquidation/Cargo.toml b/pallets/liquidation/Cargo.toml index 53ddab951..98b243076 100644 --- a/pallets/liquidation/Cargo.toml +++ b/pallets/liquidation/Cargo.toml @@ -33,7 +33,7 @@ hex-literal = { workspace = true } # HydraDX dependencies hydradx-traits = { workspace = true } -pallet-amm-support = { workspace = true } +pallet-support = { workspace = true } # Optional imports for benchmarking diff --git a/pallets/liquidation/src/tests/mock.rs b/pallets/liquidation/src/tests/mock.rs index e8778e68d..579f144e8 100644 --- a/pallets/liquidation/src/tests/mock.rs +++ b/pallets/liquidation/src/tests/mock.rs @@ -60,7 +60,7 @@ frame_support::construct_runtime!( Router: pallet_route_executor, EvmAccounts: pallet_evm_accounts, Liquidation: pallet_liquidation, - AmmSupport: pallet_amm_support, + AmmSupport:pallet_support, } ); @@ -245,7 +245,7 @@ impl pallet_route_executor::Config for Test { type WeightInfo = (); } -impl pallet_amm_support::Config for Test { +impl pallet_support::Config for Test { type RuntimeEvent = RuntimeEvent; } diff --git a/pallets/omnipool-liquidity-mining/Cargo.toml b/pallets/omnipool-liquidity-mining/Cargo.toml index 8799ee682..21330faba 100644 --- a/pallets/omnipool-liquidity-mining/Cargo.toml +++ b/pallets/omnipool-liquidity-mining/Cargo.toml @@ -51,7 +51,7 @@ sp-io = { workspace = true, optional = true } [dev-dependencies] sp-io = { workspace = true } sp-core = { workspace = true } -pallet-amm-support = { workspace = true } +pallet-support = { workspace = true } orml-tokens = { workspace = true } pretty_assertions = { workspace = true } test-utils = { workspace = true } diff --git a/pallets/omnipool-liquidity-mining/src/tests/mock.rs b/pallets/omnipool-liquidity-mining/src/tests/mock.rs index bcb197a0e..853dc1db3 100644 --- a/pallets/omnipool-liquidity-mining/src/tests/mock.rs +++ b/pallets/omnipool-liquidity-mining/src/tests/mock.rs @@ -110,7 +110,7 @@ construct_runtime!( WarehouseLM: warehouse_liquidity_mining::, OmnipoolMining: omnipool_liquidity_mining, EmaOracle: pallet_ema_oracle, - AmmSupport: pallet_amm_support, + AmmSupport:pallet_support, } ); @@ -308,7 +308,7 @@ impl pallet_omnipool::Config for Test { type Fee = FeeProvider; } -impl pallet_amm_support::Config for Test { +impl pallet_support::Config for Test { type RuntimeEvent = RuntimeEvent; } diff --git a/pallets/omnipool/Cargo.toml b/pallets/omnipool/Cargo.toml index dafc9b469..2a2576698 100644 --- a/pallets/omnipool/Cargo.toml +++ b/pallets/omnipool/Cargo.toml @@ -20,7 +20,7 @@ codec = { workspace = true } # HydraDX dependencies hydradx-traits = { workspace = true } hydra-dx-math = { workspace = true } -pallet-amm-support = { workspace = true } +pallet-support = { workspace = true } # primitives sp-runtime = { workspace = true } @@ -70,7 +70,7 @@ std = [ "pallet-balances/std", "orml-tokens/std", "frame-benchmarking/std", - "pallet-amm-support/std", + "pallet-support/std", 'hydradx-traits/std', 'hydra-dx-math/std', 'orml-traits/std', diff --git a/pallets/omnipool/src/lib.rs b/pallets/omnipool/src/lib.rs index ea0a0b41a..28b74be17 100644 --- a/pallets/omnipool/src/lib.rs +++ b/pallets/omnipool/src/lib.rs @@ -95,7 +95,7 @@ use hydra_dx_math::ema::EmaPrice; use hydra_dx_math::omnipool::types::{AssetStateChange, BalanceUpdate, I129}; use hydradx_traits::registry::Inspect as RegistryInspect; use orml_traits::{GetByKey, MultiCurrency}; -use pallet_amm_support::types::{Asset, ExecutionType, Fee}; +use pallet_support::types::{Asset, ExecutionType, Fee}; #[cfg(feature = "try-runtime")] use primitive_types::U256; use scale_info::TypeInfo; @@ -141,7 +141,7 @@ pub mod pallet { pub struct Pallet(_); #[pallet::config] - pub trait Config: frame_system::Config + pallet_amm_support::Config { + pub trait Config: frame_system::Config + pallet_support::Config { /// The overarching event type. type RuntimeEvent: From> + IsType<::RuntimeEvent>; @@ -305,7 +305,7 @@ pub mod pallet { shares_removed: Balance, }, /// Sell trade executed. - /// Deprecated. Replaced by pallet_amm_support::Swapped + /// Deprecated. Replaced bypallet_support::Swapped SellExecuted { who: T::AccountId, asset_in: T::AssetId, @@ -318,7 +318,7 @@ pub mod pallet { protocol_fee_amount: Balance, }, /// Buy trade executed. - /// Deprecated. Replaced by pallet_amm_support::Swapped + /// Deprecated. Replaced bypallet_support::Swapped BuyExecuted { who: T::AccountId, asset_in: T::AssetId, @@ -905,7 +905,7 @@ pub mod pallet { /// - `min_buy_amount`: Minimum amount required to receive /// /// Emits `SellExecuted` event when successful. Deprecated. - /// Emits `pallet_amm_support::Swapped` event when successful. + /// Emits `pallet_support::Swapped` event when successful. /// #[pallet::call_index(5)] #[pallet::weight(::WeightInfo::sell() @@ -1092,14 +1092,14 @@ pub mod pallet { protocol_fee_amount: state_changes.fee.protocol_fee, }); - pallet_amm_support::Pallet::::add_to_context(ExecutionType::Omnipool)?; + pallet_support::Pallet::::add_to_context(ExecutionType::Omnipool)?; //Swapped event for AssetA to HubAsset - pallet_amm_support::Pallet::::deposit_trade_event( + pallet_support::Pallet::::deposit_trade_event( who.clone(), Self::protocol_account(), - pallet_amm_support::types::Filler::Omnipool, - pallet_amm_support::types::TradeOperation::ExactIn, + pallet_support::types::Filler::Omnipool, + pallet_support::types::TradeOperation::ExactIn, vec![Asset::new(asset_in.into(), amount)], vec![Asset::new( T::HubAssetId::get().into(), @@ -1113,11 +1113,11 @@ pub mod pallet { ); //Swapped event for HubAsset to AssetB - pallet_amm_support::Pallet::::deposit_trade_event( + pallet_support::Pallet::::deposit_trade_event( who, Self::protocol_account(), - pallet_amm_support::types::Filler::Omnipool, - pallet_amm_support::types::TradeOperation::ExactIn, + pallet_support::types::Filler::Omnipool, + pallet_support::types::TradeOperation::ExactIn, vec![Asset::new( T::HubAssetId::get().into(), *state_changes.asset_out.delta_hub_reserve, @@ -1130,7 +1130,7 @@ pub mod pallet { }], ); - pallet_amm_support::Pallet::::remove_from_context()?; + pallet_support::Pallet::::remove_from_context()?; #[cfg(feature = "try-runtime")] Self::ensure_trade_invariant( @@ -1156,7 +1156,7 @@ pub mod pallet { /// - `max_sell_amount`: Maximum amount to be sold. /// /// Emits `BuyExecuted` event when successful. Deprecated. - /// Emits `pallet_amm_support::Swapped` event when successful. + /// Emits `pallet_support::Swapped` event when successful. /// #[pallet::call_index(6)] #[pallet::weight(::WeightInfo::buy() @@ -1337,14 +1337,14 @@ pub mod pallet { protocol_fee_amount: state_changes.fee.protocol_fee, }); - pallet_amm_support::Pallet::::add_to_context(ExecutionType::Omnipool)?; + pallet_support::Pallet::::add_to_context(ExecutionType::Omnipool)?; //Swapped even from AssetA to HubAsset - pallet_amm_support::Pallet::::deposit_trade_event( + pallet_support::Pallet::::deposit_trade_event( who.clone(), Self::protocol_account(), - pallet_amm_support::types::Filler::Omnipool, - pallet_amm_support::types::TradeOperation::ExactOut, + pallet_support::types::Filler::Omnipool, + pallet_support::types::TradeOperation::ExactOut, vec![Asset::new(asset_in.into(), *state_changes.asset_in.delta_reserve)], vec![Asset::new( T::HubAssetId::get().into(), @@ -1358,11 +1358,11 @@ pub mod pallet { ); //Swapped even from HubAsset to AssetB - pallet_amm_support::Pallet::::deposit_trade_event( + pallet_support::Pallet::::deposit_trade_event( who, Self::protocol_account(), - pallet_amm_support::types::Filler::Omnipool, - pallet_amm_support::types::TradeOperation::ExactOut, + pallet_support::types::Filler::Omnipool, + pallet_support::types::TradeOperation::ExactOut, vec![Asset::new( T::HubAssetId::get().into(), *state_changes.asset_out.delta_hub_reserve, @@ -1375,7 +1375,7 @@ pub mod pallet { }], ); - pallet_amm_support::Pallet::::remove_from_context()?; + pallet_support::Pallet::::remove_from_context()?; #[cfg(feature = "try-runtime")] Self::ensure_trade_invariant( @@ -1897,11 +1897,11 @@ impl Pallet { //No protocol fee in case of selling hub asset //TODO: we need to split up too, and in the other place too - pallet_amm_support::Pallet::::deposit_trade_event( + pallet_support::Pallet::::deposit_trade_event( who.clone(), Self::protocol_account(), - pallet_amm_support::types::Filler::Omnipool, - pallet_amm_support::types::TradeOperation::ExactIn, + pallet_support::types::Filler::Omnipool, + pallet_support::types::TradeOperation::ExactIn, vec![Asset::new( T::HubAssetId::get().into(), *state_changes.asset.delta_hub_reserve, @@ -2023,11 +2023,11 @@ impl Pallet { }); //No protocol fee in case of buying asset for hub asset - pallet_amm_support::Pallet::::deposit_trade_event( + pallet_support::Pallet::::deposit_trade_event( who.clone(), Self::protocol_account(), - pallet_amm_support::types::Filler::Omnipool, - pallet_amm_support::types::TradeOperation::ExactOut, + pallet_support::types::Filler::Omnipool, + pallet_support::types::TradeOperation::ExactOut, vec![Asset::new( T::HubAssetId::get().into(), *state_changes.asset.delta_hub_reserve, diff --git a/pallets/omnipool/src/tests/buy.rs b/pallets/omnipool/src/tests/buy.rs index 42a80f367..c33277b4c 100644 --- a/pallets/omnipool/src/tests/buy.rs +++ b/pallets/omnipool/src/tests/buy.rs @@ -437,22 +437,22 @@ fn buy_should_emit_event_with_correct_asset_fee_amount() { protocol_fee_amount: 0, } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: LP1, filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::types::Filler::Omnipool, - operation: pallet_amm_support::types::TradeOperation::ExactOut, + filler_type:pallet_support::types::Filler::Omnipool, + operation:pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(100, expected_sold_amount)], outputs: vec![Asset::new(1, 57142857142858)], fees: vec![Fee::new(LRNA, 0, Omnipool::protocol_account())], operation_stack: vec![ExecutionType::Omnipool(0)], } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: LP1, filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::types::Filler::Omnipool, - operation: pallet_amm_support::types::TradeOperation::ExactOut, + filler_type:pallet_support::types::Filler::Omnipool, + operation:pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(1, 57142857142858)], outputs: vec![Asset::new(200, buy_amount)], fees: vec![Fee::new(200, 5555555555556, Omnipool::protocol_account())], @@ -484,22 +484,22 @@ fn buy_should_emit_event_with_correct_asset_fee_amount() { protocol_fee_amount: 0, } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: LP1, filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::types::Filler::Omnipool, - operation: pallet_amm_support::types::TradeOperation::ExactOut, + filler_type:pallet_support::types::Filler::Omnipool, + operation:pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(100, 65976185738813)], outputs: vec![Asset::new(1, 60326770004314)], fees: vec![Fee::new(LRNA, 0, Omnipool::protocol_account())], operation_stack: vec![ExecutionType::Omnipool(1)], } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: LP1, filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::types::Filler::Omnipool, - operation: pallet_amm_support::types::TradeOperation::ExactOut, + filler_type:pallet_support::types::Filler::Omnipool, + operation:pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(1, 60326770004314)], outputs: vec![Asset::new(200, other_buy_amount)], fees: vec![Fee::new(200, 5555555555567, Omnipool::protocol_account())], @@ -553,22 +553,22 @@ fn buy_should_emit_event_with_correct_protocol_fee_amount() { protocol_fee_amount: 5698005698005, } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: LP1, filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::types::Filler::Omnipool, - operation: pallet_amm_support::types::TradeOperation::ExactOut, + filler_type:pallet_support::types::Filler::Omnipool, + operation:pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(100, expected_sold_amount)], outputs: vec![Asset::new(1, 56980056980057)], fees: vec![Fee::new(LRNA, 5698005698005, Omnipool::protocol_account())], operation_stack: vec![ExecutionType::Omnipool(0)], } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: LP1, filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::types::Filler::Omnipool, - operation: pallet_amm_support::types::TradeOperation::ExactOut, + filler_type:pallet_support::types::Filler::Omnipool, + operation:pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(1, 51282051282052)], outputs: vec![Asset::new(200, buy_amount)], fees: vec![Fee::new(200, 0, Omnipool::protocol_account())], diff --git a/pallets/omnipool/src/tests/mock.rs b/pallets/omnipool/src/tests/mock.rs index c70d55f74..6ebd1a958 100644 --- a/pallets/omnipool/src/tests/mock.rs +++ b/pallets/omnipool/src/tests/mock.rs @@ -86,7 +86,7 @@ construct_runtime!( Balances: pallet_balances, Omnipool: pallet_omnipool, Tokens: orml_tokens, - AmmSupport: pallet_amm_support, + AmmSupport:pallet_support, } ); @@ -181,7 +181,7 @@ parameter_types! { pub MinWithdrawFee: Permill = WITHDRAWAL_FEE.with(|v| *v.borrow()); } -impl pallet_amm_support::Config for Test { +impl pallet_support::Config for Test { type RuntimeEvent = RuntimeEvent; } diff --git a/pallets/omnipool/src/tests/sell.rs b/pallets/omnipool/src/tests/sell.rs index 270a66f6c..658e82c86 100644 --- a/pallets/omnipool/src/tests/sell.rs +++ b/pallets/omnipool/src/tests/sell.rs @@ -744,22 +744,22 @@ fn sell_should_get_same_amount() { protocol_fee_amount: 0, } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: LP1, filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::types::Filler::Omnipool, - operation: pallet_amm_support::types::TradeOperation::ExactIn, + filler_type:pallet_support::types::Filler::Omnipool, + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(100, expected_sold_amount)], outputs: vec![Asset::new(LRNA, 57142857142858)], fees: vec![Fee::new(LRNA, 0, Omnipool::protocol_account())], operation_stack: vec![ExecutionType::Omnipool(0)], } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: LP1, filler: Omnipool::protocol_account(), - filler_type: pallet_amm_support::types::Filler::Omnipool, - operation: pallet_amm_support::types::TradeOperation::ExactIn, + filler_type:pallet_support::types::Filler::Omnipool, + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(LRNA, 57142857142858)], outputs: vec![Asset::new(200, buy_amount)], fees: vec![Fee::new(200, 5555555555556, Omnipool::protocol_account())], diff --git a/pallets/otc-settlements/Cargo.toml b/pallets/otc-settlements/Cargo.toml index 047a67abf..695f1f048 100644 --- a/pallets/otc-settlements/Cargo.toml +++ b/pallets/otc-settlements/Cargo.toml @@ -39,7 +39,7 @@ pallet-asset-registry = { workspace = true } pallet-route-executor = { workspace = true } pallet-balances = { workspace = true } pallet-currencies = { workspace = true } -pallet-amm-support = { workspace = true } +pallet-support = { workspace = true } sp-api = { workspace = true } orml-traits = { workspace = true } orml-tokens = { workspace = true, features = ["std"] } diff --git a/pallets/otc-settlements/src/mock.rs b/pallets/otc-settlements/src/mock.rs index 834888973..a1ab43e73 100644 --- a/pallets/otc-settlements/src/mock.rs +++ b/pallets/otc-settlements/src/mock.rs @@ -74,7 +74,7 @@ frame_support::construct_runtime!( Omnipool: pallet_omnipool, Router: pallet_route_executor, OtcSettlements: pallet_otc_settlements, - AmmSupport: pallet_amm_support, + AmmSupport:pallet_support, } ); @@ -259,7 +259,7 @@ impl pallet_currencies::Config for Test { type WeightInfo = (); } -impl pallet_amm_support::Config for Test { +impl pallet_support::Config for Test { type RuntimeEvent = RuntimeEvent; } diff --git a/pallets/otc-settlements/src/tests.rs b/pallets/otc-settlements/src/tests.rs index f784c44ab..fb20a4dff 100644 --- a/pallets/otc-settlements/src/tests.rs +++ b/pallets/otc-settlements/src/tests.rs @@ -24,8 +24,8 @@ pub use crate::mock::*; use frame_support::{assert_ok, assert_storage_noop}; use hydradx_traits::Inspect; use orml_traits::MultiCurrency; -use pallet_amm_support::types::Asset; -use pallet_amm_support::types::Fee; +use pallet_support::types::Asset; +use pallet_support::types::Fee; pub fn expect_events(e: Vec) { e.into_iter().for_each(frame_system::Pallet::::assert_has_event); @@ -300,11 +300,11 @@ fn existing_arb_opportunity_should_trigger_trade_when_correct_amount_can_be_foun profit: 17_736_110_470_326, } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: OtcSettlements::account_id(), filler: otc.owner, - filler_type: pallet_amm_support::types::Filler::OTC(otc_id), - operation: pallet_amm_support::types::TradeOperation::ExactIn, + filler_type:pallet_support::types::Filler::OTC(otc_id), + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(HDX, 2413749694825193)], outputs: vec![Asset::new(DAI, 4948186874391645)], fees: vec![Fee::new( diff --git a/pallets/otc/Cargo.toml b/pallets/otc/Cargo.toml index 3c0e2ce60..23249ba9e 100644 --- a/pallets/otc/Cargo.toml +++ b/pallets/otc/Cargo.toml @@ -14,7 +14,7 @@ scale-info = { workspace = true } # HydraDX dependencies hydradx-traits = { workspace = true } -pallet-amm-support = { workspace = true } +pallet-support = { workspace = true } # primitives sp-runtime = { workspace = true } @@ -54,7 +54,7 @@ std = [ 'orml-traits/std', 'hydradx-traits/std', 'frame-benchmarking/std', - "pallet-amm-support/std" + "pallet-support/std" ] runtime-benchmarks = [ diff --git a/pallets/otc/src/lib.rs b/pallets/otc/src/lib.rs index 1ab2bc557..8e0f5072d 100644 --- a/pallets/otc/src/lib.rs +++ b/pallets/otc/src/lib.rs @@ -39,7 +39,7 @@ use frame_support::{pallet_prelude::*, require_transactional}; use frame_system::{ensure_signed, pallet_prelude::OriginFor}; use hydradx_traits::Inspect; use orml_traits::{GetByKey, MultiCurrency, NamedMultiReservableCurrency}; -use pallet_amm_support::types::Fee; +use pallet_support::types::Fee; use sp_core::U256; use sp_runtime::traits::{One, Zero}; use sp_runtime::Permill; @@ -57,9 +57,9 @@ pub use weights::WeightInfo; // Re-export pallet items so that they can be accessed from the crate namespace. pub use pallet::*; -use pallet_amm_support::types::Asset; +use pallet_support::types::Asset; pub type Balance = u128; -pub type OrderId = pallet_amm_support::types::OtcOrderId; //TODO: just use exacty type +pub type OrderId =pallet_support::types::OtcOrderId; //TODO: just use exacty type pub type NamedReserveIdentifier = [u8; 8]; pub const NAMED_RESERVE_ID: NamedReserveIdentifier = *b"otcorder"; @@ -83,7 +83,7 @@ pub mod pallet { pub struct Pallet(_); #[pallet::config] - pub trait Config: frame_system::Config + pallet_amm_support::Config { + pub trait Config: frame_system::Config + pallet_support::Config { /// Identifier for the class of asset. type AssetId: Member + Parameter + Copy + HasCompact + MaybeSerializeDeserialize + MaxEncodedLen + Into; @@ -126,7 +126,7 @@ pub mod pallet { /// An Order has been cancelled Cancelled { order_id: OrderId }, /// An Order has been completely filled - /// Deprecated. Replaced by pallet_amm_support::Swapped + /// Deprecated. Replaced bypallet_support::Swapped Filled { order_id: OrderId, who: T::AccountId, @@ -135,7 +135,7 @@ pub mod pallet { fee: Balance, }, /// An Order has been partially filled - /// Deprecated. Replaced by pallet_amm_support::Swapped + /// Deprecated. Replaced bypallet_support::Swapped PartiallyFilled { order_id: OrderId, who: T::AccountId, @@ -271,7 +271,7 @@ pub mod pallet { /// /// Events: /// `PartiallyFilled` event when successful. Deprecated. - /// `pallet_amm_support::Swapped` event when successful. + /// `pallet_support::Swapped` event when successful. #[pallet::call_index(1)] #[pallet::weight(::WeightInfo::partial_fill_order())] pub fn partial_fill_order(origin: OriginFor, order_id: OrderId, amount_in: Balance) -> DispatchResult { @@ -310,11 +310,11 @@ pub mod pallet { fee, }); - pallet_amm_support::Pallet::::deposit_trade_event( + pallet_support::Pallet::::deposit_trade_event( who, order.owner.clone(), - pallet_amm_support::types::Filler::OTC(order_id), - pallet_amm_support::types::TradeOperation::ExactIn, + pallet_support::types::Filler::OTC(order_id), + pallet_support::types::TradeOperation::ExactIn, vec![Asset::new(order.asset_in.into(), amount_in)], vec![Asset::new(order.asset_out.into(), amount_out)], vec![Fee { @@ -335,7 +335,7 @@ pub mod pallet { /// /// Events: /// `Filled` event when successful. Deprecated. - /// `pallet_amm_support::Swapped` event when successful. + /// `pallet_support::Swapped` event when successful. #[pallet::call_index(2)] #[pallet::weight(::WeightInfo::fill_order())] pub fn fill_order(origin: OriginFor, order_id: OrderId) -> DispatchResult { @@ -356,11 +356,11 @@ pub mod pallet { fee, }); - pallet_amm_support::Pallet::::deposit_trade_event( + pallet_support::Pallet::::deposit_trade_event( who, order.owner, - pallet_amm_support::types::Filler::OTC(order_id), - pallet_amm_support::types::TradeOperation::ExactIn, + pallet_support::types::Filler::OTC(order_id), + pallet_support::types::TradeOperation::ExactIn, vec![Asset::new(order.asset_in.into(), order.amount_in)], vec![Asset::new(order.asset_out.into(), order.amount_out)], vec![Fee { diff --git a/pallets/otc/src/tests/fill_order.rs b/pallets/otc/src/tests/fill_order.rs index f4c903dc6..1a4ac1aec 100644 --- a/pallets/otc/src/tests/fill_order.rs +++ b/pallets/otc/src/tests/fill_order.rs @@ -18,7 +18,7 @@ use crate::Event; use frame_support::{assert_noop, assert_ok}; use orml_tokens::Error::BalanceTooLow; use orml_traits::{MultiCurrency, NamedMultiReservableCurrency}; -use pallet_amm_support::types::{Asset, Fee}; +use pallet_support::types::{Asset, Fee}; use pretty_assertions::assert_eq; #[test] @@ -80,11 +80,11 @@ fn complete_fill_order_should_work() { fee: ONE, } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: BOB, filler: ALICE, - filler_type: pallet_amm_support::types::Filler::OTC(0), - operation: pallet_amm_support::types::TradeOperation::ExactIn, + filler_type:pallet_support::types::Filler::OTC(0), + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(DAI, 20 * ONE)], outputs: vec![Asset::new(HDX, 100 * ONE)], fees: vec![Fee::new(HDX, ONE, ::FeeReceiver::get())], @@ -156,11 +156,11 @@ fn complete_fill_order_should_work_when_order_is_not_partially_fillable() { fee: ONE, } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: BOB, filler: ALICE, - filler_type: pallet_amm_support::types::Filler::OTC(order_id), - operation: pallet_amm_support::types::TradeOperation::ExactIn, + filler_type:pallet_support::types::Filler::OTC(order_id), + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(DAI, 20 * ONE)], outputs: vec![Asset::new(HDX, 100 * ONE)], fees: vec![Fee::new(HDX, ONE, ::FeeReceiver::get())], @@ -244,11 +244,11 @@ fn complete_fill_order_should_work_when_there_are_multiple_orders() { fee: ONE, } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: BOB, filler: ALICE, - filler_type: pallet_amm_support::types::Filler::OTC(order_id), - operation: pallet_amm_support::types::TradeOperation::ExactIn, + filler_type:pallet_support::types::Filler::OTC(order_id), + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(DAI, 20 * ONE)], outputs: vec![Asset::new(HDX, 100 * ONE)], fees: vec![Fee::new(HDX, ONE, ::FeeReceiver::get())], diff --git a/pallets/otc/src/tests/mock.rs b/pallets/otc/src/tests/mock.rs index faf9cc75b..79beaecdd 100644 --- a/pallets/otc/src/tests/mock.rs +++ b/pallets/otc/src/tests/mock.rs @@ -57,7 +57,7 @@ frame_support::construct_runtime!( System: frame_system, OTC: otc, Tokens: orml_tokens, - AmmSupport: pallet_amm_support, + AmmSupport:pallet_support, } ); @@ -145,7 +145,7 @@ impl orml_tokens::Config for Test { type CurrencyHooks = (); } -impl pallet_amm_support::Config for Test { +impl pallet_support::Config for Test { type RuntimeEvent = RuntimeEvent; } diff --git a/pallets/otc/src/tests/partial_fill_order.rs b/pallets/otc/src/tests/partial_fill_order.rs index dbfdcfd74..7920c0cac 100644 --- a/pallets/otc/src/tests/partial_fill_order.rs +++ b/pallets/otc/src/tests/partial_fill_order.rs @@ -18,7 +18,7 @@ use crate::{Error, Event}; use frame_support::{assert_noop, assert_ok}; use orml_tokens::Error::BalanceTooLow; use orml_traits::{MultiCurrency, NamedMultiReservableCurrency}; -use pallet_amm_support::types::{Asset, Fee}; +use pallet_support::types::{Asset, Fee}; use pretty_assertions::assert_eq; #[test] @@ -94,11 +94,11 @@ fn partial_fill_order_should_work_when_order_is_partially_fillable() { fee, } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: BOB, filler: order.owner, - filler_type: pallet_amm_support::types::Filler::OTC(order_id), - operation: pallet_amm_support::types::TradeOperation::ExactIn, + filler_type:pallet_support::types::Filler::OTC(order_id), + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(order.asset_in, 5 * ONE)], outputs: vec![Asset::new(order.asset_out, expected_amount_out)], fees: vec![Fee::new( diff --git a/pallets/route-executor/Cargo.toml b/pallets/route-executor/Cargo.toml index 7c083d868..9d986078c 100644 --- a/pallets/route-executor/Cargo.toml +++ b/pallets/route-executor/Cargo.toml @@ -15,7 +15,7 @@ serde = { workspace = true } # HydraDX dependencies hydradx-traits = { workspace = true } hydra-dx-math = { workspace = true } -pallet-amm-support = { workspace = true } +pallet-support = { workspace = true } primitives = { workspace = true } # ORML dependencies @@ -56,7 +56,7 @@ std = [ 'orml-traits/std', "hydradx-adapters/std", "pallet-balances/std", - "pallet-amm-support/std", + "pallet-support/std", 'hydradx-traits/std', 'hydra-dx-math/std', 'frame-benchmarking/std', diff --git a/pallets/route-executor/src/lib.rs b/pallets/route-executor/src/lib.rs index 026fa2727..fffefc309 100644 --- a/pallets/route-executor/src/lib.rs +++ b/pallets/route-executor/src/lib.rs @@ -39,8 +39,8 @@ pub use hydradx_traits::router::{ }; use orml_traits::arithmetic::{CheckedAdd, CheckedSub}; -use pallet_amm_support::types::IncrementalIdType; -pub use pallet_amm_support::types::{ExecutionType, Fee}; +use pallet_support::types::IncrementalIdType; +pub use pallet_support::types::{ExecutionType, Fee}; use sp_core::U512; use sp_runtime::traits::{AccountIdConversion, CheckedDiv}; use sp_runtime::{ArithmeticError, DispatchError, FixedPointNumber, FixedU128, Saturating, TransactionOutcome}; @@ -74,7 +74,7 @@ pub mod pallet { pub struct Pallet(_); #[pallet::config] - pub trait Config: frame_system::Config + pallet_amm_support::Config { + pub trait Config: frame_system::Config + pallet_support::Config { type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Asset id type @@ -259,7 +259,7 @@ pub mod pallet { let route_length = route.len(); - let next_event_id = pallet_amm_support::Pallet::::add_to_context(ExecutionType::Router)?; + let next_event_id =pallet_support::Pallet::::add_to_context(ExecutionType::Router)?; for (trade_index, (trade_amount, trade)) in trade_amounts.iter().rev().zip(route).enumerate() { Self::disable_ed_handling_for_insufficient_assets(route_length, trade_index, trade); @@ -303,7 +303,7 @@ pub mod pallet { event_id: next_event_id, }); - pallet_amm_support::Pallet::::remove_from_context()?; + pallet_support::Pallet::::remove_from_context()?; Ok(()) } @@ -496,7 +496,7 @@ impl Pallet { let route_length = route.len(); - let next_event_id = pallet_amm_support::Pallet::::add_to_context(ExecutionType::Router)?; + let next_event_id =pallet_support::Pallet::::add_to_context(ExecutionType::Router)?; for (trade_index, (trade_amount, trade)) in trade_amounts.iter().zip(route.clone()).enumerate() { Self::disable_ed_handling_for_insufficient_assets(route_length, trade_index, trade); @@ -541,7 +541,7 @@ impl Pallet { event_id: next_event_id, }); - pallet_amm_support::Pallet::::remove_from_context()?; + pallet_support::Pallet::::remove_from_context()?; Ok(()) } diff --git a/pallets/route-executor/src/tests/mock.rs b/pallets/route-executor/src/tests/mock.rs index 803821f1e..f673375aa 100644 --- a/pallets/route-executor/src/tests/mock.rs +++ b/pallets/route-executor/src/tests/mock.rs @@ -50,7 +50,7 @@ frame_support::construct_runtime!( Tokens: orml_tokens, Balances: pallet_balances, Currencies: pallet_currencies, - AmmSupport: pallet_amm_support, + AmmSupport:pallet_support, } ); @@ -144,7 +144,7 @@ impl pallet_currencies::Config for Test { type WeightInfo = (); } -impl pallet_amm_support::Config for Test { +impl pallet_support::Config for Test { type RuntimeEvent = RuntimeEvent; } diff --git a/pallets/stableswap/Cargo.toml b/pallets/stableswap/Cargo.toml index 55cfa2d7f..87efde250 100644 --- a/pallets/stableswap/Cargo.toml +++ b/pallets/stableswap/Cargo.toml @@ -21,7 +21,7 @@ serde = { workspace = true } # HydraDX dependencies hydradx-traits = { workspace = true } -pallet-amm-support = { workspace = true } +pallet-support = { workspace = true } # primitives sp-runtime = { workspace = true } @@ -72,6 +72,6 @@ std = [ "frame-benchmarking/std", 'orml-traits/std', "hydra-dx-math/std", - "pallet-amm-support/std", + "pallet-support/std", ] try-runtime = ["frame-support/try-runtime"] diff --git a/pallets/stableswap/src/lib.rs b/pallets/stableswap/src/lib.rs index 1a410d2bf..fb972d665 100644 --- a/pallets/stableswap/src/lib.rs +++ b/pallets/stableswap/src/lib.rs @@ -75,7 +75,7 @@ use crate::types::{AssetAmount, Balance, PoolInfo, PoolState, StableswapHooks, T use hydra_dx_math::stableswap::types::AssetReserve; use hydradx_traits::pools::DustRemovalAccountWhitelist; use orml_traits::MultiCurrency; -use pallet_amm_support::types::{Asset, Fee}; +use pallet_support::types::{Asset, Fee}; use sp_std::collections::btree_map::BTreeMap; pub use weights::WeightInfo; @@ -104,7 +104,7 @@ pub mod pallet { use core::ops::RangeInclusive; use frame_support::pallet_prelude::*; use hydradx_traits::pools::DustRemovalAccountWhitelist; - use pallet_amm_support::types::Fee; + use pallet_support::types::Fee; use sp_runtime::traits::{BlockNumberProvider, Zero}; use sp_runtime::ArithmeticError; use sp_runtime::Permill; @@ -114,7 +114,7 @@ pub mod pallet { pub struct Pallet(_); #[pallet::config] - pub trait Config: frame_system::Config + pallet_amm_support::Config { + pub trait Config: frame_system::Config + pallet_support::Config { /// The overarching event type. type RuntimeEvent: From> + IsType<::RuntimeEvent>; @@ -212,7 +212,7 @@ pub mod pallet { fee: Balance, }, /// Sell trade executed. Trade fee paid in asset leaving the pool (already subtracted from amount_out). - /// Deprecated. Replaced by pallet_amm_support::Swapped + /// Deprecated. Replaced bypallet_support::Swapped //TODO: remove once we migrated completely to pallet_amm::Event::Swapped SellExecuted { who: T::AccountId, @@ -224,7 +224,7 @@ pub mod pallet { fee: Balance, }, /// Buy trade executed. Trade fee paid in asset entering the pool (already included in amount_in). - /// Deprecated. Replaced by pallet_amm_support::Swapped + /// Deprecated. Replaced bypallet_support::Swapped BuyExecuted { who: T::AccountId, pool_id: T::AssetId, @@ -479,7 +479,7 @@ pub mod pallet { /// - `assets`: asset id and liquidity amount provided /// /// Emits `LiquidityAdded` event when successful. - /// Emits `pallet_amm_support::Swapped` event when successful. + /// Emits `pallet_support::Swapped` event when successful. #[pallet::call_index(3)] #[pallet::weight(::WeightInfo::add_liquidity() .saturating_add(T::Hooks::on_liquidity_changed_weight(MAX_ASSETS_IN_POOL as usize)))] @@ -517,7 +517,7 @@ pub mod pallet { /// - `max_asset_amount`: slippage limit. Max amount of asset. /// /// Emits `LiquidityAdded` event when successful. - /// Emits `pallet_amm_support::Swapped` event when successful. + /// Emits `pallet_support::Swapped` event when successful. #[pallet::call_index(4)] #[pallet::weight(::WeightInfo::add_liquidity_shares() .saturating_add(T::Hooks::on_liquidity_changed_weight(MAX_ASSETS_IN_POOL as usize)))] @@ -557,7 +557,7 @@ pub mod pallet { /// - 'min_amount_out': minimum amount to receive /// /// Emits `LiquidityRemoved` event when successful. - /// Emits `pallet_amm_support::Swapped` event when successful. + /// Emits `pallet_support::Swapped` event when successful. #[pallet::call_index(5)] #[pallet::weight(::WeightInfo::remove_liquidity_one_asset() .saturating_add(T::Hooks::on_liquidity_changed_weight(MAX_ASSETS_IN_POOL as usize)))] @@ -631,11 +631,11 @@ pub mod pallet { }); //TODO: ask Martin to double check it - pallet_amm_support::Pallet::::deposit_trade_event( + pallet_support::Pallet::::deposit_trade_event( who, pool_account.clone(), - pallet_amm_support::types::Filler::Stableswap(pool_id.into()), - pallet_amm_support::types::TradeOperation::LiquidityRemove, + pallet_support::types::Filler::Stableswap(pool_id.into()), + pallet_support::types::TradeOperation::LiquidityRemove, vec![Asset::new(pool_id.into(), share_amount)], vec![Asset::new(asset_id.into(), amount)], vec![Fee { @@ -663,7 +663,7 @@ pub mod pallet { /// - 'max_share_amount': Slippage limit. Max amount of shares to burn. /// /// Emits `LiquidityRemoved` event when successful. - /// Emits `pallet_amm_support::Swapped` event when successful. + /// Emits `pallet_support::Swapped` event when successful. #[pallet::call_index(6)] #[pallet::weight(::WeightInfo::withdraw_asset_amount() .saturating_add(T::Hooks::on_liquidity_changed_weight(MAX_ASSETS_IN_POOL as usize)))] @@ -734,11 +734,11 @@ pub mod pallet { .zip(pool.assets.iter()) .map(|(balance, asset_id)| Fee::new((*asset_id).into(), *balance, pool_account.clone())) .collect::>(); - pallet_amm_support::Pallet::::deposit_trade_event( + pallet_support::Pallet::::deposit_trade_event( who, pool_account.clone(), - pallet_amm_support::types::Filler::Stableswap(pool_id.into()), - pallet_amm_support::types::TradeOperation::LiquidityRemove, + pallet_support::types::Filler::Stableswap(pool_id.into()), + pallet_support::types::TradeOperation::LiquidityRemove, vec![Asset::new(pool_id.into(), shares)], vec![Asset::new(asset_id.into(), amount)], fees, @@ -758,7 +758,7 @@ pub mod pallet { /// - `min_buy_amount`: Minimum amount required to receive /// /// Emits `SellExecuted` event when successful. Deprecated. - /// Emits `pallet_amm_support::Swapped` event when successful. + /// Emits `pallet_support::Swapped` event when successful. /// #[pallet::call_index(7)] #[pallet::weight(::WeightInfo::sell() @@ -817,11 +817,11 @@ pub mod pallet { fee: fee_amount, }); - pallet_amm_support::Pallet::::deposit_trade_event( + pallet_support::Pallet::::deposit_trade_event( who, pool_account.clone(), - pallet_amm_support::types::Filler::Stableswap(pool_id.into()), - pallet_amm_support::types::TradeOperation::ExactIn, + pallet_support::types::Filler::Stableswap(pool_id.into()), + pallet_support::types::TradeOperation::ExactIn, vec![Asset::new(asset_in.into(), amount_in)], vec![Asset::new(asset_out.into(), amount_out)], vec![Fee { @@ -848,7 +848,7 @@ pub mod pallet { /// - `max_sell_amount`: Maximum amount allowed to be sold /// /// Emits `BuyExecuted` event when successful. Deprecated. - /// Emits `pallet_amm_support::Swapped` event when successful. + /// Emits `pallet_support::Swapped` event when successful. /// #[pallet::call_index(8)] #[pallet::weight(::WeightInfo::buy() @@ -910,11 +910,11 @@ pub mod pallet { fee: fee_amount, }); - pallet_amm_support::Pallet::::deposit_trade_event( + pallet_support::Pallet::::deposit_trade_event( who, pool_account.clone(), - pallet_amm_support::types::Filler::Stableswap(pool_id.into()), - pallet_amm_support::types::TradeOperation::ExactOut, + pallet_support::types::Filler::Stableswap(pool_id.into()), + pallet_support::types::TradeOperation::ExactOut, vec![Asset::new(asset_in.into(), amount_in)], vec![Asset::new(asset_out.into(), amount_out)], vec![Fee { @@ -1273,11 +1273,11 @@ impl Pallet { .zip(pool.assets.iter()) .map(|(balance, asset_id)| Fee::new((*asset_id).into(), *balance, pool_account.clone())) .collect::>(); - pallet_amm_support::Pallet::::deposit_trade_event( + pallet_support::Pallet::::deposit_trade_event( who.clone(), pool_account.clone(), - pallet_amm_support::types::Filler::Stableswap(pool_id.into()), - pallet_amm_support::types::TradeOperation::LiquidityAdd, + pallet_support::types::Filler::Stableswap(pool_id.into()), + pallet_support::types::TradeOperation::LiquidityAdd, inputs, vec![Asset::new(pool_id.into(), share_amount)], fees, @@ -1338,11 +1338,11 @@ impl Pallet { //All done and update. let's call the on_liquidity_changed hook. Self::call_on_liquidity_change_hook(pool_id, &initial_reserves, share_issuance)?; - pallet_amm_support::Pallet::::deposit_trade_event( + pallet_support::Pallet::::deposit_trade_event( who.clone(), pool_account.clone(), - pallet_amm_support::types::Filler::Stableswap(pool_id.into()), - pallet_amm_support::types::TradeOperation::LiquidityAdd, + pallet_support::types::Filler::Stableswap(pool_id.into()), + pallet_support::types::TradeOperation::LiquidityAdd, vec![Asset::new(asset_id.into(), amount_in)], vec![Asset::new(pool_id.into(), shares)], vec![Fee { diff --git a/pallets/stableswap/src/tests/add_liquidity.rs b/pallets/stableswap/src/tests/add_liquidity.rs index 7c8241d42..a53acf075 100644 --- a/pallets/stableswap/src/tests/add_liquidity.rs +++ b/pallets/stableswap/src/tests/add_liquidity.rs @@ -2,7 +2,7 @@ use crate::tests::mock::*; use crate::types::{AssetAmount, PoolInfo}; use crate::{assert_balance, to_precision, Error}; use frame_support::{assert_noop, assert_ok, BoundedVec}; -use pallet_amm_support::types::{Asset, Fee}; +use pallet_support::types::{Asset, Fee}; use sp_runtime::Permill; use std::num::NonZeroU16; @@ -107,11 +107,11 @@ fn add_liquidity_should_emit_swapped_events() { pretty_assertions::assert_eq!( *get_last_swapped_events().last().unwrap(), - RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { swapper: BOB, filler: pool_account, - filler_type: pallet_amm_support::types::Filler::Stableswap(pool_id), - operation: pallet_amm_support::types::TradeOperation::LiquidityAdd, + filler_type:pallet_support::types::Filler::Stableswap(pool_id), + operation:pallet_support::types::TradeOperation::LiquidityAdd, inputs: vec![Asset::new(asset_a, 2000000000000000000),], outputs: vec![Asset::new(pool_id, 1947487201901031408)], fees: vec![ @@ -710,11 +710,11 @@ fn add_liquidity_should_work_correctly_when_providing_exact_amount_of_shares() { let pool_account = pool_account(pool_id); pretty_assertions::assert_eq!( *get_last_swapped_events().last().unwrap(), - RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { swapper: BOB, filler: pool_account, - filler_type: pallet_amm_support::types::Filler::Stableswap(pool_id), - operation: pallet_amm_support::types::TradeOperation::LiquidityAdd, + filler_type:pallet_support::types::Filler::Stableswap(pool_id), + operation:pallet_support::types::TradeOperation::LiquidityAdd, inputs: vec![Asset::new(asset_a, 2000000000000000003),], outputs: vec![Asset::new(pool_id, 1947597621401945851)], fees: vec![Fee::new(pool_id, 0, pool_account)], diff --git a/pallets/stableswap/src/tests/mock.rs b/pallets/stableswap/src/tests/mock.rs index 0161aa750..984059ee9 100644 --- a/pallets/stableswap/src/tests/mock.rs +++ b/pallets/stableswap/src/tests/mock.rs @@ -81,7 +81,7 @@ construct_runtime!( System: frame_system, Tokens: orml_tokens, Stableswap: pallet_stableswap, - AmmSupport: pallet_amm_support, + AmmSupport:pallet_support, } ); @@ -173,7 +173,7 @@ impl DustRemovalAccountWhitelist for Whitelist { } } -impl pallet_amm_support::Config for Test { +impl pallet_support::Config for Test { type RuntimeEvent = RuntimeEvent; } @@ -460,7 +460,7 @@ pub fn get_last_swapped_events() -> Vec { for event in last_events { let e = event.clone(); - if let RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { .. }) = e { + if let RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { .. }) = e { swapped_events.push(e); } } diff --git a/pallets/stableswap/src/tests/remove_liquidity.rs b/pallets/stableswap/src/tests/remove_liquidity.rs index fb09e2b3b..5b0ba13ed 100644 --- a/pallets/stableswap/src/tests/remove_liquidity.rs +++ b/pallets/stableswap/src/tests/remove_liquidity.rs @@ -3,7 +3,7 @@ use crate::types::{AssetAmount, PoolInfo}; use crate::{assert_balance, Error, Event, Pools}; use frame_support::traits::Contains; use frame_support::{assert_noop, assert_ok, BoundedVec}; -use pallet_amm_support::types::{Asset, Fee}; +use pallet_support::types::{Asset, Fee}; use sp_runtime::Permill; use std::num::NonZeroU16; @@ -75,11 +75,11 @@ fn remove_liquidity_should_work_when_withdrawing_all_shares() { pretty_assertions::assert_eq!( *get_last_swapped_events().last().unwrap(), - RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { swapper: BOB, filler: pool_account, - filler_type: pallet_amm_support::types::Filler::Stableswap(pool_id), - operation: pallet_amm_support::types::TradeOperation::LiquidityRemove, + filler_type:pallet_support::types::Filler::Stableswap(pool_id), + operation:pallet_support::types::TradeOperation::LiquidityRemove, inputs: vec![Asset::new(pool_id, 200516043533380244763),], outputs: vec![Asset::new(asset_c, 199999999999999)], fees: vec![Fee::new(pool_id, 0, pool_account)], @@ -1081,11 +1081,11 @@ fn removing_liquidity_with_exact_amount_should_emit_swapped_event() { pretty_assertions::assert_eq!( *get_last_swapped_events().last().unwrap(), - RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped { + RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { swapper: BOB, filler: pool_account, - filler_type: pallet_amm_support::types::Filler::Stableswap(4), - operation: pallet_amm_support::types::TradeOperation::LiquidityRemove, + filler_type:pallet_support::types::Filler::Stableswap(4), + operation:pallet_support::types::TradeOperation::LiquidityRemove, inputs: vec![Asset::new(pool_id, 979387928052053203)], outputs: vec![Asset::new(asset_a, 1000000000000000000),], fees: vec![ diff --git a/pallets/stableswap/src/tests/trades.rs b/pallets/stableswap/src/tests/trades.rs index 61be3159f..93dd888cd 100644 --- a/pallets/stableswap/src/tests/trades.rs +++ b/pallets/stableswap/src/tests/trades.rs @@ -4,7 +4,7 @@ use crate::{assert_balance, to_precision, Error, Event}; use std::num::NonZeroU16; use frame_support::{assert_noop, assert_ok}; -use pallet_amm_support::types::{Asset, Fee}; +use pallet_support::types::{Asset, Fee}; use sp_runtime::Permill; #[test] @@ -66,11 +66,11 @@ fn sell_should_work_when_correct_input_provided() { fee: 0, } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: BOB, filler: pool_account, - filler_type: pallet_amm_support::types::Filler::Stableswap(pool_id), - operation: pallet_amm_support::types::TradeOperation::ExactIn, + filler_type:pallet_support::types::Filler::Stableswap(pool_id), + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(asset_a, 30000000000000)], outputs: vec![Asset::new(asset_b, 29902625420922)], fees: vec![Fee::new(asset_b, 0, pool_account)], @@ -140,11 +140,11 @@ fn buy_should_work_when_correct_input_provided() { fee: 0, } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: BOB, filler: pool_account, - filler_type: pallet_amm_support::types::Filler::Stableswap(pool_id), - operation: pallet_amm_support::types::TradeOperation::ExactOut, + filler_type:pallet_support::types::Filler::Stableswap(pool_id), + operation:pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(asset_a, 30098072706882)], outputs: vec![Asset::new(asset_b, 30000000000000)], fees: vec![Fee::new(asset_a, 0, pool_account)], diff --git a/pallets/amm-support/Cargo.toml b/pallets/support/Cargo.toml similarity index 97% rename from pallets/amm-support/Cargo.toml rename to pallets/support/Cargo.toml index 91b88e29a..15589dc83 100644 --- a/pallets/amm-support/Cargo.toml +++ b/pallets/support/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "pallet-amm-support" +name = "pallet-support" version = "1.0.0" authors = ["GalacticCouncil"] edition = "2021" diff --git a/pallets/amm-support/README.md b/pallets/support/README.md similarity index 50% rename from pallets/amm-support/README.md rename to pallets/support/README.md index 20f239b78..702f20c02 100644 --- a/pallets/amm-support/README.md +++ b/pallets/support/README.md @@ -1,10 +1,3 @@ # AMM support pallet Support pallet for AMMs. Includes the unified event that is emitted by all AMM pallets. - -TODO - -OtcOrderId in filler etc and use u32 - - -otc pallet we dont need into<32>. instead use atleastu32Unsuged diff --git a/pallets/amm-support/src/lib.rs b/pallets/support/src/lib.rs similarity index 100% rename from pallets/amm-support/src/lib.rs rename to pallets/support/src/lib.rs diff --git a/pallets/amm-support/src/tests/incremental_id.rs b/pallets/support/src/tests/incremental_id.rs similarity index 100% rename from pallets/amm-support/src/tests/incremental_id.rs rename to pallets/support/src/tests/incremental_id.rs diff --git a/pallets/amm-support/src/tests/mock.rs b/pallets/support/src/tests/mock.rs similarity index 97% rename from pallets/amm-support/src/tests/mock.rs rename to pallets/support/src/tests/mock.rs index a3d0683af..a10ee6340 100644 --- a/pallets/amm-support/src/tests/mock.rs +++ b/pallets/support/src/tests/mock.rs @@ -15,7 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate as pallet_amm_support; +use crate as pallet_support; pub use crate::*; pub use frame_support::{ @@ -43,7 +43,7 @@ construct_runtime!( pub enum Test { System: frame_system, - AmmSupport: pallet_amm_support, + AmmSupport:pallet_support, } ); diff --git a/pallets/amm-support/src/tests/mod.rs b/pallets/support/src/tests/mod.rs similarity index 100% rename from pallets/amm-support/src/tests/mod.rs rename to pallets/support/src/tests/mod.rs diff --git a/pallets/amm-support/src/types.rs b/pallets/support/src/types.rs similarity index 100% rename from pallets/amm-support/src/types.rs rename to pallets/support/src/types.rs diff --git a/pallets/xyk/Cargo.toml b/pallets/xyk/Cargo.toml index b78d11c10..ba490041f 100644 --- a/pallets/xyk/Cargo.toml +++ b/pallets/xyk/Cargo.toml @@ -29,7 +29,7 @@ orml-traits = { workspace = true } # HydraDX dependencies hydradx-traits = { workspace = true } -pallet-amm-support = { workspace = true } +pallet-support = { workspace = true } # Substrate dependencies frame-benchmarking = { workspace = true, optional = true } @@ -66,6 +66,6 @@ std = [ 'frame-benchmarking/std', "scale-info/std", "pallet-asset-registry/std", - "pallet-amm-support/std", + "pallet-support/std", ] try-runtime = ["frame-support/try-runtime"] diff --git a/pallets/xyk/src/lib.rs b/pallets/xyk/src/lib.rs index eec5a83c2..4a57f6524 100644 --- a/pallets/xyk/src/lib.rs +++ b/pallets/xyk/src/lib.rs @@ -36,7 +36,7 @@ use hydradx_traits::{ AMMPosition, AMMTransfer, AssetPairAccountIdFor, CanCreatePool, OnCreatePoolHandler, OnLiquidityChangedHandler, OnTradeHandler, AMM, }; -use pallet_amm_support::types::{Asset, Fee}; +use pallet_support::types::{Asset, Fee}; use sp_std::{vec, vec::Vec}; @@ -78,7 +78,7 @@ pub mod pallet { impl Hooks> for Pallet {} #[pallet::config] - pub trait Config: frame_system::Config + pallet_amm_support::Config { + pub trait Config: frame_system::Config + pallet_support::Config { type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Registry support @@ -252,7 +252,7 @@ pub mod pallet { }, /// Asset sale executed. - /// Deprecated. Replaced by pallet_amm_support::Swapped + /// Deprecated. Replaced bypallet_support::Swapped SellExecuted { who: T::AccountId, asset_in: AssetId, @@ -265,7 +265,7 @@ pub mod pallet { }, /// Asset purchase executed. - /// Deprecated. Replaced by pallet_amm_support::Swapped + /// Deprecated. Replaced bypallet_support::Swapped BuyExecuted { who: T::AccountId, asset_out: AssetId, @@ -548,7 +548,7 @@ pub mod pallet { /// `max_limit` - minimum amount of `asset_out` / amount of asset_out to be obtained from the pool in exchange for `asset_in`. /// /// Emits `SellExecuted` when successful. Deprecated. - /// Emits `pallet_amm_support::Swapped` when successful. + /// Emits `pallet_support::Swapped` when successful. #[pallet::call_index(3)] #[pallet::weight(::WeightInfo::sell() + ::AMMHandler::on_trade_weight())] pub fn sell( @@ -572,7 +572,7 @@ pub mod pallet { /// /// `max_limit` - maximum amount of `asset_in` to be sold in exchange for `asset_out`. /// Emits `BuyExecuted` when successful. Deprecated. - /// Emits `pallet_amm_support::Swapped` when successful. + /// Emits `pallet_support::Swapped` when successful. #[pallet::call_index(4)] #[pallet::weight(::WeightInfo::buy() + ::AMMHandler::on_trade_weight())] pub fn buy( @@ -918,11 +918,11 @@ impl AMM for Pallet { pool: pair_account.clone(), }); - pallet_amm_support::Pallet::::deposit_trade_event( + pallet_support::Pallet::::deposit_trade_event( transfer.origin.clone(), pair_account.clone(), - pallet_amm_support::types::Filler::XYK(Self::share_token(&pair_account)), - pallet_amm_support::types::TradeOperation::ExactIn, + pallet_support::types::Filler::XYK(Self::share_token(&pair_account)), + pallet_support::types::TradeOperation::ExactIn, vec![Asset::new(transfer.assets.asset_in, transfer.amount)], vec![Asset::new(transfer.assets.asset_out, transfer.amount_b)], vec![Fee { @@ -1098,11 +1098,11 @@ impl AMM for Pallet { pool: pair_account.clone(), }); - pallet_amm_support::Pallet::::deposit_trade_event( + pallet_support::Pallet::::deposit_trade_event( transfer.origin.clone(), pair_account.clone(), - pallet_amm_support::types::Filler::XYK(Self::share_token(&pair_account)), - pallet_amm_support::types::TradeOperation::ExactOut, + pallet_support::types::Filler::XYK(Self::share_token(&pair_account)), + pallet_support::types::TradeOperation::ExactOut, vec![Asset::new(transfer.assets.asset_in, transfer.amount)], vec![Asset::new(transfer.assets.asset_out, transfer.amount_b)], vec![Fee { diff --git a/pallets/xyk/src/tests/fees.rs b/pallets/xyk/src/tests/fees.rs index baf2ec30d..a963ee69f 100644 --- a/pallets/xyk/src/tests/fees.rs +++ b/pallets/xyk/src/tests/fees.rs @@ -3,7 +3,7 @@ use crate::{Error, Event}; use frame_support::{assert_noop, assert_ok}; use hydradx_traits::AMM as AmmPool; use orml_traits::MultiCurrency; -use pallet_amm_support::types::{Asset, Fee}; +use pallet_support::types::{Asset, Fee}; use crate::types::AssetPair; @@ -146,11 +146,11 @@ fn discount_sell_fees_should_work() { pool: pair_account, } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: ALICE, filler: pair_account, - filler_type: pallet_amm_support::types::Filler::XYK(share_token), - operation: pallet_amm_support::types::TradeOperation::ExactIn, + filler_type:pallet_support::types::Filler::XYK(share_token), + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(asset_a, 10_000_000)], outputs: vec![Asset::new(asset_b, 19_986_006)], fees: vec![Fee::new(asset_b, 13_993, pair_account)], @@ -234,11 +234,11 @@ fn discount_sell_fees_should_work() { pool: pair_account, } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: ALICE, filler: pair_account, - filler_type: pallet_amm_support::types::Filler::XYK(share_token), - operation: pallet_amm_support::types::TradeOperation::ExactIn, + filler_type:pallet_support::types::Filler::XYK(share_token), + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(asset_a, 10_000_000)], outputs: vec![Asset::new(asset_b, 19_980_009)], fees: vec![Fee::new(asset_b, 19_990, pair_account)], @@ -317,11 +317,11 @@ fn discount_sell_fees_should_work() { pool: pair_account, } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: ALICE, filler: pair_account, - filler_type: pallet_amm_support::types::Filler::XYK(share_token), - operation: pallet_amm_support::types::TradeOperation::ExactIn, + filler_type:pallet_support::types::Filler::XYK(share_token), + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(asset_a, 10_000_000)], outputs: vec![Asset::new(asset_b, 19_999_999)], fees: vec![Fee::new(asset_b, 0, pair_account)], @@ -417,11 +417,11 @@ fn discount_buy_fees_should_work() { pool: pair_account, } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: ALICE, filler: pair_account, - filler_type: pallet_amm_support::types::Filler::XYK(share_token), - operation: pallet_amm_support::types::TradeOperation::ExactOut, + filler_type:pallet_support::types::Filler::XYK(share_token), + operation:pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(asset_b, 10_000_000)], outputs: vec![Asset::new(asset_a, 20_000_002)], fees: vec![Fee::new(asset_b, 14_000, pair_account)], @@ -509,11 +509,11 @@ fn discount_buy_fees_should_work() { pool: pair_account, } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: ALICE, filler: pair_account, - filler_type: pallet_amm_support::types::Filler::XYK(share_token), - operation: pallet_amm_support::types::TradeOperation::ExactOut, + filler_type:pallet_support::types::Filler::XYK(share_token), + operation:pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(asset_b, 10_000_000)], outputs: vec![Asset::new(asset_a, 20_000_002)], fees: vec![Fee::new(asset_b, 20_000, pair_account)], @@ -590,11 +590,11 @@ fn discount_buy_fees_should_work() { pool: pair_account, } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: ALICE, filler: pair_account, - filler_type: pallet_amm_support::types::Filler::XYK(share_token), - operation: pallet_amm_support::types::TradeOperation::ExactOut, + filler_type:pallet_support::types::Filler::XYK(share_token), + operation:pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(asset_b, 10_000_000)], outputs: vec![Asset::new(asset_a, 20_000_002)], fees: vec![Fee::new(asset_b, 0, pair_account)], diff --git a/pallets/xyk/src/tests/mock.rs b/pallets/xyk/src/tests/mock.rs index 08ecd9574..5109b8ffc 100644 --- a/pallets/xyk/src/tests/mock.rs +++ b/pallets/xyk/src/tests/mock.rs @@ -61,7 +61,7 @@ frame_support::construct_runtime!( XYK: xyk, Currency: orml_tokens, AssetRegistry: pallet_asset_registry, - AmmSupport: pallet_amm_support, + AmmSupport:pallet_support, } ); @@ -204,7 +204,7 @@ impl CanCreatePool for Disallow10_10Pool { } } -impl pallet_amm_support::Config for Test { +impl pallet_support::Config for Test { type RuntimeEvent = RuntimeEvent; } diff --git a/pallets/xyk/src/tests/trades.rs b/pallets/xyk/src/tests/trades.rs index 62880b55c..10f2c7d33 100644 --- a/pallets/xyk/src/tests/trades.rs +++ b/pallets/xyk/src/tests/trades.rs @@ -3,7 +3,7 @@ use crate::{AMMTransfer, Error, Event}; use frame_support::{assert_noop, assert_ok}; use hydradx_traits::AMM as AmmPool; use orml_traits::MultiCurrency; -use pallet_amm_support::types::{Asset, Fee}; +use pallet_support::types::{Asset, Fee}; use crate::types::AssetPair; @@ -71,11 +71,11 @@ fn sell_test() { pool: pair_account, } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: ALICE, filler: pair_account, - filler_type: pallet_amm_support::types::Filler::XYK(share_token), - operation: pallet_amm_support::types::TradeOperation::ExactIn, + filler_type:pallet_support::types::Filler::XYK(share_token), + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(asset_a, 456444678)], outputs: vec![Asset::new(asset_b, 1363483591788)], fees: vec![Fee::new(asset_b, 2732432046, pair_account)], @@ -135,11 +135,11 @@ fn execute_sell_should_use_event_id() { pool: pair_account, } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: ALICE, filler: pair_account, - filler_type: pallet_amm_support::types::Filler::XYK(share_token), - operation: pallet_amm_support::types::TradeOperation::ExactIn, + filler_type:pallet_support::types::Filler::XYK(share_token), + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(asset_a, 456444678)], outputs: vec![Asset::new(asset_b, 1363483591788)], fees: vec![Fee::new(asset_b, 2732432046, pair_account)], @@ -442,11 +442,11 @@ fn sell_with_correct_fees_should_work() { pool: pair_account, } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: user_1, filler: pair_account, - filler_type: pallet_amm_support::types::Filler::XYK(share_token), - operation: pallet_amm_support::types::TradeOperation::ExactIn, + filler_type:pallet_support::types::Filler::XYK(share_token), + operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(asset_a, 100_000)], outputs: vec![Asset::new(asset_b, 19_762_378)], fees: vec![Fee::new(asset_b, 39_602, pair_account)], @@ -660,11 +660,11 @@ fn single_buy_should_work() { pool: pair_account, } .into(), - pallet_amm_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: user_1, filler: pair_account, - filler_type: pallet_amm_support::types::Filler::XYK(share_token), - operation: pallet_amm_support::types::TradeOperation::ExactOut, + filler_type:pallet_support::types::Filler::XYK(share_token), + operation:pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(asset_b, 6_666_666)], outputs: vec![Asset::new(asset_a, 22_068_963_235)], fees: vec![Fee::new(asset_b, 44_137_926, pair_account)], diff --git a/runtime/adapters/Cargo.toml b/runtime/adapters/Cargo.toml index b09f40c3a..5963983cf 100644 --- a/runtime/adapters/Cargo.toml +++ b/runtime/adapters/Cargo.toml @@ -32,7 +32,7 @@ pallet-referrals = { workspace = true } pallet-lbp = { workspace = true } pallet-asset-registry = { workspace = true } pallet-bonds = { workspace = true } -pallet-amm-support = { workspace = true } +pallet-support = { workspace = true } # Substrate dependencies frame-support = { workspace = true } @@ -67,7 +67,7 @@ pallet-balances = { workspace = true } lazy_static = { workspace = true } pretty_assertions = { workspace = true } pallet-xyk = { workspace = true } -pallet-amm-support = { workspace = true } +pallet-support = { workspace = true } [features] default = ["std"] diff --git a/runtime/adapters/src/tests/mock.rs b/runtime/adapters/src/tests/mock.rs index b654be0d7..73edd8bb3 100644 --- a/runtime/adapters/src/tests/mock.rs +++ b/runtime/adapters/src/tests/mock.rs @@ -101,7 +101,7 @@ construct_runtime!( RouteExecutor: pallet_route_executor, Currencies: pallet_currencies, XYK: pallet_xyk, - AmmSupport: pallet_amm_support, + AmmSupport:pallet_support, } ); @@ -265,7 +265,7 @@ impl pallet_xyk::Config for Test { type NonDustableWhitelistHandler = DummyDuster; } -impl pallet_amm_support::Config for Test { +impl pallet_support::Config for Test { type RuntimeEvent = RuntimeEvent; } diff --git a/runtime/adapters/src/xcm_exchange.rs b/runtime/adapters/src/xcm_exchange.rs index 2348b34ee..d053b74d8 100644 --- a/runtime/adapters/src/xcm_exchange.rs +++ b/runtime/adapters/src/xcm_exchange.rs @@ -1,5 +1,5 @@ use orml_traits::MultiCurrency; -use pallet_amm_support::types::ExecutionType; +use pallet_support::types::ExecutionType; use polkadot_xcm::v4::prelude::*; use sp_core::Get; use sp_runtime::traits::{Convert, Zero}; @@ -64,7 +64,7 @@ where }; let use_onchain_route = vec![]; - pallet_amm_support::Pallet::::add_to_context(ExecutionType::XcmExchange).map_err(|_| give.clone())?; + pallet_support::Pallet::::add_to_context(ExecutionType::XcmExchange).map_err(|_| give.clone())?; let trade_result = if maximal { // sell @@ -135,7 +135,7 @@ where .map_err(|_| give.clone()) }; - pallet_amm_support::Pallet::::remove_from_context().map_err(|_| give)?; + pallet_support::Pallet::::remove_from_context().map_err(|_| give)?; trade_result } diff --git a/runtime/hydradx/Cargo.toml b/runtime/hydradx/Cargo.toml index 10c912ae3..48227602e 100644 --- a/runtime/hydradx/Cargo.toml +++ b/runtime/hydradx/Cargo.toml @@ -40,7 +40,7 @@ pallet-bonds = { workspace = true } pallet-lbp = { workspace = true } pallet-xyk = { workspace = true } pallet-referrals = { workspace = true } -pallet-amm-support = { workspace = true } +pallet-support = { workspace = true } pallet-evm-accounts = { workspace = true } pallet-evm-accounts-rpc-runtime-api = { workspace = true } pallet-xyk-liquidity-mining = { workspace = true } @@ -342,7 +342,7 @@ std = [ "pallet-conviction-voting/std", "pallet-referenda/std", "pallet-whitelist/std", - "pallet-amm-support/std", + "pallet-support/std", ] try-runtime = [ "frame-try-runtime", @@ -418,7 +418,7 @@ try-runtime = [ "pallet-conviction-voting/try-runtime", "pallet-referenda/try-runtime", "pallet-whitelist/try-runtime", - "pallet-amm-support/try-runtime", + "pallet-support/try-runtime", ] metadata-hash = [ diff --git a/runtime/hydradx/src/assets.rs b/runtime/hydradx/src/assets.rs index 399fa6cfc..315c93592 100644 --- a/runtime/hydradx/src/assets.rs +++ b/runtime/hydradx/src/assets.rs @@ -1637,7 +1637,7 @@ impl pallet_liquidation::Config for Runtime { type WeightInfo = weights::pallet_liquidation::HydraWeight; } -impl pallet_amm_support::Config for Runtime { +impl pallet_support::Config for Runtime { type RuntimeEvent = RuntimeEvent; } diff --git a/runtime/hydradx/src/lib.rs b/runtime/hydradx/src/lib.rs index ecff9da0d..1ea058252 100644 --- a/runtime/hydradx/src/lib.rs +++ b/runtime/hydradx/src/lib.rs @@ -240,7 +240,7 @@ construct_runtime!( // Warehouse - let's allocate indices 100+ for warehouse pallets EmaOracle: pallet_ema_oracle = 202, - AmmSupport: pallet_amm_support = 204, + AmmSupport:pallet_support = 204, } ); diff --git a/runtime/hydradx/src/system.rs b/runtime/hydradx/src/system.rs index b1dd4aad6..1d02b9624 100644 --- a/runtime/hydradx/src/system.rs +++ b/runtime/hydradx/src/system.rs @@ -47,7 +47,7 @@ use frame_support::{ }; use frame_system::EnsureRoot; use hydradx_adapters::{OraclePriceProvider, RelayChainBlockNumberProvider}; -use pallet_amm_support::types::ExecutionType; +use pallet_support::types::ExecutionType; use pallet_utility::BatchHook; use scale_info::TypeInfo; use sp_runtime::DispatchResult; diff --git a/runtime/hydradx/src/xcm.rs b/runtime/hydradx/src/xcm.rs index fa3711f35..53d4f8c5b 100644 --- a/runtime/hydradx/src/xcm.rs +++ b/runtime/hydradx/src/xcm.rs @@ -246,14 +246,14 @@ impl::RuntimeCall>> ExecuteXcm<::add_to_context(|event_id| ExecutionType::Xcm(unique_id, event_id)) + pallet_support::Pallet::::add_to_context(|event_id| ExecutionType::Xcm(unique_id, event_id)) .map_err(|_| message.clone())?; let prepare_result = Inner::prepare(message); //In case of error we need to clean context as xcm execution won't happen if prepare_result.is_err() { - let _ = pallet_amm_support::Pallet::::remove_from_context(); + let _ =pallet_support::Pallet::::remove_from_context(); } prepare_result @@ -267,7 +267,7 @@ impl::RuntimeCall>> ExecuteXcm< Outcome { let outcome = Inner::execute(origin, pre, id, weight_credit); - let Ok(_) = pallet_amm_support::Pallet::::remove_from_context() else { + let Ok(_) =pallet_support::Pallet::::remove_from_context() else { return Outcome::Error { error: XcmError::FailedToTransactAsset("Unexpected error at modifying unified events stack"), }; @@ -485,7 +485,7 @@ pub type LocationToAccountId = ( // Convert ETH to local substrate account EvmAddressConversion, ); -use pallet_amm_support::types::ExecutionType; +use pallet_support::types::ExecutionType; use xcm_executor::traits::{ConvertLocation, XcmAssetTransfers}; /// Converts Account20 (ethereum) addresses to AccountId32 (substrate) addresses. From e43cba96b8f2f73340a0b5c2e15ce42dd87d669e Mon Sep 17 00:00:00 2001 From: dmoka Date: Tue, 31 Dec 2024 08:55:05 +0100 Subject: [PATCH 114/142] fix failing test --- integration-tests/src/exchange_asset.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/integration-tests/src/exchange_asset.rs b/integration-tests/src/exchange_asset.rs index 27291eb95..3222efaaa 100644 --- a/integration-tests/src/exchange_asset.rs +++ b/integration-tests/src/exchange_asset.rs @@ -128,8 +128,9 @@ fn hydra_should_swap_assets_when_receiving_from_acala_with_sell() { let last_swapped_events = get_last_swapped_events(); let last_two_swapped_events = &last_swapped_events[last_swapped_events.len() - 2..]; let topic_id = [ - 88, 96, 17, 161, 1, 110, 221, 66, 135, 183, 36, 117, 203, 64, 121, 121, 144, 130, 127, 130, 11, 90, 144, - 184, 162, 244, 249, 80, 95, 193, 189, 200, + 180, 44, 225, 230, 61, 43, 219, 219, 222, 9, 44, 219, 86, 193, 219, + 212, 120, 169, 197, 209, 39, 180, 219, 225, 224, 182, 134, 141, 41, + 162, 96, 54 ]; pretty_assertions::assert_eq!( last_two_swapped_events, From 7f3b92d8b8842e63680a21c48224d07fb6ba782d Mon Sep 17 00:00:00 2001 From: dmoka Date: Tue, 31 Dec 2024 09:13:38 +0100 Subject: [PATCH 115/142] fix failing test --- integration-tests/src/xcm.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/integration-tests/src/xcm.rs b/integration-tests/src/xcm.rs index d3050e52c..7079c6514 100644 --- a/integration-tests/src/xcm.rs +++ b/integration-tests/src/xcm.rs @@ -280,6 +280,11 @@ fn xcm_call_should_populate_unified_event_call_context() { let swapped_events = get_last_swapped_events(); let last_two_swapped_events = &get_last_swapped_events()[swapped_events.len() - 2..]; + let topic_id = [ + 162, 58, 237, 167, 26, 250, 26, 161, 116, 182, 7, 12, 84, 48, 100, + 53, 175, 60, 179, 213, 59, 7, 83, 150, 136, 112, 126, 15, 199, 223, + 71, 230 + ]; pretty_assertions::assert_eq!( last_two_swapped_events, vec![ @@ -293,10 +298,7 @@ fn xcm_call_should_populate_unified_event_call_context() { fees: vec![Fee::new(LRNA, 600749, Omnipool::protocol_account()),], operation_stack: vec![ ExecutionType::Xcm( - [ - 237, 209, 186, 1, 116, 50, 158, 190, 169, 150, 18, 38, 37, 51, 136, 30, 219, 60, 5, - 253, 212, 209, 227, 230, 38, 183, 105, 62, 69, 234, 5, 249, - ], + topic_id, 0 ), ExecutionType::Omnipool(1) @@ -312,10 +314,7 @@ fn xcm_call_should_populate_unified_event_call_context() { fees: vec![Fee::new(DAI, 66716518113453, Omnipool::protocol_account()),], operation_stack: vec![ ExecutionType::Xcm( - [ - 237, 209, 186, 1, 116, 50, 158, 190, 169, 150, 18, 38, 37, 51, 136, 30, 219, 60, 5, - 253, 212, 209, 227, 230, 38, 183, 105, 62, 69, 234, 5, 249, - ], + topic_id, 0 ), ExecutionType::Omnipool(1) From ff7b18bb84657df2e00309f6336a49e925694a93 Mon Sep 17 00:00:00 2001 From: dmoka Date: Tue, 31 Dec 2024 13:03:34 +0100 Subject: [PATCH 116/142] WIP - separate normal, staking and referral fee --- integration-tests/src/referrals.rs | 75 ++++++++++++++++++++++- pallets/circuit-breaker/src/tests/mock.rs | 4 +- pallets/omnipool/src/lib.rs | 63 ++++++++++--------- pallets/omnipool/src/tests/mock.rs | 9 +-- pallets/omnipool/src/tests/sell.rs | 4 +- pallets/omnipool/src/traits.rs | 9 +-- pallets/referrals/src/lib.rs | 10 +-- pallets/staking/src/lib.rs | 8 +-- runtime/adapters/src/lib.rs | 14 +++-- 9 files changed, 136 insertions(+), 60 deletions(-) diff --git a/integration-tests/src/referrals.rs b/integration-tests/src/referrals.rs index 815e06ae2..bc82ec1cf 100644 --- a/integration-tests/src/referrals.rs +++ b/integration-tests/src/referrals.rs @@ -349,7 +349,7 @@ fn trading_in_omnipool_should_use_asset_rewards_when_set() { operation: TradeOperation::ExactIn, inputs: vec![Asset::new(LRNA, 1205165959)], outputs: vec![Asset::new(DAI, 26663424573622008)], - fees: vec![Fee::new(DAI, 70524156750724, Omnipool::protocol_account())], + fees: vec![Fee::new(DAI, 61356016373131, Omnipool::protocol_account()), Fee::new(DAI, 9168140377593, Referrals::pot_account_id())], operation_stack: vec![ExecutionType::Omnipool(0)], } .into(), @@ -406,7 +406,7 @@ fn buying_hdx_in_omnipool_should_transfer_correct_fee() { operation: TradeOperation::ExactOut, inputs: vec![Asset::new(LRNA, 1_209_141_304)], outputs: vec![Asset::new(HDX, 1_000_000_000_000)], - fees: vec![Fee::new(HDX, 2_794_789_078, Omnipool::protocol_account())], + fees: vec![Fee::new(HDX, 1, Omnipool::protocol_account()), Fee::new(HDX, 2794789077, Staking::pot_account_id())], operation_stack: vec![ExecutionType::Omnipool(0)], } .into(), @@ -419,6 +419,67 @@ fn buying_hdx_in_omnipool_should_transfer_correct_fee() { }); } +#[test] +fn buying_asset_should_result_in_splitted_trade_fees() { + Hydra::execute_with(|| { + init_omnipool_with_oracle_for_block_12(); + assert_ok!(Staking::initialize_staking(RawOrigin::Root.into())); + let staking_acc = Staking::pot_account_id(); + let ref_account = Referrals::pot_account_id(); + let orig_balance = Currencies::free_balance(DAI, &ref_account); + let stak_orig_balance = Currencies::free_balance(HDX, &staking_acc); + assert_ok!(Omnipool::buy( + RuntimeOrigin::signed(BOB.into()), + ETH, + DAI, + 1_000_000_000_000, + u128::MAX, + )); + + expect_hydra_last_events(vec![ + pallet_omnipool::Event::BuyExecuted { + who: BOB.into(), + asset_in: DAI, + asset_out: ETH, + amount_in: 26835579541620354, + amount_out: 1_000_000_000_000, + hub_amount_in: 45135, + hub_amount_out: 45113, + asset_fee_amount: 2506265665, + protocol_fee_amount: 22, + } + .into(), + pallet_support::Event::Swapped { + swapper: BOB.into(), + filler: Omnipool::protocol_account(), + filler_type: Filler::Omnipool, + operation: TradeOperation::ExactOut, + inputs: vec![Asset::new(DAI, 1001220962719)], + outputs: vec![Asset::new(LRNA, 45135)], + fees: vec![Fee::new(LRNA, 22, Omnipool::protocol_account())], + operation_stack: vec![ExecutionType::Omnipool(0)], + } + .into(), + pallet_support::Event::Swapped { + swapper: BOB.into(), + filler: Omnipool::protocol_account(), + filler_type: Filler::Omnipool, + operation: TradeOperation::ExactOut, + inputs: vec![Asset::new(LRNA, 45113)], + outputs: vec![Asset::new(ETH, 1_000_000_000_000)], + fees: vec![Fee::new(ETH, 1253132833, Omnipool::protocol_account()), Fee::new(ETH, 1253132832, Referrals::pot_account_id())], + operation_stack: vec![ExecutionType::Omnipool(0)], + } + .into(), + ]); + + let ref_dai_balance = Currencies::free_balance(DAI, &ref_account); + let staking_balance = Currencies::free_balance(HDX, &staking_acc); + assert_eq!(ref_dai_balance.abs_diff(orig_balance), 0); + assert_eq!(staking_balance.abs_diff(stak_orig_balance), 2_794_789_077); + }); +} + #[test] fn buying_with_hdx_in_omnipool_should_transfer_correct_fee() { Hydra::execute_with(|| { @@ -467,7 +528,7 @@ fn buying_with_hdx_in_omnipool_should_transfer_correct_fee() { operation:pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(LRNA, 45_200_101_724)], outputs: vec![Asset::new(DAI, 1_000_000_000_000_000_000)], - fees: vec![Fee::new(DAI, 2_644_977_450_514_458, Omnipool::protocol_account())], + fees: vec![Fee::new(DAI, 1322488725257230, Omnipool::protocol_account()), Fee::new(DAI, 1322488725257228, Referrals::pot_account_id())], operation_stack: vec![ExecutionType::Omnipool(0)], } .into(), @@ -551,6 +612,14 @@ fn init_omnipool() { AccountId::from(ALICE), )); + assert_ok!(hydradx_runtime::Omnipool::add_token( + hydradx_runtime::RuntimeOrigin::root(), + ETH, + stable_price, + Permill::from_percent(100), + AccountId::from(ALICE), + )); + assert_ok!(hydradx_runtime::Omnipool::sacrifice_position( hydradx_runtime::RuntimeOrigin::signed(ALICE.into()), native_position_id, diff --git a/pallets/circuit-breaker/src/tests/mock.rs b/pallets/circuit-breaker/src/tests/mock.rs index 5dd22fae0..1fa7f5727 100644 --- a/pallets/circuit-breaker/src/tests/mock.rs +++ b/pallets/circuit-breaker/src/tests/mock.rs @@ -318,8 +318,8 @@ where _trader: AccountId, _asset: AssetId, _amount: Balance, - ) -> Result { - Ok(Balance::zero()) + ) -> Result>, Self::Error> { + Ok(vec![]) } } diff --git a/pallets/omnipool/src/lib.rs b/pallets/omnipool/src/lib.rs index 28b74be17..c6a52fd3f 100644 --- a/pallets/omnipool/src/lib.rs +++ b/pallets/omnipool/src/lib.rs @@ -1072,7 +1072,7 @@ pub mod pallet { Self::update_hdx_subpool_hub_asset(origin, state_changes.hdx_hub_amount)?; - Self::process_trade_fee(&who, asset_out, state_changes.fee.asset_fee)?; + let trade_fees = Self::process_trade_fee(&who, asset_out, state_changes.fee.asset_fee)?; debug_assert!(*state_changes.asset_in.delta_hub_reserve >= *state_changes.asset_out.delta_hub_reserve); debug_assert_eq!( @@ -1094,6 +1094,7 @@ pub mod pallet { pallet_support::Pallet::::add_to_context(ExecutionType::Omnipool)?; + //Swapped event for AssetA to HubAsset pallet_support::Pallet::::deposit_trade_event( who.clone(), @@ -1123,11 +1124,7 @@ pub mod pallet { *state_changes.asset_out.delta_hub_reserve, )], vec![Asset::new(asset_out.into(), *state_changes.asset_out.delta_reserve)], - vec![Fee { - asset: asset_out.into(), - amount: state_changes.fee.asset_fee, - recipient: Self::protocol_account(), - }], + trade_fees ); pallet_support::Pallet::::remove_from_context()?; @@ -1317,7 +1314,7 @@ pub mod pallet { Self::update_hdx_subpool_hub_asset(origin, state_changes.hdx_hub_amount)?; - Self::process_trade_fee(&who, asset_out, state_changes.fee.asset_fee)?; + let trade_fees = Self::process_trade_fee(&who, asset_out, state_changes.fee.asset_fee)?; debug_assert!(*state_changes.asset_in.delta_hub_reserve >= *state_changes.asset_out.delta_hub_reserve); debug_assert_eq!( @@ -1368,11 +1365,7 @@ pub mod pallet { *state_changes.asset_out.delta_hub_reserve, )], vec![Asset::new(asset_out.into(), *state_changes.asset_out.delta_reserve)], - vec![Fee { - asset: asset_out.into(), - amount: state_changes.fee.asset_fee, - recipient: Self::protocol_account(), - }], + trade_fees, ); pallet_support::Pallet::::remove_from_context()?; @@ -1880,7 +1873,7 @@ impl Pallet { Self::set_asset_state(asset_out, new_asset_out_state); - Self::process_trade_fee(who, asset_out, state_changes.fee.asset_fee)?; + let trade_fees = Self::process_trade_fee(who, asset_out, state_changes.fee.asset_fee)?; // TODO: Deprecated, remove when ready Self::deposit_event(Event::SellExecuted { @@ -1907,11 +1900,7 @@ impl Pallet { *state_changes.asset.delta_hub_reserve, )], vec![Asset::new(asset_out.into(), *state_changes.asset.delta_reserve)], - vec![Fee { - asset: asset_out.into(), - amount: state_changes.fee.asset_fee, - recipient: Self::protocol_account(), - }], + trade_fees, ); T::OmnipoolHooks::on_hub_asset_trade(origin, info)?; @@ -2007,7 +1996,7 @@ impl Pallet { Self::set_asset_state(asset_out, new_asset_out_state); - Self::process_trade_fee(who, asset_out, state_changes.fee.asset_fee)?; + let trade_fees = Self::process_trade_fee(who, asset_out, state_changes.fee.asset_fee)?; // TODO: Deprecated, remove when ready Self::deposit_event(Event::BuyExecuted { @@ -2033,11 +2022,7 @@ impl Pallet { *state_changes.asset.delta_hub_reserve, )], vec![Asset::new(asset_out.into(), *state_changes.asset.delta_reserve)], - vec![Fee { - asset: asset_out.into(), - amount: state_changes.fee.asset_fee, - recipient: Self::protocol_account(), - }], + trade_fees, ); T::OmnipoolHooks::on_hub_asset_trade(origin, info)?; @@ -2140,18 +2125,40 @@ impl Pallet { } /// Calls `on_trade_fee` hook and ensures that no more than the fee amount is transferred. - fn process_trade_fee(trader: &T::AccountId, asset: T::AssetId, amount: Balance) -> DispatchResult { + fn process_trade_fee(trader: &T::AccountId, asset: T::AssetId, amount: Balance) -> Result>, DispatchError> { let account = Self::protocol_account(); let original_asset_reserve = T::Currency::free_balance(asset, &account); // Let's give little bit less to process. Subtracting one due to potential rounding errors let allowed_amount = amount.saturating_sub(Balance::one()); - let used = T::OmnipoolHooks::on_trade_fee(account.clone(), trader.clone(), asset, allowed_amount)?; + let fees = T::OmnipoolHooks::on_trade_fee(account.clone(), trader.clone(), asset, allowed_amount)?; + let additional_fees_total: Balance = fees.clone() + .into_iter() + .filter_map(|opt| opt.map(|(balance, _)| balance)) + .sum(); + let asset_reserve = T::Currency::free_balance(asset, &account); let diff = original_asset_reserve.saturating_sub(asset_reserve); ensure!(diff <= allowed_amount, Error::::FeeOverdraft); - ensure!(diff == used, Error::::FeeOverdraft); - Ok(()) + ensure!(diff == additional_fees_total, Error::::FeeOverdraft); + + let normal_trade_fee = amount.saturating_sub(additional_fees_total); + + let mut all_trade_fees = vec![Fee { + asset: asset.into(), + amount: normal_trade_fee, + recipient: Self::protocol_account(), + }]; + + let additional_fee_entries : Vec> = fees + .iter() + .filter_map(|opt| opt.clone().map(|(balance, recipient)| Fee::new(asset.into(), balance, recipient.clone()))) + .filter(|fee| fee.amount > 0) //filter out when we zero percentage is configured for fees + .collect(); + + all_trade_fees.extend(additional_fee_entries); + + Ok(all_trade_fees) } pub fn process_hub_amount(amount: Balance, dest: &T::AccountId) -> DispatchResult { diff --git a/pallets/omnipool/src/tests/mock.rs b/pallets/omnipool/src/tests/mock.rs index 6ebd1a958..6d571d722 100644 --- a/pallets/omnipool/src/tests/mock.rs +++ b/pallets/omnipool/src/tests/mock.rs @@ -725,15 +725,10 @@ impl OmnipoolHooks for MockHooks { Weight::zero() } - fn on_trade_fee( - fee_account: AccountId, - _trader: AccountId, - asset: AssetId, - amount: Balance, - ) -> Result { + fn on_trade_fee(fee_account: AccountId, _trader: AccountId, asset: AssetId, amount: Balance) -> Result>, Self::Error> { let percentage = ON_TRADE_WITHDRAWAL.with(|v| *v.borrow()); let to_take = percentage.mul_floor(amount); Tokens::withdraw(asset, &fee_account, to_take)?; - Ok(to_take) + Ok(vec![Some((to_take, AccountId::default()))]) } } diff --git a/pallets/omnipool/src/tests/sell.rs b/pallets/omnipool/src/tests/sell.rs index 658e82c86..afb4b6b71 100644 --- a/pallets/omnipool/src/tests/sell.rs +++ b/pallets/omnipool/src/tests/sell.rs @@ -718,6 +718,7 @@ fn sell_should_get_same_amount() { .with_initial_pool(FixedU128::from(1), FixedU128::from(1)) .with_token(100, FixedU128::from(1), LP2, 2000 * ONE) .with_token(200, FixedU128::from(1), LP3, 2000 * ONE) + .with_on_trade_withdrawal(Permill::from_percent(1)) .build() .execute_with(|| { let buy_amount = 50 * ONE; @@ -762,7 +763,8 @@ fn sell_should_get_same_amount() { operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(LRNA, 57142857142858)], outputs: vec![Asset::new(200, buy_amount)], - fees: vec![Fee::new(200, 5555555555556, Omnipool::protocol_account())], + fees: vec![Fee::new(200, 5500000000001, Omnipool::protocol_account()), + Fee::new(200, 55555555555, 0)], operation_stack: vec![ExecutionType::Omnipool(0)], } .into(), diff --git a/pallets/omnipool/src/traits.rs b/pallets/omnipool/src/traits.rs index d4ac40f1a..0b7e66b0f 100644 --- a/pallets/omnipool/src/traits.rs +++ b/pallets/omnipool/src/traits.rs @@ -7,7 +7,8 @@ use hydra_dx_math::omnipool::types::AssetStateChange; use sp_runtime::traits::{CheckedAdd, CheckedMul, Get, Saturating, Zero}; use sp_runtime::{DispatchError, FixedPointNumber, FixedU128, Permill}; use sp_std::fmt::Debug; - +use sp_std::vec::Vec; +use sp_std::vec; /// Asset In/Out information used in hooks. pub struct AssetInfo where @@ -64,7 +65,7 @@ where trader: AccountId, asset: AssetId, amount: Balance, - ) -> Result; + ) -> Result>, Self::Error>; } // Default implementation for no-op hooks. @@ -103,8 +104,8 @@ where _trader: AccountId, _asset: AssetId, _amount: Balance, - ) -> Result { - Ok(Balance::zero()) + ) -> Result>, Self::Error> { + Ok(vec![]) } } diff --git a/pallets/referrals/src/lib.rs b/pallets/referrals/src/lib.rs index 57871655b..3a88edf08 100644 --- a/pallets/referrals/src/lib.rs +++ b/pallets/referrals/src/lib.rs @@ -639,17 +639,17 @@ impl Pallet { /// `source`: account to take the fee from /// `trader`: account that does the trade /// - /// Returns used amount on success. + /// Returns used amount and recipient on success. #[transactional] pub fn process_trade_fee( source: T::AccountId, trader: T::AccountId, asset_id: T::AssetId, amount: Balance, - ) -> Result { + ) -> Result, DispatchError> { let Some(price) = T::PriceProvider::get_price(T::RewardAsset::get(), asset_id.clone()) else { // no price, no fun. - return Ok(Balance::zero()); + return Ok(None); }; let (level, ref_account) = if let Some(acc) = Self::linked_referral_account(&trader) { @@ -658,7 +658,7 @@ impl Pallet { (level, Some(acc)) } else { defensive!("Referrer details not found"); - return Ok(Balance::zero()); + return Ok(None); } } else { (Level::None, None) @@ -739,6 +739,6 @@ impl Pallet { PendingConversions::::insert(asset_id, ()); } - Ok(total_taken) + Ok(Some((total_taken, Self::pot_account_id()))) } } diff --git a/pallets/staking/src/lib.rs b/pallets/staking/src/lib.rs index 26f1f9197..fd4babcf0 100644 --- a/pallets/staking/src/lib.rs +++ b/pallets/staking/src/lib.rs @@ -961,17 +961,17 @@ impl Pallet { } /// Transfer given fee to pot account. - /// Returns amount of unused fee. + /// Returns amount of unused fee and its recipient. pub fn process_trade_fee( source: T::AccountId, asset: T::AssetId, amount: Balance, - ) -> Result { + ) -> Result, DispatchError> { if asset == T::NativeAssetId::get() && Self::is_initialized() { T::Currency::transfer(asset, &source, &Self::pot_account_id(), amount)?; - Ok(amount) + Ok(Some((amount, Self::pot_account_id()))) } else { - Ok(Balance::zero()) + Ok(None) } } diff --git a/runtime/adapters/src/lib.rs b/runtime/adapters/src/lib.rs index ab6240ef0..a35bdc6ab 100644 --- a/runtime/adapters/src/lib.rs +++ b/runtime/adapters/src/lib.rs @@ -59,6 +59,7 @@ use xcm_executor::{ traits::{ConvertLocation, MatchesFungible, TransactAsset, WeightTrader}, AssetsInHolding, }; +use sp_std::vec; pub mod inspect; pub mod price; @@ -335,7 +336,7 @@ where NativeAsset: Get, Runtime: pallet_ema_oracle::Config + pallet_circuit_breaker::Config - + frame_system::Config + + frame_system::Config + pallet_staking::Config + pallet_referrals::Config, ::AccountId: From, @@ -472,12 +473,12 @@ where trader: AccountId, asset: AssetId, amount: Balance, - ) -> Result { + ) -> Result>, Self::Error> { if asset == Lrna::get() { - return Ok(Balance::zero()); + return Ok(vec![]); } let referrals_used = if asset == NativeAsset::get() { - Balance::zero() + None } else { pallet_referrals::Pallet::::process_trade_fee( fee_account.clone().into(), @@ -487,12 +488,13 @@ where )? }; + let referral_amount = referrals_used.clone().map(|(balance, _)| balance).unwrap_or_default(); let staking_used = pallet_staking::Pallet::::process_trade_fee( fee_account.into(), asset.into(), - amount.saturating_sub(referrals_used), + amount.saturating_sub(referral_amount), )?; - Ok(staking_used.saturating_add(referrals_used)) + Ok(vec![staking_used, referrals_used]) } } From 20c336363b10efa2e26fa7446de6e58a4c7560a6 Mon Sep 17 00:00:00 2001 From: dmoka Date: Thu, 2 Jan 2025 09:28:00 +0100 Subject: [PATCH 117/142] remove unnecessary test --- integration-tests/src/referrals.rs | 61 ------------------------------ 1 file changed, 61 deletions(-) diff --git a/integration-tests/src/referrals.rs b/integration-tests/src/referrals.rs index bc82ec1cf..dcbe660e2 100644 --- a/integration-tests/src/referrals.rs +++ b/integration-tests/src/referrals.rs @@ -419,67 +419,6 @@ fn buying_hdx_in_omnipool_should_transfer_correct_fee() { }); } -#[test] -fn buying_asset_should_result_in_splitted_trade_fees() { - Hydra::execute_with(|| { - init_omnipool_with_oracle_for_block_12(); - assert_ok!(Staking::initialize_staking(RawOrigin::Root.into())); - let staking_acc = Staking::pot_account_id(); - let ref_account = Referrals::pot_account_id(); - let orig_balance = Currencies::free_balance(DAI, &ref_account); - let stak_orig_balance = Currencies::free_balance(HDX, &staking_acc); - assert_ok!(Omnipool::buy( - RuntimeOrigin::signed(BOB.into()), - ETH, - DAI, - 1_000_000_000_000, - u128::MAX, - )); - - expect_hydra_last_events(vec![ - pallet_omnipool::Event::BuyExecuted { - who: BOB.into(), - asset_in: DAI, - asset_out: ETH, - amount_in: 26835579541620354, - amount_out: 1_000_000_000_000, - hub_amount_in: 45135, - hub_amount_out: 45113, - asset_fee_amount: 2506265665, - protocol_fee_amount: 22, - } - .into(), - pallet_support::Event::Swapped { - swapper: BOB.into(), - filler: Omnipool::protocol_account(), - filler_type: Filler::Omnipool, - operation: TradeOperation::ExactOut, - inputs: vec![Asset::new(DAI, 1001220962719)], - outputs: vec![Asset::new(LRNA, 45135)], - fees: vec![Fee::new(LRNA, 22, Omnipool::protocol_account())], - operation_stack: vec![ExecutionType::Omnipool(0)], - } - .into(), - pallet_support::Event::Swapped { - swapper: BOB.into(), - filler: Omnipool::protocol_account(), - filler_type: Filler::Omnipool, - operation: TradeOperation::ExactOut, - inputs: vec![Asset::new(LRNA, 45113)], - outputs: vec![Asset::new(ETH, 1_000_000_000_000)], - fees: vec![Fee::new(ETH, 1253132833, Omnipool::protocol_account()), Fee::new(ETH, 1253132832, Referrals::pot_account_id())], - operation_stack: vec![ExecutionType::Omnipool(0)], - } - .into(), - ]); - - let ref_dai_balance = Currencies::free_balance(DAI, &ref_account); - let staking_balance = Currencies::free_balance(HDX, &staking_acc); - assert_eq!(ref_dai_balance.abs_diff(orig_balance), 0); - assert_eq!(staking_balance.abs_diff(stak_orig_balance), 2_794_789_077); - }); -} - #[test] fn buying_with_hdx_in_omnipool_should_transfer_correct_fee() { Hydra::execute_with(|| { From 9d72e4201cf5ec81bfdbffc14073ec368f9e15d2 Mon Sep 17 00:00:00 2001 From: dmoka Date: Thu, 2 Jan 2025 10:13:12 +0100 Subject: [PATCH 118/142] fix otc filler/swapper of swapped event --- pallets/otc-settlements/src/tests.rs | 4 ++-- pallets/otc/src/lib.rs | 2 +- pallets/otc/src/tests/partial_fill_order.rs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pallets/otc-settlements/src/tests.rs b/pallets/otc-settlements/src/tests.rs index fb20a4dff..905d682b7 100644 --- a/pallets/otc-settlements/src/tests.rs +++ b/pallets/otc-settlements/src/tests.rs @@ -301,8 +301,8 @@ fn existing_arb_opportunity_should_trigger_trade_when_correct_amount_can_be_foun } .into(), pallet_support::Event::Swapped { - swapper: OtcSettlements::account_id(), - filler: otc.owner, + swapper: otc.owner, + filler: OtcSettlements::account_id(), filler_type:pallet_support::types::Filler::OTC(otc_id), operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(HDX, 2413749694825193)], diff --git a/pallets/otc/src/lib.rs b/pallets/otc/src/lib.rs index 8e0f5072d..e997bd289 100644 --- a/pallets/otc/src/lib.rs +++ b/pallets/otc/src/lib.rs @@ -311,8 +311,8 @@ pub mod pallet { }); pallet_support::Pallet::::deposit_trade_event( - who, order.owner.clone(), + who, pallet_support::types::Filler::OTC(order_id), pallet_support::types::TradeOperation::ExactIn, vec![Asset::new(order.asset_in.into(), amount_in)], diff --git a/pallets/otc/src/tests/partial_fill_order.rs b/pallets/otc/src/tests/partial_fill_order.rs index 7920c0cac..eaf4a54d0 100644 --- a/pallets/otc/src/tests/partial_fill_order.rs +++ b/pallets/otc/src/tests/partial_fill_order.rs @@ -95,8 +95,8 @@ fn partial_fill_order_should_work_when_order_is_partially_fillable() { } .into(), pallet_support::Event::Swapped { - swapper: BOB, - filler: order.owner, + swapper:order.owner , + filler: BOB, filler_type:pallet_support::types::Filler::OTC(order_id), operation:pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(order.asset_in, 5 * ONE)], From 5fb58c21b932415efefd8d315790d3a15a3c8e80 Mon Sep 17 00:00:00 2001 From: dmoka Date: Thu, 2 Jan 2025 10:22:37 +0100 Subject: [PATCH 119/142] formatting --- integration-tests/src/dca.rs | 34 +++--- integration-tests/src/exchange_asset.rs | 21 ++-- integration-tests/src/referrals.rs | 25 +++-- integration-tests/src/router.rs | 104 +++++++++--------- integration-tests/src/utility.rs | 28 ++--- integration-tests/src/xcm.rs | 41 +++---- pallets/lbp/src/tests.rs | 24 ++-- pallets/omnipool/src/lib.rs | 21 ++-- pallets/omnipool/src/tests/buy.rs | 24 ++-- pallets/omnipool/src/tests/mock.rs | 7 +- pallets/omnipool/src/tests/sell.rs | 14 ++- pallets/omnipool/src/traits.rs | 2 +- pallets/otc-settlements/src/tests.rs | 6 +- pallets/otc/src/lib.rs | 2 +- pallets/otc/src/tests/fill_order.rs | 12 +- pallets/otc/src/tests/partial_fill_order.rs | 6 +- pallets/route-executor/src/lib.rs | 4 +- pallets/stableswap/src/tests/add_liquidity.rs | 8 +- .../stableswap/src/tests/remove_liquidity.rs | 8 +- pallets/stableswap/src/tests/trades.rs | 8 +- pallets/xyk/src/tests/fees.rs | 24 ++-- pallets/xyk/src/tests/trades.rs | 16 +-- runtime/adapters/src/lib.rs | 4 +- runtime/hydradx/src/xcm.rs | 4 +- 24 files changed, 228 insertions(+), 219 deletions(-) diff --git a/integration-tests/src/dca.rs b/integration-tests/src/dca.rs index e5be29a41..029335432 100644 --- a/integration-tests/src/dca.rs +++ b/integration-tests/src/dca.rs @@ -20,11 +20,11 @@ use hydradx_traits::router::PoolType; use hydradx_traits::router::Trade; use orml_traits::MultiCurrency; use orml_traits::MultiReservableCurrency; -use pallet_support::types::*; use pallet_dca::types::{Order, Schedule}; use pallet_omnipool::types::Tradability; use pallet_stableswap::types::AssetAmount; use pallet_stableswap::MAX_ASSETS_IN_POOL; +use pallet_support::types::*; use primitives::{AssetId, Balance}; use sp_runtime::traits::ConstU32; use sp_runtime::DispatchError; @@ -227,8 +227,8 @@ mod omnipool { RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { swapper: ALICE.into(), filler: Omnipool::protocol_account(), - filler_type:pallet_support::types::Filler::Omnipool, - operation:pallet_support::types::TradeOperation::ExactOut, + filler_type: pallet_support::types::Filler::Omnipool, + operation: pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(HDX, 140421094367051)], outputs: vec![Asset::new(LRNA, 70210545436437)], fees: vec![Fee::new(LRNA, 35105272718, Omnipool::protocol_account()),], @@ -241,8 +241,8 @@ mod omnipool { RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { swapper: ALICE.into(), filler: Omnipool::protocol_account(), - filler_type:pallet_support::types::Filler::Omnipool, - operation:pallet_support::types::TradeOperation::ExactOut, + filler_type: pallet_support::types::Filler::Omnipool, + operation: pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(LRNA, 70175440163719)], outputs: vec![Asset::new(DAI, amount_out)], fees: vec![Fee::new(DAI, 250626566417, Omnipool::protocol_account()),], @@ -265,8 +265,8 @@ mod omnipool { RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { swapper: ALICE.into(), filler: Omnipool::protocol_account(), - filler_type:pallet_support::types::Filler::Omnipool, - operation:pallet_support::types::TradeOperation::ExactOut, + filler_type: pallet_support::types::Filler::Omnipool, + operation: pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(HDX, 140421107716515)], outputs: vec![Asset::new(LRNA, 70210548448729)], fees: vec![Fee::new(LRNA, 35105274224, Omnipool::protocol_account()),], @@ -279,8 +279,8 @@ mod omnipool { RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { swapper: ALICE.into(), filler: Omnipool::protocol_account(), - filler_type:pallet_support::types::Filler::Omnipool, - operation:pallet_support::types::TradeOperation::ExactOut, + filler_type: pallet_support::types::Filler::Omnipool, + operation: pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(LRNA, 70175443174505)], outputs: vec![Asset::new(DAI, amount_out)], fees: vec![Fee::new(DAI, 250626566417, Omnipool::protocol_account()),], @@ -714,8 +714,8 @@ mod omnipool { RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { swapper: ALICE.into(), filler: Omnipool::protocol_account(), - filler_type:pallet_support::types::Filler::Omnipool, - operation:pallet_support::types::TradeOperation::ExactIn, + filler_type: pallet_support::types::Filler::Omnipool, + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(HDX, amount_to_sell)], outputs: vec![Asset::new(LRNA, 49999999159957)], fees: vec![Fee::new(LRNA, 24999999579, Omnipool::protocol_account()),], @@ -728,8 +728,8 @@ mod omnipool { RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { swapper: ALICE.into(), filler: Omnipool::protocol_account(), - filler_type:pallet_support::types::Filler::Omnipool, - operation:pallet_support::types::TradeOperation::ExactIn, + filler_type: pallet_support::types::Filler::Omnipool, + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(LRNA, 49974999160378)], outputs: vec![Asset::new(DAI, 71214372624126)], fees: vec![Fee::new(DAI, 178482136903, Omnipool::protocol_account()),], @@ -752,8 +752,8 @@ mod omnipool { RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { swapper: ALICE.into(), filler: Omnipool::protocol_account(), - filler_type:pallet_support::types::Filler::Omnipool, - operation:pallet_support::types::TradeOperation::ExactIn, + filler_type: pallet_support::types::Filler::Omnipool, + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(HDX, amount_to_sell)], outputs: vec![Asset::new(LRNA, 49999997360044)], fees: vec![Fee::new(LRNA, 24999998680, Omnipool::protocol_account()),], @@ -766,8 +766,8 @@ mod omnipool { RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { swapper: ALICE.into(), filler: Omnipool::protocol_account(), - filler_type:pallet_support::types::Filler::Omnipool, - operation:pallet_support::types::TradeOperation::ExactIn, + filler_type: pallet_support::types::Filler::Omnipool, + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(LRNA, 49974997361364)], outputs: vec![Asset::new(DAI, 71214367826179)], fees: vec![Fee::new(DAI, 178482124878, Omnipool::protocol_account()),], diff --git a/integration-tests/src/exchange_asset.rs b/integration-tests/src/exchange_asset.rs index 3222efaaa..b0895dc9e 100644 --- a/integration-tests/src/exchange_asset.rs +++ b/integration-tests/src/exchange_asset.rs @@ -128,9 +128,8 @@ fn hydra_should_swap_assets_when_receiving_from_acala_with_sell() { let last_swapped_events = get_last_swapped_events(); let last_two_swapped_events = &last_swapped_events[last_swapped_events.len() - 2..]; let topic_id = [ - 180, 44, 225, 230, 61, 43, 219, 219, 222, 9, 44, 219, 86, 193, 219, - 212, 120, 169, 197, 209, 39, 180, 219, 225, 224, 182, 134, 141, 41, - 162, 96, 54 + 180, 44, 225, 230, 61, 43, 219, 219, 222, 9, 44, 219, 86, 193, 219, 212, 120, 169, 197, 209, 39, 180, 219, + 225, 224, 182, 134, 141, 41, 162, 96, 54, ]; pretty_assertions::assert_eq!( last_two_swapped_events, @@ -138,8 +137,8 @@ fn hydra_should_swap_assets_when_receiving_from_acala_with_sell() { RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { swapper: TempAccountForXcmAssetExchange::get(), filler: Omnipool::protocol_account(), - filler_type:pallet_support::types::Filler::Omnipool, - operation:pallet_support::types::TradeOperation::ExactIn, + filler_type: pallet_support::types::Filler::Omnipool, + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![pallet_support::types::Asset::new(ACA, 50000000000000),], outputs: vec![pallet_support::types::Asset::new(LRNA::get(), 49180327868852)], fees: vec![Fee::new(LRNA::get(), 24590163934, Omnipool::protocol_account()),], @@ -153,8 +152,8 @@ fn hydra_should_swap_assets_when_receiving_from_acala_with_sell() { RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { swapper: TempAccountForXcmAssetExchange::get(), filler: Omnipool::protocol_account(), - filler_type:pallet_support::types::Filler::Omnipool, - operation:pallet_support::types::TradeOperation::ExactIn, + filler_type: pallet_support::types::Filler::Omnipool, + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![pallet_support::types::Asset::new(LRNA::get(), 49155737704918),], outputs: vec![pallet_support::types::Asset::new(HDX, 39101207131554396)], fees: vec![Fee::new(HDX, 97998012861039, Omnipool::protocol_account()),], @@ -186,8 +185,8 @@ fn hydra_should_swap_assets_when_receiving_from_acala_with_sell() { RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { swapper: ALICE.into(), filler: Omnipool::protocol_account(), - filler_type:pallet_support::types::Filler::Omnipool, - operation:pallet_support::types::TradeOperation::ExactIn, + filler_type: pallet_support::types::Filler::Omnipool, + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![pallet_support::types::Asset::new(HDX, 1 * UNITS),], outputs: vec![pallet_support::types::Asset::new(LRNA::get(), 1308673515)], fees: vec![Fee::new(LRNA::get(), 654336, Omnipool::protocol_account()),], @@ -196,8 +195,8 @@ fn hydra_should_swap_assets_when_receiving_from_acala_with_sell() { RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { swapper: ALICE.into(), filler: Omnipool::protocol_account(), - filler_type:pallet_support::types::Filler::Omnipool, - operation:pallet_support::types::TradeOperation::ExactIn, + filler_type: pallet_support::types::Filler::Omnipool, + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![pallet_support::types::Asset::new(LRNA::get(), 1308019179),], outputs: vec![pallet_support::types::Asset::new(ACA, 1348602600)], fees: vec![Fee::new(ACA, 3379957, Omnipool::protocol_account()),], diff --git a/integration-tests/src/referrals.rs b/integration-tests/src/referrals.rs index dcbe660e2..0b1b0d606 100644 --- a/integration-tests/src/referrals.rs +++ b/integration-tests/src/referrals.rs @@ -5,11 +5,11 @@ use frame_support::assert_ok; use frame_system::RawOrigin; use hydradx_runtime::{Currencies, Omnipool, Referrals, Runtime, RuntimeOrigin, Staking, Tokens}; use orml_traits::MultiCurrency; +use pallet_referrals::{FeeDistribution, ReferralCode}; use pallet_support::types::Asset; use pallet_support::types::Fee; use pallet_support::types::Filler; use pallet_support::types::TradeOperation; -use pallet_referrals::{FeeDistribution, ReferralCode}; use primitives::AccountId; use sp_core::crypto::Ss58AddressFormat; use sp_runtime::FixedU128; @@ -349,7 +349,10 @@ fn trading_in_omnipool_should_use_asset_rewards_when_set() { operation: TradeOperation::ExactIn, inputs: vec![Asset::new(LRNA, 1205165959)], outputs: vec![Asset::new(DAI, 26663424573622008)], - fees: vec![Fee::new(DAI, 61356016373131, Omnipool::protocol_account()), Fee::new(DAI, 9168140377593, Referrals::pot_account_id())], + fees: vec![ + Fee::new(DAI, 61356016373131, Omnipool::protocol_account()), + Fee::new(DAI, 9168140377593, Referrals::pot_account_id()) + ], operation_stack: vec![ExecutionType::Omnipool(0)], } .into(), @@ -406,7 +409,10 @@ fn buying_hdx_in_omnipool_should_transfer_correct_fee() { operation: TradeOperation::ExactOut, inputs: vec![Asset::new(LRNA, 1_209_141_304)], outputs: vec![Asset::new(HDX, 1_000_000_000_000)], - fees: vec![Fee::new(HDX, 1, Omnipool::protocol_account()), Fee::new(HDX, 2794789077, Staking::pot_account_id())], + fees: vec![ + Fee::new(HDX, 1, Omnipool::protocol_account()), + Fee::new(HDX, 2794789077, Staking::pot_account_id()), + ], operation_stack: vec![ExecutionType::Omnipool(0)], } .into(), @@ -452,8 +458,8 @@ fn buying_with_hdx_in_omnipool_should_transfer_correct_fee() { pallet_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type:pallet_support::types::Filler::Omnipool, - operation:pallet_support::types::TradeOperation::ExactOut, + filler_type: pallet_support::types::Filler::Omnipool, + operation: pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(HDX, 37_506_757_329_085)], outputs: vec![Asset::new(LRNA, 45_222_713_080)], fees: vec![Fee::new(LRNA, 22_611_356, Omnipool::protocol_account())], @@ -463,11 +469,14 @@ fn buying_with_hdx_in_omnipool_should_transfer_correct_fee() { pallet_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type:pallet_support::types::Filler::Omnipool, - operation:pallet_support::types::TradeOperation::ExactOut, + filler_type: pallet_support::types::Filler::Omnipool, + operation: pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(LRNA, 45_200_101_724)], outputs: vec![Asset::new(DAI, 1_000_000_000_000_000_000)], - fees: vec![Fee::new(DAI, 1322488725257230, Omnipool::protocol_account()), Fee::new(DAI, 1322488725257228, Referrals::pot_account_id())], + fees: vec![ + Fee::new(DAI, 1322488725257230, Omnipool::protocol_account()), + Fee::new(DAI, 1322488725257228, Referrals::pot_account_id()), + ], operation_stack: vec![ExecutionType::Omnipool(0)], } .into(), diff --git a/integration-tests/src/router.rs b/integration-tests/src/router.rs index a75359238..63157f29d 100644 --- a/integration-tests/src/router.rs +++ b/integration-tests/src/router.rs @@ -14,17 +14,17 @@ use hydradx_traits::{ router::{PoolType, Trade}, AssetKind, AMM, }; -use pallet_support::types::Asset; -use pallet_support::types::ExecutionType; -use pallet_support::types::Fee; -use pallet_support::types::Filler; -use pallet_support::types::TradeOperation; use pallet_lbp::weights::WeightInfo as LbpWeights; use pallet_lbp::WeightCurveType; use pallet_omnipool::traits::OmnipoolHooks; use pallet_omnipool::types::Tradability; use pallet_omnipool::weights::WeightInfo as OmnipoolWeights; use pallet_route_executor::AmmTradeWeights; +use pallet_support::types::Asset; +use pallet_support::types::ExecutionType; +use pallet_support::types::Fee; +use pallet_support::types::Filler; +use pallet_support::types::TradeOperation; use primitives::AssetId; use sp_runtime::FixedPointNumber; use std::convert::Into; @@ -161,8 +161,8 @@ mod router_different_pools_tests { pallet_support::Event::Swapped { swapper: BOB.into(), filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA)), - filler_type:pallet_support::types::Filler::LBP, - operation:pallet_support::types::TradeOperation::ExactIn, + filler_type: pallet_support::types::Filler::LBP, + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(DAI, 9980000000)], outputs: vec![Asset::new(LRNA, 5640664064)], fees: vec![Fee::new( @@ -178,8 +178,8 @@ mod router_different_pools_tests { pallet_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type:pallet_support::types::Filler::Omnipool, - operation:pallet_support::types::TradeOperation::ExactIn, + filler_type: pallet_support::types::Filler::Omnipool, + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(LRNA, 5640664064)], outputs: vec![Asset::new(HDX, 4682924837974)], fees: vec![Fee::new(HDX, 11736653730, Omnipool::protocol_account())], @@ -192,13 +192,13 @@ mod router_different_pools_tests { asset_in: HDX, asset_out: DOT, }), - filler_type:pallet_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( + filler_type: pallet_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: DOT, }, ))), - operation:pallet_support::types::TradeOperation::ExactIn, + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(HDX, 4682924837974)], outputs: vec![Asset::new(DOT, 2230008413831)], fees: vec![Fee::new( @@ -304,13 +304,13 @@ mod router_different_pools_tests { asset_in: HDX, asset_out: stable_asset_1, }), - filler_type:pallet_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( + filler_type: pallet_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: stable_asset_1, }, ))), - operation:pallet_support::types::TradeOperation::ExactIn, + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(HDX, 5640664064)], outputs: vec![Asset::new(stable_asset_1, 2811712439)], fees: vec![Fee::new( @@ -330,7 +330,7 @@ mod router_different_pools_tests { &stable_pool_id, Some(pallet_stableswap::POOL_IDENTIFIER), ), - filler_type:pallet_support::types::Filler::Stableswap(stable_pool_id), + filler_type: pallet_support::types::Filler::Stableswap(stable_pool_id), operation: TradeOperation::ExactIn, inputs: vec![Asset::new(stable_asset_1, 2811712439)], outputs: vec![Asset::new(stable_asset_2, 2783595233)], @@ -414,8 +414,8 @@ mod router_different_pools_tests { pallet_support::Event::Swapped { swapper: BOB.into(), filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA)), - filler_type:pallet_support::types::Filler::LBP, - operation:pallet_support::types::TradeOperation::ExactOut, + filler_type: pallet_support::types::Filler::LBP, + operation: pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(DAI, 4362157193)], outputs: vec![Asset::new(LRNA, 2465566245)], fees: vec![Fee::new( @@ -431,8 +431,8 @@ mod router_different_pools_tests { pallet_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type:pallet_support::types::Filler::Omnipool, - operation:pallet_support::types::TradeOperation::ExactOut, + filler_type: pallet_support::types::Filler::Omnipool, + operation: pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(LRNA, 2465566245)], outputs: vec![Asset::new(HDX, 2046938775509)], fees: vec![Fee::new(HDX, 5130172370, Omnipool::protocol_account())], @@ -445,13 +445,13 @@ mod router_different_pools_tests { asset_in: HDX, asset_out: DOT, }), - filler_type:pallet_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( + filler_type: pallet_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: DOT, }, ))), - operation:pallet_support::types::TradeOperation::ExactOut, + operation: pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(HDX, 1000000000000)], outputs: vec![Asset::new(DOT, 2040816326531)], fees: vec![Fee::new( @@ -537,8 +537,8 @@ mod router_different_pools_tests { pallet_support::Event::Swapped { swapper: BOB.into(), filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX)), - filler_type:pallet_support::types::Filler::LBP, - operation:pallet_support::types::TradeOperation::ExactOut, + filler_type: pallet_support::types::Filler::LBP, + operation: pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(DAI, 3746042043754)], outputs: vec![Asset::new(HDX, 2067851065323)], fees: vec![Fee::new( @@ -557,13 +557,13 @@ mod router_different_pools_tests { asset_in: HDX, asset_out: stable_asset_1, }), - filler_type:pallet_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( + filler_type: pallet_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: stable_asset_1, }, ))), - operation:pallet_support::types::TradeOperation::ExactOut, + operation: pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(HDX, 1010010000114)], outputs: vec![Asset::new(stable_asset_1, 2061666067122)], fees: vec![Fee::new( @@ -583,8 +583,8 @@ mod router_different_pools_tests { &stable_pool_id, Some(pallet_stableswap::POOL_IDENTIFIER), ), - filler_type:pallet_support::types::Filler::Stableswap(stable_pool_id), - operation:pallet_support::types::TradeOperation::ExactOut, + filler_type: pallet_support::types::Filler::Stableswap(stable_pool_id), + operation: pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(stable_asset_1, 1010010000114)], outputs: vec![Asset::new(stable_asset_2, 1000000000000)], fees: vec![Fee::new( @@ -665,13 +665,13 @@ mod router_different_pools_tests { asset_in: HDX, asset_out: DOT, }), - filler_type:pallet_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( + filler_type: pallet_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: DOT, }, ))), - operation:pallet_support::types::TradeOperation::ExactIn, + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(HDX, 10000000000)], outputs: vec![Asset::new(DOT, 4984501549)], fees: vec![Fee::new( @@ -691,13 +691,13 @@ mod router_different_pools_tests { asset_in: HDX, asset_out: DOT, }), - filler_type:pallet_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( + filler_type: pallet_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: DOT, }, ))), - operation:pallet_support::types::TradeOperation::ExactOut, + operation: pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(HDX, 10000000000)], outputs: vec![Asset::new(DOT, 20007996198)], fees: vec![Fee::new( @@ -717,13 +717,13 @@ mod router_different_pools_tests { asset_in: HDX, asset_out: DOT, }), - filler_type:pallet_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( + filler_type: pallet_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: DOT, }, ))), - operation:pallet_support::types::TradeOperation::ExactIn, + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(HDX, 10000000000)], outputs: vec![Asset::new(DOT, 4981510054)], fees: vec![Fee::new( @@ -2403,8 +2403,8 @@ mod omnipool_router_tests { pallet_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type:pallet_support::types::Filler::Omnipool, - operation:pallet_support::types::TradeOperation::ExactIn, + filler_type: pallet_support::types::Filler::Omnipool, + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(HDX, amount_to_sell)], outputs: vec![Asset::new(LRNA, 12014871681)], fees: vec![Fee::new(LRNA, 6007435, Omnipool::protocol_account())], @@ -2414,8 +2414,8 @@ mod omnipool_router_tests { pallet_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type:pallet_support::types::Filler::Omnipool, - operation:pallet_support::types::TradeOperation::ExactIn, + filler_type: pallet_support::types::Filler::Omnipool, + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(LRNA, 12008864246)], outputs: vec![Asset::new(DAI, amount_out)], fees: vec![Fee::new(DAI, 667155563986401, Omnipool::protocol_account())], @@ -2465,8 +2465,8 @@ mod omnipool_router_tests { pallet_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type:pallet_support::types::Filler::Omnipool, - operation:pallet_support::types::TradeOperation::ExactIn, + filler_type: pallet_support::types::Filler::Omnipool, + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(HDX, amount_to_sell)], outputs: vec![Asset::new(LRNA, 12014871681)], fees: vec![Fee::new(LRNA, 6007435, Omnipool::protocol_account())], @@ -2476,8 +2476,8 @@ mod omnipool_router_tests { pallet_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type:pallet_support::types::Filler::Omnipool, - operation:pallet_support::types::TradeOperation::ExactIn, + filler_type: pallet_support::types::Filler::Omnipool, + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(LRNA, 12008864246)], outputs: vec![Asset::new(DAI, amount_out)], fees: vec![Fee::new(DAI, 667155563986401, Omnipool::protocol_account())], @@ -2633,8 +2633,8 @@ mod omnipool_router_tests { pallet_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type:pallet_support::types::Filler::Omnipool, - operation:pallet_support::types::TradeOperation::ExactOut, + filler_type: pallet_support::types::Filler::Omnipool, + operation: pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(HDX, amount_in)], outputs: vec![Asset::new(LRNA, 45135)], fees: vec![Fee::new(LRNA, 22, Omnipool::protocol_account())], @@ -2644,8 +2644,8 @@ mod omnipool_router_tests { pallet_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type:pallet_support::types::Filler::Omnipool, - operation:pallet_support::types::TradeOperation::ExactOut, + filler_type: pallet_support::types::Filler::Omnipool, + operation: pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(LRNA, 45113)], outputs: vec![Asset::new(DAI, amount_to_buy)], fees: vec![Fee::new(DAI, 2506265665, Omnipool::protocol_account())], @@ -2695,8 +2695,8 @@ mod omnipool_router_tests { pallet_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type:pallet_support::types::Filler::Omnipool, - operation:pallet_support::types::TradeOperation::ExactOut, + filler_type: pallet_support::types::Filler::Omnipool, + operation: pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(HDX, amount_in)], outputs: vec![Asset::new(LRNA, 45135)], fees: vec![Fee::new(LRNA, 22, Omnipool::protocol_account())], @@ -2706,8 +2706,8 @@ mod omnipool_router_tests { pallet_support::Event::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type:pallet_support::types::Filler::Omnipool, - operation:pallet_support::types::TradeOperation::ExactOut, + filler_type: pallet_support::types::Filler::Omnipool, + operation: pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(LRNA, 45113)], outputs: vec![Asset::new(DAI, amount_to_buy)], fees: vec![Fee::new(DAI, 2506265665, Omnipool::protocol_account())], @@ -2990,8 +2990,8 @@ mod lbp_router_tests { pallet_support::Event::Swapped { swapper: BOB.into(), filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX)), - filler_type:pallet_support::types::Filler::LBP, - operation:pallet_support::types::TradeOperation::ExactIn, + filler_type: pallet_support::types::Filler::LBP, + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(HDX, amount_to_sell - fee)], outputs: vec![Asset::new(DAI, received_amount_out)], fees: vec![Fee::new( @@ -3046,8 +3046,8 @@ mod lbp_router_tests { pallet_support::Event::Swapped { swapper: BOB.into(), filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX)), - filler_type:pallet_support::types::Filler::LBP, - operation:pallet_support::types::TradeOperation::ExactIn, + filler_type: pallet_support::types::Filler::LBP, + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(HDX, 9_980_000_000_000)], outputs: vec![Asset::new(DAI, received_amount_out)], fees: vec![Fee::new( diff --git a/integration-tests/src/utility.rs b/integration-tests/src/utility.rs index d0cb04d6b..2c3454ae4 100644 --- a/integration-tests/src/utility.rs +++ b/integration-tests/src/utility.rs @@ -73,8 +73,8 @@ fn batch_execution_type_should_be_included_in_batch() { RuntimeEvent::AmmSupport(pallet_support::Event::::Swapped { swapper: BOB.into(), filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA)), - filler_type:pallet_support::types::Filler::LBP, - operation:pallet_support::types::TradeOperation::ExactIn, + filler_type: pallet_support::types::Filler::LBP, + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(DAI, 9980000000)], outputs: vec![Asset::new(LRNA, 5640664064)], fees: vec![Fee::new( @@ -89,8 +89,8 @@ fn batch_execution_type_should_be_included_in_batch() { RuntimeEvent::AmmSupport(pallet_support::Event::::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type:pallet_support::types::Filler::Omnipool, - operation:pallet_support::types::TradeOperation::ExactIn, + filler_type: pallet_support::types::Filler::Omnipool, + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(LRNA, 5640664064)], outputs: vec![Asset::new(HDX, 4682924837974)], fees: vec![Fee::new(HDX, 11736653730, Omnipool::protocol_account())], @@ -102,13 +102,13 @@ fn batch_execution_type_should_be_included_in_batch() { asset_in: HDX, asset_out: DOT, }), - filler_type:pallet_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( + filler_type: pallet_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: DOT, }, ))), - operation:pallet_support::types::TradeOperation::ExactIn, + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(HDX, 4682924837974)], outputs: vec![Asset::new(DOT, 2230008413831)], fees: vec![Fee::new( @@ -197,13 +197,13 @@ fn batch_execution_type_should_be_popped_when_multiple_batch_calls_happen() { asset_in: HDX, asset_out: DOT, }), - filler_type:pallet_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( + filler_type: pallet_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: DOT, }, ))), - operation:pallet_support::types::TradeOperation::ExactIn, + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(HDX, amount_to_sell)], outputs: vec![Asset::new(DOT, 4549178628)], fees: vec![Fee::new( @@ -280,8 +280,8 @@ fn nested_batch_should_represent_embeddedness() { RuntimeEvent::AmmSupport(pallet_support::Event::::Swapped { swapper: BOB.into(), filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA)), - filler_type:pallet_support::types::Filler::LBP, - operation:pallet_support::types::TradeOperation::ExactIn, + filler_type: pallet_support::types::Filler::LBP, + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(DAI, 9980000000)], outputs: vec![Asset::new(LRNA, 5640664064)], fees: vec![Fee::new( @@ -300,8 +300,8 @@ fn nested_batch_should_represent_embeddedness() { RuntimeEvent::AmmSupport(pallet_support::Event::::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), - filler_type:pallet_support::types::Filler::Omnipool, - operation:pallet_support::types::TradeOperation::ExactIn, + filler_type: pallet_support::types::Filler::Omnipool, + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(LRNA, 5640664064)], outputs: vec![Asset::new(HDX, 4682924837974)], fees: vec![Fee::new(HDX, 11736653730, Omnipool::protocol_account())], @@ -317,13 +317,13 @@ fn nested_batch_should_represent_embeddedness() { asset_in: HDX, asset_out: DOT, }), - filler_type:pallet_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( + filler_type: pallet_support::types::Filler::XYK(XYK::share_token(XYK::get_pair_id( pallet_xyk::types::AssetPair { asset_in: HDX, asset_out: DOT, }, ))), - operation:pallet_support::types::TradeOperation::ExactIn, + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(HDX, 4682924837974)], outputs: vec![Asset::new(DOT, 2230008413831)], fees: vec![Fee::new( diff --git a/integration-tests/src/xcm.rs b/integration-tests/src/xcm.rs index 7079c6514..d555d2dc4 100644 --- a/integration-tests/src/xcm.rs +++ b/integration-tests/src/xcm.rs @@ -146,8 +146,8 @@ fn global_account_derivation_should_work_when_with_other_chain_remote_account() RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { swapper: account.clone().into(), filler: Omnipool::protocol_account(), - filler_type:pallet_support::types::Filler::Omnipool, - operation:pallet_support::types::TradeOperation::ExactIn, + filler_type: pallet_support::types::Filler::Omnipool, + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![UnifiedEventAsset::new(HDX, 1000000000000)], outputs: vec![UnifiedEventAsset::new(LRNA, 1201498716)], fees: vec![Fee::new(LRNA, 600749, Omnipool::protocol_account()),], @@ -156,8 +156,8 @@ fn global_account_derivation_should_work_when_with_other_chain_remote_account() RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { swapper: account.into(), filler: Omnipool::protocol_account(), - filler_type:pallet_support::types::Filler::Omnipool, - operation:pallet_support::types::TradeOperation::ExactIn, + filler_type: pallet_support::types::Filler::Omnipool, + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![UnifiedEventAsset::new(LRNA, 1200897967)], outputs: vec![UnifiedEventAsset::new(DAI, 26619890727267708)], fees: vec![Fee::new(DAI, 66716518113453, Omnipool::protocol_account()),], @@ -281,9 +281,8 @@ fn xcm_call_should_populate_unified_event_call_context() { let swapped_events = get_last_swapped_events(); let last_two_swapped_events = &get_last_swapped_events()[swapped_events.len() - 2..]; let topic_id = [ - 162, 58, 237, 167, 26, 250, 26, 161, 116, 182, 7, 12, 84, 48, 100, - 53, 175, 60, 179, 213, 59, 7, 83, 150, 136, 112, 126, 15, 199, 223, - 71, 230 + 162, 58, 237, 167, 26, 250, 26, 161, 116, 182, 7, 12, 84, 48, 100, 53, 175, 60, 179, 213, 59, 7, 83, 150, + 136, 112, 126, 15, 199, 223, 71, 230, ]; pretty_assertions::assert_eq!( last_two_swapped_events, @@ -291,39 +290,27 @@ fn xcm_call_should_populate_unified_event_call_context() { RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { swapper: account.clone().into(), filler: Omnipool::protocol_account(), - filler_type:pallet_support::types::Filler::Omnipool, - operation:pallet_support::types::TradeOperation::ExactIn, + filler_type: pallet_support::types::Filler::Omnipool, + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![UnifiedEventAsset::new(HDX, 1000000000000)], outputs: vec![UnifiedEventAsset::new(LRNA, 1201498716)], fees: vec![Fee::new(LRNA, 600749, Omnipool::protocol_account()),], - operation_stack: vec![ - ExecutionType::Xcm( - topic_id, - 0 - ), - ExecutionType::Omnipool(1) - ] + operation_stack: vec![ExecutionType::Xcm(topic_id, 0), ExecutionType::Omnipool(1)] }), RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { swapper: account.into(), filler: Omnipool::protocol_account(), - filler_type:pallet_support::types::Filler::Omnipool, - operation:pallet_support::types::TradeOperation::ExactIn, + filler_type: pallet_support::types::Filler::Omnipool, + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![UnifiedEventAsset::new(LRNA, 1200897967)], outputs: vec![UnifiedEventAsset::new(DAI, 26619890727267708)], fees: vec![Fee::new(DAI, 66716518113453, Omnipool::protocol_account()),], - operation_stack: vec![ - ExecutionType::Xcm( - topic_id, - 0 - ), - ExecutionType::Omnipool(1) - ], + operation_stack: vec![ExecutionType::Xcm(topic_id, 0), ExecutionType::Omnipool(1)], }) ] ); - let unified_event_context =pallet_support::Pallet::::get_context().unwrap(); + let unified_event_context = pallet_support::Pallet::::get_context().unwrap(); assert!(unified_event_context.is_empty()); }); } @@ -391,7 +378,7 @@ fn unified_event_context_should_be_cleared_when_error_happens_in_xcm_prepare() { // Assert Hydra::execute_with(|| { - let context =pallet_support::Pallet::::get_context().unwrap(); + let context = pallet_support::Pallet::::get_context().unwrap(); assert!(context.is_empty()) }); } diff --git a/pallets/lbp/src/tests.rs b/pallets/lbp/src/tests.rs index 8ff23a654..0ef4c0dff 100644 --- a/pallets/lbp/src/tests.rs +++ b/pallets/lbp/src/tests.rs @@ -1846,8 +1846,8 @@ fn execute_sell_should_work() { pallet_support::Event::Swapped { swapper: ALICE, filler: pool_id, - filler_type:pallet_support::types::Filler::LBP, - operation:pallet_support::types::TradeOperation::ExactIn, + filler_type: pallet_support::types::Filler::LBP, + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(asset_in, amount_in)], outputs: vec![Asset::new(asset_out, amount_b)], fees: vec![Fee::new(asset_in, 1_000, pool_data.fee_collector)], @@ -1989,8 +1989,8 @@ fn execute_buy_should_work() { pallet_support::Event::Swapped { swapper: ALICE, filler: pool_id, - filler_type:pallet_support::types::Filler::LBP, - operation:pallet_support::types::TradeOperation::ExactOut, + filler_type: pallet_support::types::Filler::LBP, + operation: pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(asset_in, amount_in)], outputs: vec![Asset::new(asset_out, amount_b)], fees: vec![Fee::new(asset_in, 1_000, pool_data.fee_collector)], @@ -2318,8 +2318,8 @@ fn buy_should_work() { pallet_support::Event::Swapped { swapper: buyer, filler: pool_id, - filler_type:pallet_support::types::Filler::LBP, - operation:pallet_support::types::TradeOperation::ExactOut, + filler_type: pallet_support::types::Filler::LBP, + operation: pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(asset_in, 17_894_738)], outputs: vec![Asset::new(asset_out, 10_000_000)], fees: vec![Fee::new(asset_in, 35860, pool_data.fee_collector)], @@ -2463,8 +2463,8 @@ fn buy_should_work_when_limit_is_set_above_account_balance() { pallet_support::Event::Swapped { swapper: buyer, filler: pool_id, - filler_type:pallet_support::types::Filler::LBP, - operation:pallet_support::types::TradeOperation::ExactOut, + filler_type: pallet_support::types::Filler::LBP, + operation: pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(asset_in, 17_894_738)], outputs: vec![Asset::new(asset_out, 10_000_000)], fees: vec![Fee::new(asset_in, 35860, pool_data.fee_collector)], @@ -2497,8 +2497,8 @@ fn buy_should_work_when_limit_is_set_above_account_balance() { pallet_support::Event::Swapped { swapper: buyer, filler: pool_id, - filler_type:pallet_support::types::Filler::LBP, - operation:pallet_support::types::TradeOperation::ExactOut, + filler_type: pallet_support::types::Filler::LBP, + operation: pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(BSX, 5_560_304)], outputs: vec![Asset::new(KUSD, 10_000_000)], @@ -2588,8 +2588,8 @@ fn sell_should_work() { pallet_support::Event::Swapped { swapper: buyer, filler: pool_id, - filler_type:pallet_support::types::Filler::LBP, - operation:pallet_support::types::TradeOperation::ExactIn, + filler_type: pallet_support::types::Filler::LBP, + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(asset_in, 9_980_000)], outputs: vec![Asset::new(asset_out, 5_605_138)], fees: vec![Fee::new(asset_in, 20_000, pool_data.fee_collector)], diff --git a/pallets/omnipool/src/lib.rs b/pallets/omnipool/src/lib.rs index c6a52fd3f..c43963564 100644 --- a/pallets/omnipool/src/lib.rs +++ b/pallets/omnipool/src/lib.rs @@ -1094,7 +1094,6 @@ pub mod pallet { pallet_support::Pallet::::add_to_context(ExecutionType::Omnipool)?; - //Swapped event for AssetA to HubAsset pallet_support::Pallet::::deposit_trade_event( who.clone(), @@ -1124,7 +1123,7 @@ pub mod pallet { *state_changes.asset_out.delta_hub_reserve, )], vec![Asset::new(asset_out.into(), *state_changes.asset_out.delta_reserve)], - trade_fees + trade_fees, ); pallet_support::Pallet::::remove_from_context()?; @@ -1873,7 +1872,7 @@ impl Pallet { Self::set_asset_state(asset_out, new_asset_out_state); - let trade_fees = Self::process_trade_fee(who, asset_out, state_changes.fee.asset_fee)?; + let trade_fees = Self::process_trade_fee(who, asset_out, state_changes.fee.asset_fee)?; // TODO: Deprecated, remove when ready Self::deposit_event(Event::SellExecuted { @@ -2125,14 +2124,19 @@ impl Pallet { } /// Calls `on_trade_fee` hook and ensures that no more than the fee amount is transferred. - fn process_trade_fee(trader: &T::AccountId, asset: T::AssetId, amount: Balance) -> Result>, DispatchError> { + fn process_trade_fee( + trader: &T::AccountId, + asset: T::AssetId, + amount: Balance, + ) -> Result>, DispatchError> { let account = Self::protocol_account(); let original_asset_reserve = T::Currency::free_balance(asset, &account); // Let's give little bit less to process. Subtracting one due to potential rounding errors let allowed_amount = amount.saturating_sub(Balance::one()); let fees = T::OmnipoolHooks::on_trade_fee(account.clone(), trader.clone(), asset, allowed_amount)?; - let additional_fees_total: Balance = fees.clone() + let additional_fees_total: Balance = fees + .clone() .into_iter() .filter_map(|opt| opt.map(|(balance, _)| balance)) .sum(); @@ -2150,9 +2154,12 @@ impl Pallet { recipient: Self::protocol_account(), }]; - let additional_fee_entries : Vec> = fees + let additional_fee_entries: Vec> = fees .iter() - .filter_map(|opt| opt.clone().map(|(balance, recipient)| Fee::new(asset.into(), balance, recipient.clone()))) + .filter_map(|opt| { + opt.clone() + .map(|(balance, recipient)| Fee::new(asset.into(), balance, recipient.clone())) + }) .filter(|fee| fee.amount > 0) //filter out when we zero percentage is configured for fees .collect(); diff --git a/pallets/omnipool/src/tests/buy.rs b/pallets/omnipool/src/tests/buy.rs index c33277b4c..f97b40127 100644 --- a/pallets/omnipool/src/tests/buy.rs +++ b/pallets/omnipool/src/tests/buy.rs @@ -440,8 +440,8 @@ fn buy_should_emit_event_with_correct_asset_fee_amount() { pallet_support::Event::Swapped { swapper: LP1, filler: Omnipool::protocol_account(), - filler_type:pallet_support::types::Filler::Omnipool, - operation:pallet_support::types::TradeOperation::ExactOut, + filler_type: pallet_support::types::Filler::Omnipool, + operation: pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(100, expected_sold_amount)], outputs: vec![Asset::new(1, 57142857142858)], fees: vec![Fee::new(LRNA, 0, Omnipool::protocol_account())], @@ -451,8 +451,8 @@ fn buy_should_emit_event_with_correct_asset_fee_amount() { pallet_support::Event::Swapped { swapper: LP1, filler: Omnipool::protocol_account(), - filler_type:pallet_support::types::Filler::Omnipool, - operation:pallet_support::types::TradeOperation::ExactOut, + filler_type: pallet_support::types::Filler::Omnipool, + operation: pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(1, 57142857142858)], outputs: vec![Asset::new(200, buy_amount)], fees: vec![Fee::new(200, 5555555555556, Omnipool::protocol_account())], @@ -487,8 +487,8 @@ fn buy_should_emit_event_with_correct_asset_fee_amount() { pallet_support::Event::Swapped { swapper: LP1, filler: Omnipool::protocol_account(), - filler_type:pallet_support::types::Filler::Omnipool, - operation:pallet_support::types::TradeOperation::ExactOut, + filler_type: pallet_support::types::Filler::Omnipool, + operation: pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(100, 65976185738813)], outputs: vec![Asset::new(1, 60326770004314)], fees: vec![Fee::new(LRNA, 0, Omnipool::protocol_account())], @@ -498,8 +498,8 @@ fn buy_should_emit_event_with_correct_asset_fee_amount() { pallet_support::Event::Swapped { swapper: LP1, filler: Omnipool::protocol_account(), - filler_type:pallet_support::types::Filler::Omnipool, - operation:pallet_support::types::TradeOperation::ExactOut, + filler_type: pallet_support::types::Filler::Omnipool, + operation: pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(1, 60326770004314)], outputs: vec![Asset::new(200, other_buy_amount)], fees: vec![Fee::new(200, 5555555555567, Omnipool::protocol_account())], @@ -556,8 +556,8 @@ fn buy_should_emit_event_with_correct_protocol_fee_amount() { pallet_support::Event::Swapped { swapper: LP1, filler: Omnipool::protocol_account(), - filler_type:pallet_support::types::Filler::Omnipool, - operation:pallet_support::types::TradeOperation::ExactOut, + filler_type: pallet_support::types::Filler::Omnipool, + operation: pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(100, expected_sold_amount)], outputs: vec![Asset::new(1, 56980056980057)], fees: vec![Fee::new(LRNA, 5698005698005, Omnipool::protocol_account())], @@ -567,8 +567,8 @@ fn buy_should_emit_event_with_correct_protocol_fee_amount() { pallet_support::Event::Swapped { swapper: LP1, filler: Omnipool::protocol_account(), - filler_type:pallet_support::types::Filler::Omnipool, - operation:pallet_support::types::TradeOperation::ExactOut, + filler_type: pallet_support::types::Filler::Omnipool, + operation: pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(1, 51282051282052)], outputs: vec![Asset::new(200, buy_amount)], fees: vec![Fee::new(200, 0, Omnipool::protocol_account())], diff --git a/pallets/omnipool/src/tests/mock.rs b/pallets/omnipool/src/tests/mock.rs index 6d571d722..4408cec2f 100644 --- a/pallets/omnipool/src/tests/mock.rs +++ b/pallets/omnipool/src/tests/mock.rs @@ -725,7 +725,12 @@ impl OmnipoolHooks for MockHooks { Weight::zero() } - fn on_trade_fee(fee_account: AccountId, _trader: AccountId, asset: AssetId, amount: Balance) -> Result>, Self::Error> { + fn on_trade_fee( + fee_account: AccountId, + _trader: AccountId, + asset: AssetId, + amount: Balance, + ) -> Result>, Self::Error> { let percentage = ON_TRADE_WITHDRAWAL.with(|v| *v.borrow()); let to_take = percentage.mul_floor(amount); Tokens::withdraw(asset, &fee_account, to_take)?; diff --git a/pallets/omnipool/src/tests/sell.rs b/pallets/omnipool/src/tests/sell.rs index afb4b6b71..b41c41c4d 100644 --- a/pallets/omnipool/src/tests/sell.rs +++ b/pallets/omnipool/src/tests/sell.rs @@ -748,8 +748,8 @@ fn sell_should_get_same_amount() { pallet_support::Event::Swapped { swapper: LP1, filler: Omnipool::protocol_account(), - filler_type:pallet_support::types::Filler::Omnipool, - operation:pallet_support::types::TradeOperation::ExactIn, + filler_type: pallet_support::types::Filler::Omnipool, + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(100, expected_sold_amount)], outputs: vec![Asset::new(LRNA, 57142857142858)], fees: vec![Fee::new(LRNA, 0, Omnipool::protocol_account())], @@ -759,12 +759,14 @@ fn sell_should_get_same_amount() { pallet_support::Event::Swapped { swapper: LP1, filler: Omnipool::protocol_account(), - filler_type:pallet_support::types::Filler::Omnipool, - operation:pallet_support::types::TradeOperation::ExactIn, + filler_type: pallet_support::types::Filler::Omnipool, + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(LRNA, 57142857142858)], outputs: vec![Asset::new(200, buy_amount)], - fees: vec![Fee::new(200, 5500000000001, Omnipool::protocol_account()), - Fee::new(200, 55555555555, 0)], + fees: vec![ + Fee::new(200, 5500000000001, Omnipool::protocol_account()), + Fee::new(200, 55555555555, 0), + ], operation_stack: vec![ExecutionType::Omnipool(0)], } .into(), diff --git a/pallets/omnipool/src/traits.rs b/pallets/omnipool/src/traits.rs index 0b7e66b0f..78fa28c38 100644 --- a/pallets/omnipool/src/traits.rs +++ b/pallets/omnipool/src/traits.rs @@ -7,8 +7,8 @@ use hydra_dx_math::omnipool::types::AssetStateChange; use sp_runtime::traits::{CheckedAdd, CheckedMul, Get, Saturating, Zero}; use sp_runtime::{DispatchError, FixedPointNumber, FixedU128, Permill}; use sp_std::fmt::Debug; -use sp_std::vec::Vec; use sp_std::vec; +use sp_std::vec::Vec; /// Asset In/Out information used in hooks. pub struct AssetInfo where diff --git a/pallets/otc-settlements/src/tests.rs b/pallets/otc-settlements/src/tests.rs index 905d682b7..9dd07eef4 100644 --- a/pallets/otc-settlements/src/tests.rs +++ b/pallets/otc-settlements/src/tests.rs @@ -302,9 +302,9 @@ fn existing_arb_opportunity_should_trigger_trade_when_correct_amount_can_be_foun .into(), pallet_support::Event::Swapped { swapper: otc.owner, - filler: OtcSettlements::account_id(), - filler_type:pallet_support::types::Filler::OTC(otc_id), - operation:pallet_support::types::TradeOperation::ExactIn, + filler: OtcSettlements::account_id(), + filler_type: pallet_support::types::Filler::OTC(otc_id), + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(HDX, 2413749694825193)], outputs: vec![Asset::new(DAI, 4948186874391645)], fees: vec![Fee::new( diff --git a/pallets/otc/src/lib.rs b/pallets/otc/src/lib.rs index e997bd289..d43e8641f 100644 --- a/pallets/otc/src/lib.rs +++ b/pallets/otc/src/lib.rs @@ -59,7 +59,7 @@ pub use weights::WeightInfo; pub use pallet::*; use pallet_support::types::Asset; pub type Balance = u128; -pub type OrderId =pallet_support::types::OtcOrderId; //TODO: just use exacty type +pub type OrderId = pallet_support::types::OtcOrderId; //TODO: just use exacty type pub type NamedReserveIdentifier = [u8; 8]; pub const NAMED_RESERVE_ID: NamedReserveIdentifier = *b"otcorder"; diff --git a/pallets/otc/src/tests/fill_order.rs b/pallets/otc/src/tests/fill_order.rs index 1a4ac1aec..1925f53f2 100644 --- a/pallets/otc/src/tests/fill_order.rs +++ b/pallets/otc/src/tests/fill_order.rs @@ -83,8 +83,8 @@ fn complete_fill_order_should_work() { pallet_support::Event::Swapped { swapper: BOB, filler: ALICE, - filler_type:pallet_support::types::Filler::OTC(0), - operation:pallet_support::types::TradeOperation::ExactIn, + filler_type: pallet_support::types::Filler::OTC(0), + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(DAI, 20 * ONE)], outputs: vec![Asset::new(HDX, 100 * ONE)], fees: vec![Fee::new(HDX, ONE, ::FeeReceiver::get())], @@ -159,8 +159,8 @@ fn complete_fill_order_should_work_when_order_is_not_partially_fillable() { pallet_support::Event::Swapped { swapper: BOB, filler: ALICE, - filler_type:pallet_support::types::Filler::OTC(order_id), - operation:pallet_support::types::TradeOperation::ExactIn, + filler_type: pallet_support::types::Filler::OTC(order_id), + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(DAI, 20 * ONE)], outputs: vec![Asset::new(HDX, 100 * ONE)], fees: vec![Fee::new(HDX, ONE, ::FeeReceiver::get())], @@ -247,8 +247,8 @@ fn complete_fill_order_should_work_when_there_are_multiple_orders() { pallet_support::Event::Swapped { swapper: BOB, filler: ALICE, - filler_type:pallet_support::types::Filler::OTC(order_id), - operation:pallet_support::types::TradeOperation::ExactIn, + filler_type: pallet_support::types::Filler::OTC(order_id), + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(DAI, 20 * ONE)], outputs: vec![Asset::new(HDX, 100 * ONE)], fees: vec![Fee::new(HDX, ONE, ::FeeReceiver::get())], diff --git a/pallets/otc/src/tests/partial_fill_order.rs b/pallets/otc/src/tests/partial_fill_order.rs index eaf4a54d0..1f9ef36ac 100644 --- a/pallets/otc/src/tests/partial_fill_order.rs +++ b/pallets/otc/src/tests/partial_fill_order.rs @@ -95,10 +95,10 @@ fn partial_fill_order_should_work_when_order_is_partially_fillable() { } .into(), pallet_support::Event::Swapped { - swapper:order.owner , + swapper: order.owner, filler: BOB, - filler_type:pallet_support::types::Filler::OTC(order_id), - operation:pallet_support::types::TradeOperation::ExactIn, + filler_type: pallet_support::types::Filler::OTC(order_id), + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(order.asset_in, 5 * ONE)], outputs: vec![Asset::new(order.asset_out, expected_amount_out)], fees: vec![Fee::new( diff --git a/pallets/route-executor/src/lib.rs b/pallets/route-executor/src/lib.rs index fffefc309..9795e26bb 100644 --- a/pallets/route-executor/src/lib.rs +++ b/pallets/route-executor/src/lib.rs @@ -259,7 +259,7 @@ pub mod pallet { let route_length = route.len(); - let next_event_id =pallet_support::Pallet::::add_to_context(ExecutionType::Router)?; + let next_event_id = pallet_support::Pallet::::add_to_context(ExecutionType::Router)?; for (trade_index, (trade_amount, trade)) in trade_amounts.iter().rev().zip(route).enumerate() { Self::disable_ed_handling_for_insufficient_assets(route_length, trade_index, trade); @@ -496,7 +496,7 @@ impl Pallet { let route_length = route.len(); - let next_event_id =pallet_support::Pallet::::add_to_context(ExecutionType::Router)?; + let next_event_id = pallet_support::Pallet::::add_to_context(ExecutionType::Router)?; for (trade_index, (trade_amount, trade)) in trade_amounts.iter().zip(route.clone()).enumerate() { Self::disable_ed_handling_for_insufficient_assets(route_length, trade_index, trade); diff --git a/pallets/stableswap/src/tests/add_liquidity.rs b/pallets/stableswap/src/tests/add_liquidity.rs index a53acf075..7e0811829 100644 --- a/pallets/stableswap/src/tests/add_liquidity.rs +++ b/pallets/stableswap/src/tests/add_liquidity.rs @@ -110,8 +110,8 @@ fn add_liquidity_should_emit_swapped_events() { RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { swapper: BOB, filler: pool_account, - filler_type:pallet_support::types::Filler::Stableswap(pool_id), - operation:pallet_support::types::TradeOperation::LiquidityAdd, + filler_type: pallet_support::types::Filler::Stableswap(pool_id), + operation: pallet_support::types::TradeOperation::LiquidityAdd, inputs: vec![Asset::new(asset_a, 2000000000000000000),], outputs: vec![Asset::new(pool_id, 1947487201901031408)], fees: vec![ @@ -713,8 +713,8 @@ fn add_liquidity_should_work_correctly_when_providing_exact_amount_of_shares() { RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { swapper: BOB, filler: pool_account, - filler_type:pallet_support::types::Filler::Stableswap(pool_id), - operation:pallet_support::types::TradeOperation::LiquidityAdd, + filler_type: pallet_support::types::Filler::Stableswap(pool_id), + operation: pallet_support::types::TradeOperation::LiquidityAdd, inputs: vec![Asset::new(asset_a, 2000000000000000003),], outputs: vec![Asset::new(pool_id, 1947597621401945851)], fees: vec![Fee::new(pool_id, 0, pool_account)], diff --git a/pallets/stableswap/src/tests/remove_liquidity.rs b/pallets/stableswap/src/tests/remove_liquidity.rs index 5b0ba13ed..94466d586 100644 --- a/pallets/stableswap/src/tests/remove_liquidity.rs +++ b/pallets/stableswap/src/tests/remove_liquidity.rs @@ -78,8 +78,8 @@ fn remove_liquidity_should_work_when_withdrawing_all_shares() { RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { swapper: BOB, filler: pool_account, - filler_type:pallet_support::types::Filler::Stableswap(pool_id), - operation:pallet_support::types::TradeOperation::LiquidityRemove, + filler_type: pallet_support::types::Filler::Stableswap(pool_id), + operation: pallet_support::types::TradeOperation::LiquidityRemove, inputs: vec![Asset::new(pool_id, 200516043533380244763),], outputs: vec![Asset::new(asset_c, 199999999999999)], fees: vec![Fee::new(pool_id, 0, pool_account)], @@ -1084,8 +1084,8 @@ fn removing_liquidity_with_exact_amount_should_emit_swapped_event() { RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { swapper: BOB, filler: pool_account, - filler_type:pallet_support::types::Filler::Stableswap(4), - operation:pallet_support::types::TradeOperation::LiquidityRemove, + filler_type: pallet_support::types::Filler::Stableswap(4), + operation: pallet_support::types::TradeOperation::LiquidityRemove, inputs: vec![Asset::new(pool_id, 979387928052053203)], outputs: vec![Asset::new(asset_a, 1000000000000000000),], fees: vec![ diff --git a/pallets/stableswap/src/tests/trades.rs b/pallets/stableswap/src/tests/trades.rs index 93dd888cd..c5e1b6c18 100644 --- a/pallets/stableswap/src/tests/trades.rs +++ b/pallets/stableswap/src/tests/trades.rs @@ -69,8 +69,8 @@ fn sell_should_work_when_correct_input_provided() { pallet_support::Event::Swapped { swapper: BOB, filler: pool_account, - filler_type:pallet_support::types::Filler::Stableswap(pool_id), - operation:pallet_support::types::TradeOperation::ExactIn, + filler_type: pallet_support::types::Filler::Stableswap(pool_id), + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(asset_a, 30000000000000)], outputs: vec![Asset::new(asset_b, 29902625420922)], fees: vec![Fee::new(asset_b, 0, pool_account)], @@ -143,8 +143,8 @@ fn buy_should_work_when_correct_input_provided() { pallet_support::Event::Swapped { swapper: BOB, filler: pool_account, - filler_type:pallet_support::types::Filler::Stableswap(pool_id), - operation:pallet_support::types::TradeOperation::ExactOut, + filler_type: pallet_support::types::Filler::Stableswap(pool_id), + operation: pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(asset_a, 30098072706882)], outputs: vec![Asset::new(asset_b, 30000000000000)], fees: vec![Fee::new(asset_a, 0, pool_account)], diff --git a/pallets/xyk/src/tests/fees.rs b/pallets/xyk/src/tests/fees.rs index a963ee69f..e0db66fba 100644 --- a/pallets/xyk/src/tests/fees.rs +++ b/pallets/xyk/src/tests/fees.rs @@ -149,8 +149,8 @@ fn discount_sell_fees_should_work() { pallet_support::Event::Swapped { swapper: ALICE, filler: pair_account, - filler_type:pallet_support::types::Filler::XYK(share_token), - operation:pallet_support::types::TradeOperation::ExactIn, + filler_type: pallet_support::types::Filler::XYK(share_token), + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(asset_a, 10_000_000)], outputs: vec![Asset::new(asset_b, 19_986_006)], fees: vec![Fee::new(asset_b, 13_993, pair_account)], @@ -237,8 +237,8 @@ fn discount_sell_fees_should_work() { pallet_support::Event::Swapped { swapper: ALICE, filler: pair_account, - filler_type:pallet_support::types::Filler::XYK(share_token), - operation:pallet_support::types::TradeOperation::ExactIn, + filler_type: pallet_support::types::Filler::XYK(share_token), + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(asset_a, 10_000_000)], outputs: vec![Asset::new(asset_b, 19_980_009)], fees: vec![Fee::new(asset_b, 19_990, pair_account)], @@ -320,8 +320,8 @@ fn discount_sell_fees_should_work() { pallet_support::Event::Swapped { swapper: ALICE, filler: pair_account, - filler_type:pallet_support::types::Filler::XYK(share_token), - operation:pallet_support::types::TradeOperation::ExactIn, + filler_type: pallet_support::types::Filler::XYK(share_token), + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(asset_a, 10_000_000)], outputs: vec![Asset::new(asset_b, 19_999_999)], fees: vec![Fee::new(asset_b, 0, pair_account)], @@ -420,8 +420,8 @@ fn discount_buy_fees_should_work() { pallet_support::Event::Swapped { swapper: ALICE, filler: pair_account, - filler_type:pallet_support::types::Filler::XYK(share_token), - operation:pallet_support::types::TradeOperation::ExactOut, + filler_type: pallet_support::types::Filler::XYK(share_token), + operation: pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(asset_b, 10_000_000)], outputs: vec![Asset::new(asset_a, 20_000_002)], fees: vec![Fee::new(asset_b, 14_000, pair_account)], @@ -512,8 +512,8 @@ fn discount_buy_fees_should_work() { pallet_support::Event::Swapped { swapper: ALICE, filler: pair_account, - filler_type:pallet_support::types::Filler::XYK(share_token), - operation:pallet_support::types::TradeOperation::ExactOut, + filler_type: pallet_support::types::Filler::XYK(share_token), + operation: pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(asset_b, 10_000_000)], outputs: vec![Asset::new(asset_a, 20_000_002)], fees: vec![Fee::new(asset_b, 20_000, pair_account)], @@ -593,8 +593,8 @@ fn discount_buy_fees_should_work() { pallet_support::Event::Swapped { swapper: ALICE, filler: pair_account, - filler_type:pallet_support::types::Filler::XYK(share_token), - operation:pallet_support::types::TradeOperation::ExactOut, + filler_type: pallet_support::types::Filler::XYK(share_token), + operation: pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(asset_b, 10_000_000)], outputs: vec![Asset::new(asset_a, 20_000_002)], fees: vec![Fee::new(asset_b, 0, pair_account)], diff --git a/pallets/xyk/src/tests/trades.rs b/pallets/xyk/src/tests/trades.rs index 10f2c7d33..6cfb62815 100644 --- a/pallets/xyk/src/tests/trades.rs +++ b/pallets/xyk/src/tests/trades.rs @@ -74,8 +74,8 @@ fn sell_test() { pallet_support::Event::Swapped { swapper: ALICE, filler: pair_account, - filler_type:pallet_support::types::Filler::XYK(share_token), - operation:pallet_support::types::TradeOperation::ExactIn, + filler_type: pallet_support::types::Filler::XYK(share_token), + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(asset_a, 456444678)], outputs: vec![Asset::new(asset_b, 1363483591788)], fees: vec![Fee::new(asset_b, 2732432046, pair_account)], @@ -138,8 +138,8 @@ fn execute_sell_should_use_event_id() { pallet_support::Event::Swapped { swapper: ALICE, filler: pair_account, - filler_type:pallet_support::types::Filler::XYK(share_token), - operation:pallet_support::types::TradeOperation::ExactIn, + filler_type: pallet_support::types::Filler::XYK(share_token), + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(asset_a, 456444678)], outputs: vec![Asset::new(asset_b, 1363483591788)], fees: vec![Fee::new(asset_b, 2732432046, pair_account)], @@ -445,8 +445,8 @@ fn sell_with_correct_fees_should_work() { pallet_support::Event::Swapped { swapper: user_1, filler: pair_account, - filler_type:pallet_support::types::Filler::XYK(share_token), - operation:pallet_support::types::TradeOperation::ExactIn, + filler_type: pallet_support::types::Filler::XYK(share_token), + operation: pallet_support::types::TradeOperation::ExactIn, inputs: vec![Asset::new(asset_a, 100_000)], outputs: vec![Asset::new(asset_b, 19_762_378)], fees: vec![Fee::new(asset_b, 39_602, pair_account)], @@ -663,8 +663,8 @@ fn single_buy_should_work() { pallet_support::Event::Swapped { swapper: user_1, filler: pair_account, - filler_type:pallet_support::types::Filler::XYK(share_token), - operation:pallet_support::types::TradeOperation::ExactOut, + filler_type: pallet_support::types::Filler::XYK(share_token), + operation: pallet_support::types::TradeOperation::ExactOut, inputs: vec![Asset::new(asset_b, 6_666_666)], outputs: vec![Asset::new(asset_a, 22_068_963_235)], fees: vec![Fee::new(asset_b, 44_137_926, pair_account)], diff --git a/runtime/adapters/src/lib.rs b/runtime/adapters/src/lib.rs index a35bdc6ab..467b6f5cb 100644 --- a/runtime/adapters/src/lib.rs +++ b/runtime/adapters/src/lib.rs @@ -51,6 +51,7 @@ use primitive_types::{U128, U512}; use primitives::constants::chain::{STABLESWAP_SOURCE, XYK_SOURCE}; use primitives::{constants::chain::OMNIPOOL_SOURCE, AccountId, AssetId, Balance, BlockNumber, CollectionId}; use sp_runtime::traits::BlockNumberProvider; +use sp_std::vec; use sp_std::vec::Vec; use sp_std::{collections::btree_map::BTreeMap, fmt::Debug, marker::PhantomData}; use warehouse_liquidity_mining::GlobalFarmData; @@ -59,7 +60,6 @@ use xcm_executor::{ traits::{ConvertLocation, MatchesFungible, TransactAsset, WeightTrader}, AssetsInHolding, }; -use sp_std::vec; pub mod inspect; pub mod price; @@ -336,7 +336,7 @@ where NativeAsset: Get, Runtime: pallet_ema_oracle::Config + pallet_circuit_breaker::Config - + frame_system::Config + + frame_system::Config + pallet_staking::Config + pallet_referrals::Config, ::AccountId: From, diff --git a/runtime/hydradx/src/xcm.rs b/runtime/hydradx/src/xcm.rs index 53d4f8c5b..4920db8c1 100644 --- a/runtime/hydradx/src/xcm.rs +++ b/runtime/hydradx/src/xcm.rs @@ -253,7 +253,7 @@ impl::RuntimeCall>> ExecuteXcm<::remove_from_context(); + let _ = pallet_support::Pallet::::remove_from_context(); } prepare_result @@ -267,7 +267,7 @@ impl::RuntimeCall>> ExecuteXcm< Outcome { let outcome = Inner::execute(origin, pre, id, weight_credit); - let Ok(_) =pallet_support::Pallet::::remove_from_context() else { + let Ok(_) = pallet_support::Pallet::::remove_from_context() else { return Outcome::Error { error: XcmError::FailedToTransactAsset("Unexpected error at modifying unified events stack"), }; From 9b937022d589368668d9dc373456d57fa4f76fad Mon Sep 17 00:00:00 2001 From: dmoka Date: Thu, 2 Jan 2025 10:26:03 +0100 Subject: [PATCH 120/142] bump versions --- Cargo.lock | 14 +++++++------- pallets/circuit-breaker/src/tests/mock.rs | 2 +- pallets/referrals/Cargo.toml | 2 +- pallets/staking/Cargo.toml | 2 +- runtime/hydradx/Cargo.toml | 2 +- runtime/hydradx/src/lib.rs | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 811b638dc..c445b4aaa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4897,7 +4897,7 @@ dependencies = [ "pallet-referrals", "pallet-route-executor", "pallet-stableswap", - "pallet-staking 4.0.1", + "pallet-staking 4.0.2", "pallet-support", "pallet-transaction-multi-payment", "pallet-uniques", @@ -4919,7 +4919,7 @@ dependencies = [ [[package]] name = "hydradx-runtime" -version = "277.0.0" +version = "278.0.0" dependencies = [ "cumulus-pallet-aura-ext", "cumulus-pallet-parachain-system", @@ -5010,7 +5010,7 @@ dependencies = [ "pallet-scheduler", "pallet-session", "pallet-stableswap", - "pallet-staking 4.0.1", + "pallet-staking 4.0.2", "pallet-state-trie-migration", "pallet-support", "pallet-timestamp", @@ -9002,7 +9002,7 @@ dependencies = [ [[package]] name = "pallet-referrals" -version = "1.2.7" +version = "1.2.8" dependencies = [ "frame-benchmarking", "frame-support", @@ -9182,7 +9182,7 @@ dependencies = [ [[package]] name = "pallet-staking" -version = "4.0.1" +version = "4.0.2" dependencies = [ "frame-benchmarking", "frame-support", @@ -12352,7 +12352,7 @@ dependencies = [ "pallet-scheduler", "pallet-session", "pallet-stableswap", - "pallet-staking 4.0.1", + "pallet-staking 4.0.2", "pallet-support", "pallet-timestamp", "pallet-tips", @@ -12417,7 +12417,7 @@ dependencies = [ "pallet-asset-registry", "pallet-omnipool", "pallet-stableswap", - "pallet-staking 4.0.1", + "pallet-staking 4.0.2", "primitives", "scraper", "serde", diff --git a/pallets/circuit-breaker/src/tests/mock.rs b/pallets/circuit-breaker/src/tests/mock.rs index 1fa7f5727..9346b03ed 100644 --- a/pallets/circuit-breaker/src/tests/mock.rs +++ b/pallets/circuit-breaker/src/tests/mock.rs @@ -24,7 +24,7 @@ use frame_system::EnsureRoot; use hydra_dx_math::omnipool::types::BalanceUpdate; use orml_traits::{parameter_type_with_key, GetByKey}; use sp_core::H256; -use sp_runtime::traits::{ConstU128, ConstU32, Zero}; +use sp_runtime::traits::{ConstU128, ConstU32}; use sp_runtime::DispatchResult; use sp_runtime::FixedU128; use sp_runtime::Permill; diff --git a/pallets/referrals/Cargo.toml b/pallets/referrals/Cargo.toml index 9f0aba73b..9fd040a0f 100644 --- a/pallets/referrals/Cargo.toml +++ b/pallets/referrals/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-referrals" -version = "1.2.7" +version = "1.2.8" authors = ['GalacticCouncil'] edition = "2021" license = "Apache-2.0" diff --git a/pallets/staking/Cargo.toml b/pallets/staking/Cargo.toml index cccb4f3f8..7095dcdfa 100644 --- a/pallets/staking/Cargo.toml +++ b/pallets/staking/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-staking" -version = "4.0.1" +version = "4.0.2" authors = ['GalacticCouncil'] edition = "2021" license = "Apache-2.0" diff --git a/runtime/hydradx/Cargo.toml b/runtime/hydradx/Cargo.toml index 48227602e..80e0428a5 100644 --- a/runtime/hydradx/Cargo.toml +++ b/runtime/hydradx/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hydradx-runtime" -version = "277.0.0" +version = "278.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 1ea058252..80a392856 100644 --- a/runtime/hydradx/src/lib.rs +++ b/runtime/hydradx/src/lib.rs @@ -113,7 +113,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("hydradx"), impl_name: create_runtime_str!("hydradx"), authoring_version: 1, - spec_version: 277, + spec_version: 278, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, From c902d2990f7fa875303eaa2717099ad6115339ce Mon Sep 17 00:00:00 2001 From: dmoka Date: Thu, 2 Jan 2025 10:50:35 +0100 Subject: [PATCH 121/142] use patch4 release --- Cargo.lock | 554 ++++++++++++++++----------------- Cargo.toml | 894 ++++++++++++++++++++++++++--------------------------- 2 files changed, 724 insertions(+), 724 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c445b4aaa..8fb2fdd5d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -939,7 +939,7 @@ dependencies = [ [[package]] name = "binary-merkle-tree" version = "13.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "hash-db", "log", @@ -1170,7 +1170,7 @@ dependencies = [ [[package]] name = "bp-xcm-bridge-hub-router" version = "0.6.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "parity-scale-codec", "scale-info", @@ -2032,7 +2032,7 @@ dependencies = [ [[package]] name = "cumulus-client-cli" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "clap 4.5.4", "parity-scale-codec", @@ -2049,7 +2049,7 @@ dependencies = [ [[package]] name = "cumulus-client-collator" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "cumulus-client-consensus-common", "cumulus-client-network", @@ -2072,7 +2072,7 @@ dependencies = [ [[package]] name = "cumulus-client-consensus-aura" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "async-trait", "cumulus-client-collator", @@ -2114,7 +2114,7 @@ dependencies = [ [[package]] name = "cumulus-client-consensus-common" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "async-trait", "cumulus-client-pov-recovery", @@ -2143,7 +2143,7 @@ dependencies = [ [[package]] name = "cumulus-client-consensus-proposer" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "anyhow", "async-trait", @@ -2158,7 +2158,7 @@ dependencies = [ [[package]] name = "cumulus-client-network" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "async-trait", "cumulus-relay-chain-interface", @@ -2181,7 +2181,7 @@ dependencies = [ [[package]] name = "cumulus-client-parachain-inherent" version = "0.1.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "async-trait", "cumulus-primitives-core", @@ -2205,7 +2205,7 @@ dependencies = [ [[package]] name = "cumulus-client-pov-recovery" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "async-trait", "cumulus-primitives-core", @@ -2229,7 +2229,7 @@ dependencies = [ [[package]] name = "cumulus-client-service" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "cumulus-client-cli", "cumulus-client-collator", @@ -2266,7 +2266,7 @@ dependencies = [ [[package]] name = "cumulus-pallet-aura-ext" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "cumulus-pallet-parachain-system", "frame-support", @@ -2284,7 +2284,7 @@ dependencies = [ [[package]] name = "cumulus-pallet-parachain-system" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "bytes", "cumulus-pallet-parachain-system-proc-macro", @@ -2319,7 +2319,7 @@ dependencies = [ [[package]] name = "cumulus-pallet-parachain-system-proc-macro" version = "0.6.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", @@ -2330,7 +2330,7 @@ dependencies = [ [[package]] name = "cumulus-pallet-xcm" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "cumulus-primitives-core", "frame-support", @@ -2346,7 +2346,7 @@ dependencies = [ [[package]] name = "cumulus-pallet-xcmp-queue" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "bounded-collections", "bp-xcm-bridge-hub-router", @@ -2371,7 +2371,7 @@ dependencies = [ [[package]] name = "cumulus-primitives-aura" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "parity-scale-codec", "polkadot-core-primitives", @@ -2385,7 +2385,7 @@ dependencies = [ [[package]] name = "cumulus-primitives-core" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "parity-scale-codec", "polkadot-core-primitives", @@ -2402,7 +2402,7 @@ dependencies = [ [[package]] name = "cumulus-primitives-parachain-inherent" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "async-trait", "cumulus-primitives-core", @@ -2419,7 +2419,7 @@ dependencies = [ [[package]] name = "cumulus-primitives-proof-size-hostfunction" version = "0.2.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "sp-externalities", "sp-runtime-interface", @@ -2429,7 +2429,7 @@ dependencies = [ [[package]] name = "cumulus-primitives-timestamp" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "cumulus-primitives-core", "futures", @@ -2442,7 +2442,7 @@ dependencies = [ [[package]] name = "cumulus-primitives-utility" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "cumulus-primitives-core", "frame-support", @@ -2462,7 +2462,7 @@ dependencies = [ [[package]] name = "cumulus-relay-chain-inprocess-interface" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "async-trait", "cumulus-primitives-core", @@ -2486,7 +2486,7 @@ dependencies = [ [[package]] name = "cumulus-relay-chain-interface" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "async-trait", "cumulus-primitives-core", @@ -2504,7 +2504,7 @@ dependencies = [ [[package]] name = "cumulus-relay-chain-minimal-node" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "array-bytes 6.2.2", "async-trait", @@ -2546,7 +2546,7 @@ dependencies = [ [[package]] name = "cumulus-relay-chain-rpc-interface" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "async-trait", "cumulus-primitives-core", @@ -2585,7 +2585,7 @@ dependencies = [ [[package]] name = "cumulus-test-relay-sproof-builder" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "cumulus-primitives-core", "parity-scale-codec", @@ -3761,7 +3761,7 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "fork-tree" version = "12.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "parity-scale-codec", ] @@ -3877,7 +3877,7 @@ checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" [[package]] name = "frame-benchmarking" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-support", "frame-support-procedural", @@ -3902,7 +3902,7 @@ dependencies = [ [[package]] name = "frame-benchmarking-cli" version = "32.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "Inflector", "array-bytes 6.2.2", @@ -3952,7 +3952,7 @@ dependencies = [ [[package]] name = "frame-election-provider-solution-type" version = "13.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", @@ -3963,7 +3963,7 @@ dependencies = [ [[package]] name = "frame-election-provider-support" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-election-provider-solution-type", "frame-support", @@ -3980,7 +3980,7 @@ dependencies = [ [[package]] name = "frame-executive" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "aquamarine 0.3.3", "frame-support", @@ -4011,7 +4011,7 @@ dependencies = [ [[package]] name = "frame-metadata-hash-extension" version = "0.1.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "array-bytes 6.2.2", "docify", @@ -4026,7 +4026,7 @@ dependencies = [ [[package]] name = "frame-remote-externalities" version = "0.35.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "futures", "indicatif", @@ -4048,7 +4048,7 @@ dependencies = [ [[package]] name = "frame-support" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "aquamarine 0.5.0", "array-bytes 6.2.2", @@ -4089,7 +4089,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "23.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "Inflector", "cfg-expr", @@ -4108,7 +4108,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "10.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate 3.1.0", @@ -4120,7 +4120,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "11.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "proc-macro2", "quote", @@ -4130,7 +4130,7 @@ dependencies = [ [[package]] name = "frame-system" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "cfg-if", "docify", @@ -4150,7 +4150,7 @@ dependencies = [ [[package]] name = "frame-system-benchmarking" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-benchmarking", "frame-support", @@ -4165,7 +4165,7 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "26.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "parity-scale-codec", "sp-api", @@ -4174,7 +4174,7 @@ dependencies = [ [[package]] name = "frame-try-runtime" version = "0.34.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-support", "parity-scale-codec", @@ -6603,7 +6603,7 @@ dependencies = [ [[package]] name = "mmr-gadget" version = "29.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "futures", "log", @@ -6622,7 +6622,7 @@ dependencies = [ [[package]] name = "mmr-rpc" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -7505,7 +7505,7 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] name = "pallet-asset-conversion" version = "10.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-benchmarking", "frame-support", @@ -7524,7 +7524,7 @@ dependencies = [ [[package]] name = "pallet-asset-rate" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-benchmarking", "frame-support", @@ -7567,7 +7567,7 @@ dependencies = [ [[package]] name = "pallet-asset-tx-payment" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-benchmarking", "frame-support", @@ -7585,7 +7585,7 @@ dependencies = [ [[package]] name = "pallet-assets" version = "29.1.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-benchmarking", "frame-support", @@ -7601,7 +7601,7 @@ dependencies = [ [[package]] name = "pallet-aura" version = "27.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-support", "frame-system", @@ -7618,7 +7618,7 @@ dependencies = [ [[package]] name = "pallet-authority-discovery" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-support", "frame-system", @@ -7634,7 +7634,7 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-support", "frame-system", @@ -7648,7 +7648,7 @@ dependencies = [ [[package]] name = "pallet-babe" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-benchmarking", "frame-support", @@ -7672,7 +7672,7 @@ dependencies = [ [[package]] name = "pallet-bags-list" version = "27.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "aquamarine 0.5.0", "docify", @@ -7694,7 +7694,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "docify", "frame-benchmarking", @@ -7710,7 +7710,7 @@ dependencies = [ [[package]] name = "pallet-beefy" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-support", "frame-system", @@ -7730,7 +7730,7 @@ dependencies = [ [[package]] name = "pallet-beefy-mmr" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "array-bytes 6.2.2", "binary-merkle-tree", @@ -7779,7 +7779,7 @@ dependencies = [ [[package]] name = "pallet-bounties" version = "27.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-benchmarking", "frame-support", @@ -7797,7 +7797,7 @@ dependencies = [ [[package]] name = "pallet-broker" version = "0.6.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "bitvec", "frame-benchmarking", @@ -7816,7 +7816,7 @@ dependencies = [ [[package]] name = "pallet-child-bounties" version = "27.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-benchmarking", "frame-support", @@ -7907,7 +7907,7 @@ dependencies = [ [[package]] name = "pallet-collator-selection" version = "9.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-benchmarking", "frame-support", @@ -7927,7 +7927,7 @@ dependencies = [ [[package]] name = "pallet-collective" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-benchmarking", "frame-support", @@ -7944,7 +7944,7 @@ dependencies = [ [[package]] name = "pallet-conviction-voting" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "assert_matches", "frame-benchmarking", @@ -8052,7 +8052,7 @@ dependencies = [ [[package]] name = "pallet-democracy" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-benchmarking", "frame-support", @@ -8140,7 +8140,7 @@ dependencies = [ [[package]] name = "pallet-election-provider-multi-phase" version = "27.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -8163,7 +8163,7 @@ dependencies = [ [[package]] name = "pallet-election-provider-support-benchmarking" version = "27.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -8177,7 +8177,7 @@ dependencies = [ [[package]] name = "pallet-elections-phragmen" version = "29.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-benchmarking", "frame-support", @@ -8384,7 +8384,7 @@ dependencies = [ [[package]] name = "pallet-fast-unstake" version = "27.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "docify", "frame-benchmarking", @@ -8421,7 +8421,7 @@ dependencies = [ [[package]] name = "pallet-grandpa" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-benchmarking", "frame-support", @@ -8444,7 +8444,7 @@ dependencies = [ [[package]] name = "pallet-identity" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "enumflags2", "frame-benchmarking", @@ -8461,7 +8461,7 @@ dependencies = [ [[package]] name = "pallet-im-online" version = "27.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-benchmarking", "frame-support", @@ -8481,7 +8481,7 @@ dependencies = [ [[package]] name = "pallet-indices" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-benchmarking", "frame-support", @@ -8588,7 +8588,7 @@ dependencies = [ [[package]] name = "pallet-membership" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-benchmarking", "frame-support", @@ -8605,7 +8605,7 @@ dependencies = [ [[package]] name = "pallet-message-queue" version = "31.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "environmental", "frame-benchmarking", @@ -8625,7 +8625,7 @@ dependencies = [ [[package]] name = "pallet-mmr" version = "27.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-benchmarking", "frame-support", @@ -8643,7 +8643,7 @@ dependencies = [ [[package]] name = "pallet-multisig" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-benchmarking", "frame-support", @@ -8679,7 +8679,7 @@ dependencies = [ [[package]] name = "pallet-nis" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-benchmarking", "frame-support", @@ -8695,7 +8695,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools" version = "25.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-support", "frame-system", @@ -8714,7 +8714,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools-benchmarking" version = "26.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -8734,7 +8734,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools-runtime-api" version = "23.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "pallet-nomination-pools", "parity-scale-codec", @@ -8745,7 +8745,7 @@ dependencies = [ [[package]] name = "pallet-offences" version = "27.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-support", "frame-system", @@ -8762,7 +8762,7 @@ dependencies = [ [[package]] name = "pallet-offences-benchmarking" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -8900,7 +8900,7 @@ dependencies = [ [[package]] name = "pallet-parameters" version = "0.1.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "docify", "frame-benchmarking", @@ -8918,7 +8918,7 @@ dependencies = [ [[package]] name = "pallet-preimage" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-benchmarking", "frame-support", @@ -8935,7 +8935,7 @@ dependencies = [ [[package]] name = "pallet-proxy" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-benchmarking", "frame-support", @@ -8950,7 +8950,7 @@ dependencies = [ [[package]] name = "pallet-ranked-collective" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-benchmarking", "frame-support", @@ -8969,7 +8969,7 @@ dependencies = [ [[package]] name = "pallet-recovery" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-benchmarking", "frame-support", @@ -8984,7 +8984,7 @@ dependencies = [ [[package]] name = "pallet-referenda" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "assert_matches", "frame-benchmarking", @@ -9039,7 +9039,7 @@ dependencies = [ [[package]] name = "pallet-root-testing" version = "4.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-support", "frame-system", @@ -9081,7 +9081,7 @@ dependencies = [ [[package]] name = "pallet-scheduler" version = "29.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "docify", "frame-benchmarking", @@ -9099,7 +9099,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-support", "frame-system", @@ -9121,7 +9121,7 @@ dependencies = [ [[package]] name = "pallet-session-benchmarking" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-benchmarking", "frame-support", @@ -9138,7 +9138,7 @@ dependencies = [ [[package]] name = "pallet-society" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-benchmarking", "frame-support", @@ -9209,7 +9209,7 @@ dependencies = [ [[package]] name = "pallet-staking" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -9232,7 +9232,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-curve" version = "11.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", @@ -9243,7 +9243,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-fn" version = "19.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "log", "sp-arithmetic", @@ -9252,7 +9252,7 @@ dependencies = [ [[package]] name = "pallet-staking-runtime-api" version = "14.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "parity-scale-codec", "sp-api", @@ -9262,7 +9262,7 @@ dependencies = [ [[package]] name = "pallet-state-trie-migration" version = "29.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-benchmarking", "frame-support", @@ -9279,7 +9279,7 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "docify", "frame-benchmarking", @@ -9314,7 +9314,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "27.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "docify", "frame-benchmarking", @@ -9334,7 +9334,7 @@ dependencies = [ [[package]] name = "pallet-tips" version = "27.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-benchmarking", "frame-support", @@ -9402,7 +9402,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-support", "frame-system", @@ -9418,7 +9418,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "30.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "jsonrpsee", "pallet-transaction-payment-rpc-runtime-api", @@ -9434,7 +9434,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "pallet-transaction-payment", "parity-scale-codec", @@ -9446,7 +9446,7 @@ dependencies = [ [[package]] name = "pallet-treasury" version = "27.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "docify", "frame-benchmarking", @@ -9465,7 +9465,7 @@ dependencies = [ [[package]] name = "pallet-uniques" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-benchmarking", "frame-support", @@ -9480,7 +9480,7 @@ dependencies = [ [[package]] name = "pallet-utility" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-benchmarking", "frame-support", @@ -9497,7 +9497,7 @@ dependencies = [ [[package]] name = "pallet-vesting" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-benchmarking", "frame-support", @@ -9512,7 +9512,7 @@ dependencies = [ [[package]] name = "pallet-whitelist" version = "27.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-benchmarking", "frame-support", @@ -9527,7 +9527,7 @@ dependencies = [ [[package]] name = "pallet-xcm" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "bounded-collections", "frame-benchmarking", @@ -9551,7 +9551,7 @@ dependencies = [ [[package]] name = "pallet-xcm-benchmarks" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-benchmarking", "frame-support", @@ -9622,7 +9622,7 @@ dependencies = [ [[package]] name = "parachains-common" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "cumulus-primitives-core", "cumulus-primitives-utility", @@ -9994,7 +9994,7 @@ dependencies = [ [[package]] name = "polkadot-approval-distribution" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "bitvec", "futures", @@ -10014,7 +10014,7 @@ dependencies = [ [[package]] name = "polkadot-availability-bitfield-distribution" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "always-assert", "futures", @@ -10030,7 +10030,7 @@ dependencies = [ [[package]] name = "polkadot-availability-distribution" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "derive_more", "fatality", @@ -10053,7 +10053,7 @@ dependencies = [ [[package]] name = "polkadot-availability-recovery" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "async-trait", "fatality", @@ -10076,7 +10076,7 @@ dependencies = [ [[package]] name = "polkadot-cli" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "cfg-if", "clap 4.5.4", @@ -10104,7 +10104,7 @@ dependencies = [ [[package]] name = "polkadot-collator-protocol" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "bitvec", "fatality", @@ -10126,7 +10126,7 @@ dependencies = [ [[package]] name = "polkadot-core-primitives" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "parity-scale-codec", "scale-info", @@ -10138,7 +10138,7 @@ dependencies = [ [[package]] name = "polkadot-dispute-distribution" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "derive_more", "fatality", @@ -10163,7 +10163,7 @@ dependencies = [ [[package]] name = "polkadot-erasure-coding" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "parity-scale-codec", "polkadot-node-primitives", @@ -10177,7 +10177,7 @@ dependencies = [ [[package]] name = "polkadot-gossip-support" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "futures", "futures-timer", @@ -10199,7 +10199,7 @@ dependencies = [ [[package]] name = "polkadot-network-bridge" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "always-assert", "async-trait", @@ -10222,7 +10222,7 @@ dependencies = [ [[package]] name = "polkadot-node-collation-generation" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "futures", "parity-scale-codec", @@ -10240,7 +10240,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-approval-voting" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "bitvec", "derive_more", @@ -10273,7 +10273,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-av-store" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "bitvec", "futures", @@ -10295,7 +10295,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-backing" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "bitvec", "fatality", @@ -10315,7 +10315,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-bitfield-signing" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "futures", "polkadot-node-subsystem", @@ -10330,7 +10330,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-candidate-validation" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "async-trait", "futures", @@ -10351,7 +10351,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-chain-api" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "futures", "polkadot-node-metrics", @@ -10365,7 +10365,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-chain-selection" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "futures", "futures-timer", @@ -10382,7 +10382,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-dispute-coordinator" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "fatality", "futures", @@ -10401,7 +10401,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-parachains-inherent" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "async-trait", "futures", @@ -10418,7 +10418,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-prospective-parachains" version = "6.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "bitvec", "fatality", @@ -10435,7 +10435,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-provisioner" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "bitvec", "fatality", @@ -10453,7 +10453,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-pvf" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "always-assert", "array-bytes 6.2.2", @@ -10482,7 +10482,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-pvf-checker" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "futures", "polkadot-node-primitives", @@ -10498,7 +10498,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-pvf-common" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "cpu-time", "futures", @@ -10524,7 +10524,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-runtime-api" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "futures", "polkadot-node-metrics", @@ -10539,7 +10539,7 @@ dependencies = [ [[package]] name = "polkadot-node-jaeger" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "lazy_static", "log", @@ -10558,7 +10558,7 @@ dependencies = [ [[package]] name = "polkadot-node-metrics" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "bs58 0.5.0", "futures", @@ -10577,7 +10577,7 @@ dependencies = [ [[package]] name = "polkadot-node-network-protocol" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "async-channel 1.9.0", "async-trait", @@ -10603,7 +10603,7 @@ dependencies = [ [[package]] name = "polkadot-node-primitives" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "bitvec", "bounded-vec", @@ -10626,7 +10626,7 @@ dependencies = [ [[package]] name = "polkadot-node-subsystem" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "polkadot-node-jaeger", "polkadot-node-subsystem-types", @@ -10636,7 +10636,7 @@ dependencies = [ [[package]] name = "polkadot-node-subsystem-types" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "async-trait", "bitvec", @@ -10665,7 +10665,7 @@ dependencies = [ [[package]] name = "polkadot-node-subsystem-util" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "async-trait", "derive_more", @@ -10700,7 +10700,7 @@ dependencies = [ [[package]] name = "polkadot-overseer" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "async-trait", "futures", @@ -10722,7 +10722,7 @@ dependencies = [ [[package]] name = "polkadot-parachain-primitives" version = "6.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "bounded-collections", "derive_more", @@ -10739,7 +10739,7 @@ dependencies = [ [[package]] name = "polkadot-primitives" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "bitvec", "hex-literal", @@ -10766,7 +10766,7 @@ dependencies = [ [[package]] name = "polkadot-rpc" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "jsonrpsee", "mmr-rpc", @@ -10799,7 +10799,7 @@ dependencies = [ [[package]] name = "polkadot-runtime-common" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "bitvec", "frame-benchmarking", @@ -10850,7 +10850,7 @@ dependencies = [ [[package]] name = "polkadot-runtime-metrics" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "bs58 0.5.0", "frame-benchmarking", @@ -10863,7 +10863,7 @@ dependencies = [ [[package]] name = "polkadot-runtime-parachains" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "bitflags 1.3.2", "bitvec", @@ -10912,7 +10912,7 @@ dependencies = [ [[package]] name = "polkadot-service" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "async-trait", "frame-benchmarking", @@ -11030,7 +11030,7 @@ dependencies = [ [[package]] name = "polkadot-statement-distribution" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "arrayvec 0.7.4", "bitvec", @@ -11053,7 +11053,7 @@ dependencies = [ [[package]] name = "polkadot-statement-table" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "parity-scale-codec", "polkadot-primitives", @@ -12109,7 +12109,7 @@ dependencies = [ [[package]] name = "rococo-runtime" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "binary-merkle-tree", "bitvec", @@ -12210,7 +12210,7 @@ dependencies = [ [[package]] name = "rococo-runtime-constants" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-support", "polkadot-primitives", @@ -12681,7 +12681,7 @@ dependencies = [ [[package]] name = "sc-allocator" version = "23.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "log", "sp-core", @@ -12692,7 +12692,7 @@ dependencies = [ [[package]] name = "sc-authority-discovery" version = "0.34.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "async-trait", "futures", @@ -12723,7 +12723,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.34.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "futures", "futures-timer", @@ -12745,7 +12745,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.33.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "parity-scale-codec", "sp-api", @@ -12760,7 +12760,7 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "array-bytes 6.2.2", "docify", @@ -12787,7 +12787,7 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "11.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", @@ -12798,7 +12798,7 @@ dependencies = [ [[package]] name = "sc-cli" version = "0.36.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "array-bytes 6.2.2", "chrono", @@ -12839,7 +12839,7 @@ dependencies = [ [[package]] name = "sc-client-api" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "fnv", "futures", @@ -12866,7 +12866,7 @@ dependencies = [ [[package]] name = "sc-client-db" version = "0.35.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "hash-db", "kvdb", @@ -12892,7 +12892,7 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.33.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "async-trait", "futures", @@ -12917,7 +12917,7 @@ dependencies = [ [[package]] name = "sc-consensus-aura" version = "0.34.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "async-trait", "futures", @@ -12946,7 +12946,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe" version = "0.34.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "async-trait", "fork-tree", @@ -12982,7 +12982,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe-rpc" version = "0.34.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "futures", "jsonrpsee", @@ -13004,7 +13004,7 @@ dependencies = [ [[package]] name = "sc-consensus-beefy" version = "13.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "array-bytes 6.2.2", "async-channel 1.9.0", @@ -13041,7 +13041,7 @@ dependencies = [ [[package]] name = "sc-consensus-beefy-rpc" version = "13.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "futures", "jsonrpsee", @@ -13060,7 +13060,7 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" version = "0.33.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "fork-tree", "parity-scale-codec", @@ -13073,7 +13073,7 @@ dependencies = [ [[package]] name = "sc-consensus-grandpa" version = "0.19.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "ahash 0.8.6", "array-bytes 6.2.2", @@ -13117,7 +13117,7 @@ dependencies = [ [[package]] name = "sc-consensus-grandpa-rpc" version = "0.19.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "finality-grandpa", "futures", @@ -13137,7 +13137,7 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.33.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "async-trait", "futures", @@ -13160,7 +13160,7 @@ dependencies = [ [[package]] name = "sc-executor" version = "0.32.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "parity-scale-codec", "parking_lot 0.12.3", @@ -13183,7 +13183,7 @@ dependencies = [ [[package]] name = "sc-executor-common" version = "0.29.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "polkavm", "sc-allocator", @@ -13196,7 +13196,7 @@ dependencies = [ [[package]] name = "sc-executor-polkavm" version = "0.29.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "log", "polkavm", @@ -13207,7 +13207,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmtime" version = "0.29.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "anyhow", "cfg-if", @@ -13225,7 +13225,7 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.33.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "ansi_term", "futures", @@ -13242,7 +13242,7 @@ dependencies = [ [[package]] name = "sc-keystore" version = "25.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "array-bytes 6.2.2", "parking_lot 0.12.3", @@ -13256,7 +13256,7 @@ dependencies = [ [[package]] name = "sc-mixnet" version = "0.4.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "array-bytes 4.2.0", "arrayvec 0.7.4", @@ -13285,7 +13285,7 @@ dependencies = [ [[package]] name = "sc-network" version = "0.34.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "array-bytes 6.2.2", "async-channel 1.9.0", @@ -13336,7 +13336,7 @@ dependencies = [ [[package]] name = "sc-network-common" version = "0.33.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "async-trait", "bitflags 1.3.2", @@ -13354,7 +13354,7 @@ dependencies = [ [[package]] name = "sc-network-gossip" version = "0.34.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "ahash 0.8.6", "futures", @@ -13374,7 +13374,7 @@ dependencies = [ [[package]] name = "sc-network-light" version = "0.33.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "array-bytes 6.2.2", "async-channel 1.9.0", @@ -13395,7 +13395,7 @@ dependencies = [ [[package]] name = "sc-network-sync" version = "0.33.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "array-bytes 6.2.2", "async-channel 1.9.0", @@ -13432,7 +13432,7 @@ dependencies = [ [[package]] name = "sc-network-transactions" version = "0.33.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "array-bytes 6.2.2", "futures", @@ -13452,7 +13452,7 @@ dependencies = [ [[package]] name = "sc-network-types" version = "0.10.0-dev" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "bs58 0.4.0", "libp2p-identity", @@ -13466,7 +13466,7 @@ dependencies = [ [[package]] name = "sc-offchain" version = "29.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "array-bytes 6.2.2", "bytes", @@ -13501,7 +13501,7 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.17.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -13510,7 +13510,7 @@ dependencies = [ [[package]] name = "sc-rpc" version = "29.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "futures", "jsonrpsee", @@ -13542,7 +13542,7 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.33.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -13562,7 +13562,7 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "11.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "futures", "governor", @@ -13580,7 +13580,7 @@ dependencies = [ [[package]] name = "sc-rpc-spec-v2" version = "0.34.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "array-bytes 6.2.2", "futures", @@ -13612,7 +13612,7 @@ dependencies = [ [[package]] name = "sc-service" version = "0.35.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "async-trait", "directories", @@ -13676,7 +13676,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.30.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "log", "parity-scale-codec", @@ -13687,7 +13687,7 @@ dependencies = [ [[package]] name = "sc-storage-monitor" version = "0.16.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "clap 4.5.4", "fs4", @@ -13700,7 +13700,7 @@ dependencies = [ [[package]] name = "sc-sync-state-rpc" version = "0.34.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -13719,7 +13719,7 @@ dependencies = [ [[package]] name = "sc-sysinfo" version = "27.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "derive_more", "futures", @@ -13740,7 +13740,7 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "15.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "chrono", "futures", @@ -13760,7 +13760,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "ansi_term", "chrono", @@ -13790,7 +13790,7 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "11.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", @@ -13801,7 +13801,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "async-trait", "futures", @@ -13828,7 +13828,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool-api" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "async-trait", "futures", @@ -13844,7 +13844,7 @@ dependencies = [ [[package]] name = "sc-utils" version = "14.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "async-channel 1.9.0", "futures", @@ -14383,7 +14383,7 @@ dependencies = [ [[package]] name = "slot-range-helper" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "enumn", "parity-scale-codec", @@ -14577,7 +14577,7 @@ dependencies = [ [[package]] name = "sp-api" version = "26.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "hash-db", "log", @@ -14599,7 +14599,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "15.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "Inflector", "blake2 0.10.6", @@ -14613,7 +14613,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "30.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "parity-scale-codec", "scale-info", @@ -14626,7 +14626,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "23.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "docify", "integer-sqrt", @@ -14659,7 +14659,7 @@ dependencies = [ [[package]] name = "sp-authority-discovery" version = "26.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "parity-scale-codec", "scale-info", @@ -14671,7 +14671,7 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "26.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "sp-api", "sp-inherents", @@ -14681,7 +14681,7 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "futures", "log", @@ -14699,7 +14699,7 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.32.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "async-trait", "futures", @@ -14714,7 +14714,7 @@ dependencies = [ [[package]] name = "sp-consensus-aura" version = "0.32.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "async-trait", "parity-scale-codec", @@ -14730,7 +14730,7 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.32.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "async-trait", "parity-scale-codec", @@ -14748,7 +14748,7 @@ dependencies = [ [[package]] name = "sp-consensus-beefy" version = "13.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "lazy_static", "parity-scale-codec", @@ -14768,7 +14768,7 @@ dependencies = [ [[package]] name = "sp-consensus-grandpa" version = "13.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "finality-grandpa", "log", @@ -14785,7 +14785,7 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.32.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "parity-scale-codec", "scale-info", @@ -14796,7 +14796,7 @@ dependencies = [ [[package]] name = "sp-core" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "array-bytes 6.2.2", "bandersnatch_vrfs", @@ -14863,7 +14863,7 @@ dependencies = [ [[package]] name = "sp-crypto-hashing" version = "0.1.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "blake2b_simd", "byteorder", @@ -14876,7 +14876,7 @@ dependencies = [ [[package]] name = "sp-crypto-hashing-proc-macro" version = "0.1.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "quote", "sp-crypto-hashing", @@ -14886,7 +14886,7 @@ dependencies = [ [[package]] name = "sp-database" version = "10.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "kvdb", "parking_lot 0.12.3", @@ -14895,7 +14895,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "14.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "proc-macro2", "quote", @@ -14905,7 +14905,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.25.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "environmental", "parity-scale-codec", @@ -14915,7 +14915,7 @@ dependencies = [ [[package]] name = "sp-genesis-builder" version = "0.8.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "parity-scale-codec", "scale-info", @@ -14927,7 +14927,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "26.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -14940,7 +14940,7 @@ dependencies = [ [[package]] name = "sp-io" version = "30.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "bytes", "ed25519-dalek 2.1.0", @@ -14966,7 +14966,7 @@ dependencies = [ [[package]] name = "sp-keyring" version = "31.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "sp-core", "sp-runtime", @@ -14976,7 +14976,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.34.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "parity-scale-codec", "parking_lot 0.12.3", @@ -14987,7 +14987,7 @@ dependencies = [ [[package]] name = "sp-maybe-compressed-blob" version = "11.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "thiserror", "zstd 0.12.4", @@ -14996,7 +14996,7 @@ dependencies = [ [[package]] name = "sp-metadata-ir" version = "0.6.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-metadata", "parity-scale-codec", @@ -15006,7 +15006,7 @@ dependencies = [ [[package]] name = "sp-mixnet" version = "0.4.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "parity-scale-codec", "scale-info", @@ -15017,7 +15017,7 @@ dependencies = [ [[package]] name = "sp-mmr-primitives" version = "26.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "ckb-merkle-mountain-range", "log", @@ -15034,7 +15034,7 @@ dependencies = [ [[package]] name = "sp-npos-elections" version = "26.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "parity-scale-codec", "scale-info", @@ -15047,7 +15047,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "26.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "sp-api", "sp-core", @@ -15057,7 +15057,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "13.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "backtrace", "lazy_static", @@ -15067,7 +15067,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "26.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "rustc-hash", "serde", @@ -15077,7 +15077,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "31.0.1" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "docify", "either", @@ -15101,7 +15101,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "24.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -15120,7 +15120,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "17.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "Inflector", "expander 2.0.0", @@ -15133,7 +15133,7 @@ dependencies = [ [[package]] name = "sp-session" version = "27.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "parity-scale-codec", "scale-info", @@ -15147,7 +15147,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "26.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -15160,7 +15160,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.35.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "hash-db", "log", @@ -15180,7 +15180,7 @@ dependencies = [ [[package]] name = "sp-statement-store" version = "10.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "aes-gcm", "curve25519-dalek 4.1.1", @@ -15204,12 +15204,12 @@ dependencies = [ [[package]] name = "sp-std" version = "14.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" [[package]] name = "sp-storage" version = "19.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "impl-serde", "parity-scale-codec", @@ -15221,7 +15221,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "26.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "async-trait", "parity-scale-codec", @@ -15233,7 +15233,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "16.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "parity-scale-codec", "tracing", @@ -15244,7 +15244,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "26.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "sp-api", "sp-runtime", @@ -15253,7 +15253,7 @@ dependencies = [ [[package]] name = "sp-transaction-storage-proof" version = "26.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "async-trait", "parity-scale-codec", @@ -15267,7 +15267,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "29.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "ahash 0.8.6", "hash-db", @@ -15290,7 +15290,7 @@ dependencies = [ [[package]] name = "sp-version" version = "29.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "impl-serde", "parity-scale-codec", @@ -15307,7 +15307,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "13.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -15318,7 +15318,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "20.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "anyhow", "impl-trait-for-tuples", @@ -15330,7 +15330,7 @@ dependencies = [ [[package]] name = "sp-weights" version = "27.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "bounded-collections", "parity-scale-codec", @@ -15407,7 +15407,7 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "staging-parachain-info" version = "0.7.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "cumulus-primitives-core", "frame-support", @@ -15421,7 +15421,7 @@ dependencies = [ [[package]] name = "staging-xcm" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "array-bytes 6.2.2", "bounded-collections", @@ -15439,7 +15439,7 @@ dependencies = [ [[package]] name = "staging-xcm-builder" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-support", "frame-system", @@ -15461,7 +15461,7 @@ dependencies = [ [[package]] name = "staging-xcm-executor" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "environmental", "frame-benchmarking", @@ -15618,7 +15618,7 @@ dependencies = [ [[package]] name = "substrate-bip39" version = "0.4.7" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "hmac 0.12.1", "pbkdf2", @@ -15643,12 +15643,12 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "11.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" [[package]] name = "substrate-frame-rpc-system" version = "28.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-system-rpc-runtime-api", "futures", @@ -15667,7 +15667,7 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.17.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "hyper", "log", @@ -15679,7 +15679,7 @@ dependencies = [ [[package]] name = "substrate-rpc-client" version = "0.33.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "async-trait", "jsonrpsee", @@ -15692,7 +15692,7 @@ dependencies = [ [[package]] name = "substrate-state-trie-migration-rpc" version = "27.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -15709,7 +15709,7 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" version = "17.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "array-bytes 6.2.2", "build-helper", @@ -16339,7 +16339,7 @@ dependencies = [ [[package]] name = "tracing-gum" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "coarsetime", "polkadot-primitives", @@ -16350,7 +16350,7 @@ dependencies = [ [[package]] name = "tracing-gum-proc-macro" version = "5.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "expander 2.0.0", "proc-macro-crate 3.1.0", @@ -17213,7 +17213,7 @@ dependencies = [ [[package]] name = "westend-runtime" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "binary-merkle-tree", "bitvec", @@ -17320,7 +17320,7 @@ dependencies = [ [[package]] name = "westend-runtime-constants" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-support", "polkadot-primitives", @@ -17722,7 +17722,7 @@ dependencies = [ [[package]] name = "xcm-emulator" version = "0.5.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "cumulus-pallet-parachain-system", "cumulus-pallet-xcmp-queue", @@ -17756,7 +17756,7 @@ dependencies = [ [[package]] name = "xcm-fee-payment-runtime-api" version = "0.1.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "frame-support", "parity-scale-codec", @@ -17771,7 +17771,7 @@ dependencies = [ [[package]] name = "xcm-procedural" version = "7.0.0" -source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=feat/add-utlity-hook-2#688f8b38413cbd75ced39fde3c65abd44af4b887" +source = "git+https://github.com/galacticcouncil/polkadot-sdk?branch=release-polkadot-v1.11.0-patch4#fb3177d42f7ed729c03ea1184a5a74eb8f3e517c" dependencies = [ "Inflector", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 267a44499..c8a141091 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -159,110 +159,110 @@ pallet-evm-precompile-call-permit = { path = "precompiles/call-permit", default- precompile-utils = { path = "precompiles/utils", default-features = false } # Frame -frame-benchmarking = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -frame-benchmarking-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -frame-executive = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -frame-remote-externalities = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -frame-support = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false , features = ["tuples-96"]} -frame-system = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -frame-system-benchmarking = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -frame-system-rpc-runtime-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -frame-try-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -frame-metadata-hash-extension = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sp-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sp-arithmetic = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sp-authority-discovery = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sp-block-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sp-genesis-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sp-blockchain = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sp-consensus = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sp-consensus-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sp-consensus-babe = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sp-consensus-beefy = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-core = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sp-externalities = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sp-inherents = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sp-io = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sp-keystore = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sp-npos-elections = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sp-offchain = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sc-offchain = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sp-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sp-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sp-runtime-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sp-runtime-interface-proc-macro = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sp-session = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sp-staking = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sp-std = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sp-storage = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sp-state-machine = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sp-timestamp = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sp-tracing = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sp-transaction-pool = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sp-trie = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sp-version = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sp-weights = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sp-crypto-hashing= { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sp-crypto-ec-utils= { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sp-wasm-interface= { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } - -sc-basic-authorship = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sc-chain-spec = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sc-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sc-client-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sc-client-db = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sc-consensus = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sc-consensus-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sc-consensus-grandpa = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sc-executor = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sc-keystore = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sc-network = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sc-network-sync = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sc-network-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sc-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sc-rpc-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sc-service = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sc-telemetry = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sc-tracing = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sc-transaction-pool = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sc-transaction-pool-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -sc-sysinfo = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } +frame-benchmarking = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +frame-benchmarking-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +frame-executive = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +frame-remote-externalities = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +frame-support = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false , features = ["tuples-96"]} +frame-system = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +frame-system-benchmarking = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +frame-system-rpc-runtime-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +frame-try-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +frame-metadata-hash-extension = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sp-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sp-arithmetic = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sp-authority-discovery = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sp-block-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sp-genesis-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sp-blockchain = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sp-consensus = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sp-consensus-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sp-consensus-babe = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sp-consensus-beefy = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-core = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sp-externalities = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sp-inherents = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sp-io = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sp-keystore = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sp-npos-elections = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sp-offchain = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sc-offchain = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sp-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sp-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sp-runtime-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sp-runtime-interface-proc-macro = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sp-session = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sp-staking = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sp-std = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sp-storage = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sp-state-machine = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sp-timestamp = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sp-tracing = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sp-transaction-pool = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sp-trie = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sp-version = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sp-weights = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sp-crypto-hashing= { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sp-crypto-ec-utils= { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sp-wasm-interface= { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } + +sc-basic-authorship = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sc-chain-spec = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sc-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sc-client-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sc-client-db = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sc-consensus = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sc-consensus-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sc-consensus-grandpa = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sc-executor = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sc-keystore = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sc-network = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sc-network-sync = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sc-network-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sc-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sc-rpc-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sc-service = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sc-telemetry = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sc-tracing = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sc-transaction-pool = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sc-transaction-pool-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +sc-sysinfo = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } # Substrate Pallets -pallet-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -pallet-authorship = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -pallet-balances = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -pallet-bags-list = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -pallet-collective = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -pallet-conviction-voting = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -pallet-elections-phragmen = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -pallet-identity = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -pallet-multisig = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -pallet-preimage = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -pallet-proxy = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -pallet-referenda = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -pallet-scheduler = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -pallet-session = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -pallet-sudo = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -pallet-timestamp = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -pallet-tips = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -pallet-transaction-payment = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -pallet-transaction-payment-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -pallet-treasury = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -pallet-uniques = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -pallet-utility = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -pallet-im-online = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -pallet-message-queue = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -pallet-state-trie-migration = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -pallet-whitelist = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } - -substrate-build-script-utils = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -substrate-frame-rpc-system = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -substrate-prometheus-endpoint = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -substrate-rpc-client = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -substrate-wasm-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -substrate-state-trie-migration-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } +pallet-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +pallet-authorship = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +pallet-balances = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +pallet-bags-list = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +pallet-collective = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +pallet-conviction-voting = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +pallet-elections-phragmen = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +pallet-identity = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +pallet-multisig = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +pallet-preimage = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +pallet-proxy = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +pallet-referenda = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +pallet-scheduler = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +pallet-session = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +pallet-sudo = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +pallet-timestamp = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +pallet-tips = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +pallet-transaction-payment = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +pallet-transaction-payment-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +pallet-treasury = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +pallet-uniques = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +pallet-utility = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +pallet-im-online = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +pallet-message-queue = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +pallet-state-trie-migration = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +pallet-whitelist = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } + +substrate-build-script-utils = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +substrate-frame-rpc-system = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +substrate-prometheus-endpoint = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +substrate-rpc-client = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +substrate-wasm-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +substrate-state-trie-migration-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } #TODO: We use our custom ORML as it contains the fix of bug for reducible_balance check, for Preserve mode. Once the official ORML pushes a new version with the fix, we can use that again # ORML dependencies @@ -280,30 +280,30 @@ orml-xcm-support = { git = "https://github.com/galacticcouncil/open-runtime-modu orml-xtokens = { git = "https://github.com/galacticcouncil/open-runtime-module-library", branch = "polkadot-v1.11.0", default-features = false } # Cumulus dependencies -cumulus-client-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -cumulus-client-collator = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -cumulus-client-consensus-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -cumulus-client-consensus-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -cumulus-client-consensus-proposer = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -cumulus-client-network = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -cumulus-client-service = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -cumulus-pallet-aura-ext = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -cumulus-pallet-parachain-system = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -cumulus-pallet-xcm = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -cumulus-pallet-xcmp-queue = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -cumulus-primitives-core = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -cumulus-primitives-parachain-inherent = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -cumulus-primitives-timestamp = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -cumulus-primitives-utility = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -cumulus-relay-chain-inprocess-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -cumulus-relay-chain-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -cumulus-relay-chain-minimal-node = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -cumulus-test-relay-sproof-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -pallet-collator-selection = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -staging-parachain-info = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -xcm-emulator = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -xcm-fee-payment-runtime-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -parachains-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } +cumulus-client-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +cumulus-client-collator = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +cumulus-client-consensus-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +cumulus-client-consensus-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +cumulus-client-consensus-proposer = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +cumulus-client-network = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +cumulus-client-service = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +cumulus-pallet-aura-ext = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +cumulus-pallet-parachain-system = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +cumulus-pallet-xcm = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +cumulus-pallet-xcmp-queue = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +cumulus-primitives-core = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +cumulus-primitives-parachain-inherent = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +cumulus-primitives-timestamp = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +cumulus-primitives-utility = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +cumulus-relay-chain-inprocess-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +cumulus-relay-chain-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +cumulus-relay-chain-minimal-node = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +cumulus-test-relay-sproof-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +pallet-collator-selection = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +staging-parachain-info = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +xcm-emulator = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +xcm-fee-payment-runtime-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +parachains-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } # Frontier fc-consensus = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v1.11.0", default-features = false } @@ -336,35 +336,35 @@ module-evm-utility-macro = { path = "runtime/hydradx/src/evm/evm-utility/macro", ethereum = { version = "0.15.0", default-features = false, features = ["with-codec"] } # Polkadot dependencies -pallet-xcm = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -polkadot-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -polkadot-core-primitives = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -polkadot-parachain = { package = "polkadot-parachain-primitives", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false, features = [ +pallet-xcm = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +polkadot-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +polkadot-core-primitives = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +polkadot-parachain = { package = "polkadot-parachain-primitives", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false, features = [ "wasm-api", ]} -polkadot-primitives = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -polkadot-runtime-parachains = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -polkadot-service = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -polkadot-xcm = { package = "staging-xcm", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -xcm = { package = "staging-xcm", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } -xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2", default-features = false } - -polkadot-client = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -polkadot-node-core-pvf = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -polkadot-node-network-protocol = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -polkadot-node-primitives = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -polkadot-node-subsystem = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -polkadot-node-subsystem-util = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -polkadot-overseer = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -polkadot-runtime-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" , default-features = false} -polkadot-statement-table = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -rococo-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -westend-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } - -cumulus-client-pov-recovery = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-pallet-parachain-system-proc-macro = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-relay-chain-rpc-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } +polkadot-primitives = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +polkadot-runtime-parachains = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +polkadot-service = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +polkadot-xcm = { package = "staging-xcm", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +xcm = { package = "staging-xcm", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } +xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4", default-features = false } + +polkadot-client = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +polkadot-node-core-pvf = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +polkadot-node-network-protocol = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +polkadot-node-primitives = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +polkadot-node-subsystem = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +polkadot-node-subsystem-util = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +polkadot-overseer = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +polkadot-runtime-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" , default-features = false} +polkadot-statement-table = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +rococo-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +westend-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } + +cumulus-client-pov-recovery = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-pallet-parachain-system-proc-macro = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-relay-chain-rpc-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } [patch."https://github.com/moonbeam-foundation/open-runtime-module-library"] # ORML dependencies @@ -379,311 +379,311 @@ orml-xcm-support = { git = "https://github.com/galacticcouncil/open-runtime-modu orml-xtokens = { git = "https://github.com/galacticcouncil/open-runtime-module-library", branch = "polkadot-v1.11.0" } [patch."https://github.com/moonbeam-foundation/polkadot-sdk"] -frame-benchmarking = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -frame-benchmarking-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -frame-executive = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -frame-remote-externalities = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -frame-support = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -frame-system = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -frame-system-benchmarking = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -frame-system-rpc-runtime-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -frame-try-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -frame-metadata-hash-extension = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-arithmetic = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-authority-discovery = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-block-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-genesis-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-blockchain = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-consensus = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-consensus-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-consensus-babe = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-core = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-externalities = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-inherents = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-io = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-keystore = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-npos-elections = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-offchain = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-offchain = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-runtime-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-runtime-interface-proc-macro = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-wasm-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-panic-handler = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-database = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-session = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-staking = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-std = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-storage = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-timestamp = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-tracing = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-transaction-pool = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-trie = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-version = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-basic-authorship = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-chain-spec = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-client-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-client-db = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-consensus = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-consensus-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-consensus-grandpa = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-executor = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-keystore = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-network = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-network-sync = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-network-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-rpc-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-service = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-telemetry = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-tracing = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-transaction-pool = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-transaction-pool-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-sysinfo = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-utils = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-state-machine = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-weights = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2"} -sp-crypto-hashing= { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2"} +frame-benchmarking = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +frame-benchmarking-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +frame-executive = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +frame-remote-externalities = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +frame-support = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +frame-system = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +frame-system-benchmarking = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +frame-system-rpc-runtime-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +frame-try-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +frame-metadata-hash-extension = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-arithmetic = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-authority-discovery = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-block-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-genesis-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-blockchain = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-consensus = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-consensus-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-consensus-babe = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-core = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-externalities = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-inherents = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-io = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-keystore = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-npos-elections = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-offchain = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-offchain = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-runtime-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-runtime-interface-proc-macro = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-wasm-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-panic-handler = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-database = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-session = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-staking = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-std = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-storage = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-timestamp = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-tracing = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-transaction-pool = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-trie = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-version = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-basic-authorship = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-chain-spec = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-client-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-client-db = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-consensus = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-consensus-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-consensus-grandpa = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-executor = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-keystore = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-network = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-network-sync = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-network-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-rpc-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-service = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-telemetry = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-tracing = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-transaction-pool = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-transaction-pool-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-sysinfo = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-utils = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-state-machine = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-weights = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4"} +sp-crypto-hashing= { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4"} # Substrate Pallets -pallet-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-authorship = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-balances = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-collective = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-elections-phragmen = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-identity = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-multisig = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-preimage = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-proxy = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-scheduler = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-session = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-sudo = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-timestamp = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-tips = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-transaction-payment = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-transaction-payment-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-treasury = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-uniques = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-utility = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-im-online = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-message-queue = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2"} -pallet-state-trie-migration = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2"} - -substrate-build-script-utils = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -substrate-frame-rpc-system = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -substrate-prometheus-endpoint = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -substrate-rpc-client = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -substrate-wasm-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -substrate-state-trie-migration-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } +pallet-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-authorship = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-balances = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-collective = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-elections-phragmen = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-identity = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-multisig = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-preimage = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-proxy = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-scheduler = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-session = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-sudo = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-timestamp = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-tips = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-transaction-payment = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-transaction-payment-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-treasury = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-uniques = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-utility = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-im-online = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-message-queue = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4"} +pallet-state-trie-migration = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4"} + +substrate-build-script-utils = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +substrate-frame-rpc-system = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +substrate-prometheus-endpoint = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +substrate-rpc-client = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +substrate-wasm-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +substrate-state-trie-migration-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } # Cumulus dependencies -cumulus-client-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-client-collator = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-client-consensus-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-client-consensus-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-client-consensus-proposer = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-client-network = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-client-service = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-pallet-aura-ext = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-pallet-parachain-system = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-pallet-xcm = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-pallet-xcmp-queue = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-primitives-core = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-primitives-parachain-inherent = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-primitives-timestamp = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-primitives-utility = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-relay-chain-inprocess-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-relay-chain-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-relay-chain-minimal-node = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-test-relay-sproof-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-collator-selection = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -staging-parachain-info = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -xcm-emulator = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -parachains-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2"} -xcm-fee-payment-runtime-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } +cumulus-client-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-client-collator = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-client-consensus-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-client-consensus-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-client-consensus-proposer = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-client-network = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-client-service = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-pallet-aura-ext = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-pallet-parachain-system = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-pallet-xcm = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-pallet-xcmp-queue = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-primitives-core = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-primitives-parachain-inherent = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-primitives-timestamp = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-primitives-utility = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-relay-chain-inprocess-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-relay-chain-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-relay-chain-minimal-node = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-test-relay-sproof-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-collator-selection = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +staging-parachain-info = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +xcm-emulator = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +parachains-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4"} +xcm-fee-payment-runtime-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } # Polkadot dependencies -pallet-xcm = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -polkadot-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -polkadot-core-primitives = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -polkadot-parachain = { package = "polkadot-parachain-primitives", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2"} -polkadot-primitives = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -polkadot-runtime-parachains = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -polkadot-service = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -xcm = { package = "staging-xcm", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } - -polkadot-node-core-pvf = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -polkadot-node-network-protocol = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -polkadot-node-primitives = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -polkadot-node-subsystem = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -polkadot-node-subsystem-util = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -polkadot-overseer = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -polkadot-runtime-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -polkadot-statement-table = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -rococo-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -westend-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } - -cumulus-client-pov-recovery = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-pallet-parachain-system-proc-macro = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-relay-chain-rpc-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } +pallet-xcm = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +polkadot-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +polkadot-core-primitives = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +polkadot-parachain = { package = "polkadot-parachain-primitives", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4"} +polkadot-primitives = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +polkadot-runtime-parachains = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +polkadot-service = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +xcm = { package = "staging-xcm", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } + +polkadot-node-core-pvf = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +polkadot-node-network-protocol = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +polkadot-node-primitives = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +polkadot-node-subsystem = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +polkadot-node-subsystem-util = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +polkadot-overseer = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +polkadot-runtime-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +polkadot-statement-table = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +rococo-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +westend-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } + +cumulus-client-pov-recovery = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-pallet-parachain-system-proc-macro = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-relay-chain-rpc-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } [patch."https://github.com/paritytech/polkadot-sdk"] -frame-benchmarking = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -frame-benchmarking-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -frame-executive = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -frame-remote-externalities = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -frame-support = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -frame-system = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -frame-system-benchmarking = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -frame-system-rpc-runtime-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -frame-try-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -frame-metadata-hash-extension = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-arithmetic = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-authority-discovery = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-block-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-genesis-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-blockchain = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-consensus = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-consensus-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-consensus-babe = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-core = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-externalities = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-inherents = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-io = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-keystore = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-npos-elections = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-offchain = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-offchain = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-runtime-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-runtime-interface-proc-macro = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-wasm-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-panic-handler = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-database = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-session = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-staking = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-std = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-storage = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-timestamp = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-tracing = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-transaction-pool = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-trie = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-version = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-basic-authorship = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-chain-spec = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-client-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-client-db = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-consensus = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-consensus-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-consensus-grandpa = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-executor = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-keystore = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-network = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-network-sync = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-network-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-rpc-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-service = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-telemetry = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-tracing = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-transaction-pool = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-transaction-pool-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-sysinfo = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sc-utils = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-state-machine = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -sp-weights = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2"} -sp-crypto-hashing= { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2"} +frame-benchmarking = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +frame-benchmarking-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +frame-executive = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +frame-remote-externalities = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +frame-support = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +frame-system = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +frame-system-benchmarking = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +frame-system-rpc-runtime-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +frame-try-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +frame-metadata-hash-extension = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-arithmetic = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-authority-discovery = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-block-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-genesis-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-blockchain = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-consensus = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-consensus-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-consensus-babe = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-core = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-externalities = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-inherents = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-io = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-keystore = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-npos-elections = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-offchain = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-offchain = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-runtime-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-runtime-interface-proc-macro = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-wasm-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-panic-handler = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-database = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-session = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-staking = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-std = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-storage = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-timestamp = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-tracing = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-transaction-pool = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-trie = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-version = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-basic-authorship = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-chain-spec = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-client-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-client-db = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-consensus = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-consensus-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-consensus-grandpa = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-executor = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-keystore = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-network = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-network-sync = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-network-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-rpc-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-service = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-telemetry = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-tracing = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-transaction-pool = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-transaction-pool-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-sysinfo = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sc-utils = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-state-machine = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +sp-weights = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4"} +sp-crypto-hashing= { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4"} # Substrate Pallets -pallet-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-authorship = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-balances = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-collective = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-elections-phragmen = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-identity = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-multisig = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-preimage = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-proxy = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-scheduler = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-session = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-sudo = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-timestamp = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-tips = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-transaction-payment = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-transaction-payment-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-treasury = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-uniques = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-utility = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-im-online = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-message-queue = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2"} -pallet-state-trie-migration = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2"} - -substrate-build-script-utils = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -substrate-frame-rpc-system = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -substrate-prometheus-endpoint = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -substrate-rpc-client = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -substrate-wasm-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -substrate-state-trie-migration-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } +pallet-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-authorship = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-balances = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-collective = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-elections-phragmen = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-identity = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-multisig = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-preimage = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-proxy = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-scheduler = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-session = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-sudo = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-timestamp = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-tips = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-transaction-payment = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-transaction-payment-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-treasury = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-uniques = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-utility = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-im-online = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-message-queue = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4"} +pallet-state-trie-migration = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4"} + +substrate-build-script-utils = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +substrate-frame-rpc-system = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +substrate-prometheus-endpoint = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +substrate-rpc-client = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +substrate-wasm-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +substrate-state-trie-migration-rpc = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } # Cumulus dependencies -cumulus-client-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-client-collator = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-client-consensus-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-client-consensus-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-client-consensus-proposer = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-client-network = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-client-service = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-pallet-aura-ext = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-pallet-parachain-system = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-pallet-xcm = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-pallet-xcmp-queue = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-primitives-core = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-primitives-parachain-inherent = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-primitives-timestamp = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-primitives-utility = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-relay-chain-inprocess-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-relay-chain-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-relay-chain-minimal-node = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-test-relay-sproof-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -pallet-collator-selection = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -staging-parachain-info = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -xcm-emulator = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -parachains-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2"} -xcm-fee-payment-runtime-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } +cumulus-client-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-client-collator = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-client-consensus-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-client-consensus-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-client-consensus-proposer = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-client-network = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-client-service = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-pallet-aura-ext = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-pallet-parachain-system = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-pallet-xcm = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-pallet-xcmp-queue = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-primitives-core = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-primitives-parachain-inherent = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-primitives-timestamp = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-primitives-utility = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-relay-chain-inprocess-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-relay-chain-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-relay-chain-minimal-node = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-test-relay-sproof-builder = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +pallet-collator-selection = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +staging-parachain-info = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +xcm-emulator = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +parachains-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4"} +xcm-fee-payment-runtime-api = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } # Polkadot dependencies -pallet-xcm = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -polkadot-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -polkadot-core-primitives = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -polkadot-parachain = { package = "polkadot-parachain-primitives", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2"} -polkadot-primitives = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -polkadot-runtime-parachains = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -polkadot-service = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -xcm = { package = "staging-xcm", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } - -polkadot-node-core-pvf = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -polkadot-node-network-protocol = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -polkadot-node-primitives = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -polkadot-node-subsystem = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -polkadot-node-subsystem-util = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -polkadot-overseer = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -polkadot-runtime-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -polkadot-statement-table = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -rococo-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -westend-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } - -cumulus-client-pov-recovery = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-pallet-parachain-system-proc-macro = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } -cumulus-relay-chain-rpc-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "feat/add-utlity-hook-2" } +pallet-xcm = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +polkadot-cli = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +polkadot-core-primitives = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +polkadot-parachain = { package = "polkadot-parachain-primitives", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4"} +polkadot-primitives = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +polkadot-runtime-parachains = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +polkadot-service = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +xcm = { package = "staging-xcm", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } + +polkadot-node-core-pvf = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +polkadot-node-network-protocol = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +polkadot-node-primitives = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +polkadot-node-subsystem = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +polkadot-node-subsystem-util = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +polkadot-overseer = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +polkadot-runtime-common = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +polkadot-statement-table = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +rococo-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +westend-runtime = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } + +cumulus-client-pov-recovery = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-pallet-parachain-system-proc-macro = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } +cumulus-relay-chain-rpc-interface = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch = "release-polkadot-v1.11.0-patch4" } From 868c3600cfacdccc97e28c4f3ca4b1f021eac20e Mon Sep 17 00:00:00 2001 From: dmoka Date: Thu, 2 Jan 2025 17:10:54 +0100 Subject: [PATCH 122/142] fix xcm test by not asserting the specific topic id as it is dynamic --- integration-tests/src/dca.rs | 32 +++---- integration-tests/src/exchange_asset.rs | 102 ++++++++------------- integration-tests/src/polkadot_test_net.rs | 35 +++++-- integration-tests/src/utility.rs | 28 +++--- integration-tests/src/xcm.rs | 97 ++++++++------------ 5 files changed, 133 insertions(+), 161 deletions(-) diff --git a/integration-tests/src/dca.rs b/integration-tests/src/dca.rs index 029335432..7f514f31f 100644 --- a/integration-tests/src/dca.rs +++ b/integration-tests/src/dca.rs @@ -224,7 +224,7 @@ mod omnipool { pretty_assertions::assert_eq!( last_two_swapped_events, vec![ - RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: ALICE.into(), filler: Omnipool::protocol_account(), filler_type: pallet_support::types::Filler::Omnipool, @@ -237,8 +237,8 @@ mod omnipool { ExecutionType::Router(1), ExecutionType::Omnipool(2) ] - }), - RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { + }, + pallet_support::Event::Swapped { swapper: ALICE.into(), filler: Omnipool::protocol_account(), filler_type: pallet_support::types::Filler::Omnipool, @@ -251,7 +251,7 @@ mod omnipool { ExecutionType::Router(1), ExecutionType::Omnipool(2) ], - }) + } ] ); @@ -262,7 +262,7 @@ mod omnipool { pretty_assertions::assert_eq!( last_two_swapped_events, vec![ - RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: ALICE.into(), filler: Omnipool::protocol_account(), filler_type: pallet_support::types::Filler::Omnipool, @@ -275,8 +275,8 @@ mod omnipool { ExecutionType::Router(4), ExecutionType::Omnipool(5) ], - }), - RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { + }, + pallet_support::Event::Swapped { swapper: ALICE.into(), filler: Omnipool::protocol_account(), filler_type: pallet_support::types::Filler::Omnipool, @@ -289,7 +289,7 @@ mod omnipool { ExecutionType::Router(4), ExecutionType::Omnipool(5) ], - }) + } ] ); }); @@ -711,7 +711,7 @@ mod omnipool { pretty_assertions::assert_eq!( last_two_swapped_events, vec![ - RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: ALICE.into(), filler: Omnipool::protocol_account(), filler_type: pallet_support::types::Filler::Omnipool, @@ -724,8 +724,8 @@ mod omnipool { ExecutionType::Router(1), ExecutionType::Omnipool(2) ], - }), - RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { + }, + pallet_support::Event::Swapped { swapper: ALICE.into(), filler: Omnipool::protocol_account(), filler_type: pallet_support::types::Filler::Omnipool, @@ -738,7 +738,7 @@ mod omnipool { ExecutionType::Router(1), ExecutionType::Omnipool(2) ], - }) + } ] ); @@ -749,7 +749,7 @@ mod omnipool { pretty_assertions::assert_eq!( last_two_swapped_events, vec![ - RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { + pallet_support::Event::Swapped { swapper: ALICE.into(), filler: Omnipool::protocol_account(), filler_type: pallet_support::types::Filler::Omnipool, @@ -762,8 +762,8 @@ mod omnipool { ExecutionType::Router(4), ExecutionType::Omnipool(5) ], - }), - RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { + }, + pallet_support::Event::Swapped { swapper: ALICE.into(), filler: Omnipool::protocol_account(), filler_type: pallet_support::types::Filler::Omnipool, @@ -776,7 +776,7 @@ mod omnipool { ExecutionType::Router(4), ExecutionType::Omnipool(5) ], - }) + } ] ); }); diff --git a/integration-tests/src/exchange_asset.rs b/integration-tests/src/exchange_asset.rs index b0895dc9e..f56b77285 100644 --- a/integration-tests/src/exchange_asset.rs +++ b/integration-tests/src/exchange_asset.rs @@ -26,6 +26,8 @@ use sp_runtime::DispatchResult; use sp_runtime::{FixedU128, Permill, TransactionOutcome}; use sp_std::sync::Arc; use xcm_emulator::TestExt; +use crate::assert_operation_stack; + pub const SELL: bool = true; pub const BUY: bool = false; @@ -125,45 +127,28 @@ fn hydra_should_swap_assets_when_receiving_from_acala_with_sell() { let received = 39_101 * UNITS + BOB_INITIAL_NATIVE_BALANCE + 207_131_554_396; assert_eq!(hydradx_runtime::Balances::free_balance(AccountId::from(BOB)), received); - let last_swapped_events = get_last_swapped_events(); + let last_swapped_events : Vec> = get_last_swapped_events(); let last_two_swapped_events = &last_swapped_events[last_swapped_events.len() - 2..]; - let topic_id = [ - 180, 44, 225, 230, 61, 43, 219, 219, 222, 9, 44, 219, 86, 193, 219, 212, 120, 169, 197, 209, 39, 180, 219, - 225, 224, 182, 134, 141, 41, 162, 96, 54, - ]; - pretty_assertions::assert_eq!( - last_two_swapped_events, - vec![ - RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { - swapper: TempAccountForXcmAssetExchange::get(), - filler: Omnipool::protocol_account(), - filler_type: pallet_support::types::Filler::Omnipool, - operation: pallet_support::types::TradeOperation::ExactIn, - inputs: vec![pallet_support::types::Asset::new(ACA, 50000000000000),], - outputs: vec![pallet_support::types::Asset::new(LRNA::get(), 49180327868852)], - fees: vec![Fee::new(LRNA::get(), 24590163934, Omnipool::protocol_account()),], - operation_stack: vec![ - ExecutionType::Xcm(topic_id, 0), - ExecutionType::XcmExchange(1), - ExecutionType::Router(2), - ExecutionType::Omnipool(3) - ], - }), - RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { - swapper: TempAccountForXcmAssetExchange::get(), - filler: Omnipool::protocol_account(), - filler_type: pallet_support::types::Filler::Omnipool, - operation: pallet_support::types::TradeOperation::ExactIn, - inputs: vec![pallet_support::types::Asset::new(LRNA::get(), 49155737704918),], - outputs: vec![pallet_support::types::Asset::new(HDX, 39101207131554396)], - fees: vec![Fee::new(HDX, 97998012861039, Omnipool::protocol_account()),], - operation_stack: vec![ - ExecutionType::Xcm(topic_id, 0), - ExecutionType::XcmExchange(1), - ExecutionType::Router(2), - ExecutionType::Omnipool(3) - ], - }) + + let event1 = &last_two_swapped_events[0]; + assert_operation_stack!( + event1, + [ + ExecutionType::Xcm(_, 0), + ExecutionType::XcmExchange(1), + ExecutionType::Router(2), + ExecutionType::Omnipool(3) + ] + ); + + let event2 = &last_two_swapped_events[0]; + assert_operation_stack!( + event2, + [ + ExecutionType::Xcm(_, 0), + ExecutionType::XcmExchange(1), + ExecutionType::Router(2), + ExecutionType::Omnipool(3) ] ); @@ -177,31 +162,24 @@ fn hydra_should_swap_assets_when_receiving_from_acala_with_sell() { vec![], )); - let last_swapped_events = get_last_swapped_events(); + let last_swapped_events : Vec> = get_last_swapped_events(); let last_two_swapped_events = &last_swapped_events[last_swapped_events.len() - 2..]; - pretty_assertions::assert_eq!( - last_two_swapped_events, - vec![ - RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { - swapper: ALICE.into(), - filler: Omnipool::protocol_account(), - filler_type: pallet_support::types::Filler::Omnipool, - operation: pallet_support::types::TradeOperation::ExactIn, - inputs: vec![pallet_support::types::Asset::new(HDX, 1 * UNITS),], - outputs: vec![pallet_support::types::Asset::new(LRNA::get(), 1308673515)], - fees: vec![Fee::new(LRNA::get(), 654336, Omnipool::protocol_account()),], - operation_stack: vec![ExecutionType::Router(4), ExecutionType::Omnipool(5)], - }), - RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { - swapper: ALICE.into(), - filler: Omnipool::protocol_account(), - filler_type: pallet_support::types::Filler::Omnipool, - operation: pallet_support::types::TradeOperation::ExactIn, - inputs: vec![pallet_support::types::Asset::new(LRNA::get(), 1308019179),], - outputs: vec![pallet_support::types::Asset::new(ACA, 1348602600)], - fees: vec![Fee::new(ACA, 3379957, Omnipool::protocol_account()),], - operation_stack: vec![ExecutionType::Router(4), ExecutionType::Omnipool(5)], - }) + + let event1 = &last_two_swapped_events[0]; + assert_operation_stack!( + event1, + [ + ExecutionType::Router(4), + ExecutionType::Omnipool(5) + ] + ); + + let event2 = &last_two_swapped_events[0]; + assert_operation_stack!( + event2, + [ + ExecutionType::Router(4), + ExecutionType::Omnipool(5) ] ); }); diff --git a/integration-tests/src/polkadot_test_net.rs b/integration-tests/src/polkadot_test_net.rs index 8ebad28be..ac06ce8b4 100644 --- a/integration-tests/src/polkadot_test_net.rs +++ b/integration-tests/src/polkadot_test_net.rs @@ -894,16 +894,33 @@ pub fn assert_xcm_message_processing_passed() { ))); } -pub fn get_last_swapped_events() -> Vec { +pub fn get_last_swapped_events() -> Vec> { let last_events: Vec = last_hydra_events(1000); - let mut swapped_events = vec![]; - for event in last_events { - let e = event.clone(); - if let RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { .. }) = e { - swapped_events.push(e); - } - } + last_events + .into_iter() + .filter_map(|event| { + if let RuntimeEvent::AmmSupport(inner_event @ pallet_support::Event::Swapped { .. }) = event { + Some(inner_event) + } else { + None + } + }) + .collect() +} - swapped_events +#[macro_export] +macro_rules! assert_operation_stack { + ($event:expr, [$($pattern:pat),*]) => { + if let pallet_support::Event::Swapped { operation_stack, .. } = $event { + assert!(matches!(&operation_stack[..], + [ + $($pattern),* + ] + )); + } else { + panic!("Expected Swapped event"); + } + } } + diff --git a/integration-tests/src/utility.rs b/integration-tests/src/utility.rs index 2c3454ae4..51846b2a5 100644 --- a/integration-tests/src/utility.rs +++ b/integration-tests/src/utility.rs @@ -70,7 +70,7 @@ fn batch_execution_type_should_be_included_in_batch() { pretty_assertions::assert_eq!( swapped_events, vec![ - RuntimeEvent::AmmSupport(pallet_support::Event::::Swapped { + pallet_support::Event::::Swapped { swapper: BOB.into(), filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA)), filler_type: pallet_support::types::Filler::LBP, @@ -85,8 +85,8 @@ fn batch_execution_type_should_be_included_in_batch() { .fee_collector, )], operation_stack: vec![ExecutionType::Batch(0), ExecutionType::Router(1)], - }), - RuntimeEvent::AmmSupport(pallet_support::Event::::Swapped { + }, + pallet_support::Event::::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), filler_type: pallet_support::types::Filler::Omnipool, @@ -95,8 +95,8 @@ fn batch_execution_type_should_be_included_in_batch() { outputs: vec![Asset::new(HDX, 4682924837974)], fees: vec![Fee::new(HDX, 11736653730, Omnipool::protocol_account())], operation_stack: vec![ExecutionType::Batch(0), ExecutionType::Router(1)], - }), - RuntimeEvent::AmmSupport(pallet_support::Event::::Swapped { + }, + pallet_support::Event::::Swapped { swapper: BOB.into(), filler: XYK::get_pair_id(pallet_xyk::types::AssetPair { asset_in: HDX, @@ -120,7 +120,7 @@ fn batch_execution_type_should_be_included_in_batch() { }), )], operation_stack: vec![ExecutionType::Batch(0), ExecutionType::Router(1)], - }) + } ] ); }); @@ -191,7 +191,7 @@ fn batch_execution_type_should_be_popped_when_multiple_batch_calls_happen() { //Assert pretty_assertions::assert_eq!( *get_last_swapped_events().last().unwrap(), - RuntimeEvent::AmmSupport(pallet_support::Event::::Swapped { + pallet_support::Event::::Swapped { swapper: BOB.into(), filler: XYK::get_pair_id(pallet_xyk::types::AssetPair { asset_in: HDX, @@ -215,7 +215,7 @@ fn batch_execution_type_should_be_popped_when_multiple_batch_calls_happen() { }), )], operation_stack: vec![ExecutionType::Batch(2), ExecutionType::Router(3)], - }) + } ); }); } @@ -277,7 +277,7 @@ fn nested_batch_should_represent_embeddedness() { pretty_assertions::assert_eq!( swapped_events, vec![ - RuntimeEvent::AmmSupport(pallet_support::Event::::Swapped { + pallet_support::Event::::Swapped { swapper: BOB.into(), filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, LRNA)), filler_type: pallet_support::types::Filler::LBP, @@ -296,8 +296,8 @@ fn nested_batch_should_represent_embeddedness() { ExecutionType::Batch(1), ExecutionType::Router(2) ], - }), - RuntimeEvent::AmmSupport(pallet_support::Event::::Swapped { + }, + pallet_support::Event::::Swapped { swapper: BOB.into(), filler: Omnipool::protocol_account(), filler_type: pallet_support::types::Filler::Omnipool, @@ -310,8 +310,8 @@ fn nested_batch_should_represent_embeddedness() { ExecutionType::Batch(1), ExecutionType::Router(2) ], - }), - RuntimeEvent::AmmSupport(pallet_support::Event::::Swapped { + }, + pallet_support::Event::::Swapped { swapper: BOB.into(), filler: XYK::get_pair_id(pallet_xyk::types::AssetPair { asset_in: HDX, @@ -339,7 +339,7 @@ fn nested_batch_should_represent_embeddedness() { ExecutionType::Batch(1), ExecutionType::Router(2) ], - }) + } ] ); }); diff --git a/integration-tests/src/xcm.rs b/integration-tests/src/xcm.rs index d555d2dc4..58ab57eed 100644 --- a/integration-tests/src/xcm.rs +++ b/integration-tests/src/xcm.rs @@ -18,6 +18,7 @@ use xcm_builder::DescribeFamily; use xcm_builder::HashedDescription; use xcm_emulator::ConvertLocation; use xcm_emulator::TestExt; +use crate::assert_operation_stack; #[test] fn global_account_derivation_should_work_when_with_other_chain_remote_account() { @@ -134,35 +135,24 @@ fn global_account_derivation_should_work_when_with_other_chain_remote_account() "Omnipool sell swap failed as the user did not receive any DAI" ); - let swapped_events = get_last_swapped_events(); - let last_two_swapped_events = &get_last_swapped_events()[swapped_events.len() - 2..]; - let topic_id = [ - 162, 58, 237, 167, 26, 250, 26, 161, 116, 182, 7, 12, 84, 48, 100, 53, 175, 60, 179, 213, 59, 7, 83, 150, - 136, 112, 126, 15, 199, 223, 71, 230, - ]; - pretty_assertions::assert_eq!( - last_two_swapped_events, - vec![ - RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { - swapper: account.clone().into(), - filler: Omnipool::protocol_account(), - filler_type: pallet_support::types::Filler::Omnipool, - operation: pallet_support::types::TradeOperation::ExactIn, - inputs: vec![UnifiedEventAsset::new(HDX, 1000000000000)], - outputs: vec![UnifiedEventAsset::new(LRNA, 1201498716)], - fees: vec![Fee::new(LRNA, 600749, Omnipool::protocol_account()),], - operation_stack: vec![ExecutionType::Xcm(topic_id, 0), ExecutionType::Omnipool(1)] - }), - RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { - swapper: account.into(), - filler: Omnipool::protocol_account(), - filler_type: pallet_support::types::Filler::Omnipool, - operation: pallet_support::types::TradeOperation::ExactIn, - inputs: vec![UnifiedEventAsset::new(LRNA, 1200897967)], - outputs: vec![UnifiedEventAsset::new(DAI, 26619890727267708)], - fees: vec![Fee::new(DAI, 66716518113453, Omnipool::protocol_account()),], - operation_stack: vec![ExecutionType::Xcm(topic_id, 0), ExecutionType::Omnipool(1)], - }) + let last_swapped_events : Vec> = get_last_swapped_events(); + let last_two_swapped_events = &last_swapped_events[last_swapped_events.len() - 2..]; + + let event1 = &last_two_swapped_events[0]; + assert_operation_stack!( + event1, + [ + ExecutionType::Xcm(_, 0), + ExecutionType::Omnipool(1) + ] + ); + + let event2 = &last_two_swapped_events[0]; + assert_operation_stack!( + event2, + [ + ExecutionType::Xcm(_, 0), + ExecutionType::Omnipool(1) ] ); }); @@ -274,39 +264,26 @@ fn xcm_call_should_populate_unified_event_call_context() { // Assert Hydra::execute_with(|| { - let account = AccountId::from(acala_account_id_at_hydra); - assert_xcm_message_processing_passed(); - let swapped_events = get_last_swapped_events(); - let last_two_swapped_events = &get_last_swapped_events()[swapped_events.len() - 2..]; - let topic_id = [ - 162, 58, 237, 167, 26, 250, 26, 161, 116, 182, 7, 12, 84, 48, 100, 53, 175, 60, 179, 213, 59, 7, 83, 150, - 136, 112, 126, 15, 199, 223, 71, 230, - ]; - pretty_assertions::assert_eq!( - last_two_swapped_events, - vec![ - RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { - swapper: account.clone().into(), - filler: Omnipool::protocol_account(), - filler_type: pallet_support::types::Filler::Omnipool, - operation: pallet_support::types::TradeOperation::ExactIn, - inputs: vec![UnifiedEventAsset::new(HDX, 1000000000000)], - outputs: vec![UnifiedEventAsset::new(LRNA, 1201498716)], - fees: vec![Fee::new(LRNA, 600749, Omnipool::protocol_account()),], - operation_stack: vec![ExecutionType::Xcm(topic_id, 0), ExecutionType::Omnipool(1)] - }), - RuntimeEvent::AmmSupport(pallet_support::Event::Swapped { - swapper: account.into(), - filler: Omnipool::protocol_account(), - filler_type: pallet_support::types::Filler::Omnipool, - operation: pallet_support::types::TradeOperation::ExactIn, - inputs: vec![UnifiedEventAsset::new(LRNA, 1200897967)], - outputs: vec![UnifiedEventAsset::new(DAI, 26619890727267708)], - fees: vec![Fee::new(DAI, 66716518113453, Omnipool::protocol_account()),], - operation_stack: vec![ExecutionType::Xcm(topic_id, 0), ExecutionType::Omnipool(1)], - }) + let last_swapped_events : Vec> = get_last_swapped_events(); + let last_two_swapped_events = &last_swapped_events[last_swapped_events.len() - 2..]; + + let event1 = &last_two_swapped_events[0]; + assert_operation_stack!( + event1, + [ + ExecutionType::Xcm(_, 0), + ExecutionType::Omnipool(1) + ] + ); + + let event2 = &last_two_swapped_events[0]; + assert_operation_stack!( + event2, + [ + ExecutionType::Xcm(_, 0), + ExecutionType::Omnipool(1) ] ); From 54128eb40f577ed165fce89e1d3683dd535400d4 Mon Sep 17 00:00:00 2001 From: dmoka Date: Thu, 2 Jan 2025 19:18:18 +0100 Subject: [PATCH 123/142] renaming --- pallets/omnipool/src/lib.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pallets/omnipool/src/lib.rs b/pallets/omnipool/src/lib.rs index c43963564..5b4c1dd93 100644 --- a/pallets/omnipool/src/lib.rs +++ b/pallets/omnipool/src/lib.rs @@ -2134,8 +2134,8 @@ impl Pallet { // Let's give little bit less to process. Subtracting one due to potential rounding errors let allowed_amount = amount.saturating_sub(Balance::one()); - let fees = T::OmnipoolHooks::on_trade_fee(account.clone(), trader.clone(), asset, allowed_amount)?; - let additional_fees_total: Balance = fees + let taken_fee = T::OmnipoolHooks::on_trade_fee(account.clone(), trader.clone(), asset, allowed_amount)?; + let taken_fee_total: Balance = taken_fee .clone() .into_iter() .filter_map(|opt| opt.map(|(balance, _)| balance)) @@ -2144,17 +2144,17 @@ impl Pallet { let asset_reserve = T::Currency::free_balance(asset, &account); let diff = original_asset_reserve.saturating_sub(asset_reserve); ensure!(diff <= allowed_amount, Error::::FeeOverdraft); - ensure!(diff == additional_fees_total, Error::::FeeOverdraft); + ensure!(diff == taken_fee_total, Error::::FeeOverdraft); - let normal_trade_fee = amount.saturating_sub(additional_fees_total); + let protocol_fee_amount = amount.saturating_sub(taken_fee_total); let mut all_trade_fees = vec![Fee { asset: asset.into(), - amount: normal_trade_fee, + amount: protocol_fee_amount, recipient: Self::protocol_account(), }]; - let additional_fee_entries: Vec> = fees + let taken_fee_entries: Vec> = taken_fee .iter() .filter_map(|opt| { opt.clone() @@ -2163,7 +2163,7 @@ impl Pallet { .filter(|fee| fee.amount > 0) //filter out when we zero percentage is configured for fees .collect(); - all_trade_fees.extend(additional_fee_entries); + all_trade_fees.extend(taken_fee_entries); Ok(all_trade_fees) } From c6834facf1b9638c186d11395fd73680d0432116 Mon Sep 17 00:00:00 2001 From: dmoka Date: Thu, 2 Jan 2025 19:48:17 +0100 Subject: [PATCH 124/142] refactoring --- pallets/omnipool/src/lib.rs | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/pallets/omnipool/src/lib.rs b/pallets/omnipool/src/lib.rs index 5b4c1dd93..ed7a18ac6 100644 --- a/pallets/omnipool/src/lib.rs +++ b/pallets/omnipool/src/lib.rs @@ -2135,10 +2135,18 @@ impl Pallet { // Let's give little bit less to process. Subtracting one due to potential rounding errors let allowed_amount = amount.saturating_sub(Balance::one()); let taken_fee = T::OmnipoolHooks::on_trade_fee(account.clone(), trader.clone(), asset, allowed_amount)?; - let taken_fee_total: Balance = taken_fee - .clone() - .into_iter() - .filter_map(|opt| opt.map(|(balance, _)| balance)) + let taken_fee_entries: Vec> = taken_fee + .iter() + .filter_map(|opt| { + opt.clone() + .map(|(balance, recipient)| Fee::new(asset.into(), balance, recipient.clone())) + }) + .filter(|fee| fee.amount > 0) //filter out when we zero percentage is configured for fees + .collect(); + + let taken_fee_total: Balance = taken_fee_entries + .iter() + .map(|fee| fee.amount) .sum(); let asset_reserve = T::Currency::free_balance(asset, &account); @@ -2154,15 +2162,6 @@ impl Pallet { recipient: Self::protocol_account(), }]; - let taken_fee_entries: Vec> = taken_fee - .iter() - .filter_map(|opt| { - opt.clone() - .map(|(balance, recipient)| Fee::new(asset.into(), balance, recipient.clone())) - }) - .filter(|fee| fee.amount > 0) //filter out when we zero percentage is configured for fees - .collect(); - all_trade_fees.extend(taken_fee_entries); Ok(all_trade_fees) From 925cd27f8c760344257fcef573a145e73f2a2da4 Mon Sep 17 00:00:00 2001 From: dmoka Date: Thu, 2 Jan 2025 21:38:26 +0100 Subject: [PATCH 125/142] formatting --- integration-tests/src/exchange_asset.rs | 22 +++---------- integration-tests/src/polkadot_test_net.rs | 1 - integration-tests/src/xcm.rs | 38 ++++------------------ pallets/omnipool/src/lib.rs | 5 +-- 4 files changed, 13 insertions(+), 53 deletions(-) diff --git a/integration-tests/src/exchange_asset.rs b/integration-tests/src/exchange_asset.rs index f56b77285..c4c359b83 100644 --- a/integration-tests/src/exchange_asset.rs +++ b/integration-tests/src/exchange_asset.rs @@ -1,5 +1,6 @@ #![cfg(test)] +use crate::assert_operation_stack; use crate::polkadot_test_net::*; use frame_support::dispatch::GetDispatchInfo; use frame_support::storage::with_transaction; @@ -26,7 +27,6 @@ use sp_runtime::DispatchResult; use sp_runtime::{FixedU128, Permill, TransactionOutcome}; use sp_std::sync::Arc; use xcm_emulator::TestExt; -use crate::assert_operation_stack; pub const SELL: bool = true; pub const BUY: bool = false; @@ -127,7 +127,7 @@ fn hydra_should_swap_assets_when_receiving_from_acala_with_sell() { let received = 39_101 * UNITS + BOB_INITIAL_NATIVE_BALANCE + 207_131_554_396; assert_eq!(hydradx_runtime::Balances::free_balance(AccountId::from(BOB)), received); - let last_swapped_events : Vec> = get_last_swapped_events(); + let last_swapped_events: Vec> = get_last_swapped_events(); let last_two_swapped_events = &last_swapped_events[last_swapped_events.len() - 2..]; let event1 = &last_two_swapped_events[0]; @@ -162,26 +162,14 @@ fn hydra_should_swap_assets_when_receiving_from_acala_with_sell() { vec![], )); - let last_swapped_events : Vec> = get_last_swapped_events(); + let last_swapped_events: Vec> = get_last_swapped_events(); let last_two_swapped_events = &last_swapped_events[last_swapped_events.len() - 2..]; let event1 = &last_two_swapped_events[0]; - assert_operation_stack!( - event1, - [ - ExecutionType::Router(4), - ExecutionType::Omnipool(5) - ] - ); + assert_operation_stack!(event1, [ExecutionType::Router(4), ExecutionType::Omnipool(5)]); let event2 = &last_two_swapped_events[0]; - assert_operation_stack!( - event2, - [ - ExecutionType::Router(4), - ExecutionType::Omnipool(5) - ] - ); + assert_operation_stack!(event2, [ExecutionType::Router(4), ExecutionType::Omnipool(5)]); }); } diff --git a/integration-tests/src/polkadot_test_net.rs b/integration-tests/src/polkadot_test_net.rs index ac06ce8b4..e8c47051e 100644 --- a/integration-tests/src/polkadot_test_net.rs +++ b/integration-tests/src/polkadot_test_net.rs @@ -923,4 +923,3 @@ macro_rules! assert_operation_stack { } } } - diff --git a/integration-tests/src/xcm.rs b/integration-tests/src/xcm.rs index 58ab57eed..3a0b2e253 100644 --- a/integration-tests/src/xcm.rs +++ b/integration-tests/src/xcm.rs @@ -4,6 +4,7 @@ use crate::polkadot_test_net::*; use frame_support::assert_ok; use sp_runtime::codec::Encode; +use crate::assert_operation_stack; use frame_support::dispatch::GetDispatchInfo; use hydradx_runtime::Omnipool; use hydradx_runtime::RuntimeEvent; @@ -18,7 +19,6 @@ use xcm_builder::DescribeFamily; use xcm_builder::HashedDescription; use xcm_emulator::ConvertLocation; use xcm_emulator::TestExt; -use crate::assert_operation_stack; #[test] fn global_account_derivation_should_work_when_with_other_chain_remote_account() { @@ -135,26 +135,14 @@ fn global_account_derivation_should_work_when_with_other_chain_remote_account() "Omnipool sell swap failed as the user did not receive any DAI" ); - let last_swapped_events : Vec> = get_last_swapped_events(); + let last_swapped_events: Vec> = get_last_swapped_events(); let last_two_swapped_events = &last_swapped_events[last_swapped_events.len() - 2..]; let event1 = &last_two_swapped_events[0]; - assert_operation_stack!( - event1, - [ - ExecutionType::Xcm(_, 0), - ExecutionType::Omnipool(1) - ] - ); + assert_operation_stack!(event1, [ExecutionType::Xcm(_, 0), ExecutionType::Omnipool(1)]); let event2 = &last_two_swapped_events[0]; - assert_operation_stack!( - event2, - [ - ExecutionType::Xcm(_, 0), - ExecutionType::Omnipool(1) - ] - ); + assert_operation_stack!(event2, [ExecutionType::Xcm(_, 0), ExecutionType::Omnipool(1)]); }); } @@ -266,26 +254,14 @@ fn xcm_call_should_populate_unified_event_call_context() { Hydra::execute_with(|| { assert_xcm_message_processing_passed(); - let last_swapped_events : Vec> = get_last_swapped_events(); + let last_swapped_events: Vec> = get_last_swapped_events(); let last_two_swapped_events = &last_swapped_events[last_swapped_events.len() - 2..]; let event1 = &last_two_swapped_events[0]; - assert_operation_stack!( - event1, - [ - ExecutionType::Xcm(_, 0), - ExecutionType::Omnipool(1) - ] - ); + assert_operation_stack!(event1, [ExecutionType::Xcm(_, 0), ExecutionType::Omnipool(1)]); let event2 = &last_two_swapped_events[0]; - assert_operation_stack!( - event2, - [ - ExecutionType::Xcm(_, 0), - ExecutionType::Omnipool(1) - ] - ); + assert_operation_stack!(event2, [ExecutionType::Xcm(_, 0), ExecutionType::Omnipool(1)]); let unified_event_context = pallet_support::Pallet::::get_context().unwrap(); assert!(unified_event_context.is_empty()); diff --git a/pallets/omnipool/src/lib.rs b/pallets/omnipool/src/lib.rs index ed7a18ac6..8f2b44308 100644 --- a/pallets/omnipool/src/lib.rs +++ b/pallets/omnipool/src/lib.rs @@ -2144,10 +2144,7 @@ impl Pallet { .filter(|fee| fee.amount > 0) //filter out when we zero percentage is configured for fees .collect(); - let taken_fee_total: Balance = taken_fee_entries - .iter() - .map(|fee| fee.amount) - .sum(); + let taken_fee_total: Balance = taken_fee_entries.iter().map(|fee| fee.amount).sum(); let asset_reserve = T::Currency::free_balance(asset, &account); let diff = original_asset_reserve.saturating_sub(asset_reserve); From 4bd0aff5da28d3f62a81a8ba756f4cacd4490f3b Mon Sep 17 00:00:00 2001 From: dmoka Date: Fri, 3 Jan 2025 08:38:45 +0100 Subject: [PATCH 126/142] some formatting --- pallets/support/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pallets/support/src/lib.rs b/pallets/support/src/lib.rs index 3390ddb63..64e3955a9 100644 --- a/pallets/support/src/lib.rs +++ b/pallets/support/src/lib.rs @@ -33,10 +33,10 @@ pub mod types; // Re-export pallet items so that they can be accessed from the crate namespace. pub use pallet::*; -const LOG_TARGET: &str = "runtime::amm-support"; - pub const MAX_STACK_SIZE: u32 = 16; +const LOG_TARGET: &str = "runtime::amm-support"; + type ExecutionIdStack = BoundedVec>; #[frame_support::pallet] From 8c8a9f508c3319c978471d1e027c66bd27b00a78 Mon Sep 17 00:00:00 2001 From: dmoka Date: Fri, 3 Jan 2025 09:01:41 +0100 Subject: [PATCH 127/142] remove done todo --- pallets/omnipool/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/pallets/omnipool/src/lib.rs b/pallets/omnipool/src/lib.rs index 8f2b44308..ae0a4f1be 100644 --- a/pallets/omnipool/src/lib.rs +++ b/pallets/omnipool/src/lib.rs @@ -1888,7 +1888,6 @@ impl Pallet { }); //No protocol fee in case of selling hub asset - //TODO: we need to split up too, and in the other place too pallet_support::Pallet::::deposit_trade_event( who.clone(), Self::protocol_account(), From 68632a2462cb67a5cf336f961cc0a423e7bf399c Mon Sep 17 00:00:00 2001 From: dmoka Date: Fri, 3 Jan 2025 09:02:46 +0100 Subject: [PATCH 128/142] adjust doc comments --- pallets/omnipool/src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pallets/omnipool/src/lib.rs b/pallets/omnipool/src/lib.rs index ae0a4f1be..ca8fee115 100644 --- a/pallets/omnipool/src/lib.rs +++ b/pallets/omnipool/src/lib.rs @@ -305,7 +305,8 @@ pub mod pallet { shares_removed: Balance, }, /// Sell trade executed. - /// Deprecated. Replaced bypallet_support::Swapped + /// Deprecated. Replaced by pallet_support::Swapped + //TODO: remove when completely migrated to new Swapped event SellExecuted { who: T::AccountId, asset_in: T::AssetId, @@ -319,6 +320,7 @@ pub mod pallet { }, /// Buy trade executed. /// Deprecated. Replaced bypallet_support::Swapped + //TODO: remove when completely migrated to new Swapped event BuyExecuted { who: T::AccountId, asset_in: T::AssetId, @@ -1874,7 +1876,6 @@ impl Pallet { let trade_fees = Self::process_trade_fee(who, asset_out, state_changes.fee.asset_fee)?; - // TODO: Deprecated, remove when ready Self::deposit_event(Event::SellExecuted { who: who.clone(), asset_in: T::HubAssetId::get(), From 1e3e6adea390acae014fc1728258e5cd2dca7923 Mon Sep 17 00:00:00 2001 From: dmoka Date: Fri, 3 Jan 2025 09:09:42 +0100 Subject: [PATCH 129/142] remove done todo --- pallets/stableswap/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/pallets/stableswap/src/lib.rs b/pallets/stableswap/src/lib.rs index fb972d665..8ebdb499c 100644 --- a/pallets/stableswap/src/lib.rs +++ b/pallets/stableswap/src/lib.rs @@ -630,7 +630,6 @@ pub mod pallet { fee, }); - //TODO: ask Martin to double check it pallet_support::Pallet::::deposit_trade_event( who, pool_account.clone(), From 094c186a4e4763f0776f15d5f4c376c8465c58c4 Mon Sep 17 00:00:00 2001 From: dmoka Date: Fri, 3 Jan 2025 19:18:17 +0100 Subject: [PATCH 130/142] make clippy happy --- runtime/adapters/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/adapters/src/lib.rs b/runtime/adapters/src/lib.rs index 467b6f5cb..646c22dc4 100644 --- a/runtime/adapters/src/lib.rs +++ b/runtime/adapters/src/lib.rs @@ -481,8 +481,8 @@ where None } else { pallet_referrals::Pallet::::process_trade_fee( - fee_account.clone().into(), - trader.into(), + fee_account.clone(), + trader, asset.into(), amount, )? @@ -490,7 +490,7 @@ where let referral_amount = referrals_used.clone().map(|(balance, _)| balance).unwrap_or_default(); let staking_used = pallet_staking::Pallet::::process_trade_fee( - fee_account.into(), + fee_account, asset.into(), amount.saturating_sub(referral_amount), )?; From 2c7936d7926925e46a8b06f0010b6480e819d6a8 Mon Sep 17 00:00:00 2001 From: dmoka Date: Fri, 3 Jan 2025 21:35:17 +0100 Subject: [PATCH 131/142] formatting --- runtime/adapters/src/lib.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/runtime/adapters/src/lib.rs b/runtime/adapters/src/lib.rs index 646c22dc4..e38ca8821 100644 --- a/runtime/adapters/src/lib.rs +++ b/runtime/adapters/src/lib.rs @@ -480,12 +480,7 @@ where let referrals_used = if asset == NativeAsset::get() { None } else { - pallet_referrals::Pallet::::process_trade_fee( - fee_account.clone(), - trader, - asset.into(), - amount, - )? + pallet_referrals::Pallet::::process_trade_fee(fee_account.clone(), trader, asset.into(), amount)? }; let referral_amount = referrals_used.clone().map(|(balance, _)| balance).unwrap_or_default(); From d7095348e54e38a7ab55a705ccf8769beb546530 Mon Sep 17 00:00:00 2001 From: dmoka Date: Mon, 6 Jan 2025 11:48:56 +0100 Subject: [PATCH 132/142] regenerate benchmarks for pallets using unified events --- runtime/hydradx/src/weights/pallet_dca.rs | 106 ++++++---- runtime/hydradx/src/weights/pallet_lbp.rs | 160 +++++++------- .../hydradx/src/weights/pallet_omnipool.rs | 198 ++++++++++-------- runtime/hydradx/src/weights/pallet_otc.rs | 64 +++--- .../src/weights/pallet_otc_settlements.rs | 41 ++-- .../src/weights/pallet_route_executor.rs | 120 ++++++----- .../hydradx/src/weights/pallet_stableswap.rs | 128 ++++++----- .../pallet_transaction_multi_payment.rs | 49 +++-- runtime/hydradx/src/weights/pallet_xcm.rs | 164 ++++++++------- runtime/hydradx/src/weights/pallet_xyk.rs | 144 +++++++------ 10 files changed, 663 insertions(+), 511 deletions(-) diff --git a/runtime/hydradx/src/weights/pallet_dca.rs b/runtime/hydradx/src/weights/pallet_dca.rs index a922fb210..87c2dec2b 100644 --- a/runtime/hydradx/src/weights/pallet_dca.rs +++ b/runtime/hydradx/src/weights/pallet_dca.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for `pallet_dca` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-08-01, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2025-01-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bench-bot`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: `1024` @@ -61,39 +61,41 @@ impl pallet_dca::WeightInfo for HydraWeight { /// Proof: `DCA::ScheduleIdsPerBlock` (`max_values`: None, `max_size`: Some(101), added: 2576, mode: `MaxEncodedLen`) /// Storage: `DCA::Schedules` (r:1 w:0) /// Proof: `DCA::Schedules` (`max_values`: None, `max_size`: Some(191), added: 2666, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:1 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `DCA::RemainingAmounts` (r:1 w:1) /// Proof: `DCA::RemainingAmounts` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) /// Storage: `Balances::Reserves` (r:1 w:1) /// Proof: `Balances::Reserves` (`max_values`: None, `max_size`: Some(1249), added: 3724, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:2 w:2) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::IncrementalId` (r:1 w:1) + /// Proof: `AmmSupport::IncrementalId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::ExecutionContext` (r:1 w:1) + /// Proof: `AmmSupport::ExecutionContext` (`max_values`: Some(1), `max_size`: Some(593), added: 1088, mode: `MaxEncodedLen`) /// Storage: `DCA::RetriesOnError` (r:0 w:1) /// Proof: `DCA::RetriesOnError` (`max_values`: None, `max_size`: Some(21), added: 2496, mode: `MaxEncodedLen`) fn on_initialize_with_buy_trade() -> Weight { // Proof Size summary in bytes: - // Measured: `55175` + // Measured: `54994` // Estimated: `31902` - // Minimum execution time: 229_651_000 picoseconds. - Weight::from_parts(235_813_000, 31902) - .saturating_add(T::DbWeight::get().reads(18_u64)) - .saturating_add(T::DbWeight::get().writes(7_u64)) + // Minimum execution time: 221_144_000 picoseconds. + Weight::from_parts(224_534_000, 31902) + .saturating_add(T::DbWeight::get().reads(19_u64)) + .saturating_add(T::DbWeight::get().writes(9_u64)) } /// Storage: `DCA::ScheduleIdsPerBlock` (r:12 w:2) /// Proof: `DCA::ScheduleIdsPerBlock` (`max_values`: None, `max_size`: Some(101), added: 2576, mode: `MaxEncodedLen`) /// Storage: `DCA::Schedules` (r:1 w:0) /// Proof: `DCA::Schedules` (`max_values`: None, `max_size`: Some(191), added: 2666, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) + /// Storage: `MultiTransactionPayment::AcceptedCurrencies` (r:2 w:0) + /// Proof: `MultiTransactionPayment::AcceptedCurrencies` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::NextAssetId` (r:1 w:0) /// Proof: `AssetRegistry::NextAssetId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::LocationAssets` (r:1 w:0) /// Proof: `AssetRegistry::LocationAssets` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) - /// Storage: `MultiTransactionPayment::AcceptedCurrencies` (r:1 w:0) - /// Proof: `MultiTransactionPayment::AcceptedCurrencies` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) /// Storage: `Router::Routes` (r:1 w:0) /// Proof: `Router::Routes` (`max_values`: None, `max_size`: Some(90), added: 2565, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:2 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:4 w:4) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `DCA::RemainingAmounts` (r:1 w:1) @@ -102,6 +104,8 @@ impl pallet_dca::WeightInfo for HydraWeight { /// Proof: `Tokens::Reserves` (`max_values`: None, `max_size`: Some(1261), added: 3736, mode: `MaxEncodedLen`) /// Storage: `XYK::ShareToken` (r:1 w:0) /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) + /// Storage: `Router::SkipEd` (r:1 w:0) + /// Proof: `Router::SkipEd` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) /// Storage: `Duster::AccountBlacklist` (r:2 w:0) /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::BannedAssets` (r:2 w:0) @@ -112,54 +116,60 @@ impl pallet_dca::WeightInfo for HydraWeight { /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) /// Storage: `EmaOracle::WhitelistedAssets` (r:1 w:0) /// Proof: `EmaOracle::WhitelistedAssets` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::ExecutionContext` (r:1 w:1) + /// Proof: `AmmSupport::ExecutionContext` (`max_values`: Some(1), `max_size`: Some(593), added: 1088, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::IncrementalId` (r:1 w:1) + /// Proof: `AmmSupport::IncrementalId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `DCA::RetriesOnError` (r:0 w:1) /// Proof: `DCA::RetriesOnError` (`max_values`: None, `max_size`: Some(21), added: 2496, mode: `MaxEncodedLen`) fn on_initialize_with_buy_trade_with_insufficient_fee_asset() -> Weight { // Proof Size summary in bytes: - // Measured: `60689` + // Measured: `61068` // Estimated: `31902` - // Minimum execution time: 364_296_000 picoseconds. - Weight::from_parts(370_868_000, 31902) - .saturating_add(T::DbWeight::get().reads(35_u64)) - .saturating_add(T::DbWeight::get().writes(10_u64)) + // Minimum execution time: 388_604_000 picoseconds. + Weight::from_parts(396_604_000, 31902) + .saturating_add(T::DbWeight::get().reads(39_u64)) + .saturating_add(T::DbWeight::get().writes(12_u64)) } /// Storage: `DCA::ScheduleIdsPerBlock` (r:12 w:2) /// Proof: `DCA::ScheduleIdsPerBlock` (`max_values`: None, `max_size`: Some(101), added: 2576, mode: `MaxEncodedLen`) /// Storage: `DCA::Schedules` (r:1 w:0) /// Proof: `DCA::Schedules` (`max_values`: None, `max_size`: Some(191), added: 2666, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:1 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `DCA::RemainingAmounts` (r:1 w:1) /// Proof: `DCA::RemainingAmounts` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) /// Storage: `Balances::Reserves` (r:1 w:1) /// Proof: `Balances::Reserves` (`max_values`: None, `max_size`: Some(1249), added: 3724, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:2 w:2) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::IncrementalId` (r:1 w:1) + /// Proof: `AmmSupport::IncrementalId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::ExecutionContext` (r:1 w:1) + /// Proof: `AmmSupport::ExecutionContext` (`max_values`: Some(1), `max_size`: Some(593), added: 1088, mode: `MaxEncodedLen`) /// Storage: `DCA::RetriesOnError` (r:0 w:1) /// Proof: `DCA::RetriesOnError` (`max_values`: None, `max_size`: Some(21), added: 2496, mode: `MaxEncodedLen`) fn on_initialize_with_sell_trade() -> Weight { // Proof Size summary in bytes: - // Measured: `54963` + // Measured: `54782` // Estimated: `31902` - // Minimum execution time: 233_583_000 picoseconds. - Weight::from_parts(236_857_000, 31902) - .saturating_add(T::DbWeight::get().reads(18_u64)) - .saturating_add(T::DbWeight::get().writes(7_u64)) + // Minimum execution time: 223_733_000 picoseconds. + Weight::from_parts(227_341_000, 31902) + .saturating_add(T::DbWeight::get().reads(19_u64)) + .saturating_add(T::DbWeight::get().writes(9_u64)) } /// Storage: `DCA::ScheduleIdsPerBlock` (r:12 w:2) /// Proof: `DCA::ScheduleIdsPerBlock` (`max_values`: None, `max_size`: Some(101), added: 2576, mode: `MaxEncodedLen`) /// Storage: `DCA::Schedules` (r:1 w:0) /// Proof: `DCA::Schedules` (`max_values`: None, `max_size`: Some(191), added: 2666, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) + /// Storage: `MultiTransactionPayment::AcceptedCurrencies` (r:2 w:0) + /// Proof: `MultiTransactionPayment::AcceptedCurrencies` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::NextAssetId` (r:1 w:0) /// Proof: `AssetRegistry::NextAssetId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::LocationAssets` (r:1 w:0) /// Proof: `AssetRegistry::LocationAssets` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) - /// Storage: `MultiTransactionPayment::AcceptedCurrencies` (r:1 w:0) - /// Proof: `MultiTransactionPayment::AcceptedCurrencies` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) /// Storage: `Router::Routes` (r:1 w:0) /// Proof: `Router::Routes` (`max_values`: None, `max_size`: Some(90), added: 2565, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:2 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:4 w:4) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `DCA::RemainingAmounts` (r:1 w:1) @@ -168,6 +178,8 @@ impl pallet_dca::WeightInfo for HydraWeight { /// Proof: `Tokens::Reserves` (`max_values`: None, `max_size`: Some(1261), added: 3736, mode: `MaxEncodedLen`) /// Storage: `XYK::ShareToken` (r:1 w:0) /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) + /// Storage: `Router::SkipEd` (r:1 w:0) + /// Proof: `Router::SkipEd` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) /// Storage: `Duster::AccountBlacklist` (r:2 w:0) /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::BannedAssets` (r:2 w:0) @@ -178,16 +190,20 @@ impl pallet_dca::WeightInfo for HydraWeight { /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) /// Storage: `EmaOracle::WhitelistedAssets` (r:1 w:0) /// Proof: `EmaOracle::WhitelistedAssets` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::ExecutionContext` (r:1 w:1) + /// Proof: `AmmSupport::ExecutionContext` (`max_values`: Some(1), `max_size`: Some(593), added: 1088, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::IncrementalId` (r:1 w:1) + /// Proof: `AmmSupport::IncrementalId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `DCA::RetriesOnError` (r:0 w:1) /// Proof: `DCA::RetriesOnError` (`max_values`: None, `max_size`: Some(21), added: 2496, mode: `MaxEncodedLen`) fn on_initialize_with_sell_trade_with_insufficient_fee_asset() -> Weight { // Proof Size summary in bytes: - // Measured: `61565` + // Measured: `61944` // Estimated: `31902` - // Minimum execution time: 365_645_000 picoseconds. - Weight::from_parts(367_426_000, 31902) - .saturating_add(T::DbWeight::get().reads(35_u64)) - .saturating_add(T::DbWeight::get().writes(10_u64)) + // Minimum execution time: 387_494_000 picoseconds. + Weight::from_parts(393_880_000, 31902) + .saturating_add(T::DbWeight::get().reads(39_u64)) + .saturating_add(T::DbWeight::get().writes(12_u64)) } /// Storage: `DCA::ScheduleIdsPerBlock` (r:1 w:0) /// Proof: `DCA::ScheduleIdsPerBlock` (`max_values`: None, `max_size`: Some(101), added: 2576, mode: `MaxEncodedLen`) @@ -195,20 +211,20 @@ impl pallet_dca::WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `1113` // Estimated: `3566` - // Minimum execution time: 15_430_000 picoseconds. - Weight::from_parts(15_771_000, 3566) + // Minimum execution time: 15_121_000 picoseconds. + Weight::from_parts(15_348_000, 3566) .saturating_add(T::DbWeight::get().reads(1_u64)) } - /// Storage: `AssetRegistry::Assets` (r:1 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) + /// Storage: `MultiTransactionPayment::AcceptedCurrencies` (r:2 w:0) + /// Proof: `MultiTransactionPayment::AcceptedCurrencies` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::NextAssetId` (r:1 w:0) /// Proof: `AssetRegistry::NextAssetId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::LocationAssets` (r:1 w:0) /// Proof: `AssetRegistry::LocationAssets` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) - /// Storage: `MultiTransactionPayment::AcceptedCurrencies` (r:1 w:0) - /// Proof: `MultiTransactionPayment::AcceptedCurrencies` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) /// Storage: `Router::Routes` (r:1 w:0) /// Proof: `Router::Routes` (`max_values`: None, `max_size`: Some(90), added: 2565, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:2 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:3 w:1) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `DCA::ScheduleIdSequencer` (r:1 w:1) @@ -227,11 +243,11 @@ impl pallet_dca::WeightInfo for HydraWeight { /// Proof: `DCA::RemainingAmounts` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) fn schedule() -> Weight { // Proof Size summary in bytes: - // Measured: `53252` + // Measured: `53335` // Estimated: `29326` - // Minimum execution time: 192_467_000 picoseconds. - Weight::from_parts(195_247_000, 29326) - .saturating_add(T::DbWeight::get().reads(21_u64)) + // Minimum execution time: 197_371_000 picoseconds. + Weight::from_parts(199_471_000, 29326) + .saturating_add(T::DbWeight::get().reads(23_u64)) .saturating_add(T::DbWeight::get().writes(8_u64)) } /// Storage: `DCA::Schedules` (r:1 w:1) @@ -252,8 +268,8 @@ impl pallet_dca::WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `2530` // Estimated: `4714` - // Minimum execution time: 73_512_000 picoseconds. - Weight::from_parts(74_398_000, 4714) + // Minimum execution time: 73_251_000 picoseconds. + Weight::from_parts(74_112_000, 4714) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(7_u64)) } diff --git a/runtime/hydradx/src/weights/pallet_lbp.rs b/runtime/hydradx/src/weights/pallet_lbp.rs index fb172bd35..e5a09e2d1 100644 --- a/runtime/hydradx/src/weights/pallet_lbp.rs +++ b/runtime/hydradx/src/weights/pallet_lbp.rs @@ -19,23 +19,29 @@ //! Autogenerated weights for `pallet_lbp` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-09-10, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2025-01-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bench-bot`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: `1024` // Executed Command: -// target/release/hydradx +// ./target/release/hydradx // benchmark // pallet -// --chain=dev -// --steps=50 -// --repeat=20 // --wasm-execution=compiled -// --pallet=pallet-lbp -// --extrinsic=* +// --pallet +// pallet-lbp +// --extrinsic +// * +// --heap-pages +// 4096 +// --steps +// 50 +// --repeat +// 20 // --template=scripts/pallet-weight-template.hbs -// --output=./weights/pallet_lbp.rs +// --output +// lbp.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -55,6 +61,8 @@ impl pallet_lbp::WeightInfo for HydraWeight { /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) /// Storage: `LBP::FeeCollectorWithAsset` (r:1 w:1) /// Proof: `LBP::FeeCollectorWithAsset` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:2 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:4 w:4) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `Router::SkipEd` (r:1 w:0) @@ -63,8 +71,6 @@ impl pallet_lbp::WeightInfo for HydraWeight { /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::BannedAssets` (r:2 w:0) /// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:2 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:1 w:1) @@ -73,10 +79,10 @@ impl pallet_lbp::WeightInfo for HydraWeight { /// Proof: `MultiTransactionPayment::AcceptedCurrencies` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) fn create_pool() -> Weight { // Proof Size summary in bytes: - // Measured: `1519` + // Measured: `1586` // Estimated: `11322` - // Minimum execution time: 136_266_000 picoseconds. - Weight::from_parts(137_668_000, 11322) + // Minimum execution time: 142_561_000 picoseconds. + Weight::from_parts(144_186_000, 11322) .saturating_add(T::DbWeight::get().reads(16_u64)) .saturating_add(T::DbWeight::get().writes(8_u64)) } @@ -88,13 +94,15 @@ impl pallet_lbp::WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `417` // Estimated: `3628` - // Minimum execution time: 24_713_000 picoseconds. - Weight::from_parts(25_213_000, 3628) + // Minimum execution time: 24_589_000 picoseconds. + Weight::from_parts(24_818_000, 3628) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } /// Storage: `LBP::PoolData` (r:1 w:0) /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:2 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:4 w:4) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `Router::SkipEd` (r:1 w:0) @@ -103,21 +111,21 @@ impl pallet_lbp::WeightInfo for HydraWeight { /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::BannedAssets` (r:2 w:0) /// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) fn add_liquidity() -> Weight { // Proof Size summary in bytes: - // Measured: `1780` + // Measured: `1846` // Estimated: `11322` - // Minimum execution time: 104_132_000 picoseconds. - Weight::from_parts(104_897_000, 11322) + // Minimum execution time: 110_251_000 picoseconds. + Weight::from_parts(111_333_000, 11322) .saturating_add(T::DbWeight::get().reads(12_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } /// Storage: `LBP::PoolData` (r:1 w:1) /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:2 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:4 w:4) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `Router::SkipEd` (r:1 w:0) @@ -126,8 +134,6 @@ impl pallet_lbp::WeightInfo for HydraWeight { /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::BannedAssets` (r:2 w:0) /// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:1 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:1 w:1) @@ -138,13 +144,15 @@ impl pallet_lbp::WeightInfo for HydraWeight { /// Proof: `LBP::FeeCollectorWithAsset` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`) fn remove_liquidity() -> Weight { // Proof Size summary in bytes: - // Measured: `1895` + // Measured: `1962` // Estimated: `11322` - // Minimum execution time: 135_138_000 picoseconds. - Weight::from_parts(136_175_000, 11322) + // Minimum execution time: 143_015_000 picoseconds. + Weight::from_parts(144_411_000, 11322) .saturating_add(T::DbWeight::get().reads(14_u64)) .saturating_add(T::DbWeight::get().writes(8_u64)) } + /// Storage: `AssetRegistry::Assets` (r:2 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:5 w:5) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `LBP::PoolData` (r:1 w:0) @@ -157,21 +165,23 @@ impl pallet_lbp::WeightInfo for HydraWeight { /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::BannedAssets` (r:2 w:0) /// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:3 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::ExecutionContext` (r:1 w:0) + /// Proof: `AmmSupport::ExecutionContext` (`max_values`: Some(1), `max_size`: Some(593), added: 1088, mode: `MaxEncodedLen`) fn sell() -> Weight { // Proof Size summary in bytes: - // Measured: `2185` + // Measured: `2393` // Estimated: `13905` - // Minimum execution time: 237_882_000 picoseconds. - Weight::from_parts(239_360_000, 13905) - .saturating_add(T::DbWeight::get().reads(17_u64)) + // Minimum execution time: 257_842_000 picoseconds. + Weight::from_parts(259_082_000, 13905) + .saturating_add(T::DbWeight::get().reads(18_u64)) .saturating_add(T::DbWeight::get().writes(7_u64)) } /// Storage: `LBP::PoolData` (r:1 w:0) /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:2 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:5 w:5) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `Tokens::Locks` (r:1 w:1) @@ -182,21 +192,23 @@ impl pallet_lbp::WeightInfo for HydraWeight { /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::BannedAssets` (r:2 w:0) /// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:3 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::ExecutionContext` (r:1 w:0) + /// Proof: `AmmSupport::ExecutionContext` (`max_values`: Some(1), `max_size`: Some(593), added: 1088, mode: `MaxEncodedLen`) fn buy() -> Weight { // Proof Size summary in bytes: - // Measured: `2185` + // Measured: `2393` // Estimated: `13905` - // Minimum execution time: 237_046_000 picoseconds. - Weight::from_parts(238_347_000, 13905) - .saturating_add(T::DbWeight::get().reads(17_u64)) + // Minimum execution time: 256_944_000 picoseconds. + Weight::from_parts(258_678_000, 13905) + .saturating_add(T::DbWeight::get().reads(18_u64)) .saturating_add(T::DbWeight::get().writes(7_u64)) } /// Storage: `LBP::PoolData` (r:1 w:0) /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:2 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:5 w:5) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `Tokens::Locks` (r:1 w:1) @@ -207,29 +219,31 @@ impl pallet_lbp::WeightInfo for HydraWeight { /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::BannedAssets` (r:2 w:0) /// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:3 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::ExecutionContext` (r:1 w:0) + /// Proof: `AmmSupport::ExecutionContext` (`max_values`: Some(1), `max_size`: Some(593), added: 1088, mode: `MaxEncodedLen`) /// The range of component `c` is `[1, 2]`. /// The range of component `e` is `[0, 1]`. fn router_execution_sell(c: u32, e: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `822 + e * (1363 ±0)` + // Measured: `1052 + e * (1341 ±0)` // Estimated: `8799 + e * (7749 ±0)` - // Minimum execution time: 87_361_000 picoseconds. - Weight::from_parts(88_580_000, 8799) - // Standard Error: 241_438 - .saturating_add(Weight::from_parts(1_047_223, 0).saturating_mul(c.into())) - // Standard Error: 537_751 - .saturating_add(Weight::from_parts(152_397_271, 0).saturating_mul(e.into())) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().reads((14_u64).saturating_mul(e.into()))) + // Minimum execution time: 95_985_000 picoseconds. + Weight::from_parts(96_871_000, 8799) + // Standard Error: 246_612 + .saturating_add(Weight::from_parts(1_068_115, 0).saturating_mul(c.into())) + // Standard Error: 549_275 + .saturating_add(Weight::from_parts(164_399_349, 0).saturating_mul(e.into())) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().reads((13_u64).saturating_mul(e.into()))) .saturating_add(T::DbWeight::get().writes((7_u64).saturating_mul(e.into()))) .saturating_add(Weight::from_parts(0, 7749).saturating_mul(e.into())) } /// Storage: `LBP::PoolData` (r:1 w:0) /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:2 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:5 w:5) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `Tokens::Locks` (r:1 w:1) @@ -240,51 +254,55 @@ impl pallet_lbp::WeightInfo for HydraWeight { /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::BannedAssets` (r:2 w:0) /// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:3 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::ExecutionContext` (r:1 w:0) + /// Proof: `AmmSupport::ExecutionContext` (`max_values`: Some(1), `max_size`: Some(593), added: 1088, mode: `MaxEncodedLen`) /// The range of component `c` is `[1, 3]`. /// The range of component `e` is `[0, 1]`. fn router_execution_buy(c: u32, e: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `822 + e * (1363 ±0)` - // Estimated: `6156 + e * (8544 ±0)` - // Minimum execution time: 160_618_000 picoseconds. - Weight::from_parts(161_967_000, 6156) - // Standard Error: 434_297 - .saturating_add(Weight::from_parts(2_807_924, 0).saturating_mul(c.into())) - // Standard Error: 1_464_590 - .saturating_add(Weight::from_parts(113_441_082, 0).saturating_mul(e.into())) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().reads((14_u64).saturating_mul(e.into()))) + // Measured: `1052 + e * (1341 ±0)` + // Estimated: `6190 + e * (8544 ±6_084_484_329_818_434)` + // Minimum execution time: 170_892_000 picoseconds. + Weight::from_parts(172_182_000, 6190) + // Standard Error: 451_274 + .saturating_add(Weight::from_parts(3_188_052, 0).saturating_mul(c.into())) + // Standard Error: 1_521_843 + .saturating_add(Weight::from_parts(123_952_641, 0).saturating_mul(e.into())) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().reads((13_u64).saturating_mul(e.into()))) .saturating_add(T::DbWeight::get().writes((7_u64).saturating_mul(e.into()))) .saturating_add(Weight::from_parts(0, 8544).saturating_mul(e.into())) } /// Storage: `LBP::PoolData` (r:1 w:0) /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:2 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:2 w:0) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) fn calculate_buy() -> Weight { // Proof Size summary in bytes: - // Measured: `822` - // Estimated: `6156` - // Minimum execution time: 89_869_000 picoseconds. - Weight::from_parts(90_917_000, 6156) - .saturating_add(T::DbWeight::get().reads(3_u64)) + // Measured: `1052` + // Estimated: `6190` + // Minimum execution time: 98_436_000 picoseconds. + Weight::from_parts(98_880_000, 6190) + .saturating_add(T::DbWeight::get().reads(5_u64)) } /// Storage: `LBP::PoolData` (r:1 w:0) /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) /// Storage: `Tokens::Locks` (r:1 w:0) /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:2 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:2 w:0) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) fn calculate_spot_price_with_fee() -> Weight { // Proof Size summary in bytes: - // Measured: `822` - // Estimated: `6156` - // Minimum execution time: 25_211_000 picoseconds. - Weight::from_parts(25_559_000, 6156) - .saturating_add(T::DbWeight::get().reads(4_u64)) + // Measured: `1052` + // Estimated: `6190` + // Minimum execution time: 32_751_000 picoseconds. + Weight::from_parts(33_277_000, 6190) + .saturating_add(T::DbWeight::get().reads(6_u64)) } } \ No newline at end of file diff --git a/runtime/hydradx/src/weights/pallet_omnipool.rs b/runtime/hydradx/src/weights/pallet_omnipool.rs index 3c81a7897..f3fed51b7 100644 --- a/runtime/hydradx/src/weights/pallet_omnipool.rs +++ b/runtime/hydradx/src/weights/pallet_omnipool.rs @@ -19,23 +19,29 @@ //! Autogenerated weights for `pallet_omnipool` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-09-10, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2025-01-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bench-bot`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: `1024` // Executed Command: -// target/release/hydradx +// ./target/release/hydradx // benchmark // pallet -// --chain=dev -// --steps=50 -// --repeat=20 // --wasm-execution=compiled -// --pallet=pallet-omnipool -// --extrinsic=* +// --pallet +// pallet-omnipool +// --extrinsic +// * +// --heap-pages +// 4096 +// --steps +// 50 +// --repeat +// 20 // --template=scripts/pallet-weight-template.hbs -// --output=./weights/pallet_omnipool.rs +// --output +// omni.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -79,13 +85,15 @@ impl pallet_omnipool::WeightInfo for HydraWeight { /// Proof: `Omnipool::Positions` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) fn add_token() -> Weight { // Proof Size summary in bytes: - // Measured: `3128` + // Measured: `3162` // Estimated: `7406` - // Minimum execution time: 129_737_000 picoseconds. - Weight::from_parts(131_001_000, 7406) + // Minimum execution time: 133_850_000 picoseconds. + Weight::from_parts(135_071_000, 7406) .saturating_add(T::DbWeight::get().reads(13_u64)) .saturating_add(T::DbWeight::get().writes(10_u64)) } + /// Storage: `AssetRegistry::Assets` (r:2 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:3 w:3) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `Omnipool::Assets` (r:1 w:1) @@ -108,8 +116,6 @@ impl pallet_omnipool::WeightInfo for HydraWeight { /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::BannedAssets` (r:2 w:0) /// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) /// Storage: `Tokens::TotalIssuance` (r:1 w:1) @@ -130,10 +136,10 @@ impl pallet_omnipool::WeightInfo for HydraWeight { /// Proof: `Omnipool::Positions` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) fn add_liquidity() -> Weight { // Proof Size summary in bytes: - // Measured: `4552` + // Measured: `4619` // Estimated: `8739` - // Minimum execution time: 218_146_000 picoseconds. - Weight::from_parts(219_509_000, 8739) + // Minimum execution time: 225_181_000 picoseconds. + Weight::from_parts(226_916_000, 8739) .saturating_add(T::DbWeight::get().reads(24_u64)) .saturating_add(T::DbWeight::get().writes(14_u64)) } @@ -143,6 +149,8 @@ impl pallet_omnipool::WeightInfo for HydraWeight { /// Proof: `Omnipool::Positions` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) /// Storage: `Omnipool::Assets` (r:1 w:1) /// Proof: `Omnipool::Assets` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:2 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:4 w:4) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `EmaOracle::Oracles` (r:2 w:0) @@ -155,8 +163,6 @@ impl pallet_omnipool::WeightInfo for HydraWeight { /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::BannedAssets` (r:2 w:0) /// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:2 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) /// Storage: `Tokens::TotalIssuance` (r:1 w:1) @@ -183,13 +189,15 @@ impl pallet_omnipool::WeightInfo for HydraWeight { /// Proof: `Uniques::ItemPriceOf` (`max_values`: None, `max_size`: Some(113), added: 2588, mode: `MaxEncodedLen`) fn remove_liquidity() -> Weight { // Proof Size summary in bytes: - // Measured: `7463` + // Measured: `7925` // Estimated: `11322` - // Minimum execution time: 288_313_000 picoseconds. - Weight::from_parts(290_432_000, 11322) + // Minimum execution time: 293_473_000 picoseconds. + Weight::from_parts(294_927_000, 11322) .saturating_add(T::DbWeight::get().reads(27_u64)) .saturating_add(T::DbWeight::get().writes(16_u64)) } + /// Storage: `AssetRegistry::Assets` (r:4 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:5 w:5) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `Omnipool::Assets` (r:3 w:3) @@ -204,8 +212,6 @@ impl pallet_omnipool::WeightInfo for HydraWeight { /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::BannedAssets` (r:2 w:0) /// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:4 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:3 w:2) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:2 w:2) @@ -240,17 +246,23 @@ impl pallet_omnipool::WeightInfo for HydraWeight { /// Proof: `Referrals::PendingConversions` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`) /// Storage: `Referrals::CounterForPendingConversions` (r:1 w:1) /// Proof: `Referrals::CounterForPendingConversions` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::IncrementalId` (r:1 w:1) + /// Proof: `AmmSupport::IncrementalId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::ExecutionContext` (r:1 w:1) + /// Proof: `AmmSupport::ExecutionContext` (`max_values`: Some(1), `max_size`: Some(593), added: 1088, mode: `MaxEncodedLen`) fn sell() -> Weight { // Proof Size summary in bytes: - // Measured: `7823` + // Measured: `8475` // Estimated: `13905` - // Minimum execution time: 333_717_000 picoseconds. - Weight::from_parts(335_901_000, 13905) - .saturating_add(T::DbWeight::get().reads(42_u64)) - .saturating_add(T::DbWeight::get().writes(23_u64)) + // Minimum execution time: 362_238_000 picoseconds. + Weight::from_parts(364_468_000, 13905) + .saturating_add(T::DbWeight::get().reads(44_u64)) + .saturating_add(T::DbWeight::get().writes(25_u64)) } /// Storage: `Omnipool::Assets` (r:3 w:3) /// Proof: `Omnipool::Assets` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:4 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:5 w:5) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `Omnipool::HubAssetImbalance` (r:1 w:1) @@ -263,8 +275,6 @@ impl pallet_omnipool::WeightInfo for HydraWeight { /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::BannedAssets` (r:2 w:0) /// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:4 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:3 w:2) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:2 w:2) @@ -299,28 +309,34 @@ impl pallet_omnipool::WeightInfo for HydraWeight { /// Proof: `Referrals::PendingConversions` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`) /// Storage: `Referrals::CounterForPendingConversions` (r:1 w:1) /// Proof: `Referrals::CounterForPendingConversions` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::IncrementalId` (r:1 w:1) + /// Proof: `AmmSupport::IncrementalId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::ExecutionContext` (r:1 w:1) + /// Proof: `AmmSupport::ExecutionContext` (`max_values`: Some(1), `max_size`: Some(593), added: 1088, mode: `MaxEncodedLen`) fn buy() -> Weight { // Proof Size summary in bytes: - // Measured: `7823` + // Measured: `8475` // Estimated: `13905` - // Minimum execution time: 335_910_000 picoseconds. - Weight::from_parts(337_763_000, 13905) - .saturating_add(T::DbWeight::get().reads(42_u64)) - .saturating_add(T::DbWeight::get().writes(23_u64)) + // Minimum execution time: 363_114_000 picoseconds. + Weight::from_parts(364_872_000, 13905) + .saturating_add(T::DbWeight::get().reads(44_u64)) + .saturating_add(T::DbWeight::get().writes(25_u64)) } /// Storage: `Omnipool::Assets` (r:1 w:1) /// Proof: `Omnipool::Assets` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `MaxEncodedLen`) fn set_asset_tradable_state() -> Weight { // Proof Size summary in bytes: - // Measured: `1305` + // Measured: `1338` // Estimated: `3550` - // Minimum execution time: 28_270_000 picoseconds. - Weight::from_parts(28_812_000, 3550) + // Minimum execution time: 27_936_000 picoseconds. + Weight::from_parts(28_283_000, 3550) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: `Omnipool::Assets` (r:1 w:0) /// Proof: `Omnipool::Assets` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:1 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:2 w:2) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `Router::SkipEd` (r:1 w:0) @@ -329,8 +345,6 @@ impl pallet_omnipool::WeightInfo for HydraWeight { /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::BannedAssets` (r:1 w:0) /// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:1 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:2 w:2) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:1 w:1) @@ -339,10 +353,10 @@ impl pallet_omnipool::WeightInfo for HydraWeight { /// Proof: `MultiTransactionPayment::AcceptedCurrencies` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) fn refund_refused_asset() -> Weight { // Proof Size summary in bytes: - // Measured: `2850` + // Measured: `2918` // Estimated: `6196` - // Minimum execution time: 104_659_000 picoseconds. - Weight::from_parts(105_287_000, 6196) + // Minimum execution time: 106_732_000 picoseconds. + Weight::from_parts(107_480_000, 6196) .saturating_add(T::DbWeight::get().reads(11_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -360,10 +374,10 @@ impl pallet_omnipool::WeightInfo for HydraWeight { /// Proof: `Uniques::ItemPriceOf` (`max_values`: None, `max_size`: Some(113), added: 2588, mode: `MaxEncodedLen`) fn sacrifice_position() -> Weight { // Proof Size summary in bytes: - // Measured: `2910` + // Measured: `2943` // Estimated: `3655` - // Minimum execution time: 67_565_000 picoseconds. - Weight::from_parts(68_526_000, 3655) + // Minimum execution time: 66_273_000 picoseconds. + Weight::from_parts(66_844_000, 3655) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -371,15 +385,17 @@ impl pallet_omnipool::WeightInfo for HydraWeight { /// Proof: `Omnipool::Assets` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `MaxEncodedLen`) fn set_asset_weight_cap() -> Weight { // Proof Size summary in bytes: - // Measured: `1305` + // Measured: `1338` // Estimated: `3550` - // Minimum execution time: 28_717_000 picoseconds. - Weight::from_parts(29_137_000, 3550) + // Minimum execution time: 28_141_000 picoseconds. + Weight::from_parts(28_478_000, 3550) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: `Omnipool::Assets` (r:1 w:1) /// Proof: `Omnipool::Assets` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:2 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:3 w:3) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `Omnipool::HubAssetImbalance` (r:1 w:1) @@ -390,8 +406,6 @@ impl pallet_omnipool::WeightInfo for HydraWeight { /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::BannedAssets` (r:1 w:0) /// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:2 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:1 w:0) @@ -404,21 +418,21 @@ impl pallet_omnipool::WeightInfo for HydraWeight { /// Proof: `EmaOracle::Accumulator` (`max_values`: Some(1), `max_size`: Some(5921), added: 6416, mode: `MaxEncodedLen`) fn withdraw_protocol_liquidity() -> Weight { // Proof Size summary in bytes: - // Measured: `4545` + // Measured: `4613` // Estimated: `8739` - // Minimum execution time: 150_915_000 picoseconds. - Weight::from_parts(152_374_000, 8739) + // Minimum execution time: 155_481_000 picoseconds. + Weight::from_parts(156_810_000, 8739) .saturating_add(T::DbWeight::get().reads(16_u64)) .saturating_add(T::DbWeight::get().writes(8_u64)) } /// Storage: `Omnipool::Assets` (r:1 w:1) /// Proof: `Omnipool::Assets` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:3 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:4 w:3) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `Omnipool::HubAssetImbalance` (r:1 w:1) /// Proof: `Omnipool::HubAssetImbalance` (`max_values`: Some(1), `max_size`: Some(17), added: 512, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Tokens::TotalIssuance` (r:1 w:1) /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) /// Storage: `Router::SkipEd` (r:1 w:0) @@ -435,15 +449,17 @@ impl pallet_omnipool::WeightInfo for HydraWeight { /// Proof: `MultiTransactionPayment::AcceptedCurrencies` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) fn remove_token() -> Weight { // Proof Size summary in bytes: - // Measured: `3636` + // Measured: `3721` // Estimated: `11322` - // Minimum execution time: 151_145_000 picoseconds. - Weight::from_parts(152_034_000, 11322) - .saturating_add(T::DbWeight::get().reads(17_u64)) + // Minimum execution time: 158_665_000 picoseconds. + Weight::from_parts(160_565_000, 11322) + .saturating_add(T::DbWeight::get().reads(18_u64)) .saturating_add(T::DbWeight::get().writes(8_u64)) } /// Storage: `Omnipool::Assets` (r:3 w:3) /// Proof: `Omnipool::Assets` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:4 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:5 w:5) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `Omnipool::HubAssetImbalance` (r:1 w:1) @@ -456,8 +472,6 @@ impl pallet_omnipool::WeightInfo for HydraWeight { /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::BannedAssets` (r:2 w:0) /// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:4 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:3 w:2) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:2 w:2) @@ -488,25 +502,29 @@ impl pallet_omnipool::WeightInfo for HydraWeight { /// Proof: `Referrals::PendingConversions` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`) /// Storage: `Referrals::CounterForPendingConversions` (r:1 w:1) /// Proof: `Referrals::CounterForPendingConversions` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::IncrementalId` (r:1 w:1) + /// Proof: `AmmSupport::IncrementalId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::ExecutionContext` (r:1 w:1) + /// Proof: `AmmSupport::ExecutionContext` (`max_values`: Some(1), `max_size`: Some(593), added: 1088, mode: `MaxEncodedLen`) /// The range of component `c` is `[1, 2]`. /// The range of component `e` is `[0, 1]`. - fn router_execution_sell(c: u32, e: u32, ) -> Weight { + fn router_execution_sell(_c: u32, e: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1974 + e * (5348 ±0)` - // Estimated: `11390 + e * (7749 ±0)` - // Minimum execution time: 45_263_000 picoseconds. - Weight::from_parts(45_693_748, 11390) - // Standard Error: 134_488 - .saturating_add(Weight::from_parts(268_691, 0).saturating_mul(c.into())) - // Standard Error: 134_488 - .saturating_add(Weight::from_parts(289_580_167, 0).saturating_mul(e.into())) - .saturating_add(T::DbWeight::get().reads(7_u64)) + // Measured: `2403 + e * (5571 ±0)` + // Estimated: `8799 + e * (7749 ±0)` + // Minimum execution time: 56_991_000 picoseconds. + Weight::from_parts(58_969_824, 8799) + // Standard Error: 117_597 + .saturating_add(Weight::from_parts(305_808_985, 0).saturating_mul(e.into())) + .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().reads((32_u64).saturating_mul(e.into()))) - .saturating_add(T::DbWeight::get().writes((21_u64).saturating_mul(e.into()))) + .saturating_add(T::DbWeight::get().writes((23_u64).saturating_mul(e.into()))) .saturating_add(Weight::from_parts(0, 7749).saturating_mul(e.into())) } /// Storage: `Omnipool::Assets` (r:3 w:3) /// Proof: `Omnipool::Assets` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:4 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:5 w:5) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `Omnipool::HubAssetImbalance` (r:1 w:1) @@ -519,8 +537,6 @@ impl pallet_omnipool::WeightInfo for HydraWeight { /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::BannedAssets` (r:2 w:0) /// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:4 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:3 w:2) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:2 w:2) @@ -551,31 +567,37 @@ impl pallet_omnipool::WeightInfo for HydraWeight { /// Proof: `Referrals::PendingConversions` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`) /// Storage: `Referrals::CounterForPendingConversions` (r:1 w:1) /// Proof: `Referrals::CounterForPendingConversions` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::IncrementalId` (r:1 w:1) + /// Proof: `AmmSupport::IncrementalId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::ExecutionContext` (r:1 w:1) + /// Proof: `AmmSupport::ExecutionContext` (`max_values`: Some(1), `max_size`: Some(593), added: 1088, mode: `MaxEncodedLen`) /// The range of component `c` is `[1, 2]`. /// The range of component `e` is `[0, 1]`. fn router_execution_buy(c: u32, _e: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `7322` + // Measured: `7974` // Estimated: `13905` - // Minimum execution time: 319_285_000 picoseconds. - Weight::from_parts(311_604_346, 13905) - // Standard Error: 213_268 - .saturating_add(Weight::from_parts(12_523_973, 0).saturating_mul(c.into())) - .saturating_add(T::DbWeight::get().reads(39_u64)) - .saturating_add(T::DbWeight::get().writes(21_u64)) + // Minimum execution time: 344_466_000 picoseconds. + Weight::from_parts(333_207_673, 13905) + // Standard Error: 156_769 + .saturating_add(Weight::from_parts(15_937_317, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(41_u64)) + .saturating_add(T::DbWeight::get().writes(23_u64)) } /// Storage: `DynamicFees::AssetFee` (r:2 w:0) /// Proof: `DynamicFees::AssetFee` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) /// Storage: `Omnipool::Assets` (r:2 w:0) /// Proof: `Omnipool::Assets` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:2 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:2 w:0) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) fn calculate_spot_price_with_fee() -> Weight { // Proof Size summary in bytes: - // Measured: `1933` - // Estimated: `6156` - // Minimum execution time: 44_268_000 picoseconds. - Weight::from_parts(44_633_000, 6156) - .saturating_add(T::DbWeight::get().reads(6_u64)) + // Measured: `2362` + // Estimated: `6190` + // Minimum execution time: 53_222_000 picoseconds. + Weight::from_parts(53_566_000, 6190) + .saturating_add(T::DbWeight::get().reads(8_u64)) } } \ No newline at end of file diff --git a/runtime/hydradx/src/weights/pallet_otc.rs b/runtime/hydradx/src/weights/pallet_otc.rs index 4159772bc..0e2e11e32 100644 --- a/runtime/hydradx/src/weights/pallet_otc.rs +++ b/runtime/hydradx/src/weights/pallet_otc.rs @@ -19,23 +19,29 @@ //! Autogenerated weights for `pallet_otc` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-09-10, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2025-01-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bench-bot`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: `1024` // Executed Command: -// target/release/hydradx +// ./target/release/hydradx // benchmark // pallet -// --chain=dev -// --steps=50 -// --repeat=20 // --wasm-execution=compiled -// --pallet=pallet-otc -// --extrinsic=* +// --pallet +// pallet-otc +// --extrinsic +// * +// --heap-pages +// 4096 +// --steps +// 50 +// --repeat +// 20 // --template=scripts/pallet-weight-template.hbs -// --output=./weights/pallet_otc.rs +// --output +// otc.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -63,10 +69,10 @@ impl pallet_otc::WeightInfo for HydraWeight { /// Proof: `OTC::Orders` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `MaxEncodedLen`) fn place_order() -> Weight { // Proof Size summary in bytes: - // Measured: `963` + // Measured: `996` // Estimated: `6190` - // Minimum execution time: 46_446_000 picoseconds. - Weight::from_parts(47_816_000, 6190) + // Minimum execution time: 48_891_000 picoseconds. + Weight::from_parts(49_393_000, 6190) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -90,17 +96,21 @@ impl pallet_otc::WeightInfo for HydraWeight { /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) /// Storage: `MultiTransactionPayment::AcceptedCurrencies` (r:1 w:0) /// Proof: `MultiTransactionPayment::AcceptedCurrencies` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::ExecutionContext` (r:1 w:0) + /// Proof: `AmmSupport::ExecutionContext` (`max_values`: Some(1), `max_size`: Some(593), added: 1088, mode: `MaxEncodedLen`) fn partial_fill_order() -> Weight { // Proof Size summary in bytes: - // Measured: `2436` + // Measured: `2645` // Estimated: `13905` - // Minimum execution time: 165_029_000 picoseconds. - Weight::from_parts(166_577_000, 13905) - .saturating_add(T::DbWeight::get().reads(19_u64)) + // Minimum execution time: 177_304_000 picoseconds. + Weight::from_parts(178_656_000, 13905) + .saturating_add(T::DbWeight::get().reads(20_u64)) .saturating_add(T::DbWeight::get().writes(8_u64)) } /// Storage: `OTC::Orders` (r:1 w:1) /// Proof: `OTC::Orders` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:2 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Router::SkipEd` (r:1 w:0) /// Proof: `Router::SkipEd` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) /// Storage: `Duster::AccountBlacklist` (r:2 w:0) @@ -109,8 +119,6 @@ impl pallet_otc::WeightInfo for HydraWeight { /// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:5 w:5) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:3 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) /// Storage: `Tokens::Reserves` (r:1 w:1) @@ -119,29 +127,31 @@ impl pallet_otc::WeightInfo for HydraWeight { /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) /// Storage: `MultiTransactionPayment::AcceptedCurrencies` (r:1 w:0) /// Proof: `MultiTransactionPayment::AcceptedCurrencies` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::ExecutionContext` (r:1 w:0) + /// Proof: `AmmSupport::ExecutionContext` (`max_values`: Some(1), `max_size`: Some(593), added: 1088, mode: `MaxEncodedLen`) fn fill_order() -> Weight { // Proof Size summary in bytes: - // Measured: `2436` + // Measured: `2645` // Estimated: `13905` - // Minimum execution time: 161_252_000 picoseconds. - Weight::from_parts(162_540_000, 13905) - .saturating_add(T::DbWeight::get().reads(19_u64)) + // Minimum execution time: 174_232_000 picoseconds. + Weight::from_parts(175_930_000, 13905) + .saturating_add(T::DbWeight::get().reads(20_u64)) .saturating_add(T::DbWeight::get().writes(8_u64)) } /// Storage: `OTC::Orders` (r:1 w:1) /// Proof: `OTC::Orders` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:1 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Tokens::Reserves` (r:1 w:1) /// Proof: `Tokens::Reserves` (`max_values`: None, `max_size`: Some(1261), added: 3736, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:1 w:1) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:1 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) fn cancel_order() -> Weight { // Proof Size summary in bytes: - // Measured: `1197` + // Measured: `1230` // Estimated: `4726` - // Minimum execution time: 42_576_000 picoseconds. - Weight::from_parts(42_962_000, 4726) + // Minimum execution time: 43_680_000 picoseconds. + Weight::from_parts(44_561_000, 4726) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } diff --git a/runtime/hydradx/src/weights/pallet_otc_settlements.rs b/runtime/hydradx/src/weights/pallet_otc_settlements.rs index 510edd4a0..a04c5ee45 100644 --- a/runtime/hydradx/src/weights/pallet_otc_settlements.rs +++ b/runtime/hydradx/src/weights/pallet_otc_settlements.rs @@ -19,48 +19,59 @@ //! Autogenerated weights for `pallet_otc_settlements` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-09-11, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2025-01-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bench-bot`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: `1024` // Executed Command: -// target/release/hydradx +// ./target/release/hydradx // benchmark // pallet -// --chain=dev -// --steps=50 -// --repeat=20 // --wasm-execution=compiled -// --pallet=pallet-otc-settlements -// --extrinsic=* +// --pallet +// pallet-otc_settlements +// --extrinsic +// * +// --heap-pages +// 4096 +// --steps +// 50 +// --repeat +// 20 // --template=scripts/pallet-weight-template.hbs -// --output=./weights/pallet_otc_settlements.rs +// --output +// otcs.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] #![allow(missing_docs)] -use frame_support::{traits::Get, weights::Weight}; +use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; use core::marker::PhantomData; +/// Weights for `pallet_otc_settlements`. +pub struct WeightInfo(PhantomData); + /// Weights for `pallet_otc_settlements` using the HydraDX node and recommended hardware. pub struct HydraWeight(PhantomData); -impl pallet_otc_settlements::weights::WeightInfo for HydraWeight { +impl pallet_otc_settlements::WeightInfo for HydraWeight { /// Storage: `OTC::Orders` (r:1 w:0) /// Proof: `OTC::Orders` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:2 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:1 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:1 w:0) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) fn settle_otc_order() -> Weight { // Proof Size summary in bytes: - // Measured: `747` + // Measured: `1099` // Estimated: `6196` - // Minimum execution time: 101_333_000 picoseconds. - Weight::from_parts(102_441_000, 6196) - .saturating_add(T::DbWeight::get().reads(4_u64)) + // Minimum execution time: 107_618_000 picoseconds. + Weight::from_parts(108_445_000, 6196) + .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } } \ No newline at end of file diff --git a/runtime/hydradx/src/weights/pallet_route_executor.rs b/runtime/hydradx/src/weights/pallet_route_executor.rs index 2aaa06528..fea357b97 100644 --- a/runtime/hydradx/src/weights/pallet_route_executor.rs +++ b/runtime/hydradx/src/weights/pallet_route_executor.rs @@ -19,23 +19,29 @@ //! Autogenerated weights for `pallet_route_executor` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-09-11, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2025-01-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bench-bot`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: `1024` // Executed Command: -// target/release/hydradx +// ./target/release/hydradx // benchmark // pallet -// --chain=dev -// --steps=50 -// --repeat=20 // --wasm-execution=compiled -// --pallet=pallet-route-executor -// --extrinsic=* +// --pallet +// pallet-route-executor +// --extrinsic +// * +// --heap-pages +// 4096 +// --steps +// 50 +// --repeat +// 20 // --template=scripts/pallet-weight-template.hbs -// --output=./weights/pallet_route_executor.rs +// --output +// router.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -59,19 +65,23 @@ impl pallet_route_executor::WeightInfo for HydraWeight< // Proof Size summary in bytes: // Measured: `944` // Estimated: `3590` - // Minimum execution time: 14_078_000 picoseconds. - Weight::from_parts(14_311_000, 3590) + // Minimum execution time: 14_401_000 picoseconds. + Weight::from_parts(14_833_000, 3590) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: `LBP::PoolData` (r:1 w:0) /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:2 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:5 w:5) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:3 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::IncrementalId` (r:1 w:1) + /// Proof: `AmmSupport::IncrementalId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::ExecutionContext` (r:1 w:1) + /// Proof: `AmmSupport::ExecutionContext` (`max_values`: Some(1), `max_size`: Some(593), added: 1088, mode: `MaxEncodedLen`) /// Storage: `Tokens::Locks` (r:1 w:1) /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, mode: `MaxEncodedLen`) /// Storage: `Router::SkipEd` (r:1 w:1) @@ -83,23 +93,27 @@ impl pallet_route_executor::WeightInfo for HydraWeight< /// The range of component `c` is `[0, 1]`. fn calculate_and_execute_sell_in_lbp(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `3743` + // Measured: `3951` // Estimated: `13905` - // Minimum execution time: 358_498_000 picoseconds. - Weight::from_parts(363_434_920, 13905) - // Standard Error: 527_071 - .saturating_add(Weight::from_parts(73_831_579, 0).saturating_mul(c.into())) - .saturating_add(T::DbWeight::get().reads(17_u64)) - .saturating_add(T::DbWeight::get().writes(8_u64)) + // Minimum execution time: 394_133_000 picoseconds. + Weight::from_parts(399_837_120, 13905) + // Standard Error: 480_761 + .saturating_add(Weight::from_parts(79_466_379, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(19_u64)) + .saturating_add(T::DbWeight::get().writes(10_u64)) } /// Storage: `LBP::PoolData` (r:1 w:0) /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:2 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:5 w:5) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:3 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::IncrementalId` (r:1 w:1) + /// Proof: `AmmSupport::IncrementalId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::ExecutionContext` (r:1 w:1) + /// Proof: `AmmSupport::ExecutionContext` (`max_values`: Some(1), `max_size`: Some(593), added: 1088, mode: `MaxEncodedLen`) /// Storage: `Tokens::Locks` (r:1 w:1) /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, mode: `MaxEncodedLen`) /// Storage: `Router::SkipEd` (r:1 w:1) @@ -112,17 +126,17 @@ impl pallet_route_executor::WeightInfo for HydraWeight< /// The range of component `b` is `[0, 1]`. fn calculate_and_execute_buy_in_lbp(c: u32, b: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1637 + b * (2131 ±0)` + // Measured: `1992 + b * (1984 ±0)` // Estimated: `8799 + b * (7749 ±0)` - // Minimum execution time: 97_161_000 picoseconds. - Weight::from_parts(98_156_000, 8799) - // Standard Error: 243_998 - .saturating_add(Weight::from_parts(1_011_059, 0).saturating_mul(c.into())) - // Standard Error: 543_453 - .saturating_add(Weight::from_parts(269_812_210, 0).saturating_mul(b.into())) - .saturating_add(T::DbWeight::get().reads(3_u64)) + // Minimum execution time: 105_766_000 picoseconds. + Weight::from_parts(106_850_000, 8799) + // Standard Error: 247_261 + .saturating_add(Weight::from_parts(1_058_218, 0).saturating_mul(c.into())) + // Standard Error: 550_720 + .saturating_add(Weight::from_parts(295_076_249, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().reads((14_u64).saturating_mul(b.into()))) - .saturating_add(T::DbWeight::get().writes((8_u64).saturating_mul(b.into()))) + .saturating_add(T::DbWeight::get().writes((10_u64).saturating_mul(b.into()))) .saturating_add(Weight::from_parts(0, 7749).saturating_mul(b.into())) } /// Storage: `EmaOracle::Oracles` (r:2 w:0) @@ -131,12 +145,16 @@ impl pallet_route_executor::WeightInfo for HydraWeight< /// Proof: `Router::Routes` (`max_values`: None, `max_size`: Some(90), added: 2565, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:7 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - /// Storage: `Tokens::Accounts` (r:15 w:0) - /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::Assets` (r:6 w:0) /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) + /// Storage: `Tokens::Accounts` (r:15 w:0) + /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `XYK::ShareToken` (r:6 w:0) /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::IncrementalId` (r:1 w:0) + /// Proof: `AmmSupport::IncrementalId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::ExecutionContext` (r:1 w:0) + /// Proof: `AmmSupport::ExecutionContext` (`max_values`: Some(1), `max_size`: Some(593), added: 1088, mode: `MaxEncodedLen`) /// Storage: `Router::SkipEd` (r:1 w:0) /// Proof: `Router::SkipEd` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) /// Storage: `Duster::AccountBlacklist` (r:7 w:0) @@ -153,11 +171,11 @@ impl pallet_route_executor::WeightInfo for HydraWeight< /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) fn set_route_for_xyk() -> Weight { // Proof Size summary in bytes: - // Measured: `7004` + // Measured: `7213` // Estimated: `39735` - // Minimum execution time: 1_934_148_000 picoseconds. - Weight::from_parts(1_942_875_000, 39735) - .saturating_add(T::DbWeight::get().reads(58_u64)) + // Minimum execution time: 2_267_256_000 picoseconds. + Weight::from_parts(2_276_393_000, 39735) + .saturating_add(T::DbWeight::get().reads(60_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: `Router::Routes` (r:0 w:1) @@ -166,8 +184,8 @@ impl pallet_route_executor::WeightInfo for HydraWeight< // Proof Size summary in bytes: // Measured: `1012` // Estimated: `0` - // Minimum execution time: 25_655_000 picoseconds. - Weight::from_parts(26_130_000, 0) + // Minimum execution time: 25_660_000 picoseconds. + Weight::from_parts(25_971_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: `Router::Routes` (r:1 w:0) @@ -176,8 +194,8 @@ impl pallet_route_executor::WeightInfo for HydraWeight< // Proof Size summary in bytes: // Measured: `800` // Estimated: `3555` - // Minimum execution time: 7_524_000 picoseconds. - Weight::from_parts(7_759_000, 3555) + // Minimum execution time: 7_380_000 picoseconds. + Weight::from_parts(7_625_000, 3555) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// Storage: `EmaOracle::Oracles` (r:2 w:0) @@ -186,8 +204,8 @@ impl pallet_route_executor::WeightInfo for HydraWeight< // Proof Size summary in bytes: // Measured: `1452` // Estimated: `6294` - // Minimum execution time: 26_686_000 picoseconds. - Weight::from_parts(26_929_000, 6294) + // Minimum execution time: 26_435_000 picoseconds. + Weight::from_parts(26_846_000, 6294) .saturating_add(T::DbWeight::get().reads(2_u64)) } /// Storage: `EmaOracle::Oracles` (r:4 w:0) @@ -196,22 +214,24 @@ impl pallet_route_executor::WeightInfo for HydraWeight< // Proof Size summary in bytes: // Measured: `1814` // Estimated: `11598` - // Minimum execution time: 40_799_000 picoseconds. - Weight::from_parts(41_526_000, 11598) + // Minimum execution time: 40_530_000 picoseconds. + Weight::from_parts(41_113_000, 11598) .saturating_add(T::DbWeight::get().reads(4_u64)) } /// Storage: `LBP::PoolData` (r:1 w:0) /// Proof: `LBP::PoolData` (`max_values`: None, `max_size`: Some(163), added: 2638, mode: `MaxEncodedLen`) /// Storage: `Tokens::Locks` (r:1 w:0) /// Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1261), added: 3736, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:2 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:2 w:0) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) fn calculate_spot_price_with_fee_in_lbp() -> Weight { // Proof Size summary in bytes: - // Measured: `1674` - // Estimated: `6156` - // Minimum execution time: 36_673_000 picoseconds. - Weight::from_parts(37_031_000, 6156) - .saturating_add(T::DbWeight::get().reads(4_u64)) + // Measured: `2029` + // Estimated: `6190` + // Minimum execution time: 44_535_000 picoseconds. + Weight::from_parts(45_317_000, 6190) + .saturating_add(T::DbWeight::get().reads(6_u64)) } } \ No newline at end of file diff --git a/runtime/hydradx/src/weights/pallet_stableswap.rs b/runtime/hydradx/src/weights/pallet_stableswap.rs index 2c48d648b..88bf0cf47 100644 --- a/runtime/hydradx/src/weights/pallet_stableswap.rs +++ b/runtime/hydradx/src/weights/pallet_stableswap.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for `pallet_stableswap` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-11-04, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2025-01-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bench-bot`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: `1024` @@ -41,7 +41,7 @@ // 20 // --template=scripts/pallet-weight-template.hbs // --output -// weights.rs +// stable.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -67,8 +67,8 @@ impl pallet_stableswap::WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `855` // Estimated: `16590` - // Minimum execution time: 43_034_000 picoseconds. - Weight::from_parts(43_494_000, 16590) + // Minimum execution time: 42_627_000 picoseconds. + Weight::from_parts(43_257_000, 16590) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -96,13 +96,15 @@ impl pallet_stableswap::WeightInfo for HydraWeight { /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `EmaOracle::Accumulator` (r:1 w:1) /// Proof: `EmaOracle::Accumulator` (`max_values`: Some(1), `max_size`: Some(5921), added: 6416, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::ExecutionContext` (r:1 w:0) + /// Proof: `AmmSupport::ExecutionContext` (`max_values`: Some(1), `max_size`: Some(593), added: 1088, mode: `MaxEncodedLen`) fn add_liquidity() -> Weight { // Proof Size summary in bytes: - // Measured: `3679` + // Measured: `3888` // Estimated: `29403` - // Minimum execution time: 1_392_606_000 picoseconds. - Weight::from_parts(1_396_550_000, 29403) - .saturating_add(T::DbWeight::get().reads(36_u64)) + // Minimum execution time: 1_396_711_000 picoseconds. + Weight::from_parts(1_399_810_000, 29403) + .saturating_add(T::DbWeight::get().reads(37_u64)) .saturating_add(T::DbWeight::get().writes(14_u64)) } /// Storage: `Stableswap::AssetTradability` (r:1 w:0) @@ -129,13 +131,15 @@ impl pallet_stableswap::WeightInfo for HydraWeight { /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `EmaOracle::Accumulator` (r:1 w:1) /// Proof: `EmaOracle::Accumulator` (`max_values`: Some(1), `max_size`: Some(5921), added: 6416, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::ExecutionContext` (r:1 w:0) + /// Proof: `AmmSupport::ExecutionContext` (`max_values`: Some(1), `max_size`: Some(593), added: 1088, mode: `MaxEncodedLen`) fn add_liquidity_shares() -> Weight { // Proof Size summary in bytes: - // Measured: `3548` + // Measured: `3757` // Estimated: `19071` - // Minimum execution time: 942_454_000 picoseconds. - Weight::from_parts(946_345_000, 19071) - .saturating_add(T::DbWeight::get().reads(24_u64)) + // Minimum execution time: 951_042_000 picoseconds. + Weight::from_parts(956_992_000, 19071) + .saturating_add(T::DbWeight::get().reads(25_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } /// Storage: `Stableswap::AssetTradability` (r:1 w:0) @@ -160,15 +164,17 @@ impl pallet_stableswap::WeightInfo for HydraWeight { /// Proof: `MultiTransactionPayment::AcceptedCurrencies` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) /// Storage: `EmaOracle::Accumulator` (r:1 w:1) /// Proof: `EmaOracle::Accumulator` (`max_values`: Some(1), `max_size`: Some(5921), added: 6416, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::ExecutionContext` (r:1 w:0) + /// Proof: `AmmSupport::ExecutionContext` (`max_values`: Some(1), `max_size`: Some(593), added: 1088, mode: `MaxEncodedLen`) /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:0 w:1) /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) fn remove_liquidity_one_asset() -> Weight { // Proof Size summary in bytes: - // Measured: `3571` + // Measured: `3780` // Estimated: `19071` - // Minimum execution time: 981_411_000 picoseconds. - Weight::from_parts(986_942_000, 19071) - .saturating_add(T::DbWeight::get().reads(23_u64)) + // Minimum execution time: 973_675_000 picoseconds. + Weight::from_parts(978_123_000, 19071) + .saturating_add(T::DbWeight::get().reads(24_u64)) .saturating_add(T::DbWeight::get().writes(7_u64)) } /// Storage: `AssetRegistry::Assets` (r:6 w:0) @@ -197,10 +203,10 @@ impl pallet_stableswap::WeightInfo for HydraWeight { /// Proof: `EmaOracle::Accumulator` (`max_values`: Some(1), `max_size`: Some(5921), added: 6416, mode: `MaxEncodedLen`) fn remove_liquidity() -> Weight { // Proof Size summary in bytes: - // Measured: `3571` + // Measured: `3638` // Estimated: `29403` - // Minimum execution time: 713_843_000 picoseconds. - Weight::from_parts(717_284_000, 29403) + // Minimum execution time: 714_149_000 picoseconds. + Weight::from_parts(717_802_000, 29403) .saturating_add(T::DbWeight::get().reads(40_u64)) .saturating_add(T::DbWeight::get().writes(14_u64)) } @@ -228,13 +234,15 @@ impl pallet_stableswap::WeightInfo for HydraWeight { /// Proof: `MultiTransactionPayment::AcceptedCurrencies` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) /// Storage: `EmaOracle::Accumulator` (r:1 w:1) /// Proof: `EmaOracle::Accumulator` (`max_values`: Some(1), `max_size`: Some(5921), added: 6416, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::ExecutionContext` (r:1 w:0) + /// Proof: `AmmSupport::ExecutionContext` (`max_values`: Some(1), `max_size`: Some(593), added: 1088, mode: `MaxEncodedLen`) fn withdraw_asset_amount() -> Weight { // Proof Size summary in bytes: - // Measured: `3571` + // Measured: `3780` // Estimated: `19071` - // Minimum execution time: 1_321_443_000 picoseconds. - Weight::from_parts(1_330_485_000, 19071) - .saturating_add(T::DbWeight::get().reads(24_u64)) + // Minimum execution time: 1_304_045_000 picoseconds. + Weight::from_parts(1_310_888_000, 19071) + .saturating_add(T::DbWeight::get().reads(25_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } /// Storage: `Stableswap::AssetTradability` (r:2 w:0) @@ -259,15 +267,17 @@ impl pallet_stableswap::WeightInfo for HydraWeight { /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) /// Storage: `EmaOracle::Accumulator` (r:1 w:1) /// Proof: `EmaOracle::Accumulator` (`max_values`: Some(1), `max_size`: Some(5921), added: 6416, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::ExecutionContext` (r:1 w:0) + /// Proof: `AmmSupport::ExecutionContext` (`max_values`: Some(1), `max_size`: Some(593), added: 1088, mode: `MaxEncodedLen`) /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:0 w:1) /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) fn sell() -> Weight { // Proof Size summary in bytes: - // Measured: `3634` + // Measured: `3843` // Estimated: `19071` - // Minimum execution time: 916_352_000 picoseconds. - Weight::from_parts(920_145_000, 19071) - .saturating_add(T::DbWeight::get().reads(26_u64)) + // Minimum execution time: 932_943_000 picoseconds. + Weight::from_parts(938_765_000, 19071) + .saturating_add(T::DbWeight::get().reads(27_u64)) .saturating_add(T::DbWeight::get().writes(7_u64)) } /// Storage: `Stableswap::AssetTradability` (r:2 w:0) @@ -294,13 +304,15 @@ impl pallet_stableswap::WeightInfo for HydraWeight { /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) /// Storage: `EmaOracle::Accumulator` (r:1 w:1) /// Proof: `EmaOracle::Accumulator` (`max_values`: Some(1), `max_size`: Some(5921), added: 6416, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::ExecutionContext` (r:1 w:0) + /// Proof: `AmmSupport::ExecutionContext` (`max_values`: Some(1), `max_size`: Some(593), added: 1088, mode: `MaxEncodedLen`) fn buy() -> Weight { // Proof Size summary in bytes: - // Measured: `3604` + // Measured: `3813` // Estimated: `19071` - // Minimum execution time: 896_389_000 picoseconds. - Weight::from_parts(900_423_000, 19071) - .saturating_add(T::DbWeight::get().reads(27_u64)) + // Minimum execution time: 899_028_000 picoseconds. + Weight::from_parts(902_695_000, 19071) + .saturating_add(T::DbWeight::get().reads(28_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } /// Storage: `Stableswap::Pools` (r:1 w:0) @@ -311,8 +323,8 @@ impl pallet_stableswap::WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `291` // Estimated: `3522` - // Minimum execution time: 20_400_000 picoseconds. - Weight::from_parts(20_642_000, 3522) + // Minimum execution time: 20_448_000 picoseconds. + Weight::from_parts(20_790_000, 3522) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -322,8 +334,8 @@ impl pallet_stableswap::WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `291` // Estimated: `3522` - // Minimum execution time: 17_775_000 picoseconds. - Weight::from_parts(18_177_000, 3522) + // Minimum execution time: 18_046_000 picoseconds. + Weight::from_parts(18_248_000, 3522) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -333,8 +345,8 @@ impl pallet_stableswap::WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `291` // Estimated: `3522` - // Minimum execution time: 18_598_000 picoseconds. - Weight::from_parts(19_175_000, 3522) + // Minimum execution time: 18_832_000 picoseconds. + Weight::from_parts(19_283_000, 3522) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -360,22 +372,22 @@ impl pallet_stableswap::WeightInfo for HydraWeight { /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) /// Storage: `EmaOracle::Accumulator` (r:1 w:1) /// Proof: `EmaOracle::Accumulator` (`max_values`: Some(1), `max_size`: Some(5921), added: 6416, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::ExecutionContext` (r:1 w:0) + /// Proof: `AmmSupport::ExecutionContext` (`max_values`: Some(1), `max_size`: Some(593), added: 1088, mode: `MaxEncodedLen`) /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:0 w:1) /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) /// The range of component `c` is `[1, 2]`. /// The range of component `e` is `[0, 1]`. - fn router_execution_sell(c: u32, e: u32, ) -> Weight { + fn router_execution_sell(_c: u32, e: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1621 + e * (2013 ±0)` + // Measured: `1654 + e * (2189 ±0)` // Estimated: `13990 + e * (5166 ±0)` - // Minimum execution time: 387_637_000 picoseconds. - Weight::from_parts(387_839_091, 13990) - // Standard Error: 754_096 - .saturating_add(Weight::from_parts(2_363_309, 0).saturating_mul(c.into())) - // Standard Error: 754_096 - .saturating_add(Weight::from_parts(891_811_539, 0).saturating_mul(e.into())) + // Minimum execution time: 389_951_000 picoseconds. + Weight::from_parts(413_140_502, 13990) + // Standard Error: 1_517_346 + .saturating_add(Weight::from_parts(890_143_515, 0).saturating_mul(e.into())) .saturating_add(T::DbWeight::get().reads(11_u64)) - .saturating_add(T::DbWeight::get().reads((15_u64).saturating_mul(e.into()))) + .saturating_add(T::DbWeight::get().reads((16_u64).saturating_mul(e.into()))) .saturating_add(T::DbWeight::get().writes((7_u64).saturating_mul(e.into()))) .saturating_add(Weight::from_parts(0, 5166).saturating_mul(e.into())) } @@ -403,20 +415,22 @@ impl pallet_stableswap::WeightInfo for HydraWeight { /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) /// Storage: `EmaOracle::Accumulator` (r:1 w:1) /// Proof: `EmaOracle::Accumulator` (`max_values`: Some(1), `max_size`: Some(5921), added: 6416, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::ExecutionContext` (r:1 w:0) + /// Proof: `AmmSupport::ExecutionContext` (`max_values`: Some(1), `max_size`: Some(593), added: 1088, mode: `MaxEncodedLen`) /// The range of component `c` is `[1, 2]`. /// The range of component `e` is `[0, 1]`. fn router_execution_buy(c: u32, e: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1620 + e * (1984 ±0)` + // Measured: `1653 + e * (2160 ±0)` // Estimated: `13990 + e * (5166 ±0)` - // Minimum execution time: 389_169_000 picoseconds. - Weight::from_parts(391_578_000, 13990) - // Standard Error: 1_117_835 - .saturating_add(Weight::from_parts(4_197_174, 0).saturating_mul(c.into())) - // Standard Error: 2_489_735 - .saturating_add(Weight::from_parts(517_256_553, 0).saturating_mul(e.into())) + // Minimum execution time: 389_033_000 picoseconds. + Weight::from_parts(390_900_000, 13990) + // Standard Error: 1_178_861 + .saturating_add(Weight::from_parts(4_367_320, 0).saturating_mul(c.into())) + // Standard Error: 2_625_656 + .saturating_add(Weight::from_parts(529_308_020, 0).saturating_mul(e.into())) .saturating_add(T::DbWeight::get().reads(11_u64)) - .saturating_add(T::DbWeight::get().reads((16_u64).saturating_mul(e.into()))) + .saturating_add(T::DbWeight::get().reads((17_u64).saturating_mul(e.into()))) .saturating_add(T::DbWeight::get().writes((6_u64).saturating_mul(e.into()))) .saturating_add(Weight::from_parts(0, 5166).saturating_mul(e.into())) } @@ -430,10 +444,10 @@ impl pallet_stableswap::WeightInfo for HydraWeight { /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) fn calculate_spot_price_with_fee() -> Weight { // Proof Size summary in bytes: - // Measured: `1852` + // Measured: `1885` // Estimated: `16590` - // Minimum execution time: 334_088_000 picoseconds. - Weight::from_parts(335_160_000, 16590) + // Minimum execution time: 325_545_000 picoseconds. + Weight::from_parts(326_127_000, 16590) .saturating_add(T::DbWeight::get().reads(13_u64)) } } \ No newline at end of file diff --git a/runtime/hydradx/src/weights/pallet_transaction_multi_payment.rs b/runtime/hydradx/src/weights/pallet_transaction_multi_payment.rs index f667bd8b2..bc9ab15ba 100644 --- a/runtime/hydradx/src/weights/pallet_transaction_multi_payment.rs +++ b/runtime/hydradx/src/weights/pallet_transaction_multi_payment.rs @@ -19,18 +19,15 @@ //! Autogenerated weights for `pallet_transaction_multi_payment` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-08-30, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2025-01-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bench-bot`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: `1024` // Executed Command: -// target/release/hydradx +// ./target/release/hydradx // benchmark // pallet -// --chain=dev -// --steps=50 -// --repeat=20 // --wasm-execution=compiled // --pallet // pallet_transaction_multi_payment @@ -64,10 +61,10 @@ impl pallet_transaction_multi_payment::WeightInfo for H /// Proof: `MultiTransactionPayment::AcceptedCurrencies` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) fn add_currency() -> Weight { // Proof Size summary in bytes: - // Measured: `1176` + // Measured: `1209` // Estimated: `3493` - // Minimum execution time: 20_221_000 picoseconds. - Weight::from_parts(20_863_000, 3493) + // Minimum execution time: 19_680_000 picoseconds. + Weight::from_parts(20_493_000, 3493) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -75,10 +72,10 @@ impl pallet_transaction_multi_payment::WeightInfo for H /// Proof: `MultiTransactionPayment::AcceptedCurrencies` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) fn remove_currency() -> Weight { // Proof Size summary in bytes: - // Measured: `1207` + // Measured: `1240` // Estimated: `3493` - // Minimum execution time: 20_985_000 picoseconds. - Weight::from_parts(21_358_000, 3493) + // Minimum execution time: 20_452_000 picoseconds. + Weight::from_parts(20_811_000, 3493) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -88,10 +85,10 @@ impl pallet_transaction_multi_payment::WeightInfo for H /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) fn set_currency() -> Weight { // Proof Size summary in bytes: - // Measured: `1272` + // Measured: `1305` // Estimated: `3493` - // Minimum execution time: 29_947_000 picoseconds. - Weight::from_parts(30_593_000, 3493) + // Minimum execution time: 30_233_000 picoseconds. + Weight::from_parts(30_698_000, 3493) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -103,8 +100,8 @@ impl pallet_transaction_multi_payment::WeightInfo for H // Proof Size summary in bytes: // Measured: `3221` // Estimated: `27510` - // Minimum execution time: 89_961_000 picoseconds. - Weight::from_parts(92_275_000, 27510) + // Minimum execution time: 88_773_000 picoseconds. + Weight::from_parts(89_513_000, 27510) .saturating_add(T::DbWeight::get().reads(11_u64)) } /// Storage: `AssetRegistry::NextAssetId` (r:1 w:0) @@ -117,8 +114,8 @@ impl pallet_transaction_multi_payment::WeightInfo for H // Proof Size summary in bytes: // Measured: `1313` // Estimated: `4087` - // Minimum execution time: 23_076_000 picoseconds. - Weight::from_parts(23_748_000, 4087) + // Minimum execution time: 22_879_000 picoseconds. + Weight::from_parts(23_385_000, 4087) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -136,6 +133,8 @@ impl pallet_transaction_multi_payment::WeightInfo for H /// Proof: `Router::Routes` (`max_values`: None, `max_size`: Some(90), added: 2565, mode: `MaxEncodedLen`) /// Storage: `EmaOracle::Oracles` (r:1 w:0) /// Proof: `EmaOracle::Oracles` (`max_values`: None, `max_size`: Some(177), added: 2652, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:2 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:4 w:4) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `XYK::ShareToken` (r:1 w:0) @@ -146,21 +145,21 @@ impl pallet_transaction_multi_payment::WeightInfo for H /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::BannedAssets` (r:2 w:0) /// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:2 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:2 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) /// Storage: `EmaOracle::WhitelistedAssets` (r:1 w:0) /// Proof: `EmaOracle::WhitelistedAssets` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::ExecutionContext` (r:1 w:0) + /// Proof: `AmmSupport::ExecutionContext` (`max_values`: Some(1), `max_size`: Some(593), added: 1088, mode: `MaxEncodedLen`) /// Storage: `Tokens::TotalIssuance` (r:1 w:1) /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) fn withdraw_fee() -> Weight { // Proof Size summary in bytes: - // Measured: `4091` + // Measured: `4300` // Estimated: `11322` - // Minimum execution time: 222_263_000 picoseconds. - Weight::from_parts(223_179_000, 11322) - .saturating_add(T::DbWeight::get().reads(24_u64)) + // Minimum execution time: 246_466_000 picoseconds. + Weight::from_parts(248_428_000, 11322) + .saturating_add(T::DbWeight::get().reads(25_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } } \ No newline at end of file diff --git a/runtime/hydradx/src/weights/pallet_xcm.rs b/runtime/hydradx/src/weights/pallet_xcm.rs index d289dbbd6..09cad56dc 100644 --- a/runtime/hydradx/src/weights/pallet_xcm.rs +++ b/runtime/hydradx/src/weights/pallet_xcm.rs @@ -19,23 +19,29 @@ //! Autogenerated weights for `pallet_xcm` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-09-10, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2025-01-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bench-bot`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: `1024` // Executed Command: -// target/release/hydradx +// ./target/release/hydradx // benchmark // pallet -// --chain=dev -// --steps=50 -// --repeat=20 // --wasm-execution=compiled -// --pallet=pallet-xcm -// --extrinsic=* +// --pallet +// pallet-xcm +// --extrinsic +// * +// --heap-pages +// 4096 +// --steps +// 50 +// --repeat +// 20 // --template=scripts/pallet-weight-template.hbs -// --output=./weights/pallet_xcm.rs +// --output +// xcm.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -63,10 +69,10 @@ impl pallet_xcm::WeightInfo for HydraWeight { /// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn send() -> Weight { // Proof Size summary in bytes: - // Measured: `145` - // Estimated: `3610` - // Minimum execution time: 26_808_000 picoseconds. - Weight::from_parts(27_657_000, 3610) + // Measured: `178` + // Estimated: `3643` + // Minimum execution time: 29_644_000 picoseconds. + Weight::from_parts(30_115_000, 3643) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -81,6 +87,10 @@ impl pallet_xcm::WeightInfo for HydraWeight { } /// Storage: `ParachainInfo::ParachainId` (r:1 w:0) /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::IncrementalId` (r:1 w:1) + /// Proof: `AmmSupport::IncrementalId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::ExecutionContext` (r:1 w:1) + /// Proof: `AmmSupport::ExecutionContext` (`max_values`: Some(1), `max_size`: Some(593), added: 1088, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:1 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) @@ -97,15 +107,19 @@ impl pallet_xcm::WeightInfo for HydraWeight { /// Proof: `XcmpQueue::OutboundXcmpMessages` (`max_values`: None, `max_size`: None, mode: `Measured`) fn reserve_transfer_assets() -> Weight { // Proof Size summary in bytes: - // Measured: `536` - // Estimated: `4001` - // Minimum execution time: 119_808_000 picoseconds. - Weight::from_parts(120_772_000, 4001) - .saturating_add(T::DbWeight::get().reads(7_u64)) - .saturating_add(T::DbWeight::get().writes(4_u64)) + // Measured: `711` + // Estimated: `4176` + // Minimum execution time: 128_779_000 picoseconds. + Weight::from_parts(129_535_000, 4176) + .saturating_add(T::DbWeight::get().reads(9_u64)) + .saturating_add(T::DbWeight::get().writes(6_u64)) } /// Storage: `ParachainInfo::ParachainId` (r:1 w:0) /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::IncrementalId` (r:1 w:1) + /// Proof: `AmmSupport::IncrementalId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::ExecutionContext` (r:1 w:1) + /// Proof: `AmmSupport::ExecutionContext` (`max_values`: Some(1), `max_size`: Some(593), added: 1088, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:1 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) @@ -122,19 +136,25 @@ impl pallet_xcm::WeightInfo for HydraWeight { /// Proof: `XcmpQueue::OutboundXcmpMessages` (`max_values`: None, `max_size`: None, mode: `Measured`) fn transfer_assets() -> Weight { // Proof Size summary in bytes: - // Measured: `536` - // Estimated: `4001` - // Minimum execution time: 113_768_000 picoseconds. - Weight::from_parts(114_458_000, 4001) - .saturating_add(T::DbWeight::get().reads(7_u64)) - .saturating_add(T::DbWeight::get().writes(4_u64)) + // Measured: `711` + // Estimated: `4176` + // Minimum execution time: 122_013_000 picoseconds. + Weight::from_parts(123_163_000, 4176) + .saturating_add(T::DbWeight::get().reads(9_u64)) + .saturating_add(T::DbWeight::get().writes(6_u64)) } + /// Storage: `AmmSupport::IncrementalId` (r:1 w:1) + /// Proof: `AmmSupport::IncrementalId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::ExecutionContext` (r:1 w:1) + /// Proof: `AmmSupport::ExecutionContext` (`max_values`: Some(1), `max_size`: Some(593), added: 1088, mode: `MaxEncodedLen`) fn execute() -> Weight { // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 10_674_000 picoseconds. - Weight::from_parts(11_085_000, 0) + // Measured: `142` + // Estimated: `2078` + // Minimum execution time: 17_574_000 picoseconds. + Weight::from_parts(18_069_000, 2078) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } /// Storage: `PolkadotXcm::SupportedVersion` (r:0 w:1) /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -142,8 +162,8 @@ impl pallet_xcm::WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 10_294_000 picoseconds. - Weight::from_parts(10_566_000, 0) + // Minimum execution time: 10_032_000 picoseconds. + Weight::from_parts(10_479_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: `PolkadotXcm::SafeXcmVersion` (r:0 w:1) @@ -152,8 +172,8 @@ impl pallet_xcm::WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_300_000 picoseconds. - Weight::from_parts(3_438_000, 0) + // Minimum execution time: 3_395_000 picoseconds. + Weight::from_parts(3_543_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: `PolkadotXcm::VersionNotifiers` (r:1 w:1) @@ -174,10 +194,10 @@ impl pallet_xcm::WeightInfo for HydraWeight { /// Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) fn force_subscribe_version_notify() -> Weight { // Proof Size summary in bytes: - // Measured: `145` - // Estimated: `3610` - // Minimum execution time: 34_496_000 picoseconds. - Weight::from_parts(35_126_000, 3610) + // Measured: `178` + // Estimated: `3643` + // Minimum execution time: 37_227_000 picoseconds. + Weight::from_parts(37_856_000, 3643) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -197,10 +217,10 @@ impl pallet_xcm::WeightInfo for HydraWeight { /// Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) fn force_unsubscribe_version_notify() -> Weight { // Proof Size summary in bytes: - // Measured: `328` - // Estimated: `3793` - // Minimum execution time: 35_498_000 picoseconds. - Weight::from_parts(36_205_000, 3793) + // Measured: `396` + // Estimated: `3861` + // Minimum execution time: 38_626_000 picoseconds. + Weight::from_parts(39_233_000, 3861) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -210,8 +230,8 @@ impl pallet_xcm::WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_429_000 picoseconds. - Weight::from_parts(3_514_000, 0) + // Minimum execution time: 3_311_000 picoseconds. + Weight::from_parts(3_389_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: `PolkadotXcm::SupportedVersion` (r:5 w:2) @@ -220,8 +240,8 @@ impl pallet_xcm::WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `125` // Estimated: `13490` - // Minimum execution time: 23_899_000 picoseconds. - Weight::from_parts(24_595_000, 13490) + // Minimum execution time: 24_330_000 picoseconds. + Weight::from_parts(24_610_000, 13490) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -231,8 +251,8 @@ impl pallet_xcm::WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `129` // Estimated: `13494` - // Minimum execution time: 24_345_000 picoseconds. - Weight::from_parts(24_819_000, 13494) + // Minimum execution time: 24_094_000 picoseconds. + Weight::from_parts(24_531_000, 13494) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -242,8 +262,8 @@ impl pallet_xcm::WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `178` // Estimated: `16018` - // Minimum execution time: 25_896_000 picoseconds. - Weight::from_parts(26_370_000, 16018) + // Minimum execution time: 25_687_000 picoseconds. + Weight::from_parts(26_023_000, 16018) .saturating_add(T::DbWeight::get().reads(6_u64)) } /// Storage: `PolkadotXcm::VersionNotifyTargets` (r:2 w:1) @@ -260,10 +280,10 @@ impl pallet_xcm::WeightInfo for HydraWeight { /// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn notify_current_targets() -> Weight { // Proof Size summary in bytes: - // Measured: `212` - // Estimated: `6152` - // Minimum execution time: 33_012_000 picoseconds. - Weight::from_parts(33_556_000, 6152) + // Measured: `245` + // Estimated: `6185` + // Minimum execution time: 35_187_000 picoseconds. + Weight::from_parts(35_810_000, 6185) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -273,8 +293,8 @@ impl pallet_xcm::WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `172` // Estimated: `11062` - // Minimum execution time: 15_074_000 picoseconds. - Weight::from_parts(15_300_000, 11062) + // Minimum execution time: 15_029_000 picoseconds. + Weight::from_parts(15_317_000, 11062) .saturating_add(T::DbWeight::get().reads(4_u64)) } /// Storage: `PolkadotXcm::VersionNotifyTargets` (r:5 w:2) @@ -283,8 +303,8 @@ impl pallet_xcm::WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `136` // Estimated: `13501` - // Minimum execution time: 24_481_000 picoseconds. - Weight::from_parts(24_983_000, 13501) + // Minimum execution time: 24_032_000 picoseconds. + Weight::from_parts(24_609_000, 13501) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -302,10 +322,10 @@ impl pallet_xcm::WeightInfo for HydraWeight { /// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn migrate_and_notify_old_targets() -> Weight { // Proof Size summary in bytes: - // Measured: `212` - // Estimated: `13577` - // Minimum execution time: 43_872_000 picoseconds. - Weight::from_parts(44_246_000, 13577) + // Measured: `245` + // Estimated: `13610` + // Minimum execution time: 45_864_000 picoseconds. + Weight::from_parts(46_515_000, 13610) .saturating_add(T::DbWeight::get().reads(10_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -317,8 +337,8 @@ impl pallet_xcm::WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `69` // Estimated: `1554` - // Minimum execution time: 5_184_000 picoseconds. - Weight::from_parts(5_385_000, 1554) + // Minimum execution time: 5_268_000 picoseconds. + Weight::from_parts(5_334_000, 1554) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -328,11 +348,15 @@ impl pallet_xcm::WeightInfo for HydraWeight { // Proof Size summary in bytes: // Measured: `7706` // Estimated: `11171` - // Minimum execution time: 36_167_000 picoseconds. - Weight::from_parts(36_522_000, 11171) + // Minimum execution time: 34_683_000 picoseconds. + Weight::from_parts(35_383_000, 11171) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } + /// Storage: `AmmSupport::IncrementalId` (r:1 w:1) + /// Proof: `AmmSupport::IncrementalId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::ExecutionContext` (r:1 w:1) + /// Proof: `AmmSupport::ExecutionContext` (`max_values`: Some(1), `max_size`: Some(593), added: 1088, mode: `MaxEncodedLen`) /// Storage: `PolkadotXcm::AssetTraps` (r:1 w:1) /// Proof: `PolkadotXcm::AssetTraps` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `AssetRegistry::LocationAssets` (r:1 w:0) @@ -341,11 +365,11 @@ impl pallet_xcm::WeightInfo for HydraWeight { /// Proof: `UnknownTokens::ConcreteFungibleBalances` (`max_values`: None, `max_size`: None, mode: `Measured`) fn claim_assets() -> Weight { // Proof Size summary in bytes: - // Measured: `448` + // Measured: `590` // Estimated: `4087` - // Minimum execution time: 42_235_000 picoseconds. - Weight::from_parts(42_824_000, 4087) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) + // Minimum execution time: 50_134_000 picoseconds. + Weight::from_parts(50_681_000, 4087) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) } } \ No newline at end of file diff --git a/runtime/hydradx/src/weights/pallet_xyk.rs b/runtime/hydradx/src/weights/pallet_xyk.rs index 1e6fc1551..d4f2bf1f9 100644 --- a/runtime/hydradx/src/weights/pallet_xyk.rs +++ b/runtime/hydradx/src/weights/pallet_xyk.rs @@ -19,23 +19,29 @@ //! Autogenerated weights for `pallet_xyk` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-09-10, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2025-01-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bench-bot`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: `1024` // Executed Command: -// target/release/hydradx +// ./target/release/hydradx // benchmark // pallet -// --chain=dev -// --steps=50 -// --repeat=20 // --wasm-execution=compiled -// --pallet=pallet-xyk -// --extrinsic=* +// --pallet +// pallet-xyk +// --extrinsic +// * +// --heap-pages +// 4096 +// --steps +// 50 +// --repeat +// 20 // --template=scripts/pallet-weight-template.hbs -// --output=./weights/pallet_xyk.rs +// --output +// xyk.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -85,21 +91,25 @@ impl pallet_xyk::WeightInfo for HydraWeight { /// Proof: `AssetRegistry::ExistentialDepositCounter` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) /// Storage: `Tokens::TotalIssuance` (r:1 w:1) /// Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) + /// Storage: `EVM::AccountCodes` (r:0 w:1) + /// Proof: `EVM::AccountCodes` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `XYK::TotalLiquidity` (r:0 w:1) /// Proof: `XYK::TotalLiquidity` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`) /// Storage: `XYK::PoolAssets` (r:0 w:1) /// Proof: `XYK::PoolAssets` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `MaxEncodedLen`) fn create_pool() -> Weight { // Proof Size summary in bytes: - // Measured: `3863` + // Measured: `3930` // Estimated: `19071` - // Minimum execution time: 482_234_000 picoseconds. - Weight::from_parts(487_055_000, 19071) + // Minimum execution time: 514_551_000 picoseconds. + Weight::from_parts(517_902_000, 19071) .saturating_add(T::DbWeight::get().reads(34_u64)) - .saturating_add(T::DbWeight::get().writes(20_u64)) + .saturating_add(T::DbWeight::get().writes(21_u64)) } /// Storage: `XYK::ShareToken` (r:1 w:0) /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:4 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:7 w:7) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `XYK::TotalLiquidity` (r:1 w:1) @@ -110,8 +120,6 @@ impl pallet_xyk::WeightInfo for HydraWeight { /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::BannedAssets` (r:4 w:0) /// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:4 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:2 w:2) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:1 w:0) @@ -130,10 +138,10 @@ impl pallet_xyk::WeightInfo for HydraWeight { /// Proof: `EmaOracle::WhitelistedAssets` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`) fn add_liquidity() -> Weight { // Proof Size summary in bytes: - // Measured: `4499` + // Measured: `4566` // Estimated: `19071` - // Minimum execution time: 300_637_000 picoseconds. - Weight::from_parts(301_659_000, 19071) + // Minimum execution time: 322_959_000 picoseconds. + Weight::from_parts(324_407_000, 19071) .saturating_add(T::DbWeight::get().reads(28_u64)) .saturating_add(T::DbWeight::get().writes(13_u64)) } @@ -141,6 +149,8 @@ impl pallet_xyk::WeightInfo for HydraWeight { /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) /// Storage: `XYK::TotalLiquidity` (r:1 w:1) /// Proof: `XYK::TotalLiquidity` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:4 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:7 w:7) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `Router::SkipEd` (r:1 w:0) @@ -149,8 +159,6 @@ impl pallet_xyk::WeightInfo for HydraWeight { /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::BannedAssets` (r:3 w:0) /// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:4 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:2 w:0) /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) /// Storage: `MultiTransactionPayment::AcceptedCurrencyPrice` (r:1 w:0) @@ -171,15 +179,17 @@ impl pallet_xyk::WeightInfo for HydraWeight { /// Proof: `XYK::PoolAssets` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `MaxEncodedLen`) fn remove_liquidity() -> Weight { // Proof Size summary in bytes: - // Measured: `4549` + // Measured: `4616` // Estimated: `19071` - // Minimum execution time: 437_485_000 picoseconds. - Weight::from_parts(441_006_000, 19071) + // Minimum execution time: 465_242_000 picoseconds. + Weight::from_parts(467_621_000, 19071) .saturating_add(T::DbWeight::get().reads(30_u64)) .saturating_add(T::DbWeight::get().writes(17_u64)) } /// Storage: `XYK::ShareToken` (r:1 w:0) /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:3 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:6 w:6) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `Router::SkipEd` (r:1 w:0) @@ -188,8 +198,6 @@ impl pallet_xyk::WeightInfo for HydraWeight { /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::BannedAssets` (r:3 w:0) /// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:3 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:3 w:2) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:1 w:0) @@ -204,17 +212,21 @@ impl pallet_xyk::WeightInfo for HydraWeight { /// Proof: `MultiTransactionPayment::AcceptedCurrencyPrice` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) /// Storage: `EmaOracle::WhitelistedAssets` (r:1 w:0) /// Proof: `EmaOracle::WhitelistedAssets` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::ExecutionContext` (r:1 w:0) + /// Proof: `AmmSupport::ExecutionContext` (`max_values`: Some(1), `max_size`: Some(593), added: 1088, mode: `MaxEncodedLen`) fn sell() -> Weight { // Proof Size summary in bytes: - // Measured: `4398` + // Measured: `4607` // Estimated: `16488` - // Minimum execution time: 263_251_000 picoseconds. - Weight::from_parts(265_158_000, 16488) - .saturating_add(T::DbWeight::get().reads(25_u64)) + // Minimum execution time: 291_799_000 picoseconds. + Weight::from_parts(294_762_000, 16488) + .saturating_add(T::DbWeight::get().reads(26_u64)) .saturating_add(T::DbWeight::get().writes(10_u64)) } /// Storage: `XYK::ShareToken` (r:1 w:0) /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:3 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:6 w:6) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `Router::SkipEd` (r:1 w:0) @@ -223,8 +235,6 @@ impl pallet_xyk::WeightInfo for HydraWeight { /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::BannedAssets` (r:3 w:0) /// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:3 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:1 w:0) /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) /// Storage: `MultiTransactionPayment::AcceptedCurrencyPrice` (r:1 w:0) @@ -239,17 +249,21 @@ impl pallet_xyk::WeightInfo for HydraWeight { /// Proof: `AssetRegistry::ExistentialDepositCounter` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) /// Storage: `EmaOracle::WhitelistedAssets` (r:1 w:0) /// Proof: `EmaOracle::WhitelistedAssets` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::ExecutionContext` (r:1 w:0) + /// Proof: `AmmSupport::ExecutionContext` (`max_values`: Some(1), `max_size`: Some(593), added: 1088, mode: `MaxEncodedLen`) fn buy() -> Weight { // Proof Size summary in bytes: - // Measured: `4398` + // Measured: `4607` // Estimated: `16488` - // Minimum execution time: 261_604_000 picoseconds. - Weight::from_parts(262_778_000, 16488) - .saturating_add(T::DbWeight::get().reads(25_u64)) + // Minimum execution time: 290_794_000 picoseconds. + Weight::from_parts(291_891_000, 16488) + .saturating_add(T::DbWeight::get().reads(26_u64)) .saturating_add(T::DbWeight::get().writes(10_u64)) } /// Storage: `XYK::ShareToken` (r:1 w:0) /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:3 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:6 w:6) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `Router::SkipEd` (r:1 w:0) @@ -258,8 +272,6 @@ impl pallet_xyk::WeightInfo for HydraWeight { /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::BannedAssets` (r:3 w:0) /// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:3 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:3 w:2) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:1 w:0) @@ -274,25 +286,29 @@ impl pallet_xyk::WeightInfo for HydraWeight { /// Proof: `MultiTransactionPayment::AcceptedCurrencyPrice` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) /// Storage: `EmaOracle::WhitelistedAssets` (r:1 w:0) /// Proof: `EmaOracle::WhitelistedAssets` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::ExecutionContext` (r:1 w:0) + /// Proof: `AmmSupport::ExecutionContext` (`max_values`: Some(1), `max_size`: Some(593), added: 1088, mode: `MaxEncodedLen`) /// The range of component `c` is `[1, 2]`. /// The range of component `e` is `[0, 1]`. fn router_execution_sell(c: u32, e: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1221 + e * (3177 ±0)` + // Measured: `1786 + e * (2821 ±0)` // Estimated: `8799 + e * (10332 ±0)` - // Minimum execution time: 24_468_000 picoseconds. - Weight::from_parts(8_259_951, 8799) - // Standard Error: 78_193 - .saturating_add(Weight::from_parts(8_502_639, 0).saturating_mul(c.into())) - // Standard Error: 78_193 - .saturating_add(Weight::from_parts(247_520_019, 0).saturating_mul(e.into())) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().reads((22_u64).saturating_mul(e.into()))) + // Minimum execution time: 36_204_000 picoseconds. + Weight::from_parts(15_925_932, 8799) + // Standard Error: 142_323 + .saturating_add(Weight::from_parts(10_665_022, 0).saturating_mul(c.into())) + // Standard Error: 142_323 + .saturating_add(Weight::from_parts(265_461_022, 0).saturating_mul(e.into())) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().reads((21_u64).saturating_mul(e.into()))) .saturating_add(T::DbWeight::get().writes((10_u64).saturating_mul(e.into()))) .saturating_add(Weight::from_parts(0, 10332).saturating_mul(e.into())) } /// Storage: `XYK::ShareToken` (r:1 w:0) /// Proof: `XYK::ShareToken` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) + /// Storage: `AssetRegistry::Assets` (r:3 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:6 w:6) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) /// Storage: `Router::SkipEd` (r:1 w:0) @@ -301,8 +317,6 @@ impl pallet_xyk::WeightInfo for HydraWeight { /// Proof: `Duster::AccountBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `AssetRegistry::BannedAssets` (r:3 w:0) /// Proof: `AssetRegistry::BannedAssets` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`) - /// Storage: `AssetRegistry::Assets` (r:3 w:0) - /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `MultiTransactionPayment::AccountCurrencyMap` (r:1 w:0) /// Proof: `MultiTransactionPayment::AccountCurrencyMap` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) /// Storage: `MultiTransactionPayment::AcceptedCurrencyPrice` (r:1 w:0) @@ -317,31 +331,35 @@ impl pallet_xyk::WeightInfo for HydraWeight { /// Proof: `AssetRegistry::ExistentialDepositCounter` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) /// Storage: `EmaOracle::WhitelistedAssets` (r:1 w:0) /// Proof: `EmaOracle::WhitelistedAssets` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`) + /// Storage: `AmmSupport::ExecutionContext` (r:1 w:0) + /// Proof: `AmmSupport::ExecutionContext` (`max_values`: Some(1), `max_size`: Some(593), added: 1088, mode: `MaxEncodedLen`) /// The range of component `c` is `[1, 3]`. /// The range of component `e` is `[0, 1]`. fn router_execution_buy(c: u32, e: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1221 + e * (3177 ±0)` - // Estimated: `6156 + e * (10332 ±3_500_844_840_074_025)` - // Minimum execution time: 31_785_000 picoseconds. - Weight::from_parts(11_618_923, 6156) - // Standard Error: 29_806 - .saturating_add(Weight::from_parts(6_978_081, 0).saturating_mul(c.into())) - // Standard Error: 49_613 - .saturating_add(Weight::from_parts(245_134_509, 0).saturating_mul(e.into())) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().reads((22_u64).saturating_mul(e.into()))) + // Measured: `1786 + e * (2821 ±0)` + // Estimated: `6190 + e * (10332 ±13_724_751_572_184_578)` + // Minimum execution time: 46_966_000 picoseconds. + Weight::from_parts(16_613_427, 6190) + // Standard Error: 34_017 + .saturating_add(Weight::from_parts(10_415_848, 0).saturating_mul(c.into())) + // Standard Error: 56_624 + .saturating_add(Weight::from_parts(263_188_553, 0).saturating_mul(e.into())) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().reads((21_u64).saturating_mul(e.into()))) .saturating_add(T::DbWeight::get().writes((10_u64).saturating_mul(e.into()))) .saturating_add(Weight::from_parts(0, 10332).saturating_mul(e.into())) } + /// Storage: `AssetRegistry::Assets` (r:2 w:0) + /// Proof: `AssetRegistry::Assets` (`max_values`: None, `max_size`: Some(125), added: 2600, mode: `MaxEncodedLen`) /// Storage: `Tokens::Accounts` (r:2 w:0) /// Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`) fn calculate_spot_price_with_fee() -> Weight { // Proof Size summary in bytes: - // Measured: `1021` - // Estimated: `6156` - // Minimum execution time: 19_349_000 picoseconds. - Weight::from_parts(19_578_000, 6156) - .saturating_add(T::DbWeight::get().reads(2_u64)) + // Measured: `1586` + // Estimated: `6190` + // Minimum execution time: 31_091_000 picoseconds. + Weight::from_parts(31_529_000, 6190) + .saturating_add(T::DbWeight::get().reads(4_u64)) } } \ No newline at end of file From 06a3f52da40ff248a8fd765ffb053567387eb531 Mon Sep 17 00:00:00 2001 From: dmoka Date: Mon, 6 Jan 2025 12:19:38 +0100 Subject: [PATCH 133/142] fix compilation error --- runtime/hydradx/src/weights/pallet_otc_settlements.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/runtime/hydradx/src/weights/pallet_otc_settlements.rs b/runtime/hydradx/src/weights/pallet_otc_settlements.rs index a04c5ee45..b67c4e42d 100644 --- a/runtime/hydradx/src/weights/pallet_otc_settlements.rs +++ b/runtime/hydradx/src/weights/pallet_otc_settlements.rs @@ -52,11 +52,10 @@ use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; use core::marker::PhantomData; /// Weights for `pallet_otc_settlements`. -pub struct WeightInfo(PhantomData); /// Weights for `pallet_otc_settlements` using the HydraDX node and recommended hardware. pub struct HydraWeight(PhantomData); -impl pallet_otc_settlements::WeightInfo for HydraWeight { +impl pallet_otc_settlements::weights::WeightInfo for HydraWeight { /// Storage: `OTC::Orders` (r:1 w:0) /// Proof: `OTC::Orders` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:2 w:1) From f78f216d6437d403f2a9f7e842340093964e9d24 Mon Sep 17 00:00:00 2001 From: dmoka Date: Mon, 6 Jan 2025 13:30:32 +0100 Subject: [PATCH 134/142] remove unecessary calls --- integration-tests/src/dca.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/integration-tests/src/dca.rs b/integration-tests/src/dca.rs index 7f514f31f..74f610193 100644 --- a/integration-tests/src/dca.rs +++ b/integration-tests/src/dca.rs @@ -220,7 +220,7 @@ mod omnipool { //Assert let swapped_events = get_last_swapped_events(); - let last_two_swapped_events = &get_last_swapped_events()[swapped_events.len() - 2..]; + let last_two_swapped_events = &swapped_events[swapped_events.len() - 2..]; pretty_assertions::assert_eq!( last_two_swapped_events, vec![ @@ -258,7 +258,7 @@ mod omnipool { run_to_block(13, 17); let swapped_events = get_last_swapped_events(); - let last_two_swapped_events = &get_last_swapped_events()[swapped_events.len() - 2..]; + let last_two_swapped_events = &swapped_events[swapped_events.len() - 2..]; pretty_assertions::assert_eq!( last_two_swapped_events, vec![ @@ -707,7 +707,7 @@ mod omnipool { //Assert let swapped_events = get_last_swapped_events(); - let last_two_swapped_events = &get_last_swapped_events()[swapped_events.len() - 2..]; + let last_two_swapped_events = &swapped_events[swapped_events.len() - 2..]; pretty_assertions::assert_eq!( last_two_swapped_events, vec![ @@ -745,7 +745,7 @@ mod omnipool { run_to_block(13, 17); let swapped_events = get_last_swapped_events(); - let last_two_swapped_events = &get_last_swapped_events()[swapped_events.len() - 2..]; + let last_two_swapped_events = &swapped_events[swapped_events.len() - 2..]; pretty_assertions::assert_eq!( last_two_swapped_events, vec![ From 1ac661266734479e4861efbc0410a2531024e111 Mon Sep 17 00:00:00 2001 From: Daniel Moka Date: Mon, 6 Jan 2025 13:38:30 +0100 Subject: [PATCH 135/142] Update pallets/lbp/src/lib.rs Co-authored-by: Richard Roznovjak --- pallets/lbp/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/lbp/src/lib.rs b/pallets/lbp/src/lib.rs index a0f8e5c6e..9b6af5bd7 100644 --- a/pallets/lbp/src/lib.rs +++ b/pallets/lbp/src/lib.rs @@ -343,7 +343,7 @@ pub mod pallet { }, /// Sale executed. - /// Deprecated. Replaced bypallet_support::Swapped + /// Deprecated. Replaced by pallet_support::Swapped SellExecuted { who: T::AccountId, asset_in: AssetId, From d1d565aa61ac93f747767a36da63d622decfa031 Mon Sep 17 00:00:00 2001 From: Daniel Moka Date: Mon, 6 Jan 2025 13:39:13 +0100 Subject: [PATCH 136/142] Update pallets/lbp/src/lib.rs Co-authored-by: Richard Roznovjak --- pallets/lbp/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/lbp/src/lib.rs b/pallets/lbp/src/lib.rs index 9b6af5bd7..c9b39a572 100644 --- a/pallets/lbp/src/lib.rs +++ b/pallets/lbp/src/lib.rs @@ -355,7 +355,7 @@ pub mod pallet { }, /// Purchase executed. - /// Deprecated. Replaced bypallet_support::Swapped + /// Deprecated. Replaced by pallet_support::Swapped BuyExecuted { who: T::AccountId, asset_out: AssetId, From c3c093158ce6a2cbc2f3ea985b155b8ee768a552 Mon Sep 17 00:00:00 2001 From: Daniel Moka Date: Mon, 6 Jan 2025 13:39:34 +0100 Subject: [PATCH 137/142] Update pallets/support/src/lib.rs Co-authored-by: Richard Roznovjak --- pallets/support/src/lib.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pallets/support/src/lib.rs b/pallets/support/src/lib.rs index 64e3955a9..26bf5483a 100644 --- a/pallets/support/src/lib.rs +++ b/pallets/support/src/lib.rs @@ -88,12 +88,9 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { fn on_initialize(_n: BlockNumberFor) -> Weight { - let mut weight: Weight = Weight::zero(); - weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 1)); - ExecutionContext::::kill(); - - Weight::from_parts(weight.ref_time(), 0) + + T::DbWeight::get().reads_writes(1, 1) } } From 5a836acdf97ba1ccffd62f2aa5e6a0f2c7a7fd6f Mon Sep 17 00:00:00 2001 From: Daniel Moka Date: Mon, 6 Jan 2025 13:39:57 +0100 Subject: [PATCH 138/142] fix typo Co-authored-by: Richard Roznovjak --- pallets/stableswap/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/stableswap/src/lib.rs b/pallets/stableswap/src/lib.rs index 8ebdb499c..e7f8036e1 100644 --- a/pallets/stableswap/src/lib.rs +++ b/pallets/stableswap/src/lib.rs @@ -212,7 +212,7 @@ pub mod pallet { fee: Balance, }, /// Sell trade executed. Trade fee paid in asset leaving the pool (already subtracted from amount_out). - /// Deprecated. Replaced bypallet_support::Swapped + /// Deprecated. Replaced by pallet_support::Swapped //TODO: remove once we migrated completely to pallet_amm::Event::Swapped SellExecuted { who: T::AccountId, From 2407cf222d03c4483b4a74325025bc507d47bab4 Mon Sep 17 00:00:00 2001 From: dmoka Date: Mon, 6 Jan 2025 13:39:07 +0100 Subject: [PATCH 139/142] remove unecessary dep --- pallets/dca/Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pallets/dca/Cargo.toml b/pallets/dca/Cargo.toml index f1c375b66..e4eca4ae1 100644 --- a/pallets/dca/Cargo.toml +++ b/pallets/dca/Cargo.toml @@ -53,7 +53,6 @@ primitives = { path = "../../primitives", default-features = false } pallet-route-executor = { workspace = true } smallvec = { workspace = true } pallet-balances = { workspace = true } -pallet-support = { workspace = true } pallet-currencies = { workspace = true } lazy_static = { workspace = true } sp-api = { workspace = true } From eac55ed930c441f4111f7f1559c04461f3d380c5 Mon Sep 17 00:00:00 2001 From: dmoka Date: Mon, 6 Jan 2025 13:41:31 +0100 Subject: [PATCH 140/142] set back version as there as no change in crate --- Cargo.lock | 2 +- primitives/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8fb2fdd5d..4182b63f0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11353,7 +11353,7 @@ dependencies = [ [[package]] name = "primitives" -version = "6.1.1" +version = "6.1.0" dependencies = [ "frame-support", "hex-literal", diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml index f8c1797e4..4892f5f2b 100644 --- a/primitives/Cargo.toml +++ b/primitives/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "primitives" -version = "6.1.1" +version = "6.1.0" authors = ["GalacticCouncil"] edition = "2021" repository = "https://github.com/galacticcouncil/HydraDX-node" From 7279c7cb489981d69d2b228bd5aea1d801113274 Mon Sep 17 00:00:00 2001 From: Daniel Moka Date: Mon, 6 Jan 2025 13:43:24 +0100 Subject: [PATCH 141/142] use context call directly Co-authored-by: Richard Roznovjak --- pallets/support/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/support/src/lib.rs b/pallets/support/src/lib.rs index 26bf5483a..e2083d5f1 100644 --- a/pallets/support/src/lib.rs +++ b/pallets/support/src/lib.rs @@ -108,7 +108,7 @@ impl Pallet { outputs: Vec, fees: Vec>, ) { - let operation_stack = ExecutionContext::::get().to_vec(); + let operation_stack = Self::get_context(); Self::deposit_event(Event::::Swapped { swapper, filler, From 95156dd4f6f457f9e2c7e4772d7f16354674462e Mon Sep 17 00:00:00 2001 From: dmoka Date: Mon, 6 Jan 2025 13:46:53 +0100 Subject: [PATCH 142/142] return stack directly as no need for error propagation --- integration-tests/src/xcm.rs | 4 ++-- pallets/support/src/lib.rs | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/integration-tests/src/xcm.rs b/integration-tests/src/xcm.rs index 3a0b2e253..40ee88c28 100644 --- a/integration-tests/src/xcm.rs +++ b/integration-tests/src/xcm.rs @@ -263,7 +263,7 @@ fn xcm_call_should_populate_unified_event_call_context() { let event2 = &last_two_swapped_events[0]; assert_operation_stack!(event2, [ExecutionType::Xcm(_, 0), ExecutionType::Omnipool(1)]); - let unified_event_context = pallet_support::Pallet::::get_context().unwrap(); + let unified_event_context = pallet_support::Pallet::::get_context(); assert!(unified_event_context.is_empty()); }); } @@ -331,7 +331,7 @@ fn unified_event_context_should_be_cleared_when_error_happens_in_xcm_prepare() { // Assert Hydra::execute_with(|| { - let context = pallet_support::Pallet::::get_context().unwrap(); + let context = pallet_support::Pallet::::get_context(); assert!(context.is_empty()) }); } diff --git a/pallets/support/src/lib.rs b/pallets/support/src/lib.rs index 26bf5483a..bb92cca95 100644 --- a/pallets/support/src/lib.rs +++ b/pallets/support/src/lib.rs @@ -159,9 +159,7 @@ impl Pallet { Ok(()) } - pub fn get_context() -> Result, DispatchError> { - let stack = ExecutionContext::::get().to_vec(); - - Ok(stack) + pub fn get_context() -> Vec { + ExecutionContext::::get().to_vec() } }